Placing data in FLASH memory
On the Zero there is no need to use PROGMEM to put data in Flash, it is enough to specify variables as const. (source: https://forum.arduino.cc/index.php?topic=345026.msg2379203#msg2379203 )
Using FLASH memory as RAM (sort of)
It is possible to write to Flash Memory at runtime using the functions and example at http://www.nongnu.org/avr-libc/user-manual/group__avr__boot.html . So that could be used to make a game with LOTS and LOTS of content. Yay!
Optimising the Audio_Handler
The Audio_Handler in the AudioZero library use the generic analogWrite to write the data to the analog pin, and that function seems to have quite the overhead. Look into writing a custom optimised analogWrite. Look into:
- pinMode is called on every analogWrite. Is this necessary of the pin is always marked as OUTPUT?
- digitalPinToBitMask reads, via pgm_read_something, from the array digital_pin_to_bit_mask_PGM at the index defined by the constant A0. Resolve this read beforehand.
- digitalPinToTimer reads, via pgm_read_something, from the array digital_pin_to_bit_mask_PGM at the index defined by the constant A0. Resolve this read beforehand.
- The constant A0 is defined i pins_arduino.h and is unique for each platform