-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Milestone
Description
micropython-microbit-v2/src/codal_app/microbithal_audio.cpp
Lines 78 to 84 in eeb1db3
| void microbit_hal_audio_set_volume(int value) { | |
| if (value >= 255) { | |
| uBit.audio.setVolume(128); | |
| } else { | |
| uBit.audio.setVolume(value / 2); | |
| } | |
| } |
And uBit.audio.setVolume() input range is 0 to 255:
codal-microbit-v2/source/MicroBitAudio.cpp#L161-L169
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
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)Metadata
Metadata
Assignees
Labels
No labels