Sawtooth - A Chiptune Music Player : DevLog

I have hit roadblock after roadblock over the past week (or 9 days). BUT, I've overcome!

The C++ library I was attempting to use was blowing up on device and crashing as soon as I attempted to instantiate an emulator. I had a heck of a time trying to debug whatever was happening down in the c++ library. (it would be super cool if we could step through a debugger in c or c++ code)

Then I had an epiphany, I looked up RockBOX source (iPod alternative firmware) and found that they have a C library of the Game Music Engine. I've ripped out all of the c++ stuff from my project and replaced it with c code i've lifted from rockbox codecs.

ANNNDDD...It Works! (sound on!)

That playdate.UpButtonUp event is doing the following:

  1. Loading a .nsf file from disk
  2. Creating a NSF Emulator
  3. Starting up the emulator
  4. Playing through the song (track #40 - Jump!)
  5. unweaving the output buffer (left & right channel) and feeding them into a playdate soundsource via the Audio Callback Source (major help found in this thread)

So, Sawtooth lives! Now I have a ton of work to make it proper software but getting actual sound emulation done on device lifts my burgeoning Playdate C development spirits! (speaking of learning, I figured out from my previous post that I wasn't using alloc & malloc to clear space on the heap prior to loading a file....what a n00b. (this code snippet is poetry...thank you @shaun & @james))

6 Likes