| Joel wrote:
[snip]
>The problem is that hard drive access
>time isn't quick enough to keep up with my 44.1kHz clock; hence, within
>22usec I could never hope to make 4 reads to the
>hard drive, and the samples to the DACs aren't making it there fast enough!
>I thought about loading my samples first into
>RAM, but that wouldn't be very efficient and would place a severe limit on
>the size of the sound file(100 secs of quad
>music takes around 35 Megabytes). Does anyone know how a sound card achieves
>its output? Surely it uses some kind of
>buffering (maybe with DMA?) that will keep on filling up a buffer with the
>samples, and then the samples are just
>ported out from the buffer, thus allowing the critical 22usec time frame to
>be achieved so that all DACs are filled and
>outputed according to the 44.1kHz clock before the next set of samples comes
>in.
>
>Any knowlege on sound card output would be appreciated...
Joel, as you suspected, soundcards do typically use DMA to read the
samples
out of a buffer. But, you *may* be able to make your existing hardware
work,
by doing what you say, which is to hold the samples in memory, and
writing
4 samples to the soundcard every clock tick. (I assume there is at least
a latch on your soundcard, to store the 4 samples, so that the precise
time that the processor writes the samples during the interrupt service
routine doesn't matter? I.e, I assume that the processor doesn't
write directly to the DACs! :) This would not necessarily
limit the size of the soundfile, because you could maintain a buffer,
and re-fill it when it has emptied to a certain lower threshold. But no,
this is not generally how it's done - it places a high overhead on the
processor, since it has to service 44100 interrupts a second.
I am not a "soundcard pro", and cannot give you details on
exactly how to do the DMA interface. There are books
on interfacing to PCs - I think you should obtain one.
I *think*, though, that there are two main ways to do the
DMA: (my memory is very hazy - please do not rely
on this information without backing it up with
a more reliable source!)
Single DMA channel
This mode requires the soundcard to be able to
generate an interrupt to the main processor.
The DMA controller (on the motherboard) is configured
for, say, 64K, and the interrupt generator on the
soundcard is configured to interrupt at two points -
when the buffer pointer is half way through the buffer,
and when the buffer pointer is at the end. The DMA
controller is configured to automatically reset and
start reading from the beginning of the memory buffer
when it reaches the end of the buffer. When you
receive an interrupt, you can load samples into
the other half of the memory buffer, etc. etc.
Dual DMA channels
This mode has the advantage of not requering an interrupt
generator on the soundcard, but has the disadvantage of
consuming two DMA channels. The DMA controller
is itself configured to generate an interrupt
when either channel reaches the end of it's buffer.
When a channel reaches the end of it's buffer,
the soundcard immediately switches over to the
other channel. In the mean time, software loads
samples into the other channel's buffer.
Note that not all soundcards use DMA. For example,
I know that some Turtle Beach soundcards have
their own memory buffer on the souncard,
which is made available in the upper memory
address range. Software is able to write
samples directly into this memory
buffer. My understanding is that this
method can be more efficient than DMA,
because DMA cyles are not very efficient
on an ISA bus. (it takes considerable time
for the processor to relinquish control
of the bus to the DMA controller, and
again to regain control)
Greg.
Greg.
> |