This thread is to continue the discussion started in the Bumble Bots Re-Pair thread, regarding Sound FX and Music, which drifted slowly off-topic.
The easiest way to play music on the Gamebuino is by playing WAV files. A drawback is that this requires relatively a lot of storage. One minute of music at the default sample rate, 44.1 Hz, requires a 2.6 MB file. Another drawback is that the samples are only eight bits. Converting an exiting track, which typically uses 32-bit samples, down to use eight bits often introduces noise. A third drawback is that these sound files currently cannot be included with the game when published on this site, so users will have to download and install these separately which is a bit cumbersome.
So, as an alternative one might consider generating music programmatically. Although that definitely requires skill, it is in principle a way to very efficiently encode the music. Instead of storing all the samples, you simply describe how to generate these. The PICO-8 virtual gaming console uses this to good effect.
Unfortunately, Gamebuino does not yet support this. So, @jicehel, that you cannot do this is therefore not caused by lack of skill at your end. At least, that’s not the only factor… :-). The current Sound FX library can be used to generate in-game sound effects, but is not powerful enough to create music. It might be used as a basis, but more is required.
So what is lacking? PICO-8 can be used as an easy reference. First, the current sound effects are a bit limited. The library currently only supports square waves and noise. The latter is mostly useful for creating sound effects (e.g. crashes) but not so much for music. Adding more wave forms would make it easier to create different instruments. Also, support for extra effects (slides, arpeggios, etc) would help.
Second, the sound effects currently only have one channel. Starting a new sound effect while another is playing cuts of the latter. Multi-channel playing of Sound FX is required to give each instrument its own channel. A challenge will be combining the various channels. You do not want distortions when they are all loud at the same moment, but you may want to avoid unnecessarily limiting the volume of the individual channels beforehand.
Third, you need a higher-level language that allows you to describe the musical composition. E.g. loop this bass track for four bars, next switch to this track for two bars. Meanwhile, the melody line will play these three bars, then repeat. Etc.
Unfortunately, my musical skills are quite poor. Nevertheless, writing the above down does make me wonder what is possible on the Gamebuino. If I find the time, I may have a go at trying to programmatically reproduce the Bumble Bots sound track created by my brother.
Anyway, has anyone already tried to programmatically create music on the Gamebuino? Or experience with creating 8-bit music? Any thoughts or ideas?