Skip to main content

Driver library for the nuvoton NAU88L21 audio CODEC

Project description

Introduction

Documentation Status Discord Build Status Code Style: Ruff

Driver library for the nuvoton NAU88L21 audio CODEC

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-nau88l21

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

sudo pip3 install adafruit-circuitpython-nau88l21

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-nau88l21

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_nau88l21

Or the following command to update an existing version:

circup update

Usage Example

import time

import audiobusio
import board
import synthio

import adafruit_nau88l21

RATE = 48000  # frame rate on the wire; also what the codec's FLL locks to

DAC_VOLUME = 0
HEADPHONE_VOLUME = 0

# MIDI note numbers for a C-major scale, C4 up to C5.
SCALE = (60, 62, 64, 65, 67, 69, 71, 72)
NOTE_SECONDS = 0.4

# CAUTION: this drives the headphone amplifier. Take the headphones off before
# the first run and confirm the level is comfortable before wearing them.

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

synth = synthio.Synthesizer(sample_rate=RATE)

i2s.play(synth)

codec = adafruit_nau88l21.NAU88L21(board.I2C())
codec.configure_clocks()

codec.headphone_output = True
codec.dac_volume = DAC_VOLUME
codec.headphone_volume = HEADPHONE_VOLUME

print("playing scale")
try:
    while True:
        for note in SCALE:
            synth.press(note)
            time.sleep(0.25)
            synth.release(note)
            time.sleep(0.125)
finally:
    i2s.stop()
    i2s.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.

Project details


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_nau88l21-1.0.0.tar.gz (40.7 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_nau88l21-1.0.0-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for adafruit_circuitpython_nau88l21-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5a79b57f6e5f4cda8ee77b6e7cea4b0be936b582447a317bc0134e603a050fcd
MD5 11d5f0239a01f6c24cce53cbf838fba5
BLAKE2b-256 f1d0ab74892d7c3c349373b0966dcc8e0224ff8c234777e14dae1f69585ee29a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for adafruit_circuitpython_nau88l21-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5cfbbd345cbdfee0297f56d7ef852a262a9a4ace826ca105a24ab6a466e85fb5
MD5 7c455f2f3a73fb88f8d3b61586fa2f66
BLAKE2b-256 d98007b7a360cd2a49ce2b4c8a29d35d521486bd8fbf84158025b604086823b8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page