Skip to content
Snippets Groups Projects
Commit 878ee950 authored by LERAYS Camille's avatar LERAYS Camille
Browse files

coucou

parent 45ca8ab8
No related branches found
No related tags found
No related merge requests found
% Question 1 :
[x,fe]=audioread("C:\Users\camil\Documents\IMT_A\semestre_6\electrical engineering\tp-audio-ee-etudiant-c24leray\src\wav\single_tone_celtic-harp-a3.wav");
soundsc(x,fe);
L1 = length(x1);
X1 = fftshift(fft(x1));
f1 = (-L1/2 : L1/2 - 1)*(fe1/L1);
figure;
plot(f1, log(abs(X1)),'r');
title("spectre")
xlabel("fréquence en Hz")
ylabel("log|X(f)|")
\ No newline at end of file
% Question 2 :
[x1,fe1]=audioread("C:\Users\camil\Documents\IMT_A\semestre_6\electrical engineering\tp-audio-ee-etudiant-c24leray\src\wav\single_tone_piano1.wav");
[x2,fe2]=audioread("C:\Users\camil\Documents\IMT_A\semestre_6\electrical engineering\tp-audio-ee-etudiant-c24leray\src\wav\single_tone_piano2.wav");
soundsc(x1,fe1);
soundsc(x2,fe2);
L1 = length(x1);
L2 = length(x2);
X1 = fftshift(fft(x1));
X2 = fftshift(fft(x2));
f1 = (-L1/2 : L1/2 - 1)*(fe1/L1);
f2 = (-L2/2 : L2/2 - 1)*(fe2/L2);
figure;
plot(f1, log(abs(X1)),'r');
hold on;
plot(f2, log(abs(X2)),'b');
title("spectre");
xlabel("fréquence en Hz");
ylabel("10*log|X(f)|");
\ No newline at end of file
% Question 3 :
freq_r=[220;442;663;885;1108;1331;1556;1782;2009];
Amplitude = [7259; 5541; 982; 1408; 502; 672; 573; 114; 347];
% Durée et fréquence d'échantillonnage
Fe = 44100; % fréquence d'échantillonnage (standard audio)
duree = 1; % durée du signal en secondes
t = 0:1/Fe:duree; % vecteur temps
% Initialiser le signal composite
s = zeros(size(t));
% Ajouter les sinusoïdes
for k = 1:length(freq_r)
s = s + Amplitude(k) * sin(2*pi*freq_r(k)*t);
end
% Normaliser pour éviter la saturation (valeurs entre -1 et 1)
s = s / max(abs(s));
% Jouer le son
soundsc(s, Fe);
figure;
plot(t,s)
\ No newline at end of file
% Question 4
% Define ADSR parameters
A = 0.1; % Attack time (seconds)
D = 0.005; % Decay time (seconds)
S = 0.8; % Sustain level (0 to 1)
R = 0.75; % Release time (seconds)
fs = 44100; % Sampling frequency (Hz)
% Total duration of the envelope
totalTime = A + D + R;
% totalTime = totalTime * 6; % Extend the envelope for 6 seconds
t = linspace(0, totalTime, totalTime * fs);
% Generate ADSR envelope
attack = linspace(0, 1, A * fs);
decay = linspace(1, S, D * fs);
release = linspace(S, 0, R * fs);
% Combine all segments
adsrEnvelope = [attack, decay, release];
% Plot the envelope
plot(t, adsrEnvelope);
xlabel('Time (s)');
ylabel('Amplitude');
title('ADSR Envelope');
[x, fe] = audioread("C:\Users\camil\Documents\IMT_A\semestre_6\electrical engineering\tp-audio-ee-etudiant-c24leray\src\wav\single_tone_piano2.wav");
% Apply the ADSR envelope to the audio signal
adsrSignal = x(1:length(adsrEnvelope)) .* adsrEnvelope';
sound(adsrSignal, fe);
audiowrite("C:\Users\camil\Documents\IMT_A\semestre_6\electrical engineering\tp-audio-ee-etudiant-c24leray\src\wav\single_tone_piano2.wav", adsrSignal, fe);
\ No newline at end of file
[xA, feA] = audioread("C:\Users\camil\Documents\IMT_A\semestre_6\electrical engineering\tp-audio-ee-etudiant-c24leray\src\wav\single_tone_piano2.wav");
% Apply the ADSR envelope to the audio signal
adsrSignal = abs(ifftshift(ifft(xA)));
sound(adsrSignal, feA);
% Plot the envelope
figure;
plot(feA, adsrSignal);
xlabel('Time (s)');
ylabel('Amplitude');
title('ADSR Envelope');
audiowrite("C:\Users\camil\Documents\IMT_A\semestre_6\electrical engineering\tp-audio-ee-etudiant-c24leray\src\wav\single_tone_piano2.wav", adsrSignal, fe);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment