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.

Metadata

Release files for adafruit-circuitpython-tas2505 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adafruit-circuitpython-tas2505 1.0.0
File Size Uploaded
adafruit_circuitpython_tas2505-1.0.0.tar.gz 42.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for adafruit-circuitpython-tas2505 1.0.0
File Interpreter ABI Platform
adafruit_circuitpython_tas2505-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 65.5 kB

Release files / adafruit_circuitpython_tas2505-1.0.0.tar.gz

Download URL adafruit_circuitpython_tas2505-1.0.0.tar.gz
Size 42.4 kB
Tags Source
SHA-256 checksum
How to use checksums
986ed6d7c429240b6bc52f5865d4344c7374a157eadbc5215514bfdaac0ab9d2
BLAKE2b-256 checksum
How to use checksums
48cf461fbf98440d0aaeff6f902a56db24681750e16174258b0be725f756fbe6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / adafruit_circuitpython_tas2505-1.0.0-py3-none-any.whl

Download URL adafruit_circuitpython_tas2505-1.0.0-py3-none-any.whl
Size 23.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ac5bdc109122cdd2082c3d38fd2d1bdd1e8d4eabc3d63272bdda393471e4081
BLAKE2b-256 checksum
How to use checksums
240ca9e0405a9cafe59f9d3050eca39a9b3ed6f769c05bc5102bfdb622a55052
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release 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