adafruit_wm8960.advanced

CircuitPython driver for WM8960 Stereo CODEC with advanced control

  • Author(s): Scott Shawcroft, Cooper Dalrymple

Originally authored by Pete Lewis @ SparkFun Electronics, October 14th, 2022 https://github.com/sparkfun/SparkFun_Arduino_Library

Implementation Notes

Software and Dependencies:

# * Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice

adafruit_wm8960.advanced.ADC_VOLUME_MAX = 30.0

The maximum digital volume allowed by the WM8960 ADC in decibels. Used by the attributes WM8960_Advanced.left_adc_volume, WM8960_Advanced.right_adc_volume, and WM8960_Advanced.adc_volume.

adafruit_wm8960.advanced.ADC_VOLUME_MIN = -97.0

The minimum digital volume allowed by the WM8960 ADC in decibels. Used by the attributes WM8960_Advanced.left_adc_volume, WM8960_Advanced.right_adc_volume, and WM8960_Advanced.adc_volume.

adafruit_wm8960.advanced.ALC_ATTACK_TIME_MAX = 6.14

The maximum amount of time allowed by the attack (Gain Ramp-Down) time of the automatic level control (ALC) of the WM8960 in seconds. Used by the attribute WM8960_Advanced.alc_attack_time.

adafruit_wm8960.advanced.ALC_ATTACK_TIME_MIN = 0.006

The minimum amount of time allowed by the attack (Gain Ramp-Down) time of the automatic level control (ALC) of the WM8960 in seconds. Used by the attribute WM8960_Advanced.alc_attack_time.

adafruit_wm8960.advanced.ALC_DECAY_TIME_MAX = 24.58

The maximum amount of time allowed by the decay (Gain Ramp-Up) time of the automatic level control (ALC) of the WM8960 in seconds. Used by the attribute WM8960_Advanced.alc_decay_time.

adafruit_wm8960.advanced.ALC_DECAY_TIME_MIN = 0.024

The minimum amount of time allowed by the decay (Gain Ramp-Up) time of the automatic level control (ALC) of the WM8960 in seconds. Used by the attribute WM8960_Advanced.alc_decay_time.

adafruit_wm8960.advanced.ALC_HOLD_TIME_MAX = 43.691

The maximum amount of time allowed by the hold time of the automatic level control (ALC) of the WM8960 in seconds. Used by the attribute WM8960_Advanced.alc_hold_time.

adafruit_wm8960.advanced.ALC_HOLD_TIME_MIN = 0.00267

The minimum amount of time allowed by the hold time of the automatic level control (ALC) of the WM8960 in seconds. Used by the attribute WM8960_Advanced.alc_hold_time.

adafruit_wm8960.advanced.ALC_MAX_GAIN_MAX = 30.0

The maximum gain of the maximum allowed gain of the WM8960 automatic level control (ALC) in decibels. Used by the attribute WM8960_Advanced.alc_max_gain.

adafruit_wm8960.advanced.ALC_MAX_GAIN_MIN = -12.0

The minimum gain of the maximum allowed gain of the WM8960 automatic level control (ALC) in decibels. Used by the attribute WM8960_Advanced.alc_max_gain.

adafruit_wm8960.advanced.ALC_MIN_GAIN_MAX = 24.75

The maximum gain of the minimum allowed gain of the WM8960 automatic level control (ALC) in decibels. Used by the attribute WM8960_Advanced.alc_min_gain.

adafruit_wm8960.advanced.ALC_MIN_GAIN_MIN = -17.25

The minimum gain of the minimum allowed gain of the WM8960 automatic level control (ALC) in decibels. Used by the attribute WM8960_Advanced.alc_min_gain.

adafruit_wm8960.advanced.ALC_TARGET_MAX = -1.5

The maximum target level of the WM8960 automatic level control (ALC) in decibels. Used by the attribute WM8960_Advanced.alc_target.

adafruit_wm8960.advanced.ALC_TARGET_MIN = -22.5

The minimum target level of the WM8960 automatic level control (ALC) in decibels. Used by the attribute WM8960_Advanced.alc_target.

adafruit_wm8960.advanced.AMP_VOLUME_MAX = 6.0

The maximum volume level used by the headphone and speaker amplifiers of the WM8960 in decibels. Used by the attributes WM8960_Advanced.left_headphone_volume, WM8960_Advanced.right_headphone_volume, WM8960_Advanced.headphone_volume, WM8960_Advanced.left_speaker_volume, WM8960_Advanced.right_speaker_volume, and WM8960_Advanced.speaker_volume.

