creating the chorus effect without using a loop
16 views (last 30 days)
Show older comments
okay so I made some progress but I am still lost and im not sure what sound I am suppose to hear back. There are not any helpful youtube videos about this topic.. but now I am hearing a static noise for about 3 seconds. Please if anyone can look at my updated code and help me out so I can see what I am doing wrong. Do it for a veteran :)
[x,Fs]=audioread('slowguitar.wav');
sound(x, Fs);
n=44100;
D=round(Fs*40e-3);
x=rand(1,n);
y=zeros(1,n);
y(1)=x(1);
y(2:n) =x(2:n)+x(n-D);
sound(y(2:n), Fs);
2 Comments
Paul
on 15 Nov 2022
Hi Damien,
I don't know what the chorus effect is, so don't know how it should be implemented. If it can be explained, preferably in mathematical terms, it's likely someone could help implement it in Matlab.
In the above code, the variable x is an output from audioread, but four lines later it's overwritten with random numbers. Is that correct?
Accepted Answer
Mathieu NOE
on 15 Nov 2022
hello
the chorus effect is basically a multiple echo effect ; the echo by itself is a delayed version of the original signal , added to it with a given amplitude (therefore you can tweak the delay and amount of the echo)
when you have understood the echo principle , apply it multiple times and here you have a chorus effect (like many people singing at different distance from the listening point, causing different delays and amplitudes)
the code below is for a wav file (attached if you want to try it) but you can easily modify it at your convenience
infile='DirectGuitar.wav';
outfile='out_chorus.wav';
% current sample is 11kHz so 0-3 ms is 0 - 33 samples
% read the sample waveform
[x,Fs] = audioread(infile);
% normalize x to +/- 1 amplitude
x = x ./ (max(abs(x)));
samples = length(x);
nb_effects = 4; % assume we do 4 delayed versions of the signal that will be summed
% amplitude is now a vector
amp = [0.7 0.7 0.7 0.7]; % suggested coefficient from page 71 DAFX; the values apply to the 4 delayed versions of x
cur_delay = [134;248;422;13]; % fixed delay case
max_samp_delay=max(cur_delay);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y = x; % init y
for i = (max_samp_delay+1):samples
% add the amp weigthed multiple delayed x values
y(i) = x(i) + sum(amp(1:nb_effects)'.*x(i-cur_delay)); % add all 4 delayed sample (in one line !)
end
% write output
% normalize y to +/- 1 amplitude
y = y ./ (max(abs(y)));
audiowrite(outfile, y, Fs);
figure(1)
hold on
plot(x,'r');
plot(y,'b');
title('Chorus and Original Signal');
legend('Original','Chorus');
sound(y,Fs);
10 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!