필터 지우기
필터 지우기

Apply a variable delay to an audio signal

조회 수: 6 (최근 30일)
Jesse
Jesse 2011년 9월 5일
Hi,
Ill try to explain my goal, then where I am so far.
I am trying to simulate a moving sound source by creating a 2 microphone signals. The first channel contains a set of harmonic sinusoids with different amplitudes and frequencies. The second channel should be a delayed version of the first channel. I would like the delay to start at zero, move to -1 millisecond, back to zero, then to +1 millisecond before returning again to zero delay. In this way by computing the time delay of arrival with a simple cross correlation it would appear the sound source is to one side then the other.
To accomplish this I have found dsp.VariableIntegerDelay class which I think is suitable for the task, however I believe this is only available in 2011a, I have the student version 2011a. Is there another way to create this variable delay in the second signal?
Help is much appreciated! thanks Jesse

채택된 답변

Daniel Shub
Daniel Shub 2011년 9월 5일
What you want to do is "delay" time by some amount. If your waveform is:
sin(2*pi*f*t)
then the delayed version is:
sin(2*pi*f*(t-tau))
where tau can be either a scalar or a vector the same size as t whose magnitude represents the delay in seconds. A better solution is probably to delay one channel by tau/2 and advance the other channel by tau/2. You do not specify how you want the delay to change. I am assuming a sinusoidal change, but you could easily make it linear (or anything else).
Fs = 44.1e3;
t = (0:1/Fs:1)';
tau = 1e-3*sin(2*pi*t);
f0 = 100;
N = 10;
x = zeros(length(t), 2);
for ii = 1:N
x = x+[sin(2*pi*ii*f0*(t-tau/2)), sin(2*pi*ii*f0*(t+tau/2))];
end
  댓글 수: 1
Jesse
Jesse 2011년 9월 5일
Hi Daniel, thanks very very much for the reply. I believe this works to delay the signals.
thank you
I am working now to get the cross correlation to work, there appears to be some common noise or some sort of signal at t=0 (no delay) in the crosscorellation which results in a high correlation. I will try to figure out where that comes from
thanks
Jesse

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Fangjun Jiang
Fangjun Jiang 2011년 9월 5일
If you want to delay a signal, usually you can pad zeros in front of it. Let's say x is your signal data, it's sample time is 0.1 millisecond, then you need to pad 10 zeros at the beginning to reflect 1 millisecond delay.
Ts=1e-4;
Delay=1e-3;
N=Delay/Ts;
y=[zeros(1,N) x];%x is row vector
%y=zeros(N,1);x];%x is column vector
Not sure what you mean by delay -1 millisecond. You want to cut off 1 millisecond of sound? That's easy.
y=x(N+1:end);
  댓글 수: 3
Daniel Shub
Daniel Shub 2011년 9월 5일
One problem with adding zeros is that with the typical sample rate of 44.1 kHz a single 0 adds a delay of over 22 micro seconds. This is over twice the magnitude of the delay that is just detectable. It is much better to add the delay in the frequency domain.
Fangjun Jiang
Fangjun Jiang 2011년 9월 5일
Now I think Daniel's answer using sin(2*pi*f*(t-tau)) is what you want since you are not really delay an existing signal. You are creating two signals with designed delay among them.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Signal Operations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by