# Impulse Response h(t) [closed]

I have a project in which I have to create chorus effect to an audio file. I have tried this code and i don't know weather its right or wroung. Anyway the code is below

[x,fs]=wavread('ShortWAV.wav');
f=0.25;
delay_in_sampels=0.05*fs;%50 ms delay
index=1:length(x);
sincurve = 1*sin(2*pi*index*f);
y = zeros(length(x):1);
y(1:delay_in_sampels)=x(1:delay_in_sampels);
a=1;
b=5;
for i =(delay_in_sampels+1):length(x)
i=floor(i);
sink=abs(sincurve(i));
delay=(delay_in_sampels+sink);
o=ceil(i-delay);
y(i)=(a*x(i)) + b*(x(o));
end
soundsc(y,fs)


Now I have been asked to find its impulse response.

• Is this a homework question? If so, the question should be tagged. – Jacob Jun 5 '13 at 14:57
• Actually i am new to this site or any site like this. and its given me as mini project in signals and systems. – Tauseef Jun 18 '13 at 19:46

A chorus effect is achieved by adding a delayed version to the original signal and then modulating the delay. There are typically three parameters that control a chorus

1. Speed: frequency of the delay modulation
2. Depth: amplitude of delay modulation
3. Mix: Ratio of original and delayed signal

There are a few more things to play around with: min delay, modulation shape, number of taps, etc..

There are lots problems with your code:

1. The speed of your modulation is not 0.25 Hz (which you probably intended) but a quarter of the sample rate, which is way too fast for a chorus
2. The delay needs to calculated as d[n] = dMax*(1 + sin(modFreq*t)) so it needs to be centered around a medium delay with the modulation going up and down from there
3. You need a sub sample delay and not just round to the nearest integer
4. The delayed signal should never be larger than the original one

Finally, there is no impulse response. By definition the chorus is a time variant system and impulse responses can only be defined for time invariant systems.

• Note that a time-variant systems can indeed be characterized by an impulse response as long as it is linear. This impulse response is, however, a 2-dimensional function. The output signal can be computed by $y(t)=\int_{-\infty}^{\infty}h(t,\tau)x(\tau)d\tau$ where $h(t,\tau)$ is the impulse response of the linear time-variant system. – Matt L. Jun 5 '13 at 15:30
• Thank you very much for your answers.I consulted another teacher in this regard. He told me that the code is fine but now I have to find fourier transform for the input and output. So if you can help me in this. And once again thank you very much. – Tauseef Jun 18 '13 at 19:50