The ArduboyTones library allows you to put the score in RAM and play it using tonesInRAM(). Since a score consists of just frequency and duration pairs, you could speed up or slow down the score by altering every other word (the duration values) in the score array.
Having the score in RAM also allows you to dynamically and āalgorithmicallyā generate the music.
But I play it one by one depends on the current frame count. So, the score will be dynamically follows the speed of the current frame rate. But Iām sure itās not the best way to do it .
If you want a score to be synced to the frame rate, the best way would be to step through the score yourself.
You would start a note to play forever using tone(frequency) then use a counter that is incremented or decremented per frame, to count the number of frames that you want the note to play. When the count is reached, start the next note in the score (which will automatically cancel the currently playing note), then set the counter for this note.
Step through the entire score this way. Start back at the beginning when you reach the end if you want the score to repeat continuously.
I see, I think I already did that. But I didnāt play the tone forever, I set the time for each individual tone. Yours is much easier to implement, but too bad Iām already did it the hard way . I donāt know that if you play it forever, and you play the next note, it will cancel the previous one (But still my bad, I didnāt try it).