Homebrew Audio streaming code issue

Poketard

Well-Known Member
OP
Member
Joined
Apr 3, 2013
Messages
180
Trophies
1
XP
1,490
Country
United States
Trying to avoid using maxmod, I'm developing my own simple sound library for the DS, but I'm having difficulty getting audio streaming working. On emulator it has audio popping, while on real hardware it seems to just play static for a brief moment before nothing at all.
My method is playing a looping sound of 4096 samples, then starting a timer to read to the 4096 sample buffer, determining how much to read by the sample rate and said timer. I've included the source code in a zip, if anyone is knowledgeable on this subject and willing to help me I would be very grateful.
Post automatically merged:

Okay. So I fixed the popping, and changed my code to use a single timer, so it's overall better. But it still doesn't work on hardware. And I still have no idea why. Updated source attached, if necessary.
 

Attachments

  • DSAudioTest.zip
    2 MB · Views: 32
Last edited by Poketard,

Poketard

Well-Known Member
OP
Member
Joined
Apr 3, 2013
Messages
180
Trophies
1
XP
1,490
Country
United States
Okay, I believe I fixed it. For any curious; there were 2 issues, first: I had to liberally flush the cache when sending stuff to the arm7, second I had to recode it to fread to a different buffer outside of the timer interrupt and read from that buffer inside the timer interrupt. I.e. I had to not fread inside the interrupt itself.
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,030
Country
United States
I started looking at this and I ran into a few issues ... flushing the cache and the signed/unsigned sample conversion to name a few. and then I ended up just making a simple streaming only example. not what you asked for but it seemed like fun.

this example uses a larger playback buffer - and the code only handles the 8-bit mono example file. since the ds only supports panning instead of full stereo - the only way to implement stereo would be to to simultaneously playback a left and right sound - while splitting the audio data into two separate buffers - panned full left/right each.
it can be compiled to run either using the timer interrupt or by calling a stream fill function periodically. both options work on no$gba and on hardware. I only tested hardware on my dsi launching with memory pit and hb menu - and only long enough to have the sound loop and restart.
on hardware it does have the issue where there is a tick every so often as the timer and playback get out of sync. I think the only real solution to that is to pick one of the perfect ds playback rates that line up exactly with the sound and timer rates - and then converting the audio to that playback rate,
 

Attachments

  • ds-strm.zip
    2 MB · Views: 36

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Sonic Angel Knight @ Sonic Angel Knight: :ninja: