What are you having trouble with?
As previously posted...
I'm trying to get a handle on sound processing via LIBNDS.
I understand the basics... enough that my emulators have full sound... but it's far from ideal. Right now, here is my basic scheme:
I pick a sound frequency - say 15360Hz which works well because it's 256 samples per frame at NTSC 60Hz.
The emulator will emulate the sound chip for the ancient gaming system... and place samples into a circular buffer of size 256 (basically it fills the buffer every frame).
I set up TIMER2 as my sound timer:
TIMER2_DATA = TIMER_FREQ(mySoundFrequency);
TIMER2_CR = TIMER_DIV_1 | TIMER_IRQ_REQ | TIMER_ENABLE;
irqSet(IRQ_TIMER2, VsoundHandler);
This IRQ handler will move 1 sample from the 256 entry sample buffer over to a larger shared buffer between the ARM9 and ARM7 cores... this other buffer is, arbitrarily, 2048 to give me a bit of sound buffering without too much latency.
And I tell the ARM7 core to use this shared memory buffer and tell it my sound frequency of 15360.
And it all works... mostly. The sound is good but every 10-30 seconds I can hear a "zinger" ... a sound glitch that I think is related to the two CPUs either accessing the shared memory together or somehow they are not in sync. But I'm not sure... I've tried larger buffers and while that makes the 'zing' happen less frequently - but it also increases the potential sound lag. I've tried hacks like letting the ARM7 run a little faster or slower... that just produces more "zingers". The only solution I've found so far is to use the FIFO to pass a single sound sample across to the ARM7 ... this works but consumes so much CPU as to be practically useless long-term.
I'm (quite obviously!) not a sound engineer... but are there any basic tricks I could use or obvious flaws in my setup? Before anyone gets too technical, assume that I'll need this explained to me on a 5th grade level