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.
It can be found here.
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_t
s 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!
#include <Arduboy2.h>
#include "src/ArduboyTonesFX.h"
#include <ArduboyFX.h>
#include "fxdata/fxdata.h"
Arduboy2 arduboy;
uint16_t buffer[8];
ArduboyTonesFX sound(arduboy.audio.enabled, buffer);
void loop() {
if (!arduboy.nextFrame()) return;
arduboy.pollButtons();
sound.fillBufferFromFX();
...
sound.tonesFromFX(KickOutTheJams);