Hi Noman
I see that you wish to create a 7 band equalizer with the given specifications.
To design a seven-band equalizer using Hamming and Hanning windows in MATLAB, you'll need to implement filters that meet the specified requirements. Here's a structured approach to achieve this:Design Steps
Sampling Frequency: Choose a high sampling frequency, e.g.1 MHz, to ensure accurate representation of the highest frequency (756 kHz).
Filter Specifications:
- Low Pass Filter (LPF): Cutoff frequency at 27 kHz.
- Band Pass Filters (BPF): Each filter covers a bandwidth of 27 kHz, starting from 27 kHz to 54 kHz.
- High Pass Filter (HPF): Cutoff frequency begins at 54 kHz.
Window Functions: Use Hamming and Hanning windows to design the filters, as they provide different trade-offs in terms of main lobe width and side lobe attenuation.
Design : Use the fir1 function in MATLAB to design FIR filters with specified window functions.
Assembly of Equalizer: Combine the filters to form the seven-band equalizer. Adjust the gain of each band to achieve the desired equalization effect.
Refer to the code snippet below for sample implementation.
fs = 1e6; % Sampling frequency
n = 128; % Filter order, adjust as needed
% Low Pass Filter
lpf_cutoff = 27e3 / (fs/2);
lpf_hamming = fir1(n, lpf_cutoff, 'low', hamming(n+1));
lpf_hanning = fir1(n, lpf_cutoff, 'low', hanning(n+1));
% Band Pass Filters
bpf_cutoffs = [27e3 54e3] / (fs/2);
bpf_hamming = fir1(n, bpf_cutoffs, 'bandpass', hamming(n+1));
bpf_hanning = fir1(n, bpf_cutoffs, 'bandpass', hanning(n+1));
% High Pass Filter
hpf_cutoff = 54e3 / (fs/2);
hpf_hamming = fir1(n, hpf_cutoff, 'high', hamming(n+1));
hpf_hanning = fir1(n, hpf_cutoff, 'high', hanning(n+1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Assemble %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Sample signal
t = 0:1/fs:1-1/fs;
input_signal = sin(2*pi*1e3*t); % Example input signal
% Gain settings for each band
gain_lpf = 3.0; % Gain for low pass filter
gain_bpf = [1.0, 1.0, 2.0, 3.0, 1.0]; % Gains for band pass filters
gain_hpf = 1.0; % Gain for high pass filter
% Filter outputs
output_lpf = filter(lpf_hamming, 1, input_signal) * gain_lpf;
output_bpf = zeros(5, length(input_signal));
for i = 1:5
output_bpf(i, :) = filter(bpf_hamming, 1, input_signal) * gain_bpf(i);
end
output_hpf = filter(hpf_hamming, 1, input_signal) * gain_hpf;
% Combine all filter outputs
equalized_signal = output_lpf + sum(output_bpf, 1) + output_hpf;
figure
plot(t,input_signal)
xlim([0.45 0.5])
ylim([-1.5 1.5])
% Visualization
plot(t, equalized_signal);
xlabel('Time (s)');
ylabel('Amplitude');
title('Equalized Signal');
xlim([0.45 0.5])
ylim([-3 3])
Please refer to the following documentation links to learn more about fir1 and filter funciton.
- https://www.mathworks.com/help/signal/ref/fir1.html
- https://www.mathworks.com/help/matlab/ref/filter.html
Hope this helps!