-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22037ef
commit 7099e69
Showing
16 changed files
with
128 additions
and
20 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
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
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
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,75 @@ | ||
//! Frequency domain resynthesis. WIP. | ||
use super::audionode::*; | ||
use super::*; | ||
use num_complex::Complex32; | ||
|
||
pub struct FftWindow<T, I, O> | ||
where | ||
T: Float, | ||
I: Size<T>, | ||
O: Size<T>, | ||
{ | ||
/// Window length. Equals the length of each input and output channel vector. | ||
length: usize, | ||
/// Input samples for each input channel. | ||
input: Vec<Vec<f32>>, | ||
/// Input samples for each input channel in frequency domain. | ||
input_fft: Vec<Vec<Complex32>>, | ||
/// Output samples for each output channel in frequency domain. | ||
output_fft: Vec<Vec<Complex32>>, | ||
/// Output samples for each output channel. | ||
output: Vec<Vec<f32>>, | ||
/// Sample rate for convenience. | ||
sample_rate: f32, | ||
_marker: std::marker::PhantomData<(T, I, O)>, | ||
} | ||
|
||
impl<T, I, O> FftWindow<T, I, O> | ||
where | ||
T: Float, | ||
I: Size<T>, | ||
O: Size<T>, | ||
{ | ||
/// Number of input channels. | ||
#[inline] | ||
pub fn inputs(&self) -> usize { | ||
self.input.len() | ||
} | ||
|
||
/// Number of output channels. | ||
#[inline] | ||
pub fn outputs(&self) -> usize { | ||
self.output.len() | ||
} | ||
|
||
/// FFT window length. Must be divisible by four. | ||
#[inline] | ||
pub fn length(&self) -> usize { | ||
self.length | ||
} | ||
|
||
/// Number of FFT bins. Equals the length of each frequency domain vector. | ||
#[inline] | ||
pub fn bins(&self) -> usize { | ||
(self.length() >> 1) + 1 | ||
} | ||
|
||
/// Get input value at bin `i` of `channel`. | ||
#[inline] | ||
pub fn at(&self, channel: usize, i: usize) -> Complex32 { | ||
self.input_fft[channel][i] | ||
} | ||
|
||
/// Set output value for bin `i` of `channel`. | ||
#[inline] | ||
pub fn set(&mut self, channel: usize, i: usize, value: Complex32) { | ||
self.output_fft[channel][i] = value; | ||
} | ||
|
||
/// Return frequency associated with bin `i`. | ||
#[inline] | ||
pub fn frequency(&self, i: usize) -> f32 { | ||
self.sample_rate / self.length() as f32 * i as f32 | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//! Basic component tests. | ||
#![allow( | ||
dead_code, | ||
clippy::precedence, | ||
|
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,5 @@ | ||
//! Dynamics components tests. | ||
#![allow(clippy::manual_range_contains)] | ||
#![allow(dead_code)] | ||
|
||
|
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