adafruit_wm8960.advanced.AMP_VOLUME_MIN = -73.0

The minimum volume level used by the headphone and speaker amplifiers of the WM8960 in decibels. Used by the attributes WM8960_Advanced.left_headphone_volume, WM8960_Advanced.right_headphone_volume, WM8960_Advanced.headphone_volume, WM8960_Advanced.left_speaker_volume, WM8960_Advanced.right_speaker_volume, and WM8960_Advanced.speaker_volume.

adafruit_wm8960.advanced.BOOST_GAIN_MAX = 6.0

The maximum gain allowed by the WM8960 input boost mixers in decibels. Used by the attributes WM8960_Advanced.left_input2_boost, WM8960_Advanced.right_input2_boost, WM8960_Advanced.input2_boost, WM8960_Advanced.left_input3_boost, WM8960_Advanced.right_input3_boost, and WM8960_Advanced.input3_boost.

adafruit_wm8960.advanced.BOOST_GAIN_MIN = -12.0

The minimum gain allowed by the WM8960 input boost mixers in decibels. Used by the attributes WM8960_Advanced.left_input2_boost, WM8960_Advanced.right_input2_boost, WM8960_Advanced.input2_boost, WM8960_Advanced.left_input3_boost, WM8960_Advanced.right_input3_boost, and WM8960_Advanced.input3_boost.

adafruit_wm8960.advanced.DAC_VOLUME_MAX = 0.0

The maximum digital volume allowed by the WM8960 DAC in decibels. Used by the attributes WM8960_Advanced.left_dac_volume, WM8960_Advanced.right_dac_volume, and WM8960_Advanced.dac_volume.

adafruit_wm8960.advanced.DAC_VOLUME_MIN = -127.0

The minimum digital volume allowed by the WM8960 DAC in decibels. Used by the attributes WM8960_Advanced.left_dac_volume, WM8960_Advanced.right_dac_volume, and WM8960_Advanced.dac_volume.

adafruit_wm8960.advanced.GATE_THRESHOLD_MAX = -30.0

The maximum level to trigger the noise gate of the WM8960 in decibels. Used by the attribute WM8960_Advanced.noise_gate_threshold.

adafruit_wm8960.advanced.GATE_THRESHOLD_MIN = -76.5

The minimum level to trigger the noise gate of the WM8960 in decibels. Used by the attribute WM8960_Advanced.noise_gate_threshold.

adafruit_wm8960.advanced.MIC_GAIN_MAX = 30.0

The maximum gain allowed by the WM8960 PGA (microphone) amplifier in decibels. Used by the attributes WM8960_Advanced.left_mic_volume, WM8960_Advanced.right_mic_volume, and WM8960_Advanced.mic_volume.

adafruit_wm8960.advanced.MIC_GAIN_MIN = -17.25

The minimum gain allowed by the WM8960 PGA (microphone) amplifier in decibels. Used by the attributes WM8960_Advanced.left_mic_volume, WM8960_Advanced.right_mic_volume, and WM8960_Advanced.mic_volume.

class adafruit_wm8960.advanced.Mic_Input

An enum-like class representing the microphone amplifier (PGA) input modes. Used for the attributes WM8960_Advanced.left_mic_input, WM8960_Advanced.right_mic_input, and WM8960_Advanced.mic_input.

INPUT2 = 1

Connect the signal of input 2 to the non-inverting input of the amplifier.

INPUT3 = 2

Connect the signal of input 3 to the non-inverting input of the amplifier.

VMID = 0

Disconnect both input 2 and input 3 from the non-inverting input of the amplifier and instead connect it to the internally buffered VMID refernce (see WM8960_Advanced.vmid).

adafruit_wm8960.advanced.OUTPUT_VOLUME_MAX = 0.0

The maximum volume level used by the analog bypass output mixers of the WM8960 in decibels. Used by the attributes WM8960_Advanced.left_input3_output_volume, WM8960_Advanced.right_input3_output_volume, WM8960_Advanced.input3_output_volume, WM8960_Advanced.left_mic_output_volume, WM8960_Advanced.right_mic_output_volume, and WM8960_Advanced.mic_output_volume.

adafruit_wm8960.advanced.OUTPUT_VOLUME_MIN = -21.0

The minimum volume level used by the analog bypass output mixers of the WM8960 in decibels. Used by the attributes WM8960_Advanced.left_input3_output_volume, WM8960_Advanced.right_input3_output_volume, WM8960_Advanced.input3_output_volume, WM8960_Advanced.left_mic_output_volume, WM8960_Advanced.right_mic_output_volume, and WM8960_Advanced.mic_output_volume.

class adafruit_wm8960.advanced.Vmid_Mode

An enum-like class representing possible Vmid reference voltage modes used in conjunction with the attribute WM8960_Advanced.vmid.

DISABLED = 0

Disable the vmid reference voltage used by both the microphone amplifier (PGA) and OUT3 when mono output is disabled as a buffered headphone ground.

FASTSTART = 3

Set the internal voltage reference to a 2*5kOhm potential divider. Use this setting if a fast start-up of playback operation is desired. This setting will consume more power.

LOWPOWER = 2

Set the internal voltage reference to a 2*250kOhm potential divider. Use this setting for low power maintenance when all other operations of the WM8960 are disabled.

PLAYBACK = 1

Set the internal voltage reference to a 2*50kOhm potential divider. This setting is typical for normal playback and power consumption and is used for the microphone amplifier and as a buffered headphone ground.

class adafruit_wm8960.advanced.WM8960_Advanced(i2c_bus: busio.I2C, address: int = _DEFAULT_I2C_ADDR)

Driver for interacting directly with a WM8960 audio codec to control analog and digital audio pathways over an I2C connection.

Initialize the WM8960 device.

This function initialized the I2C device, performs a reset, turns on power, and sets vmid to Vmid_Mode.PLAYBACK.

Parameters:
  • i2c – The I2C bus.

  • address – The I2C address of the device. Defaults to 0x1A.

property adc: bool

Whether or not the both channels of the ADC are enabled.

Default:

False

adc_channel_swap: bool

Whether or not to swap left and right ADC data.

Default:

False

property adc_clock_divider: float

The sample rate divisor of the ADC as SYSCLK / (value * 256). Accepts a value of 1.0, 1.5, 2.0, 3.0, 4.0, 5.5, or 6.0.

Default:

1.0

property adc_volume: float

The digital volume of both channels of the ADC in decibels. Accepts a minimum value of -97.0dB (ADC_VOLUME_MIN) and a maximum of +30.0dB (ADC_VOLUME_MAX). In order to digitally mute the ADC, set this value below -97.0dB. If muted, a value of None will be returned.

Default:

None

property alc: bool

Whether or not both channels of the automatic level control (ALC) are enabled. The ALC will automatically adjust the gain of incoming signal into the microphone amplifier.

Default:

False

property alc_attack_time: float

The time that it takes for the microphone amplifier gain to ramp down and adjust the incoming signal to its target level, alc_target. This time is relative depending on the gain adjustment required. Accepts a minimum value of 0.006s (ALC_HOLD_TIME_MIN) increasing exponentially to a maximum of 6.14s (ALC_HOLD_TIME_MAX).

Default:

0.024

property alc_decay_time: float

The time that it takes for the microphone amplifier gain to ramp up and return to its target value, alc_target. This time is relative depending on the gain adjustment required. Accepts a minimum value of 0.024s (ALC_HOLD_TIME_MIN) increasing exponentially to a maximum of 43.691s (ALC_HOLD_TIME_MAX).

Default:

0.024

property alc_hold_time: float

The time delay between the peak level detected being below target and the microphone amplifier gain beginning to ramp up. However, there is no delay before ramping the gain down when the signal level is above target. Accepts a minimum value of 0.00267s (ALC_HOLD_TIME_MIN) increasing exponentially to a maximum of 43.691s (ALC_HOLD_TIME_MAX). This value can also be set to 0.

Default:

30.0

alc_limiter: bool

Whether or not the ALC limiter is enabled to prevent clipping. This function is automatically enabled whenever alc is set to True.

Default:

False

property alc_max_gain: float

The maximum potential gain of the ALC to be applied to the microphone amplifier in decibels. Accepts a value between -12.0dB (ALC_MAX_GAIN_MIN) and +30.0dB (ALC_MAX_GAIN_MAX).

Default:

30.0

property alc_min_gain: float

The minimum allowed gain of the ALC to be applied to the microphone amplifier in decibels. Accepts a value between -17.25dB (ALC_MIN_GAIN_MIN) and +24.75dB (ALC_MIN_GAIN_MAX).

Default:

-17.25

property alc_target: float

The target level of the input signal out of the microphone amplifier as controlled by the ALC in decibels. Accepts a value between -22.5dB (ALC_TARGET_MIN) and +6.0dB (ALC_TARGET_MAX).

Default:

False

property amp_clock_divider: float

