I have hacked a copy of @MLXXXp’s ArduboyTones to work with the FX chip. You can now stream music and graphics from the FX chip simultaneously. I have included a sample program that shows how and includes streaming from the FX and from Ram as a comparison.
The approach is slightly different to the other tones() functions as it uses a circular buffer to hold the data to play. The buffer is replenished as part of the standard loop() processing, as shown below. This is primarily due to the fact that the FX and ArduboyTones would fight over interrupts.
The buffer size is configurable but my testing has shown that even the smallest buffer of 4 - 6 unit16_ts is enough. I guess if you have some really, really fast music and a really, really slow frame rate you could up it to a lavish length of 16!
After speaking with @mlxxxp, I might maintain this library in parallel to the official ArduboyTones library. I was thinking what I started with would be heavily altered to incorporate into the official library in a way that doesn’t add additional memory requirements or break anything.
Thus, these sorts of improvements are more than welcome.
I’d agree, but I feel like I might be deeply offending someone somewhere. (Probably someone who lives in a very urban area and likes to go clubbing. Or Markus Persson.)
If you’re going to do that, perhaps it would be better to name it ArduboyTonesFX, ditch the conditional compilation and only retain the FX-relevant functionality?
After all, I doubt many people are likely to be storing their sounds both in progmem and on the FX.
That’s about all I have to offer at the moment, and I only really mention it because it’s a bit of a no-brainer (zero cost + ease of use + extra safety), but if I get chance to look in more detail and spot anything useful I’ll let you know.