Dear All, I hope this message finds you well. I am currently working with Altera FPGA Cyclone IV and aim to implement a FIR filter for the ADC data originating from a microphone. Quartus provides an IP core (FIR II) for this purpose, and I intend to implement the coefficients generated with Matlab FilterDesigner. More specifically I record for 2 seconds the sound from a microphone but when I choose to play the recording it has a lot of noise. I would like to inquire if it's possible to import a .wav audio file into MATLAB for simulation and testing. I aim to fine-tune the filter and subsequently proceed to FPGA. Could you please guide me on the necessary steps to import the audio file, pass it through the digital filter, and observe the results in MATLAB?" Thank you.
Prashant Kumar answered .
2025-11-20
[signal, fs] = audioread('your_audio_file.wav');
filtered_signal = filter(b, 1, signal);
sound(signal, fs);
To play the filtered audio:
sound(filtered_signal, fs);
subplot(2,1,1);
plot(signal);
title('Original Audio Signal');
xlabel('Sample Number');
ylabel('Amplitude');
subplot(2,1,2);
plot(filtered_signal);
title('Filtered Audio Signal');
xlabel('Sample Number');
ylabel('Amplitude');
Frequency Spectrum:You can also visualize the frequency spectrum of your audio signal using the Fourier Transform.
L = length(signal); % Length of the signal
Y = fft(signal); % Fast Fourier Transform of the original signal
P2 = abs(Y/L); % Two-sided spectrum
P1 = P2(1:L/2+1); % Single-sided spectrum
P1(2:end-1) = 2*P1(2:end-1);
f = fs*(0:(L/2))/L;
plot(f, P1);
title('Single-Sided Amplitude Spectrum of Original Audio');
xlabel('Frequency (Hz)');
ylabel('|P1(f)|');
audiowrite('filtered_audio.wav', filtered_signal, fs);