Mail Archives: djgpp/1998/04/07/19:45:52
Joshua Hale writes:
>Can anyone help me with the timer interrupt under DOS? I'm trying to
>play a sample using the timer interupt on a Sound Blaster, but I have
>a problem that I think is caused by my timer interrupt taking too long.
That isn't a very good way to go about sample playback, because as you
have discovered it is very hard (I would say impossible) to get an
interrupt going fast enough. A much better solution would be to use a
DMA transfer mode: you allocate a buffer somewhere in conventional
memory, fill it with sample data, program the DMA controller to transfer
this information to your soundcard, and then the sound will play at
whatever rate you specify while your program gets on with doing other
things in the foreground. The SB will generate an interrupt when the
buffer has finished playing, and you can use this to switch across to
another buffer of sample data, so you can build up longer sounds out of
a series of small DMA transfers.
For some working code that does this, look at the sb.c and dma.c files
from Allegro.
--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
"Pigs use it for a tambourine" - Frank Zappa
- Raw text -