Closed microbit-carlos closed 2 months ago
https://github.com/microbit-foundation/micropython-microbit-v2/blob/eeb1db318df7d678dbc7063934efe4258eaa70ab/src/codal_app/microbithal_audio.cpp#L78-L84
And uBit.audio.setVolume() input range is 0 to 255: codal-microbit-v2/source/MicroBitAudio.cpp#L161-L169
uBit.audio.setVolume()
int MicroBitAudio::setVolume(int volume) { if (volume < 0 || volume > 255) return DEVICE_INVALID_PARAMETER; mixer.setVolume(volume*4); return DEVICE_OK; }
And Synthesizer::setVolume() does take a value between 0 and 1023: codal-core/source/streams/Synthesizer.cpp#L277-L289
Synthesizer::setVolume()
So in a programme like this, we can hear the volume drop:
from microbit import * import music music.pitch(440, duration=1000) set_volume(255) music.pitch(440, duration=1000)
Should be fixed by a37bc963d23dc2fb39fd7998775db003b52bdf12
This just needs testing @microbit-carlos
Can confirm this is now working, thanks Damien!
https://github.com/microbit-foundation/micropython-microbit-v2/blob/eeb1db318df7d678dbc7063934efe4258eaa70ab/src/codal_app/microbithal_audio.cpp#L78-L84
And
uBit.audio.setVolume()
input range is 0 to 255: codal-microbit-v2/source/MicroBitAudio.cpp#L161-L169And
Synthesizer::setVolume()
does take a value between 0 and 1023: codal-core/source/streams/Synthesizer.cpp#L277-L289So in a programme like this, we can hear the volume drop: