-
Notifications
You must be signed in to change notification settings - Fork 4
Volume and output interface API #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
thanks, can you add a simple playback example even with just like synthio to make tones or chicken.wav since this came up https://forums.adafruit.com/viewtopic.php?t=219668 |
cc @mikeysklar |
I updated the audio examples that play wav files to use this new API in the latest commits. I'll work on a new one that uses synthio. |
Added a new synthio example that plays a scale at some of the different available volumes |
FYI, I've been checking the code for Adafruit_CircuitPython_TLV320, and there's at least one bug with the I filed an issue that I'm updating with details as I find them: Volume setting properties don't work right # 9 There might be other similar stuff for headphones that I haven't found yet. |
Here's an example of some code that does the gain-dB to register-value conversion to match the non-linear lookup table values from Table 6-24: |
I re-tested this and made a few adjustments based on the updated TLV320 driver. Default volume level, and limit are both a bit lower now, the new default limit The examples have been updated to top out at the new default limit. The warning message was reworded to get rid of hardcoded default value. I think this is ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, a few suggestions.
Co-authored-by: Dan Halbert <halbert@halwitz.org>
…r warning message
Thank you, the latest commits update this to use simplemath instead of simpleio, use multi-line string and re-word the warning, and use the suggested logic syntax. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for investigating the multi-line string concatenation thing. Looks great!
Updating https://github.com/adafruit/Adafruit_CircuitPython_DotStar to 2.2.18 from 2.2.17: > Merge pull request adafruit/Adafruit_CircuitPython_DotStar#71 from dhalbert/spi-lock-managment Updating https://github.com/adafruit/Adafruit_CircuitPython_EPD to 2.15.0 from 2.14.0: > Merge pull request adafruit/Adafruit_CircuitPython_EPD#94 from adafruit/UC8197 > Merge pull request adafruit/Adafruit_CircuitPython_EPD#95 from adafruit/ssd1883 > Merge pull request adafruit/Adafruit_CircuitPython_EPD#93 from adafruit/ssd1680_fix > Merge pull request adafruit/Adafruit_CircuitPython_EPD#90 from AJMansfield/patch-1 Updating https://github.com/adafruit/Adafruit_CircuitPython_JD79661 to 1.0.1 from 1.0.0: > Merge pull request adafruit/Adafruit_CircuitPython_JD79661#1 from adafruit/cleanup Updating https://github.com/adafruit/Adafruit_CircuitPython_TLV320 to 1.2.1 from 1.1.0: > Merge pull request adafruit/Adafruit_CircuitPython_TLV320#11 from samblenny/fix-example-link > Merge pull request adafruit/Adafruit_CircuitPython_TLV320#10 from samblenny/volume-fixes Updating https://github.com/adafruit/Adafruit_CircuitPython_FruitJam to 1.2.0 from 0.5.0: > Merge pull request adafruit/Adafruit_CircuitPython_FruitJam#13 from FoamyGuy/volume_api > Merge pull request adafruit/Adafruit_CircuitPython_FruitJam#14 from mikeysklar/ntp-helper > Merge pull request adafruit/Adafruit_CircuitPython_FruitJam#12 from mikeysklar/headphone-speaker > Merge pull request adafruit/Adafruit_CircuitPython_FruitJam#11 from adafruit/TheKitty-patch-1 > Merge pull request adafruit/Adafruit_CircuitPython_FruitJam#9 from relic-se/request_display_config-default > Merge pull request adafruit/Adafruit_CircuitPython_FruitJam#8 from relic-se/any_button_pressed-fix Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Added the following libraries: Adafruit_CircuitPython_UC8253
Changes:
volume
property that takes a simple value 1-20 and maps it to the db range then sets on the DAC. User code can use this simplified API instead of trying to manage all of the different volume controls in the TLV, and with the range of 1-20 there is no need to worry about the -60ish to 23ish range of db that are allowed by the TLV driver.audio_output
property and argument that can be used to set the output to speaker or headphonesafe_volume_limit
property and argument that limits the volume to a specified value. Default limit is 15 which seems okay to me on both the tiny JST speaker and a cheap pair of powered 3.5mm speakers I've been using for testing. Attempting to set the volume higher raises an exception with a warning about speaker damage. User code can override it up to 20 to get the full range of volume, or just access the DAC directly.