adafruit_wm8960¶
CircuitPython driver for WM8960 Stereo CODEC
Author(s): Scott Shawcroft, Cooper Dalrymple
Implementation Notes¶
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
# * Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- class adafruit_wm8960.Input¶
An enum-like class representing the input options of the WM8960. Used for
WM8960.input.- DISABLED = 0¶
Disconnect all inputs.
- LINE2 = 2¶
Connect input 2 as a line input.
- LINE3 = 4¶
Connect input 3 as a line input.
- MIC1 = 1¶
Connect input 1 to the microphone amplifier in single-ended mode.
- MIC2 = 3¶
Connect input 1 and 2 to the microphone amplifier in differential mode.
- MIC3 = 5¶
Connect input 1 and 3 to the microphone amplifier in differential mode.
- class adafruit_wm8960.WM8960(i2c_bus: busio.I2C, sample_rate: int = 44100, bit_depth: int = 16)¶
Driver for controlling the WM8960 audio codec over an I2C connection. Used for receiving line and microphone input through the ADC over I2S, monitoring analog input to the output mixer, and sending digital audio to the headphone and speaker amplifiers via I2S.
NOTE: This driver assumes that the master clock of the WM8960 is 24 MHz in order determine appropriate clock settings.
- Parameters:
i2c (
I2C) – The I2C bus.sample_rate (
int, optional) – The sample rate of each audio frame used by the digital interface of the WM8960. The sample rates 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, and 48000 are supported. Defaults to 44100.bit_depth (
int, optional) – The number of bits per sample. The values 16, 20, 24, and 32 are supported. Defaults to 16.
- property alc: bool¶
Whether or not the Automatic Level Control (ALC) is enabled. The ALC uses the digital signal within the ADC to control the gain of the microphone amplifier. This feature does not apply if one of the line-level inputs is used for
input(ie:Input.LINE2orInput.LINE3).- Default:
- property alc_gain: tuple¶
The gain properties of the Automatic Level Control (ALC). Provided as a tuple in the format of target, max gain, min gain, and noise gate threshold all as monotonic
floatvalues.- Default:
(0.733333, 1.0, 0.0, 0.0)
- property alc_time: tuple¶
The time properties of the Automatic Level Control (ALC). Provided as a tuple in the format of attack time (from 0.006s to 6.14s), decay time (from 0.024s to 24.58s), and hold time (from 0.00267s to 43.691s) all as seconds within
floatvalues.- Default:
(0.024, 0.192, 0.0)
- property enhance: float¶
The amount of digital 3D stereo enhancement that artificially increases the separation between the left and right channels within the DAC. Set to 0.0 to disable.
- Default:
0.0
- property headphone: float¶
The volume of the headphone amplifier output from 0.0 to 1.0. Setting this property to 0.0 will mute and power off the headphone amplifier.
- Default:
0.0
- property input: int¶
The signal used as the input to the ADC. See
Inputfor available selections.- Default:
- property loopback: bool¶
Whether or not the data from the ADC is routed directly into the DAC internally. If set to
True, the I2S interface will be disabled. This property is useful if you would like to applyenhanceto the input signal.- Default:
- property monitor: float¶
The volume of the analog input bypassed to the output mixer. If set to 0.0, this bypass will be muted.
- Default:
0.0
- property sample_rate: int¶
The rate of the I2S bus in samples per second. This property is read-only.