Closed cefn closed 11 years ago
In case it's relevant, I've forked the repo and reimplemented the functionality of arduino-rtttl-player in an Object-Oriented sort of a way, as well as replacing the existing _play*() functions with a non-blocking implementation.
You can see the new examples at... https://github.com/cefn/non-blocking-rtttl-arduino/tree/master/rtttl/examples
Sorry for the late answer, thanks for the fix!
The example testing the use of songs stored in Ram (Ram.pde) reveals a bug (which is implicit also in the other examples). In my environment at least, the Ram version of the examples doesn't play correctly, and never could.
That's because the notes array is declared as...
...and the read_word function is mistakenly invoked with a boolean which actually records whether the const char *p for the song should be interpreted as progmem or not, not the notes array.
This bug in the logic therefore confuses the reading of the notes[] array if the song is NOT stored in progmem.
The result is that if that the line in the _play(...) function which reads...
...breaks when pgm is false, or in other words, mistakenly tries to access the PROGMEM notes array as if it was in ordinary RAM, just because pgm is false (the song itself happens to be stored in RAM). This creates junk notes on playback. Changing this line in rtttl.h so it reads...
...should fix the problem for all playback types.