Skip to content
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

Play Sound block not reliably playing on hardware #4720

Closed
Jaqster opened this issue Jun 3, 2022 · 12 comments
Closed

Play Sound block not reliably playing on hardware #4720

Jaqster opened this issue Jun 3, 2022 · 12 comments

Comments

@Jaqster
Copy link
Member

Jaqster commented Jun 3, 2022

Repro - I have a bunch of music sounds in a Button pressed event
When I download (through Web USB) to the micro:bit and press button A, I don't hear the second Play Sound block. Then when I press button A again, nothing plays.
I am on Windows, Edge, with a micro:bit V2.2
test project - https://makecode.microbit.org/_FA8hVFe49e9u

@jaustin
Copy link
Collaborator

jaustin commented Jun 3, 2022

@JohnVidler this looks similar to the issue we saw on support that @microbit-pauline couldn't get to reproduce in /beta.

@Jaqster I think this sample program gets munged because the link doesn't open in /beta - can I modify the URL to load it in /beta or can you please share the TypeScript?

Does this need specific parameters in play sound? I've been using it a lot in programs and haven't seen this. However we did notice some interesting timing issues earlier this week that could be related. CC @microbit-carlos

@Jaqster
Copy link
Member Author

Jaqster commented Jun 3, 2022

Can't you just go to https://makecode.microbit.org/beta then click the Import button to copy/paste this URL?

@jaustin
Copy link
Collaborator

jaustin commented Jun 3, 2022

Yes, thanks. Didn't know that route. I wonder if the issue here is the combo of 'old' music blocks and new, which I think gives us multiple mixer channels.

@jaustin
Copy link
Collaborator

jaustin commented Jun 6, 2022

@Jaqster querying the P2 label on this - seems more like a P1 or P0 to me. Is there a mitigation for this or does it only happen in a subset of situations?

@JohnVidler
Copy link
Collaborator

I've boiled this down to a minimal program with just a play sound block in a button event:

image

It appears that if I set anything else, it works fine, but setting the interpolation to log results in the behaviour described here, so there's definitely something funky with the synth log generator.

Will investigate further.

@JohnVidler
Copy link
Collaborator

Additional note - playing both audio routes (melody and sound) works just fine, provided that the sound generator isn't using log interpolation.

@jaustin
Copy link
Collaborator

jaustin commented Jun 6, 2022

So if this is limited to log interpolation, I'm happy with the P2 label too.

@JohnVidler
Copy link
Collaborator

JohnVidler commented Jun 8, 2022

After further investigation, it seems that the log effect generator results in extreme values at both ends of the scale. Super high values from an effect result in the board locking up, and negative values result in unpleasent clicks from the speaker.

For now, as time is short for the 2022 Makecode release, I've implemented some hard stops for just this effect ( see https://github.com/lancaster-university/codal-microbit-v2/blob/master/source/SoundSynthesizerEffects.cpp#L102 ) which anyone wanting to test this can pull in right now, but ultimately this probably means we need to check the edge cases for each generator just in case.

This does avoid the hard stop that @Jaqster originally reported, and works for testing on the next tag.

I'm going to leave this open for now, however, but please demote its priority back down to P3 so we can track testing the other generators.

@pelikhan
Copy link
Member

pelikhan commented Jun 10, 2022

@JohnVidler can you try the program attached here? #4733 It should stress out the sound generation. @jaustin . It locks almost instantly on hardware. It works without logarithmic.

@JohnVidler
Copy link
Collaborator

@pelikhan I'm unable to test this until we push the next tag and generate the beta PR, but I'll put that on my todo immediately after that happens.

@pelikhan
Copy link
Member

Pushed

@abchatra
Copy link
Contributor

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants