-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression test cases for IIR filter (#1429)
- Loading branch information
Showing
18 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
test/manual/iir_filter/1415_the-nervous-filter/.gitattributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.ogg filter=lfs diff=lfs merge=lfs -text | ||
*.flac filter=lfs diff=lfs merge=lfs -text | ||
*.wav filter=lfs diff=lfs merge=lfs -text | ||
*.sf2 filter=lfs diff=lfs merge=lfs -text |
Binary file added
BIN
+2.95 KB
test/manual/iir_filter/1415_the-nervous-filter/The Nervous Filter trimmed.mid
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
test/manual/iir_filter/1415_the-nervous-filter/The Nervous Filter trimmed.ogg
Git LFS file not shown
Binary file added
BIN
+23.9 KB
test/manual/iir_filter/1415_the-nervous-filter/The Nervous Filter.mid
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
test/manual/iir_filter/1417_filter-envelope-noise/.gitattributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
filter-envelope-noise-1345[[:space:]]reverted.flac filter=lfs diff=lfs merge=lfs -text | ||
filter-envelope-noise-FluidSynth[[:space:]]2.4.flac filter=lfs diff=lfs merge=lfs -text | ||
filter-envelope-noise.mid filter=lfs diff=lfs merge=lfs -text | ||
*.flac filter=lfs diff=lfs merge=lfs -text | ||
*.sf2 filter=lfs diff=lfs merge=lfs -text |
3 changes: 3 additions & 0 deletions
3
test/manual/iir_filter/1417_filter-envelope-noise/filter envelope-noise-Roland SC8820.flac
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
test/manual/iir_filter/1417_filter-envelope-noise/filter-envelope-noise-1345 reverted.flac
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
test/manual/iir_filter/1417_filter-envelope-noise/filter-envelope-noise-FluidSynth 2.4.flac
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
test/manual/iir_filter/1417_filter-envelope-noise/filter-envelope-noise.mid
Git LFS file not shown
1 change: 1 addition & 0 deletions
1
test/manual/iir_filter/1424_clicks-on-ModEnv-FilterFc-change/.gitattributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
echo_drops.sf2 filter=lfs diff=lfs merge=lfs -text |
Binary file added
BIN
+69 Bytes
test/manual/iir_filter/1424_clicks-on-ModEnv-FilterFc-change/1424.mid
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
test/manual/iir_filter/1424_clicks-on-ModEnv-FilterFc-change/echo_drops.sf2
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
test/manual/iir_filter/1427_high-Q-note-cutoff/.gitattributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
high_Q_note_cutoff_test.sf2 filter=lfs diff=lfs merge=lfs -text | ||
fluidsynth_iir-tests.flac filter=lfs diff=lfs merge=lfs -text | ||
high_Q_note_cutoff_test.mid filter=lfs diff=lfs merge=lfs -text |
3 changes: 3 additions & 0 deletions
3
test/manual/iir_filter/1427_high-Q-note-cutoff/fluidsynth_iir-tests.flac
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
test/manual/iir_filter/1427_high-Q-note-cutoff/high_Q_note_cutoff_test.mid
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
test/manual/iir_filter/1427_high-Q-note-cutoff/high_Q_note_cutoff_test.sf2
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# | ||
# This Matlab script implements an interactive Bode plot of fluidsynth's IIR filter. | ||
# To run it, just call interactive_biquad_lowpass() and a window will open up, allowing | ||
# you to adjust the cutoff frequency and Q. | ||
# Note that Q is in linear range here! | ||
# | ||
function interactive_biquad_lowpass() | ||
% Initial values | ||
f_c = 1000; % Initial cutoff frequency in Hz | ||
Q = 0.707; % Initial quality factor | ||
f_s = 48000; % Sampling frequency in Hz | ||
|
||
% Create the figure | ||
hFig = figure('Name', 'Interactive Biquad Lowpass Filter', 'NumberTitle', 'off'); | ||
|
||
% Create axes for the magnitude and phase plots | ||
hAxesMag = subplot(2, 1, 1, 'Parent', hFig); | ||
hAxesPhase = subplot(2, 1, 2, 'Parent', hFig); | ||
|
||
% Plot the initial response | ||
plot_response(hAxesMag, hAxesPhase, f_c, Q, f_s); | ||
|
||
% Create slider for cutoff frequency | ||
uicontrol('Style', 'text', 'Position', [20 20 150 20], 'String', 'Cutoff Frequency (Hz)'); | ||
hSliderFc = uicontrol('Style', 'slider', 'Min', 100, 'Max', 20000, 'Value', f_c, ... | ||
'Position', [20 40 300 20]); | ||
hTextFc = uicontrol('Style', 'text', 'Position', [330 40 50 20], 'String', num2str(f_c)); | ||
|
||
% Create slider for quality factor | ||
uicontrol('Style', 'text', 'Position', [20 80 150 20], 'String', 'Quality Factor (Q)'); | ||
hSliderQ = uicontrol('Style', 'slider', 'Min', 0.1, 'Max', 100, 'Value', Q, ... | ||
'Position', [20 100 300 20]); | ||
hTextQ = uicontrol('Style', 'text', 'Position', [330 100 50 20], 'String', num2str(Q)); | ||
|
||
% Add listeners for both sliders | ||
addlistener(hSliderFc, 'Value', 'PreSet', @(src, event) update_plot(hAxesMag, hAxesPhase, hSliderFc, hSliderQ, f_s, hTextFc, hTextQ)); | ||
addlistener(hSliderQ, 'Value', 'PreSet', @(src, event) update_plot(hAxesMag, hAxesPhase, hSliderFc, hSliderQ, f_s, hTextFc, hTextQ)); | ||
end | ||
|
||
function update_plot(hAxesMag, hAxesPhase, hSliderFc, hSliderQ, f_s, hTextFc, hTextQ) | ||
% Get the current values from the sliders | ||
f_c = get(hSliderFc, 'Value'); | ||
Q = get(hSliderQ, 'Value'); | ||
|
||
% Update the text displays | ||
set(hTextFc, 'String', num2str(f_c, '%.1f')); % Display cutoff frequency | ||
set(hTextQ, 'String', num2str(Q, '%.2f')); % Display quality factor | ||
|
||
% Update the plot with the new values | ||
plot_response(hAxesMag, hAxesPhase, f_c, Q, f_s); | ||
end | ||
|
||
function plot_response(hAxesMag, hAxesPhase, f_c, Q, f_s) | ||
% Design the biquad lowpass filter | ||
w0 = 2 * pi * f_c / f_s; | ||
alpha = sin(w0) / (2 * Q); | ||
|
||
b0 = (1 - cos(w0)) / 2; | ||
b1 = 1 - cos(w0); | ||
b2 = (1 - cos(w0)) / 2; | ||
a0 = 1 + alpha; | ||
a1 = -2 * cos(w0); | ||
a2 = 1 - alpha; | ||
|
||
% Normalize coefficients | ||
b = [b0 / a0, b1 / a0, b2 / a0]; | ||
a = [1, a1 / a0, a2 / a0]; | ||
|
||
% Compute the frequency response | ||
[h, w] = freqz(b, a, 1024, f_s); | ||
|
||
% Clear the axes and plot the new response | ||
cla(hAxesMag); | ||
plot(hAxesMag, w, 20*log10(abs(h))); | ||
title(hAxesMag, 'Magnitude Response'); | ||
xlabel(hAxesMag, 'Frequency (Hz)'); | ||
ylabel(hAxesMag, 'Magnitude (dB)'); | ||
grid(hAxesMag, 'on'); | ||
|
||
cla(hAxesPhase); | ||
plot(hAxesPhase, w, angle(h) * (180/pi)); | ||
title(hAxesPhase, 'Phase Response'); | ||
xlabel(hAxesPhase, 'Frequency (Hz)'); | ||
ylabel(hAxesPhase, 'Phase (degrees)'); | ||
grid(hAxesPhase, 'on'); | ||
end |