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

coucou

parent 69d39fbd
Branches
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@ f2 = (-L2/2 : L2/2 - 1)*(fe2/L2);
figure;
plot(f1, log(abs(X1)),'r');
hold on;
hold on
plot(f2, log(abs(X2)),'b');
title("spectre");
xlabel("fréquence en Hz");
......
......@@ -12,7 +12,7 @@ fs = 44100; % Sampling frequency (Hz)
totalTime = A + D + R;
% totalTime = totalTime * 6; % Extend the envelope for 6 seconds
t = linspace(0, totalTime, totalTime * fs);
t = linspace(0, totalTime, totalTime * 6);
% Generate ADSR envelope
attack = linspace(0, 1, A * fs);
......@@ -30,6 +30,6 @@ 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
audiowrite("C:\Users\camil\Documents\IMT_A\semestre_6\electrical engineering\tp-audio-ee-etudiant-c24leray\src\wav\single_tone_piano2.wav", adsrSignal, fe);
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
soundsc(adsrSignal, fs);
\ No newline at end of file
......@@ -19,8 +19,6 @@ title('spectre du signal carré');
x_2 = sawtooth(2*pi*t/T);
plot(t,x_2)
title('sawtooth')
%fft
X_2 = 10*log10(abs(fftshift(fft(x_2))));
......@@ -71,4 +69,29 @@ xlim([-5000 5000]);
%question 2.3
sound(y,fe)
soundsc(x_1,fe)
% 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)
% Total duration of the envelope
totalTime = A + D + R;
% totalTime = totalTime * 6; % Extend the envelope for 6 seconds
t = linspace(0, totalTime, totalTime * 6);
% Generate ADSR envelope
attack = linspace(0, 1, A * fe);
decay = linspace(1, S, D * fe);
release = linspace(S, 0, R * fe);
% Combine all segments
adsrEnvelope = [attack, decay, release];
adsrSignal = x_1(1:length(adsrEnvelope)) .* adsrEnvelope';
soundsc(adsrSignal, fe);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment