Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • main
1 result

Target

Select target project
  • ueee/sar-signal-audio/gr-vhdl-l24soo/tp-audio-ee-etudiant-l24soo
1 result
Select Git revision
  • main
1 result
Show changes
Commits on Source (4)
.DS_Store
cello_harp.png

37.3 KiB

clarinet_sax.png

37 KiB

File added
piano1_piano2.png

33.3 KiB

File added
This diff is collapsed.
function [h] = analyse_delay(g,tau,N)
b = 1; % Partie non récursive
a = [1, zeros(1, tau-1), g]; % Partie récursive
x = [1, zeros(1, N-1)]; % Impulsion
h = filter(b, a, x);
end
[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
function [y_delayed] = effet_delay(x,s,g,Fe)
tau = round(s * Fe);
b = 1; % Partie non récursive
a = [1, zeros(1, tau - 1), g]; % Partie récursive
y_delayed = filter(b, a, x);
end
\ No newline at end of file
function y = effet_delay_filtre(x,delay,g,K,Fe)
N=length(x);
t=round(delay*Fe);
y=zeros(1,N);
for k =1:N
somme = 0;
for n =0:(K-1)
i=k-t-n;
if i>0
somme=somme+y(i);
end
end
y(k)=x(k)-(g/K)*somme;
end
\ No newline at end of file
function [y] = effet_reverb(x,h)
y = conv(x,h);
end
\ No newline at end of file
function [y] = effet_reverb_FFT(x,h)
NFFT=min(length(h),length(x));
y = ifft(fft(h,NFFT).*fft(x,NFFT));
end
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
File added