finished exercise except for some parts of number 1

This commit is contained in:
2026-05-09 17:16:35 +02:00
parent a4f2001671
commit 99b68b10eb
14 changed files with 301 additions and 217 deletions

View File

@@ -0,0 +1,42 @@
% Read and play original audio
[audio, fs] = audioread('./audio.wav');
%sound(audio, fs);
% Read and play room impulse response (RIR)
[rir, fs_rir] = audioread('./rir.wav');
%sound(rir, fs_rir);
% Apply convolution (reverb effect)
audio_reverb = conv(audio, rir);
%sound(audio_reverb, fs);
% Plot the waveforms
figure;
% Original audio
subplot(2,1,1);
plot(audio);
title('Original Audio');
xlabel('Sample Number');
ylabel('Amplitude');
% Reverberated audio
subplot(2,1,2);
plot(audio_reverb);
title('Audio with Reverb');
xlabel('Sample Number');
ylabel('Amplitude');
% Calculate signal energy
function [ W ] = energy( x )
W = sum(abs(x).^2);
end
energy_rir = energy(rir)
energy_original = energy(audio)
energy_reverb = energy(audio_reverb)
% Display energy values
fprintf('Original Audio Energy: %.4f\n', energy_original);
fprintf('Reverberated Audio Energy: %.4f\n', energy_reverb);