|
[...] After spending some time looking at the source I realized that the sample data output by your library is in a 16-bit *signed* format, which was not welcome at all by Allegro. So, I decided to use another sound library to output the data, namely PortAudio, which seems to work quite well.
Just about everything I've encountered uses signed samples when they are 16 bits (8 bit samples are common in both formats). If you use unsigned you've got to add a compensation offset when adding or multiplying samples. This function swaps between signed and unsigned representation:
void toggle_signedness( int16_t* p, size_t s ) { while ( s-- ) { *p ^= 0x8000; ++p; //*p++ ^= 0x8000; // might trigger obscure compiler bugs :) } }
Is there any way you could output samples in an unsigned manner?
Convert the buffer in-place; the only downside is the tiny performance hit. Blip_Reader allows inline reading from a Blip_Buffer, but it's much less friendly and not well documented yet. Blip_Reader will be better documented in a future release.
How can I find out the amount of cycles "stolen" (killed, murdered, whatever) by the DMC unit as it fetches sample data? Also, is there any way of knowing the exact time (timestamp) at which those cycles were stolen? Or, do you think all of this is not needed at all?
I measured 4 CPU cycles stolen by a DMC memory read (see the APU reference), which you can account for when your DMC reader callback is invoked. Regarding adjustment of the CPU, I'm going to start a new thread for the issue since it's involved.
|