-
Notifications
You must be signed in to change notification settings - Fork 17
Calling tone() right on startup results in a shorter duration audio #241
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
Comments
Wow the logic analyzer is so cool! I tested using 500ms on 500ms off duration and I can also confirm the waveform looks right (from the logic analyzer view). What do you think? |
Good job! Your little experiment pointed me at the right direction. This is what happens: when you start the simulation, it doesn't know yet how fast your CPU runs. So it runs the simulation at maximum speed for a few milliseconds, and then uses that to estimate the slowdown factor. The virtual logic analyzer uses the simulation time, not the real time. That's why everything looks good there. But since the simulation itself is running faster than real time for the first few milliseconds, you're getting a shorter tone / blink at the beginning. |
Happy to help! LOL - great work finding the cause of this - it may solve other start-up related issues :)
When I try to change the quick-fix |
It gets the speed of the simulated MCU. But it doesn't really know how faster your own processor is, as well as the environment (browser + OS). So it tries to run the simulation as fast as possible, and gradually slows down until it (hopefully) converges around 100% of real-time speed. If you simulate an ATtiny85 running at 1MHz, the jump is even more pronounced. It can jump a few seconds into the simulation before the speed stabilizes. Up to now, it hasn't really been a concern - you are the first person to find and report an issue related to this. So now I have a reason to look into how to improve it :) |
Ohh now I got it!
Lucky me with my special talent to ruin the party by pointing out this kind of stuff ;) Well good luck with this one! please let me and others know how you solved it here before closing the issue. |
This should be fixed now, thanks to change in how the simulation scheduler works. |
Describe the bug
Calling tone() right on startup results in a shorter duration audio.
To Reproduce
Play this - and hear the first beep is shorter than the others.
Expected behavior
Both beeps play for the same duration.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: