-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Description
I'm not hearing any change when adjusting the dac.headphone_volume property.
Below is my variation of tlv320_simpletest.py running on Adafruit CircuitPython 10.0.0-alpha.3 on 2025-05-02; Raspberry Pi Pico with rp2040. The perceived volume coming out of the headphones is constant
import time, math, time
import ulab.numpy as np
import board, busio, audiobusio, audiocore, audiomixer
import adafruit_tlv320
SAMPLE_RATE = 44100
CHANNEL_COUNT = 1
BUFFER_SIZE = 2048
i2c_sda_pin, i2c_scl_pin = board.GP16, board.GP17
i2s_bck_pin, i2s_lck_pin, i2s_dat_pin = board.GP20, board.GP21, board.GP22
i2c = busio.I2C(scl=i2c_scl_pin, sda=i2c_sda_pin)
audio = audiobusio.I2SOut(bit_clock=i2s_bck_pin, word_select=i2s_lck_pin, data=i2s_dat_pin)
dac = adafruit_tlv320.TLV320DAC3100(i2c)
dac.configure_clocks(sample_rate=SAMPLE_RATE, bit_depth=16)
dac.headphone_output = True
dac.headphone_volume = -35 # dB, does not seem to work?
mixer = audiomixer.Mixer(sample_rate=SAMPLE_RATE, channel_count=CHANNEL_COUNT, buffer_size=BUFFER_SIZE)
audio.play(mixer)
# generate a sine wave
tone_volume = 0.5
frequency = 440
length = SAMPLE_RATE // frequency
sine_wave = np.array(np.sin(np.linspace(0, 2*np.pi, length, endpoint=False))
* tone_volume * 32767, dtype=np.int16)
sine_wave_sample = audiocore.RawSample(sine_wave, sample_rate=SAMPLE_RATE)
mixer.voice[0].play(sine_wave_sample, loop=True)
while True:
for db in range(-60, 0, 5):
print("setting headphone db:", db)
dac.headphone_volume = db
time.sleep(0.5)Metadata
Metadata
Assignees
Labels
No labels