ADSR envelope shaping on audio file
Mostra commenti meno recenti
I'm trying to apply ADSR envelope shaping to an audio file as shown below.
load handel y Fs;
N = 1.5 * Fs;
t = [0:N-1]/Fs;
x = y/Fs;
env = interp1([0 0.1 0.3 1.1 1.5], [0 1 0.4 0.4 0], t);
y = env .* x;
sound(y,Fs)
However, when performing the .* calculation, MATLAB freezes as the calculation is too large.
Could you assist in solving this problem? Thanks in advance.
Risposta accettata
Più risposte (1)
Mathieu NOE
il 6 Nov 2020
ok
so simple problem of vector dimensions mismatch in your code
the env vector is either too short or the vector on which it is applied is too long
you have to modify one or the other
below my 2 cents suggestion, assuming N was supposed to be the number of samples extracted from the original file
also I didn't get why the line : x = y/Fs; this will simply reduce the amplitude of the output signal to almost zero
load handel y Fs;
N = round(1.5 * Fs); % why 1;5 ??
t = [0:N-1]/Fs;
% x = y/Fs; % why ??
env = interp1([0 0.1 0.3 1.1 1.5], [0 1 0.4 0.4 0], t);
env = env(:);
x_truncated = y(1:N); % only the first N samples of the audio file
x_truncated = x_truncated(:);
y = env .* x_truncated;
sound(y,Fs)
3 Commenti
John D
il 6 Nov 2020
Mathieu NOE
il 6 Nov 2020
Was the size of the envelope supposed to equal the length of the total audio file ?
if yes you simply have to correct the t (time) vector length
N = length(y) ; (and not N = round(1.5 * Fs))
John D
il 7 Nov 2020
Categorie
Scopri di più su Audio Plugin Creation and Hosting in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!