gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Audio > Sound Newbie

#5862 - peltazoid - Sun May 11, 2003 1:25 am

after reading the few articles on sound coding, i'm trying to get the irq mode to work.

the code is based on belogics directsound code.

but the sample i play is distorted, sometimes it corrects its self near the end?

the sample has been saved at 16386Hz, i'm using the 1024 cycle clock.
the interrupt handler copies the next 32bit word into the fifo buffer every 4 cycles.

conversly my dma code works fine, noise, perfect output.

i can not test this on hardware as yet. i'm using vba 1.5 as my emulator.

any suggestions, also whats the best way to play back samples? dma or irq? timing i take synching to vblank is a good method?

Cheers,

#5873 - gb_feedback - Sun May 11, 2003 11:51 am

I toyed with using IRQ myself while trying to write my midi player.
If you mean what I think which is using IRQ to write to the FIFO then I found (the obvious fact) that it involves a tremendous overhead in handling IRQs all the time, and they don't have the priority that DMA has. And if you ever have to do so much in an IRQ that you miss the next one - there goes your sound...

My conclusion, for general purpose sound, do what everyone else does and use dma. BTW this involves no IRQ at all, except for the VBLANK.

EDIT: One point to watch is that, if you have to do something processing-intensive every now and then to progress your music or whatever, the time taken to do it is spread over a whole frame when you use dma, whereas it has to fit into 4 samples worth of time if you do it during an IRQ. That was my main problem in any case.

EDIT: My only other reservation is using emulators for testing time critical code. I've never tried it myself but it has to be asking for problems.

For what its worth (not a lot) - I put a description of how my sound generation works on my web page (click the Midi link at the left). I suspect it describes the way most people do it.
_________________
http://www.bookreader.co.uk/