The TeamArg demo is neat as neat, and I would love to have music in Ardu Valley, but space is a serious concern. This got me to thinking about the smallest code I could come up with to play ‘music’ in my game. Behold, the following.
uint16_t l = 0;
void loop() {
if(!arduboy.nextFrame()){ return; }
uint8_t rbt = pgm_read_byte_near(l++);
if(!(l%31) || !(l%15)){
sound.tone(150 + (rbt*10 % 100),400);
}
//rest of game here
It basically steps through your progmem from address 0 and interprets it as a tone. You can adjust the modulo values and the tone range to get different outcomes. Here is what Ardu Valley sounds like with the above code.
It’s actually a technique that used to be used back in the day reasonably often. You would just search your compiled code for byte patters than gave you nice music
Actually, I was also thinking about how possible it would be to compile static data in such an order that you could extrapolate a longish melody hidden within everything.
it would be easy enough to make a score that is basically pairs of numbers. When your program counter for your tone location is equal to the first number, change to the second number. Obv you would need to do this last thing.
Procedural music is totally a thing! I think it takes some serious musical chops to build something that sounds intelligible to humans. Seen it done in demo scene world right? Do some of those guys publish their music in formula mode I wonder?
AND when you’re at it, just copy paste this in the “left” box and press generate sound: f=t*Math.pow(2,(0x75054970>>((t>>13&7)<<2)&0xF)/12+2)*((t>>11&3)+1),Math.abs(f%256-128)-64