-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial setup for FM synth filter internalization
* Create filter module for FM synth to support the different filter configurations * Set up initial code for filter application and param source integration
- Loading branch information
Showing
6 changed files
with
425 additions
and
60 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
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
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,41 @@ | ||
use crate::FRAME_SIZE; | ||
|
||
use super::biquad::{BiquadFilter, FilterMode}; | ||
|
||
#[inline] | ||
pub fn apply_filter_chain_full<const N: usize>( | ||
chain: &mut [BiquadFilter; N], | ||
input_buf: [f32; FRAME_SIZE], | ||
output_buf: &mut [f32; FRAME_SIZE], | ||
) { | ||
let mut filtered = input_buf; | ||
for filter in chain.iter_mut() { | ||
for i in 0..FRAME_SIZE { | ||
filtered[i] = filter.apply(filtered[i]); | ||
} | ||
} | ||
|
||
for i in 0..FRAME_SIZE { | ||
output_buf[i] = filtered[i]; | ||
} | ||
} | ||
|
||
#[inline] | ||
pub fn apply_filter_chain_and_compute_coefficients<const N: usize>( | ||
chain: &mut [BiquadFilter; N], | ||
frame: &mut [f32; FRAME_SIZE], | ||
filter_mode: FilterMode, | ||
q: &[f32; FRAME_SIZE], | ||
cutoff_freq: &[f32; FRAME_SIZE], | ||
gain: &[f32; FRAME_SIZE], | ||
) { | ||
for i in 0..frame.len() { | ||
let coeffs = BiquadFilter::compute_coefficients(filter_mode, q[i], 0., cutoff_freq[i], gain[i]); | ||
|
||
let mut val = frame[i]; | ||
for filter in chain.into_iter() { | ||
val = filter.apply_with_coefficients(val, coeffs.0, coeffs.1, coeffs.2, coeffs.3, coeffs.4); | ||
} | ||
frame[i] = val; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod biquad; | ||
pub mod butterworth; | ||
pub mod dc_blocker; | ||
pub mod filter_chain; |
Oops, something went wrong.