The divisor of the SYSCLK used to operating the Class D amplifier switching clock as SYSCLK / value. Accepts a value of 1.5 (not recommended), 2.0, 3.0, 4.0, 6.0, 8.0, 12.0, and 16.0.

Default:

16.0

property base_clock_divider: float

The divisor of the SYSCLK (when master_mode is set to True) when determining BCLK frequency as SYSCLK / value. Accepts a value of 1.0, 1.5, 2.0, 3.0, 4.0, 5.5, 6.0, 8.0, 11.0, 12.0, 16.0, 22.0, 24.0, or 32.0.

Default:

1.0

property bit_depth: int

The number of bits per sample. The values 16, 20, 24, and 32 are supported.

Default:

32

clock_fractional_mode: bool

Whether the integer mode (False) or fractional mode (True) of the PLL is used to calculate the output clock.

Default:

False

clock_from_pll: bool

Whether the SYSCLK is derived from MCLK (False) or the output of the PLL (True).

Default:

False

property dac: bool

Whether or not the boths channels of the DAC are enabled.

Default:

False

dac_attenuation: bool

When set to True, the signal of the DAC will be attenuated by -6dB. This is commonly used when enhance is set to True to avoid limiting.

Default:

False

property dac_clock_divider: float

The sample rate divisor of the DAC as SYSCLK / (value * 256). Accepts a value of 1.0, 1.5, 2.0, 3.0, 4.0, 5.5, or 6.0.

Default:

1.0

dac_mute: bool

Whether or not the DAC is soft-muted. By default, this feature is enabled. To play back an audio signal from the DAC, this must first set to False.

Default:

True

property dac_output: bool

Whether or not both channels of the DAC are connected to the output mixer. Required for playback of the DAC through the headphone or speaker amplifier.

Default:

False

dac_slow_soft_mute: bool

The rate at which the DAC soft mute, dac_mute, ramps up or down. When set to False, it takes roughly 10.7ms to mute or unmute (when sample_rate is set to 48000). When set to True, it takes roughly 171ms.

Default:

False

dac_soft_mute: bool

Prevents a sudden volume increase when disabling dac_mute during playback to avoid creating a popping noise.

Default:

False

property dac_volume: float

The digital volume of both channels of the DAC in decibels. Accepts a minimum value of -127.0dB (DAC_VOLUME_MIN) and a maximum of +0.0dB (DAC_VOLUME_MAX).

Default:

0.0

enhance: bool

Whether or not the digital 3D stereo enhancement feature on the DAC is enabled. This option will artificially increase the separation between the left and right channels.

Default:

False

property enhance_depth: float

The depth of the 3D stereo enhancement effect. Accepts a monotonic value of 0.0 to 1.0.

Default:

0.0

enhance_filter_hpf: bool

Whether or not a high-pass filter is applied before 3D enhancement processing. Recommended when sample_rate is less than 32000.

Default:

False

enhance_filter_lpf: bool

Whether or not a low-pass filter is applied before 3D enhancement processing. Recommended when sample_rate is less than 32000.

Default:

False

property gpio_clock_divider: float

The divisor of the GPIO clock (when gpio_output_mode is set to 4) as SYSCLK / value. Accepts a value of 1.0, 2.0, 3.0, 4.0, 5.5, or 6.0.

Default:

1.0

gpio_output: bool

Whether or not to enable special GPIO operation modes on the ADCLRC/GPIO1 pin.

Default:

False

gpio_output_invert: bool

Whether or not to invert the polarity of the output of ADCLRC/GPIO1 when gpio_output is set to True.

Default:

False

gpio_output_mode: int

The GPIO operation mode of ADCLRC/GPIO1 when gpio_output is set to True. Accepts a value between 0 and 7. See WM8960 datasheet for the operation of each function.

Default:

0

property headphone: bool

Whether or not the headphone amplifier is powered on.

Default:

False

headphone_standby: bool

Headphone amplifier standby mode.

Default:

False

property headphone_volume: float

The volume level of both channels of the headphone amplifier in decibels. Accepts a minimum value of -73.0dB (AMP_VOLUME_MIN) and a maximum of +6.0dB (AMP_VOLUME_MAX). If set to a value less than the minimum (-73.0dB), the amplifier will be muted and this property will return a value of None.

Default:

None

property headphone_zero_cross: bool

Whether or not the volume of the headphone amplifier channel will be adjusted when a “zero” input level is detected in order to avoid harsh jumps in the output.

Default:

False

property input: bool

