Here’s a quick test - it works in the emulator, but I haven’t tried it on hardware yet. I basically just pasted simple loops 4 onto the end of the file, and combined the snare+hi-hat into a single percussion track to avoid sound effect collisions:
I think you’d need something longer and more interesting than a single bar of music in a loop, otherwise it’s likely to drive the poor players insane :-/ The 12-bar pattern is arguably still too short, and it doesn’t help that I’m kind of tone deaf and am trying to compose songs based on half-understood music theory…
Once you have a longer piece, you’d either end up with a gigantic melody string that would be a pain to edit manually, or you’d need to use multiple distinct parts that you’d then need to synchronize. While the single-string example is easy to use with a single play()
command, it’s a bit inefficient since it repeatedly switches back and forth between waveforms and envelopes in a way that has a lot of redundant pieces.
Separately, you need to be careful about the overall parallel sound channels being used. You’ll want to keep some available for sound effects, and I think there are also some collision issues when starting new sounds while previous ones are still playing. A new bar of melody might end up cutting off an ongoing sound effect instead of replacing a sustain from the previous bar’s last note.
I think it would be an interesting experiment to see what’s possible. Anyone up for tackling something like Ballblazer’s algorithmic theme music?