Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added q value parameter to be passed to filter functions #515

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/source/blt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use crate::Source;
// Implemented following http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt

/// Internal function that builds a `BltFilter` object.
pub fn low_pass<I>(input: I, freq: u32) -> BltFilter<I>
pub fn low_pass<I>(input: I, freq: u32, q: f32) -> BltFilter<I>
where
I: Source<Item = f32>,
{
BltFilter {
input,
formula: BltFormula::LowPass { freq, q: 0.5 },
formula: BltFormula::LowPass { freq, q },
applier: None,
x_n1: 0.0,
x_n2: 0.0,
Expand All @@ -21,13 +21,13 @@ where
}
}

pub fn high_pass<I>(input: I, freq: u32) -> BltFilter<I>
pub fn high_pass<I>(input: I, freq: u32, q: f32) -> BltFilter<I>
where
I: Source<Item = f32>,
{
BltFilter {
input,
formula: BltFormula::HighPass { freq, q: 0.5 },
formula: BltFormula::HighPass { freq, q },
applier: None,
x_n1: 0.0,
x_n2: 0.0,
Expand All @@ -49,14 +49,14 @@ pub struct BltFilter<I> {

impl<I> BltFilter<I> {
/// Modifies this filter so that it becomes a low-pass filter.
pub fn to_low_pass(&mut self, freq: u32) {
self.formula = BltFormula::LowPass { freq, q: 0.5 };
pub fn to_low_pass(&mut self, freq: u32, q: f32) {
self.formula = BltFormula::LowPass { freq, q };
self.applier = None;
}

/// Modifies this filter so that it becomes a high-pass filter
pub fn to_high_pass(&mut self, freq: u32) {
self.formula = BltFormula::HighPass { freq, q: 0.5 };
pub fn to_high_pass(&mut self, freq: u32, q: f32) {
self.formula = BltFormula::HighPass { freq, q };
self.applier = None;
}

Expand Down
8 changes: 4 additions & 4 deletions src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,21 +335,21 @@ where
/// Applies a low-pass filter to the source.
/// **Warning**: Probably buggy.
#[inline]
fn low_pass(self, freq: u32) -> BltFilter<Self>
fn low_pass(self, freq: u32, q: f32) -> BltFilter<Self>
where
Self: Sized,
Self: Source<Item = f32>,
{
blt::low_pass(self, freq)
blt::low_pass(self, freq, q)
}

#[inline]
fn high_pass(self, freq: u32) -> BltFilter<Self>
fn high_pass(self, freq: u32, q: f32) -> BltFilter<Self>
where
Self: Sized,
Self: Source<Item = f32>,
{
blt::high_pass(self, freq)
blt::high_pass(self, freq, q)
}
}

Expand Down
Loading