Mail Archives: djgpp/1999/08/11/07:45:54
Sahab Yazdani writes:
> I have some code that will play a RAW sound file. The problem is that
> the interrupt gets called only once! See I want to make it so that in
> the future I can mix some sounds together also. So the code for
> actually sending data has to be in the handler.
That's how it is supposed to work. Inside your handler, you restart
the SB and DMA controller with another buffer of data. You need to
do this very quickly to avoid clicking and distortion problems.
Alternatively, on the more recent types of SB you can use an
autoinit DMA mode. You have to program both the SB and DMA
controller differently to enable this, but then it will loop
endlessly around a single transfer buffer. People usually program
the SB with half the buffer size of the DMA controller, which
raises an interrupt twice per buffer, giving you a chance to mix
new samples into whichever half of the buffer isn't currently
playing, for click-free playback.
The Allegro dma.c and sb.c files would be a good place to look
to see this in action.
Shawn Hargreaves.
- Raw text -