Clear Filters
Clear Filters

audio wave filter out bandpass 900-1kHz

2 views (last 30 days)
ting po chun
ting po chun on 23 Jun 2023
Commented: ting po chun on 23 Jun 2023
Hi;
I want to filter the recorded audio file out of the 900-1kHz range and convert it into an impulse response. How can I do it?

Answers (1)

Deep
Deep on 23 Jun 2023
You can read your audio file using the audioread function:
[y, Fs] = audioread('audiofile.wav');
More info: audioread
To filter out the 900-1kHz range, you can use a bandstop filter. MATLAB provides the designfilt function for this purpose:
d = designfilt('bandstopiir', 'FilterOrder', 2, ...
'HalfPowerFrequency1', 900, 'HalfPowerFrequency2', 1000, ...
'DesignMethod', 'butter', 'SampleRate', Fs);
filtered_audio = filtfilt(d, y);
More info:
Finally, you can convert the filtered audio into an impulse response using the inverse Fast Fourier Transform, provided by the ifft function:
impulse_response = ifft(filtered_audio);
More info: ifft
This impulse response might not be in a playable range, so you might want to normalize it:
impulse_response = impulse_response / max(abs(impulse_response));
Please explore the documentation links provided to understand more about the functions used.
  3 Comments
Deep
Deep on 23 Jun 2023
Sure, plotting can be done by simply using the plot function.
% Define the sample rate. You can check this in your WAV file's properties.
Fs = 44100;
% Create a time vector
t = (0:length(impulse_response)-1)/Fs;
% Plot the impulse response
plot(t, impulse_response);
xlabel('Time (s)');
ylabel('Amplitude');
title('Impulse Response');
Hope this helps! :)

Sign in to comment.

Categories

Find more on Audio Processing Algorithm Design in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!