The power state of the stereo boost stage and microphone amplifier (if mic is set to True).

Default:

False

property input2_boost: float

The gain of both channels of input 2 boost amp into the boost mixer before the ADC in decibels. Accepts a minimum value of -12.0dB (BOOST_GAIN_MIN) and a maximum of +6.0dB (BOOST_GAIN_MAX). In order to mute line-level input 2 into the ADC, set this value below -12.0dB. If muted, a value of None will be returned.

Default:

None

property input3_boost: float

The gain of both channels of input 3 boost amp into the boost mixer before the ADC in decibels. Accepts a minimum value of -12.0dB (BOOST_GAIN_MIN) and a maximum of +6.0dB (BOOST_GAIN_MAX). In order to mute line-level input 3 into the ADC, set this value below -12.0dB. If muted, a value of None will be returned.

Default:

None

property input3_output: bool

The connection of both channels of input 3 directly to the output mixer, bypassing the ADC.

Default:

False

property input3_output_volume: float

The level of both channels of input 3 into the output mixer in decibels. Accepts a value from -21.0dB (OUTPUT_VOLUME_MIN) to +0.0dB (OUTPUT_VOLUME_MAX).

Default:

-21.0

left_adc: bool

Whether or not the left channel of the ADC is enabled.

Default:

False

property left_adc_volume: float

The digital volume of the left channel ADC in decibels. Accepts a minimum value of -97.0dB (ADC_VOLUME_MIN) and a maximum of +30.0dB (ADC_VOLUME_MAX). In order to digitally mute the left channel of the ADC, set this value below -97.0dB. If muted, a value of None will be returned.

Default:

None

left_alc: bool

Whether or not the left channel of the automatic level control (ALC) is enabled.

Default:

False

left_dac: bool

Whether or not the left channel of the DAC is enabled.

Default:

False

left_dac_output: bool

Whether or not the left channel of the DAC is connected to the left channel of the output mixer.

Default:

False

property left_dac_volume: float

The digital volume of the left channel DAC in decibels. Accepts a minimum value of -127.0dB (DAC_VOLUME_MIN) and a maximum of +0.0dB (DAC_VOLUME_MAX).

Default:

0.0

left_headphone: bool

Whether or not the left channel of the headphone amplifier is powered on.

Default:

False

property left_headphone_volume: float

The volume level of the left channel of the headphone amplifier in decibels. Accepts a minimum value of -73.0dB (AMP_VOLUME_MIN) and a maximum of +6.0dB (AMP_VOLUME_MAX). If set to a value less than the minimum (-73.0dB), the left channel will be muted and this property will return a value of None.

Default:

None

left_headphone_zero_cross: bool

Whether or not the volume of the left headphone amplifier channel will be adjusted when a “zero” input level is detected in order to avoid harsh jumps in the output.

Default:

False

left_input: bool

The power state of the left channel boost stage and microphone amplifier (if left_mic is set to True).

Default:

False

property left_input2_boost: float

The gain of the left channel of input 2 boost amp into the boost mixer before the ADC in decibels. Accepts a minimum value of -12.0dB (BOOST_GAIN_MIN) and a maximum of +6.0dB (BOOST_GAIN_MAX). In order to mute line-level input 2 into the ADC, set this value below -12.0dB. If muted, a value of None will be returned.

Default:

None

property left_input3_boost: float

The gain of the left channel of input 3 boost amp into the boost mixer before the ADC in decibels. Accepts a minimum value of -12.0dB (BOOST_GAIN_MIN) and a maximum of +6.0dB (BOOST_GAIN_MAX). In order to mute line-level input 3 into the ADC, set this value below -12.0dB. If muted, a value of None will be returned.

Default:

None

left_input3_output: bool

The connection of the left channel of input 3 directly to the output mixer, bypassing the ADC.

Default:

False

property left_input3_output_volume: float

The level of the left channel of input 3 into the output mixer in decibels. Accepts a value from -21.0dB (OUTPUT_VOLUME_MIN) to +0.0dB (OUTPUT_VOLUME_MAX).

Default:

-21.0

left_mic: bool

The power state of the left channel microphone amplifier (if left_input is set to True).

Default:

False

left_mic_boost: bool

The connection to the left input boost of the microphone amplifier.

Default:

False

property left_mic_boost_gain: float

The amount of gain of the left input boost of the microphone amplifier in decibels. Allowed values are 0.0, 13.0, 20.0, and 29.0. WM8960_Advanced.left_mic_boost must be set to True.

Default:

0.0

property left_mic_input: int

