Borrar filtros
Borrar filtros

Time and Frequency domain variable delay filter implementation

2 visualizaciones (últimos 30 días)
Shakeel Raja
Shakeel Raja el 11 de Abr. de 2017
Respondida: Sachin Kumar el 19 de Abr. de 2017
Dear friends, I am working towards developing a variable delay filter (FLANGER) in time and frequency domain and compare the performance and quality. Currently I have the time domain filtering working fine with following code....
clc; clear all; close all;
% BASIC FLANGER y(n) = x(n) + gx[n - M(n)]
[x,Fs] = audioread('guit.mp3');
x = x(:,1);
% CONTROLLING PARAMETERS
delay=0.003; % 3ms max delay in seconds
depth = delay; % Amount of depth
modRate = 2; % rate of flange in Hz
FeedBack = 1; % MIX control. Original signal strength
FlangAmp = 0.5 ; % MIX control. Flanged signal strength
% Change to samples
DELAY = round(delay*Fs); % delay in samples
DEPTH = round(depth*Fs); % mod. depth in samples
MODF = modRate/Fs; % modulation frequency in samples
if DEPTH>DELAY
error('Depth cant be greater than Delay . max depth =< delay, min depth = 0');
return;
end
LEN=length(x); % Samples in input file
DLEN=2+DELAY+DEPTH*2; % Length of the entire delay
Delayline=zeros(DLEN,1); % Vector for delay line
y=zeros(size(x)); % Output vector
for n=1:(LEN)
MOD = (sin(MODF*2*pi*n));
TAP= 1+DELAY+DEPTH*MOD;
F(n)= 1+DELAY+DEPTH*abs(MOD);
%TAP(n)=1+DELAY+DEPTH*MOD(n);
i= floor(TAP);
frac= TAP-i;
Delayline= [x(n);Delayline(1:DLEN-1)];
%Linear Interpolation
y(n)= Delayline(i+1)*frac+Delayline(i)*(1-frac);
end
% construct the output signal with MIX controls.
out = FeedBack*x + FlangAmp*y;
sound(out, Fs);
This produces a nice controllable delay effect as desired. Can i improve the performance of this filter in any way ?? to perform faster and/or better quality.
Also, trying to implement this in frequency domain is giving me horrific results. sounds more like a distortion than flanger. here is the code im trying with ... following above section ..
lfo = (F);
Y = (fft(x));
y2 = abs(Y);
a = lfo' .* Y ;
b = real(ifft(a));
sound(b,Fs);
Could you kindly advise me what exactly am i doing wrong ?? Do i have to use windowing before multiplication here? if yes, how would i control the variable delay.
Thanks :)

Respuestas (1)

Sachin Kumar
Sachin Kumar el 19 de Abr. de 2017
nfft = 2^nextpow2(2*LEN);
fax = Fs*(-nfft/2:nfft/2-1)'/nfft;
shft = exp(-1j*delay*2*pi*fax); % w=2*pi*fax,, Frequency function for delay
fsd = fft(x(:,1),nfft); % Take FFT
fsd = fsd.*shft; % Apply delay
dum = ifft(fsd); % Return to time domain
sd(:,1) = real(dum(1:LEN));
sound(sd,Fs);
Use the above code for frequency domain delay.

Categorías

Más información sobre Audio I/O and Waveform Generation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by