I'm basically done with my kotlin oscillator demo.
There was surprisingly little code left to write - in the last update, I was able to create the classes necessary to produce a simple song, in this case, the main theme from Super Mario Bros. But it only included the melody, not the harmony, bass line, or percussion.
To produce multiple tunes at once, I was going to need to generate multiple instruments and do some mixing. This turned out to be simpler than I though. In the case of multiple instruments, I just changed the instrument in the Song class into a list of instruments. I created a SongAudioGenerator class, that has an InstrumentAudioGenerator for each instrument. Then, it has each instrument generator create the audio needed to produce the sound. And then it just takes the results and adds them together.
Seriously. That's all mixing is. Adding the numbers together.
The harmony part was another square wave, and the bass line was a triangle wave. I honestly spent more time tracking the notes out than anything else.
For percussion, I created a noise oscillator, which is just based on random numbers. I don't think it's the best way to make a noise oscillator, nor does it actually sound like the percussion from the original audio. But it will do the trick, so I'm going to leave it as-is.
So, this is likely as far as I'm going to go on this project, as I'm going to move on to my next one, a protracker player, also based in Kotlin. This has been fun, and I've learned a lot.
Comments
Post a Comment