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

Loudness measurement should be rate-limited #72

Closed
ericrosenbaum opened this issue Jan 16, 2018 · 0 comments · Fixed by scratchfoundation/scratch-vm#930
Closed

Loudness measurement should be rate-limited #72

ericrosenbaum opened this issue Jan 16, 2018 · 0 comments · Fixed by scratchfoundation/scratch-vm#930
Assignees
Milestone

Comments

@ericrosenbaum
Copy link
Collaborator

Expected behavior

If you use several loudness blocks, they should not cause the loudness analysis code to run multiple times in a single scratch animation frame.

Actual behavior

Each time a loudness reporter is called it runs the loudness analysis.

Steps to reproduce

This program uses a run-without-screen-refresh custom block to check the loudness 100,000 times, and measure the time it takes:

screen shot 2018-01-16 at 6 05 53 pm

On Scratch 2.0 on my machine, this reports 0.08 seconds, and on Scratch 3.0 it reports about 0.45 seconds.

Notes

One strategy for improving this would be store a timestamp each time the loudness is requested, and also store the loudness value itself. Then, each time, if the current time is long enough after the timestamp (e.g. one frame at 30fps- since we are not measuring the platform's audio buffer duration), then make a new measurement- otherwise just return the stored value. For the program above, this should result in the loudness analysis being done once each time the custom block is run, instead of 100,000 times.

Operating system and browser

Mac OS 10.12.6 Chrome 63

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

Successfully merging a pull request may close this issue.

2 participants