Skip to main content

Introduction

Documentation Status Discord Build Status Code Style: Ruff

CircuitPython driver library for TI TAS2505 audio amplifier

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle or individual libraries can be installed using circup.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install adafruit-circuitpython-tas2505

To install system-wide (this may be required in some cases):

sudo pip3 install adafruit-circuitpython-tas2505

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .venv
source .env/bin/activate
pip3 install adafruit-circuitpython-tas2505

Installing to a Connected CircuitPython Device with Circup

Make sure that you have circup installed in your Python environment. Install it with the following command if necessary:

pip3 install circup

With circup installed and your CircuitPython device connected use the following command to install:

circup install adafruit_tas2505

Or the following command to update an existing version:

circup update

Usage Example

import array
import math
import time

import audiobusio
import audiocore
import board
import digitalio

import adafruit_tas2505

RATE = 44100

DAC_VOLUME = 0  # digital, 0 to -63.5
SPEAKER_VOLUME = 0  # analog, 0 to -72.3
SPEAKER_GAIN = 6  # Class-D amplifier, 6 to 24

reset_pin = digitalio.DigitalInOut(board.TAS_RESET)
reset_pin.direction = digitalio.Direction.OUTPUT
reset_pin.value = False
time.sleep(0.01)
reset_pin.value = True
time.sleep(0.01)

dac = adafruit_tas2505.TAS2505(board.I2C())
dac.configure_clocks(sample_rate=RATE)

dac.speaker_output = True
dac.dac_volume = DAC_VOLUME
dac.speaker_volume = SPEAKER_VOLUME
dac.speaker_gain = SPEAKER_GAIN

audio = audiobusio.I2SOut(board.I2S_BIT_CLOCK, board.I2S_WORD_SELECT, board.I2S_DOUT)

# One cycle of a 440 Hz sine, played on a loop
length = RATE // 440
sine_wave = array.array("h", [0] * length)
for i in range(length):
    sine_wave[i] = int(math.sin(math.pi * 2 * i / length) * 0.5 * (2**15 - 1))
sine_wave_sample = audiocore.RawSample(sine_wave, sample_rate=RATE)

try:
    while True:
        audio.play(sine_wave_sample, loop=True)
        time.sleep(1)
        audio.stop()
        time.sleep(1)
finally:
    dac.speaker_output = False
    audio.stop()
    audio.deinit()
    reset_pin.deinit()

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adafruit_circuitpython_tas2505-1.0.0.tar.gz (42.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adafruit_circuitpython_tas2505-1.0.0-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file adafruit_circuitpython_tas2505-1.0.0.tar.gz.

File metadata

File hashes

Hashes for adafruit_circuitpython_tas2505-1.0.0.tar.gz
Algorithm Hash digest
SHA256 986ed6d7c429240b6bc52f5865d4344c7374a157eadbc5215514bfdaac0ab9d2
MD5 b668498037f11e04faeb85d48f6e6413
BLAKE2b-256 48cf461fbf98440d0aaeff6f902a56db24681750e16174258b0be725f756fbe6

See more details on using hashes here.

File details

Details for the file adafruit_circuitpython_tas2505-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for adafruit_circuitpython_tas2505-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ac5bdc109122cdd2082c3d38fd2d1bdd1e8d4eabc3d63272bdda393471e4081
MD5 d67dce433e3309638a25431789a26240
BLAKE2b-256 240ca9e0405a9cafe59f9d3050eca39a9b3ed6f769c05bc5102bfdb622a55052

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page