-
Notifications
You must be signed in to change notification settings - Fork 29
codal_port: Add SoundEffect class. #106
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
I noticed that after playing a sound expression, the micro:bit consumes about 2x the power at idle REPL. |
Thanks Damien, this is great to start playing with SoundEffects! I take it the Also, playing the default SoundEffect() doesn't produce any sound and seems to crash or freeze:
But changing the interpolation to a value other than log works
So it might be related to this:
We might need to update CODAL to ensure we've got the latest fixes.
@JohnVidler any ideas about the larger power consumption? |
I've now updated CODAL to v0.2.40 and this default works correctly. |
But I just noticed that the microphone LED is permanently on now and the micro:bit draws 17mA extra compared to CODAL v0.2.35. And after playing a sound the micro:bit draws 54mA total at an idle REPL (it used to be 20mA at the REPL). |
I think maybe using |
Not had any cycles to investigate the power consumption yet, but my best guess would be that the audio pipline is being turned on, and left running after the initial playback, perhaps? Or that the speaker pin is being pulled strongly high/low at the end of playback rather than going back to floating when no data is present. In either case, consider this on my radar. |
TODO:
|
I think I'd also add that we'd like
|
Quick thing I've found, setting the volume to a value
|
Do we want to rename |
Yes, let's rename |
Need to also think about the default settings for the following parameters which are not exposed by the API here:
The value of steps makes a difference for the default sound. |
381972b
to
ab084f4
Compare
This was a rounding error converting between a range of 255 and 1023. Now fixed. |
ab084f4
to
5aa03ad
Compare
As per issue #103 and PR #106. Current limitations: - can't play an iterable of SoundEffect objects - if a sound effect is playing with wait=False and another one is started then the first one will be stopped immediately Signed-off-by: Damien George <[email protected]>
5aa03ad
to
854658d
Compare
As per issue #103 and PR #106. Current limitations: - can't play an iterable of SoundEffect objects - if a sound effect is playing with wait=False and another one is started then the first one will be stopped immediately Signed-off-by: Damien George <[email protected]>
854658d
to
a54e8a0
Compare
Implemented support for playing a tuple/list of |
For simplicity of implementation, this just concatenates the tuple/list of SoundEffect's into a big string to be passed directly to CODAL. Signed-off-by: Damien George <[email protected]>
a54e8a0
to
822b3c9
Compare
This is an initial implementation of the
SoundEffect
class, per #103.As a way to facilitate debugging/experimentation, the
SoundEffect
constructor can take a 72-length string as thepreset
value, which is interpreted as a CODAL sound expression string.The following example will play the GIGGLE sound (string data taken directly from CODAL source):
Output:
Limitations:
SoundEffect
objectswait=False
and another one is started then the first one will be stopped immediately