diff --git a/src/audio_exo.m b/src/audio_exo.m deleted file mode 100644 index 6bff89fae8745b9e1dae28e91f0be812b1d81e2c..0000000000000000000000000000000000000000 --- a/src/audio_exo.m +++ /dev/null @@ -1,102 +0,0 @@ -[x,fe]=audioread("src/wav/single_tone_piano1.wav"); -[f,mod]=module_fft("src/wav/single_tone_piano1.wav"); -[f2,mod2]=module_fft("src/wav/single_tone_piano2.wav"); - -[fmax,idx1]=max(mod); -f1=f(idx1); -disp('f1_piano1 :'); -disp(abs(f1)); - -[fmax2,idx2]=max(mod2); -f1_2=f2(idx2); -%disp('f2_piano2 :'); -%disp(abs(f1_2)); - -t=tiledlayout(2,1); -nexttile -plot(f,mod); -legend('FFT piano1'); -xlabel('Fréquence (Hz)'); -ylabel('Amplitude'); -nexttile -plot(f2,mod2); -legend('FFT piano2'); -xlabel('Fréquence (Hz)'); -ylabel('Amplitude'); - -n=2; -fonda=220.456; -tab_fmesuree=[220.456,442.124,663.307,855.622,1107.94,1331.54,1556.29,1783]; -tab_ftheo= fonda*(1:1:8); -amplitude=[ 7287, 5565, 1088, 1414, 934, 671, 570, 114]; -%amplitude = amplitude / max(amplitude); -ftheo_piano1=n*abs(f1); -%{ -disp('ftheo_piano1 :'); -disp(ftheo_piano1); -epsfh_piano1=1200*(log2(fftshift(fft(tab_fmesuree(n)))))-log2(ftheo_piano1); -disp('epsfh_piano1 :'); -disp(abs(epsfh_piano1)); -%} - -size=length(tab_fmesuree); -duree =2;%length(f)/fe; -tmp = 0:1/fe:duree; -signal=0; -for k = 1:size - signal=signal + amplitude(k)*sin(2*pi*tab_fmesuree(k)*tmp); -end -signal = signal / max(abs(signal)); - - -%{ -n_sig=length(signal); -len_phase = round(n_sig / 4); -A = linspace(0, 0.9, 1000); -D = linspace(0.9, 0.7,3100); -S = linspace(0.7, 0.7,40000); -R = linspace(0.7, 0,44101); -envelope = [A D S R] ; -m=length(envelope); -if n_sig<m - envelope=envelope(1:n_sig); -end -if n_sig>m - signal=signal(1:m); -end -tone=signal.* envelope; - -%} - -n_sig = length(signal); -len_attack = round(n_sig * 0.0); % 5% pour l'attaque -len_decay = round(n_sig * 0.85); % 15% pour le déclin -len_sustain = round(n_sig * 0.1); % 10% pour le sustain -len_release = 0.05; - -A = linspace(0, 0.8, len_attack); % Montée rapide -D = linspace(0.8, 0.5, len_decay); % Déclin rapide -S = linspace(0.5, 0.5, len_sustain); % Faible sustain -R = linspace(0.5, 0, len_release); % Relâchement progressif - -envelope = [A, D, S, R]; - -% Ajuster la taille si nécessaire -if length(envelope) > n_sig - envelope = envelope(1:n_sig); -elseif length(envelope) < n_sig - envelope = [envelope, zeros(1, n_sig - length(envelope))]; -end -tone=signal.* envelope; - -sound(tone, fe); -%sound(x, fe); - - -function [f,mod] = module_fft(signal) - [x,fe]=audioread(signal); - y=fftshift(fft(x)); - f = linspace(-fe/2, fe/2, length(y)); - mod =abs(y); -end - diff --git a/src/example_with_wave_file.m b/src/example_with_wave_file.m deleted file mode 100644 index e288ffce5280fbee6268f915d49b999fd7d6082e..0000000000000000000000000000000000000000 --- a/src/example_with_wave_file.m +++ /dev/null @@ -1,12 +0,0 @@ -%% this is a simple example to read and play a wave file with matlab - -% set a string variable to a wave filename we want to open: -toneFileName = "wav/single_tone_piano1.wav"; -% read the content of the wave file: -[data,fe] = audioread(toneFileName); -% data is a matrix with 2 columns if the sound is stereo; keep the mono to ease further processing -data = data(:,1); -% get the number of sample in vector data -N = length(data); -% play the sound in the audio output: -soundsc(data,fe); \ No newline at end of file