The connection to the left non-inverting input of the microphone amplifier. Use constants from class Mic_Input.

Default:

Mic_Input.VMID

left_mic_inverting_input: bool

The connection of the left inverting input of the microphone amplifier (PGA) to the left input 1.

Default:

False

property left_mic_mute: bool

The muted state of the left channel of the microphone amplifier.

Default:

False

left_mic_output: bool

The connection of the left channel of the microphone amplifier directly to the output mixer, bypassing the ADC.

Default:

False

property left_mic_output_volume: float

The level of the left channel of the microphone amplifier into the output mixer in decibels. Accepts a value from -21.0dB (OUTPUT_VOLUME_MIN) to +0.0dB (OUTPUT_VOLUME_MAX).

Default:

-21.0

property left_mic_volume: float

The level of the left microphone amplifier in decibels. Value ranges from a minimum of -17.25dB (MIC_GAIN_MIN) to a maximum of +30.0dB (MIC_GAIN_MAX). WM8960_Advanced.left_mic must be set to True.

Default:

0.0

left_mic_zero_cross: bool

Whether or not the volume of the left microphone amplifier channel will be adjusted when a “zero” input level is detected in order to avoid harsh jumps in the waveform.

Default:

False

left_output: bool

Whether or not the left channel of the output mixer is enabled.

Default:

False

property left_speaker: bool

Whether or not the left channel of the speaker amplifier is powered on.

Default:

False

property left_speaker_volume: float

The volume level of the left channel of the speaker amplifier in decibels. Accepts a minimum value of -73.0dB (AMP_VOLUME_MIN) and a maximum of +6.0dB (AMP_VOLUME_MAX). If set to a value less than the minimum (-73.0dB), the left channel will be muted and this property will return a value of None.

Default:

None

left_speaker_zero_cross: bool

Whether or not the volume of the left speaker amplifier channel will be adjusted when a “zero” input level is detected in order to avoid harsh jumps in the output.

Default:

False

loopback: bool

Whether or not digital loopback between the ADC and DAC is enabled.

Default:

False

master_mode: bool

Whether the operation of the digital interface is controlled externally in slave mode (False) or operated internally in master mode (True).

Default:

False

property mic: bool

The power state of the stereo microphone amplifier (if input is set to True).

Default:

False

mic_bias: bool

Whether or not the WM8960 is outputting a reference voltage on the MICBIAS pin for biasing electret type microphones.

Default:

False

mic_bias_voltage: bool

The electret type microphone bias mode. WM8960.mic_bias must be set to True to utilize this setting. False = the reference voltage is 0.9 * AVDD or 1.8 * VMID True = the reference voltage is 0.65 * AVDD or 1.3 * VMID

Default:

False

property mic_boost: bool

The connection to the input boost of the microphone amplifier.

Default:

False

property mic_boost_gain: float

The amount of gain of the input boost of the microphone amplifier in decibels. Allowed values are 0.0, 13.0, 20.0, and 29.0. WM8960_Advanced.mic_boost must be set to True.

Default:

0.0

property mic_input: int

The connection to the non-inverting input of the microphone amplifier. Use constants from class Mic_Input.

Default:

Mic_Input.VMID

property mic_inverting_input: bool

The connection of the inverting input of the microphone amplifier (PGA) to input 1.

Default:

False

property mic_mute: bool

The muted state of the microphone amplifier.

Default:

False

property mic_output: bool

The connection of both channels of the microphone amplifier directly to the output mixer, bypassing the ADC.

Default:

False

property mic_output_volume: float

The level of both channels of the microphone amplifier into the output mixer in decibels. Accepts a value from -21.0dB (OUTPUT_VOLUME_MIN) to +0.0dB (OUTPUT_VOLUME_MAX).

Default:

-21.0

property mic_volume: float

The level of the microphone amplifier in decibels. Value ranges from a minimum of -17.25dB (MIC_GAIN_MIN) to a maximum of +30.0dB (MIC_GAIN_MAX). WM8960_Advanced.mic must be set to True.

Default:

0.0

property mic_zero_cross: bool

Whether or not the volume of the microphone amplifier will be adjusted when a “zero” input level is detected in order to avoid harsh jumps in the waveform.

Default:

False

mono_left_mix: bool

Whether or not the left channel of the output mixer is connected to the mono output.

Default:

False

property mono_mix: bool

Whether or not both channels of the output mixer are connected to the mono output.

Default:

False

mono_output: bool

Whether or not the mono output mixer is enabled. This can be used to provide a mono mix of the left and right channels of the output mixer (if mono_left_mix or mono_right_mix is set to True) or as a buffer for the headphone amplifier to allow capless headphone output.

Default:

False

mono_output_attenuation: bool

When set to True, the signal of the mono output will be attenuated by -6dB. This can help prevent clipping. This property should not be modified when mono_output is set to True as this may cause an audible click noise.

Default:

False

mono_right_mix: bool

Whether or not the right channel of the output mixer is connected to the mono output.

Default:

False

noise_gate: bool

Whether or not the noise gate is enabled. The ALC, alc, must be set to True for this functionality to work. This feature will help prevent “noise pumping” during periods of quiet input signal. Only applicable to signal into the microphone amplifier.

Default:

False

property noise_gate_threshold: float

The input signal level below at which to engage the noise gate in decibels.

Default:

-76.5

property output: bool

Whether or not both channels of the output mixer are enabled.

Default:

False

pll: bool

Whether or not the phase-locked loop (PLL) clock is powered on.

Default:

False

property pll_k: int

The fractional (K) part of PLL input/output ratio. Accepts a 24-bit unsigned integer.

Default:

0x3126E9

pll_n: int

The intenger (N) part of PLL input/output ratio. Accepts a value greater than 5 and less than 13.

Default:

8

pll_prescale_div2: bool

Divide MCLK by 2 before input to PLL.

Default:

False

power: bool

Control the power state of all functions of the WM8960.

Default:

True

property power_supply: float

The incoming voltage of the AVDD power supply in volts. Setting this value appropriately will optimize bias current. Accepts a value of 2.7v or 3.3v.

Default:

3.3

reset() None

Resets all parameters of the WM8960. All audio and digital functionality will be disabled after calling this function. In order to resume normal operation, power must be set to True and vmid should be set to Vmid_Mode.PLAYBACK.

right_adc: bool

Whether or not the right channel of the ADC is enabled.

Default:

False

property right_adc_volume: float

The digital volume of the right channel ADC in decibels. Accepts a minimum value of -97.0dB (ADC_VOLUME_MIN) and a maximum of +30.0dB (ADC_VOLUME_MAX). In order to digitally mute the right channel of the ADC, set this value below -97.0dB. If muted, a value of None will be returned.

Default:

None

right_alc: bool

Whether or not the right channel of the automatic level control (ALC) is enabled.

Default:

False

right_dac: bool

Whether or not the right channel of the DAC is enabled.

Default:

False

right_dac_output: bool

Whether or not the right channel of the DAC is connected to the right channel of the output mixer.

Default:

False

property right_dac_volume: float

The digital volume of the right channel DAC in decibels. Accepts a minimum value of -127.0dB (DAC_VOLUME_MIN) and a maximum of +0.0dB (DAC_VOLUME_MAX).

Default:

0.0

right_headphone: bool

Whether or not the right channel of the headphone amplifier is powered on.

Default:

False

property right_headphone_volume: float

The volume level of the right channel of the headphone amplifier in decibels. Accepts a minimum value of -73.0dB (AMP_VOLUME_MIN) and a maximum of +6.0dB (AMP_VOLUME_MAX). If set to a value less than the minimum (-73.0dB), the right channel will be muted and this property will return a value of None.

Default:

None

right_headphone_zero_cross: bool

Whether or not the volume of the right headphone amplifier channel will be adjusted when a “zero” input level is detected in order to avoid harsh jumps in the output.

Default:

False

right_input: bool

The power state of the right channel boost stage and microphone amplifier (if right_mic is set to True).

Default:

False

property right_input2_boost: float

The gain of the right channel of input 2 boost amp into the boost mixer before the ADC in decibels. Accepts a minimum value of -12.0dB (BOOST_GAIN_MIN) and a maximum of +6.0dB (BOOST_GAIN_MAX). In order to mute line-level input 2 into the ADC, set this value below -12.0dB. If muted, a value of None will be returned.

Default:

None

property right_input3_boost: float

The gain of the right channel of input 3 boost amp into the boost mixer before the ADC in decibels. Accepts a minimum value of -12.0dB (BOOST_GAIN_MIN) and a maximum of +6.0dB (BOOST_GAIN_MAX). In order to mute line-level input 3 into the ADC, set this value below -12.0dB. If muted, a value of None will be returned.

Default:

None

right_input3_output: bool

The connection of the right channel of input 3 directly to the output mixer, bypassing the ADC.

Default:

False

property right_input3_output_volume: float

The level of the right channel of input 3 into the output mixer in decibels. Accepts a value from -21.0dB (OUTPUT_VOLUME_MIN) to +0.0dB (OUTPUT_VOLUME_MAX).

Default:

-21.0

right_mic: bool

The power state of the right channel microphone amplifier (if right_input is set to True).

Default:

False

right_mic_boost: bool

The connection to the right input boost of the microphone amplifier.

Default:

False

property right_mic_boost_gain: float

The amount of gain of the right input boost of the microphone amplifier in decibels. Allowed values are 0.0, 13.0, 20.0, and 29.0. WM8960_Advanced.right_mic_boost must be set to True.

Default:

0.0

property right_mic_input: int

The connection to the right non-inverting input of the microphone amplifier. Use constants from class Mic_Input.

Default:

Mic_Input.VMID

right_mic_inverting_input: bool

The connection the right inverting input of the microphone amplifier (PGA) to the right input 1.

Default:

False

property right_mic_mute: bool

The muted state of the right channel of the microphone amplifier.

Default:

False

right_mic_output: bool

The connection of the right channel of the microphone amplifier directly to the output mixer, bypassing the ADC.

Default:

False

property right_mic_output_volume: float

The level of the right channel of the microphone amplifier into the output mixer in decibels. Accepts a value from -21.0dB (OUTPUT_VOLUME_MIN) to +0.0dB (OUTPUT_VOLUME_MAX).

Default:

-21.0

property right_mic_volume: float

The level of the right microphone amplifier in decibels. Value ranges from a minimum of -17.25dB (MIC_GAIN_MIN) to a maximum of +30.0dB (MIC_GAIN_MAX). WM8960_Advanced.right_mic must be set to True.

Default:

0.0

right_mic_zero_cross: bool

Whether or not the volume of the right microphone amplifier channel will be adjusted when a “zero” input level is detected in order to avoid harsh jumps in the waveform.

Default:

False

right_output: bool

Whether or not the right channel of the output mixer is enabled.

Default:

False

property right_speaker: bool

Whether or not the right channel of the speaker amplifier is powered on.

Default:

False

property right_speaker_volume: float

The volume level of the right channel of the speaker amplifier in decibels. Accepts a minimum value of -73.0dB (AMP_VOLUME_MIN) and a maximum of +6.0dB (AMP_VOLUME_MAX). If set to a value less than the minimum (-73.0dB), the right channel will be muted and this property will return a value of None.

Default:

None

right_speaker_zero_cross: bool

Whether or not the volume of the right speaker amplifier channel will be adjusted when a “zero” input level is detected in order to avoid harsh jumps in the output.

Default:

False

property sample_rate: int

The rate of the ADC/DAC processing of the device in samples per second used for I2S communication and internal digital processing. If this property has not been set to a valid value before being accessed, it will return None. The sample rates 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, and 48000 are supported.

NOTE: This assumes that the master clock of the WM8960 is 24 MHz in order determine appropriate clock settings.

Default:

None

property speaker: bool

Whether or not the speaker amplifier is powered on.

Default:

False

property speaker_ac_gain: float

Speaker AC output level boost on both left and right channels in decibels. Accepts values of +0.0dB, +2.1dB, +2.9dB, +3.6dB, +4.5dB, and +5.1dB.

Default:

0.0

property speaker_dc_gain: float

Speaker DC output level boost on both left and right channels in decibels. Accepts values of +0.0dB, +2.1dB, +2.9dB, +3.6dB, +4.5dB, and +5.1dB.

Default:

0.0

property speaker_volume: float

The volume level of the speaker amplifier in decibels. Accepts a minimum value of -73.0dB (AMP_VOLUME_MIN) and a maximum of +6.0dB (AMP_VOLUME_MAX). If set to a value less than the minimum (-73.0dB), the amplifier will be muted and this property will return a value of None.

Default:

None

property speaker_zero_cross: bool

Whether or not the volume of the speaker amplifier will be adjusted when a “zero” input level is detected in order to avoid harsh jumps in the output.

Default:

False

property system_clock_div2: bool

Whether the clock source of the SYSCLK (see clock_from_pll) is divided by 1 (False) or 2 (True).

Default:

False

vmid: int

The buffered reference voltage mode. Use constants from class Vmid_Mode.

Default:

Vmid_Mode.PLAYBACK

property vref_output: bool

Whether or not VMID is sent to the output circuitry. If set to False, it will essentially disable the output of the device.

:default True

word_select_invert: bool

The polarity of the LRCLK, either left-first (False) or right-first (True).

Default:

False