Skip to content

Conversation

FoamyGuy
Copy link
Contributor

I noticed by default that speaker_volume after DAC init is 63.1579 which is outside the range specified by the speaker_volume property.

I don't think this setting is actually taking effect because the sound output from the speaker is still fairly quiet.

However I think it's best to explicitly set both of these to a value we know is safe for the speakers that are stocked in the shop. Both to avoid any potential damage to hardware, and to make it less confusing if anyone happens to check the value of and assumes that the value it returns will be valid for passing back to it to be set.

@FoamyGuy FoamyGuy requested a review from dhalbert August 19, 2025 17:00
Copy link

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is something wrong with the speaker volume getter or setter:

>>> t = adafruit_tlv320.TLV320DAC3100(board.I2C())
>>> t.speaker_volume
63.1579
>>> t.speaker_volume = -15
>>> t.speaker_volume
-15.7895
>>> t.headphone_volume
-63.5
>>> t.headphone_volume = -15
>>> t.headphone_volume
-15.0                     # looks ok
>>> t.speaker_volume = 0
>>> t.speaker_volume
0.0
>>> t.speaker_volume = 63.1579
>>> t.speaker_volume
0.0                         # hunh?
>>> t.speaker_volume = 50
>>> t.speaker_volume
0.0
>>> t.speaker_volume = 20
>>> t.speaker_volume
0.0

@samblenny
Copy link
Contributor

The speaker_volume setter and getter are using a dB to register value conversion formula that's unrelated to how the datasheet says the conversion is supposed to work. The datasheet says the analog volume (attenuation) registers should use the lookup table values in Table 6-24. There's a similar but less severe problem with the setter and getter for headphone_volume. I've documented the details at Volume setting properties don't work right # 9

@FoamyGuy
Copy link
Contributor Author

closing in favor of #10

@FoamyGuy FoamyGuy closed this Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants