Skip to content
Snippets Groups Projects
Commit 6b5015ba authored by PERBEN Anatole's avatar PERBEN Anatole
Browse files

Upload New File

parent 5a60c118
No related branches found
No related tags found
No related merge requests found
% Paramètres de base
f0 = 220; % Fréquence fondamentale
amplitudes = [77, 75, 60, 63, 60, 56.5, 55, 41];
Fs = 44100;
duration = 4;
N = duration * Fs; % nombre total d'échantillons
% Créer un spectre de taille N (complexe)
X = zeros(1, N);
% Positionner les harmoniques dans le spectre (en amplitude complexe)
for n = 1:8
bin = round(n * f0 * N / Fs); % position dans le spectre
X(bin + 1) = amplitudes(n) / 2; % moitié en partie réelle
X(N - bin + 1) = conj(X(bin + 1)); % symétrie conjuguée
end
% Signal temps par IFFT
signal = real(ifft(X));
% Normalisation
signal = signal / max(abs(signal));
% Enveloppe ADSR (même que précédemment)
A = 0.01;
D = 0.05;
S = 0.2;
R = 0.1;
Na = round(A * Fs);
Nd = round(D * Fs);
Nr = round(R * Fs);
Ns = N - (Na + Nd + Nr);
envelope = [linspace(0, 1, Na), ...
linspace(1, S, Nd), ...
S * ones(1, Ns), ...
linspace(S, 0, Nr)];
envelope = envelope(1:length(signal));
% Application enveloppe
signal = signal .* envelope;
% Lecture
sound(signal, Fs);
% Affichage
t = linspace(0, duration, N);
figure;
plot(t(1:3000), signal(1:3000));
title('Son généré par IFFT avec enveloppe ADSR');
xlabel('Temps (s)');
ylabel('Amplitude');
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment