DSPRelated.com
Forums

introduce input/output delay in soundcards

Started by Ubi March 4, 2008
Can anyone tell me the best way to introduce a delay between audio input and 
output in PCs?

I explain better.
I have an external audio source, connected to the MIC input of the laptop.

I would like that the soundcard outputs the such input with a 3 seconds 
delay?

Are there software to do this?


Daniele 


Ubi wrote:
> Can anyone tell me the best way to introduce a delay between audio input and > output in PCs? > > I explain better. > I have an external audio source, connected to the MIC input of the laptop. > > I would like that the soundcard outputs the such input with a 3 seconds > delay? > > Are there software to do this?
What is the sample rate and bit depth? You need RAM to store three seconds of sound. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
> What is the sample rate and bit depth? You need RAM to store three seconds > of sound.
It doesn't need to be of great quality. Let's say 64kbps. Is there a software to do that? Thanks Daniele
Ubi wrote:
>> What is the sample rate and bit depth? You need RAM to store three seconds >> of sound. > > It doesn't need to be of great quality. > Let's say 64kbps. > > Is there a software to do that?
Do you know how to write a circular buffer? That's all you need in addition to the I/O routines, and they probably are available with your sound card. Your paritcular circular buffer is the simplest kind. Input and output are in lockstep, so you need only one pointer. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
> Do you know how to write a circular buffer? That's all you need in > addition to the I/O routines, and they probably are available with your > sound card. Your paritcular circular buffer is the simplest kind. Input > and output are in lockstep, so you need only one pointer.
I never dealt with DSP before (a part from one exam at uni). Do you think I can find some basic software which can do it? My soundcard is "SoundMax Digital Audio" and it's integrated in the motherboard of the laptop. Thanks for your clarifications Daniele
Ubi wrote:
>> Do you know how to write a circular buffer? That's all you need in >> addition to the I/O routines, and they probably are available with your >> sound card. Your paritcular circular buffer is the simplest kind. Input >> and output are in lockstep, so you need only one pointer. > > > I never dealt with DSP before (a part from one exam at uni). > Do you think I can find some basic software which can do it? > > My soundcard is "SoundMax Digital Audio" and it's integrated in the > motherboard of the laptop. > > Thanks for your clarifications
You will have to find out for yourself how to get a sample from your sound board and how to feed it one. There ought to be documentation for that; Google might help. The circular buffer is simple. You want a three-second delay. If you sample at 8,000 sample per second, that's 24,000 samples (3 * 8 = 24). You need a pointer into a 24,000 word region of memory. When a sample becomes available from the ADC, you grab a sample from memory where the pointer points, feed it to the DAC, then fetch the sample from the ADC and store it in the same place. Then you increment the pointer and check to see that it's still in bounds. If it went past the end, set it back to the beginning; otherwise, leave it alone. Either way, wait for the next sample and do it all over. Initialize the buffer to zero in order to avoid noise the first time around. Writing a program is a bit like building a house. (I have done both.) It's futile to just start putting things together; you need some sort of plan; a vision of what the final result will look like and what parts it will have. Even if you don't know all the details, knowing what needs to be accomplished at each stage is leads to confidence of success. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
If I interpret the OPs quest it's for something like Audacity but running in 
streaming mode.  I don't know of any streaming mode "program" with tools 
built in.  Knowing about such things might be interesting though......

Many people have suggested programming up the needed application - but I 
sense that's not where the OP is coming from.

So, I think the answer to the fundamental question is "no", there isn't such 
a "program".

Fred 


Fred Marshall wrote:
> If I interpret the OPs quest it's for something like Audacity but running in > streaming mode. I don't know of any streaming mode "program" with tools > built in. Knowing about such things might be interesting though...... > > Many people have suggested programming up the needed application - but I > sense that's not where the OP is coming from. > > So, I think the answer to the fundamental question is "no", there isn't such > a "program".
Sadly, I think you're right. Still, it amuses me to think of myself as the plural "many people". As far as I know, I have been Daniele's only respondent. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Fred Marshall wrote:
> If I interpret the OPs quest it's for something like Audacity but running in > streaming mode. I don't know of any streaming mode "program" with tools > built in. Knowing about such things might be interesting though...... >
It's a very trivial job for any of the open-source audio tools such as Csound, PD, Supercollider, all of which support real-time streaming. Even one of the demo projects in the VST SDK (Steinberg) features a plain delay effect. It is hard-coded for one second at sr=44100, but not exactly hard to change that. A (slightly) more interesting question is, just how precise that delay has to be. The i/o latency of a multimedia soundcard can amount to several msecs according to the hardware buffer size and the number of buffers. It also depends on the host API being used. Windows MME typically incurring high latency, and ASIO (Steinberg again) the lowest. Linux (using alsa) almost certainly still has the edge, with latencies of < 2msecs being all but routine. And indeed, there is any number of free VST effects "out there", which the simplest Google search will find; I just spotted one claiming delay times up to 80 secs. Richard Dobson
"Jerry Avins" <jya@ieee.org> wrote in message 
news:ZP2dnWA1NMQ4Q1PanZ2dnUVZ_vbinZ2d@rcn.net...
> > Sadly, I think you're right. Still, it amuses me to think of myself as the > plural "many people". As far as I know, I have been Daniele's only > respondent. > > Jerry
Hmmmmm... my lack of observation amuses you. :-) I'm glad I could amuse. And, sorry then if it seemed overly critical. Wasn't meant to be. Fred