Load audio
clc;
clear;
close all;
% Load audio file
[x, fs] = audioread('[Link]'); % File ko current folder me
rakhein
x = mean(x, 2); % Stereo ko mono me convert karein
% Play the audio
sound(x, fs); % ya soundsc(x, fs) - ye automatically volume adjust kar deta
hai
add noise
clc;
clear;
close all;
% 1. Load audio file
[x, fs] = audioread('[Link]'); % Correct file name, remove
double .wav if any
x = mean(x, 2); % Stereo ko mono me convert karein
% 2. Play original audio
disp('Playing original audio...');
soundsc(x, fs); % soundsc auto-scales volume
pause(length(x)/fs + 1); % Wait until audio finishes
% 3. Add random noise
noise_level = 0.02; % Noise ka level adjust karen (0.01-
0.05)
noise = noise_level * randn(size(x)); % Random noise generate karein
noisy_signal = x + noise; % Original signal me noise add
karein
% 4. Play noisy audio
disp('Playing noisy audio...');
soundsc(noisy_signal, fs); % Play noisy audio
pause(length(noisy_signal)/fs + 1); % Wait until audio finishes
% 5. Optional: Plot original and noisy signals
t = (0:length(x)-1)/fs;
figure;
subplot(2,1,1);
plot(t, x);
title('Original Audio');
xlabel('Time (s)'); ylabel('Amplitude');
subplot(2,1,2);
plot(t, noisy_signal);
title('Noisy Audio');
xlabel('Time (s)'); ylabel('Amplitude');
design a low pass filter
clc;
clear;
close all;
%% 1. Load audio
[x, fs] = audioread('[Link]');
x = mean(x, 2); % Stereo to mono
%% 2. Add random noise
noise_level = 0.02;
noise = noise_level * randn(size(x));
noisy_signal = x + noise;
%% 3. Design FIR Low-Pass Filter
% Filter specifications
Fc = 3000; % Cutoff frequency in Hz (adjust as needed)
N = 50; % Filter order (adjust for smoother response)
% Normalized cutoff frequency (0 to 1, 1 = Nyquist freq)
Wn = Fc/(fs/2);
% Design filter using window method
b = fir1(N, Wn, 'low'); % Low-pass FIR filter coefficients
%% 4. Apply filter to noisy signal
filtered_signal = filter(b, 1, noisy_signal);
%% 5. Play signals
disp('Playing original audio...');
soundsc(x, fs);
pause(length(x)/fs + 1);
disp('Playing noisy audio...');
soundsc(noisy_signal, fs);
pause(length(noisy_signal)/fs + 1);
disp('Playing filtered audio...');
soundsc(filtered_signal, fs);
pause(length(filtered_signal)/fs + 1);
%% 6. Plot signals
t = (0:length(x)-1)/fs;
figure;
subplot(3,1,1);
plot(t, x);
title('Original Audio'); xlabel('Time (s)'); ylabel('Amplitude');
subplot(3,1,2);
plot(t, noisy_signal);
title('Noisy Audio'); xlabel('Time (s)'); ylabel('Amplitude');
subplot(3,1,3);
plot(t, filtered_signal);
title('Filtered Audio (FIR Low-Pass)'); xlabel('Time (s)');
ylabel('Amplitude');
with low pass filter
clc;
clear;
close all;
%% Load audio
[x, fs] = audioread('[Link]');
x = mean(x, 2); % Stereo to mono
%% Add noise
noise_level = 0.02;
noise = noise_level * randn(size(x));
noisy_signal = x + noise;
%% Design stronger FIR low-pass filter
Fc = 2500; % Lower cutoff frequency for more noise removal
N = 150; % Higher filter order = better attenuation
Wn = Fc/(fs/2);
b = fir1(N, Wn, 'low'); % Low-pass FIR
%% Filter noisy signal
filtered_signal = filter(b, 1, noisy_signal);
%% Play audio
disp('Playing original audio...');
soundsc(x, fs); pause(length(x)/fs + 1);
disp('Playing noisy audio...');
soundsc(noisy_signal, fs); pause(length(noisy_signal)/fs + 1);
disp('Playing filtered audio...');
soundsc(filtered_signal, fs); pause(length(filtered_signal)/fs + 1);
%% Plot signals
t = (0:length(x)-1)/fs;
figure;
subplot(3,1,1); plot(t,x); title('Original'); xlabel('Time');
ylabel('Amplitude');
subplot(3,1,2); plot(t,noisy_signal); title('Noisy'); xlabel('Time');
ylabel('Amplitude');
subplot(3,1,3); plot(t,filtered_signal); title('Filtered'); xlabel('Time');
ylabel('Amplitude');