Skip to content
Snippets Groups Projects
Commit d0bd45ad authored by YE Victor's avatar YE Victor
Browse files

Upload New File

parent 7dfc7e7e
No related branches found
No related tags found
No related merge requests found
function synthese_soustractive_optimisee()
% Paramètres
Fe = 44100;
D = 1; f0 = 220;
t = 0:1/Fe:D-1/Fe;
% Enveloppe ADSR
env = envelope_adsr(length(t), Fe, 0.05, 0.2, 0.6, 0.2); % plus rapide + sustain moyen
x = sawtooth(2*pi*f0*t);
% Filtre passe-bas FIR
fc = 600; % fréquence de coupure proche de 5*f0
ordre = 50;
Wn = fc / (Fe/2); % normalisation
b = fir1(ordre, Wn, 'low'); % filtre passe-bas
% Application du filtre
y = filter(b, 1, x);
% Application de l’enveloppe
y = y .* env;
% Écoute
soundsc(y, Fe);
end
function env = envelope_adsr(N, Fe, A, D, S, R)
Na = round(A * Fe);
Nd = round(D * Fe);
Nr = round(R * Fe);
Ns = N - Na - Nd - Nr;
if Ns < 0
error('Durée totale trop courte pour ADSR.');
end
attack = linspace(0, 1, Na);
decay = linspace(1, S, Nd);
sustain = S * ones(1, Ns);
release = linspace(S, 0, Nr);
env = [attack, decay, sustain, release];
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment