My problem is that using the ToneLibray (with the fix mention in the last post from here) to play at minimum 3 speakers at different times has brought up the problem that using the delay() functions or millis() or those related functions will completely halt the program. I've tried a work around with loops pausing until a certain time has passed with millis(), but it seems to not work as well. The array that the original loop runs off is a pretty large integer, declared as int CSVSong [][2], with the first part of the entry being the note value and the second being the tick. Essentially, if a note isn't being played at a certain tick and there is not 3 speakers being used, an open speaker will be found and played using the note, and if the note is found, the speaker using it will be turned off.
The problem I'm facing is that, even though it seems that delay() is somewhat frowned upon because it blocks, I still need it to space out the notes and keep the durations and spacings the same. Unfortunately, I can't seem to use it at all.
The board I'm using is an Arduino Mega 2560, I know it's capable of using multiple speakers at one time with the library because I have tested out simple code to play several tunes at once.
I've included the files (except the library), and, I know some of it is really messy and could be improved, but I'm more focused on the problem at hand. I'm always open to suggestions though
Any help would be greatly appreciated, I've been working on this for some time and, even though I'm really tired and stressed about trying to fix it, I really don't want it to all go to waste because I simply gave up. I don't know all too much about using the timers directly; I was led to believe that several timers were for core functions and by using only 3 speakers, there would still be the essential core timers left open.
ForumProblem.ino (1.38 KB)
CSVStuff.h (21.5 KB)
pitches.h (1.73 KB)