I've been messing about with SGDK in my spare time. One of the things I was trying to do was come up with a more flexible resource system for myself. The idea is that the resource system reads in a sort of manifest file, a JSON file which contains references to different files as well as metadata, and compiles those files into a few BIN files which are compiled into the game using Rescomp. The idea being each group of files, for instance audio, has a table in the output BIN file which can be used to map an index into an offset which can be used to get a pointer to the actual data. And since it stores the audio as an array in the manifest JSON file, it can somewhat easily map an audio path to an index, so that a data file which refers to an audio path can have that path transformed into a simple index in the resulting BIN file.
So, right now, I'm just working on the PCM sound. The layout of the file goes like this:
Code: Select all
u32 numSounds; // number of sounds which have been compiled
u32[] soundOffsets; // offsets from start of BIN blob to each sound's raw data
u16[] soundLengths; // length of each sound's raw data.
// header zero-padded to a multiple of 256 bytes so that raw audio data can be aligned on 256-byte address boundaries
s8[] rawSoundData; // just a big dump of all sounds' raw data. Use soundOffsets to find start of each sound, and soundLengths to find size of each sound. Each sound is also zero-padded to be a multiple of 256 bytes in length.
The thing is, this works almost perfectly except for one detail: every single sound has a pop at the end of it. It's the exact same pop for all sounds if I look at it in Audacity (recording emulator via WASAPI loopback), so it's probably not something funky like accidentally playing the next sound's data (otherwise each one, being at a different location in memory, would theoretically have a different pop). Even a purely silent sound exhibits this pop, despite verifying with a hex editor that the output file has all zero bytes, and in Audacity the levels don't change whatsoever until the pop (so it's not a DC offset issue or anything).
I can work on other stuff in the meantime since the sounds *do* play like they're supposed to and sound just like they're supposed to, but that popping is really damn irritating and I'd love to get any help on resolving it. It seems for all the world like a bug in SGDK, but I can also try compiling the WAV file with Rescomp and playing that to see if it has the same issue there too.