Re: Reading audio samples immediately
- From: Michael Zarky <mXzarky@xxxxxxxxxxxxx>
- Date: Fri, 05 Oct 2007 07:06:39 -0700
Hitchkas wrote:
This is probably asking too much but do you know if it is possible to
read audio samples as they are sampled. For example if the soundcard
is sampling at 22 kS/sec then each sample becomes available every
45usec. Is it possible in this case to have a callback function
invoked every 45usec immediately after the sample is taken?
Thanks
I once did exactly that; but it was a total hack and incompatible with
the operating system. I don't know (but would love to know) how to adapt
it to Windows today.
My project is real-time pitch feedback. Way back under W3.1, as I was
learning about how soundcards operate, I copied and adapted the basic
driver assembly code for my particular soundcard and set up, started and
stopped the card and the DMA controller myself. The card used DMA to
transfer the incoming/outgoing data and by polling the particular DMA
control words I could see exactly when the next data point was dropped
into the memory area I had allocated. So I did have a latency of only
one sample (44 kHZ). In one mode I play back an "in-tune" note depending
upon which note is closest to what the user is playing/singing. This is
the only time I have had such a mode work really beautifully, it could
react basically instantly - using the Windows sound interface, ( a total
piece of $@!&*, the input and output delays are just so long that the
results are often pathetic.
Of course this isn't compatible with running anything else
simultaneously, it completely took over the system with a polling loop,
or with keeping Windows from crashing. But I learned a lot, and keep
wishing some special mode would be created for use of real-time sound.
But from what has been written on newsgroups about Vista, we step
backwards with each new incarnation.
I don't know exactly what contemporary sound cards do for data transfer
but suspect that with USB or whatever, there is little datum-by-datum
transfer, but rather a block of data moves at one time. And it doesn't
help to set up WaveIn with tiny buffers, as the driver often uses a
bigger buffer and so you can't get the data any more quickly than the
size the driver uses. DirectX from all reports is no better than the
WaveIn API, as it all depends on the driver's latency.
You might look into the Macs instead! I've heard they are much better
but I have no experience.
Michael
.
- Follow-Ups:
- Re: Reading audio samples immediately
- From: Jerry
- Re: Reading audio samples immediately
- References:
- Reading audio samples immediately
- From: Hitchkas
- Reading audio samples immediately
- Prev by Date: Re: Reading audio samples immediately
- Next by Date: GSM Wav file format question
- Previous by thread: Re: Reading audio samples immediately
- Next by thread: Re: Reading audio samples immediately
- Index(es):
Relevant Pages
|
Loading