-
Notifications
You must be signed in to change notification settings - Fork 792
Add audio output option file to Larsio and Chip's Challenge #3103
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
base: main
Are you sure you want to change the base?
Changes from all commits
ce4c56b
986f736
5b72675
33eceaf
118806a
5c59c04
83d33d6
db6b00d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
import picodvi | ||
import framebufferio | ||
import displayio | ||
import adafruit_tlv320 | ||
import audiobusio | ||
from audio import Audio | ||
from game import Game | ||
|
@@ -39,16 +38,12 @@ | |
|
||
displayio.release_displays() | ||
|
||
i2c = board.I2C() | ||
dac = adafruit_tlv320.TLV320DAC3100(i2c) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I lean towards leaving the hardware init and configuration in code.py rather than move it to definitions.py. I would defer to @makermelissa if she has an opinion on it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be easy enough to move the init back to code.py. The reason I moved it to definitions.py was that I thought it was useful for setting a default value for PLAY_SOUNDS that would avoid crashes on hardware that didn't have the DAC hardware. The sound in Chip's Challenge is awesome, but the game is still lots of fun without it. The default isn't necessary though and after looking at definitions.py again I can see that my code made it less clear that PLAY_SOUND was a definition that could be customized. I've added an update that I think helps with that issue but I'm happy to switch the default back to True and move the initialization back to code.py if that's the way you and Melissa want to go 😁 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another reason for moving the sound config to definitions.py was that although it's probably unlikely, if @makermelissa ever wanted to make some of the parameters in definitions.py user settable, the launcher_config dictionary would already be available without having to have it opened and read in two different modules. |
||
dac.configure_clocks(sample_rate=44100, bit_depth=16) | ||
dac.headphone_output = True | ||
dac.headphone_volume = -15 # dB | ||
|
||
if hasattr(board, "I2S_BCLK"): | ||
audio_bus = audiobusio.I2SOut(board.I2S_BCLK, board.I2S_WS, board.I2S_DIN) | ||
else: | ||
elif hasattr(board, "D9") and hasattr(board, "D10") and hasattr(board, "D11"): | ||
audio_bus = audiobusio.I2SOut(board.D9, board.D10, board.D11) | ||
else: | ||
audio_bus = None | ||
audio = Audio(audio_bus, SOUND_EFFECTS) | ||
|
||
fb = picodvi.Framebuffer(320, 240, clk_dp=board.CKP, clk_dn=board.CKN, | ||
|
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.
does this end up playing louder than the previous sound level with
-15
on headphone_volume?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.
It's hard for me to say because when I was using the headphone_volume & speaker_volume and switching back and forth between the outputs the volume levels seemed to jump around randomly (probably not but in a way I didn't understand). The headphone level at dac_volume=0 seems good on the headphones I've been using.