Struct pvoc::PhaseVocoder [−][src]
A phase vocoder.
Roughly translated from http://blogs.zynaptiq.com/bernsee/pitch-shifting-using-the-ft/
Implementations
impl PhaseVocoder
[src]
pub fn new(
channels: usize,
sample_rate: f64,
frame_size: usize,
time_res: usize
) -> PhaseVocoder
[src]
channels: usize,
sample_rate: f64,
frame_size: usize,
time_res: usize
) -> PhaseVocoder
Constructs a new phase vocoder.
channels
is the number of channels of audio.
sample_rate
is the sample rate.
frame_size
is the fourier transform size. It must be > 1
.
For optimal computation speed, this should be a power of 2.
Will be rounded to a multiple of time_res
.
time_res
is the number of frames to overlap.
Panics
Panics if frame_size
is <= 1
after rounding.
pub fn num_channels(&self) -> usize
[src]
pub fn num_bins(&self) -> usize
[src]
pub fn time_res(&self) -> usize
[src]
pub fn sample_rate(&self) -> f64
[src]
pub fn process<S, F>(
&mut self,
input: &[&[S]],
output: &mut [&mut [S]],
mut processor: F
) -> usize where
S: Float + ToPrimitive + FromPrimitive,
F: FnMut(usize, usize, &[Vec<Bin>], &mut [Vec<Bin>]),
[src]
&mut self,
input: &[&[S]],
output: &mut [&mut [S]],
mut processor: F
) -> usize where
S: Float + ToPrimitive + FromPrimitive,
F: FnMut(usize, usize, &[Vec<Bin>], &mut [Vec<Bin>]),
Reads samples from input
, processes the samples, then resynthesizes as many samples as
possible into output
. Returns the number of frames written to output
.
processor
is a function to manipulate the spectrum before it is resynthesized. Its
arguments are respectively num_channels
, num_bins
, analysis_output
and
synthesis_input
.
Samples are expected to be normalized to the range [-1, 1].
This method can be called multiple times on the same PhaseVocoder
.
If this happens, in the analysis step, it will be assumed that the input
is a continuation
of the input
that was passed during the previous call.
It is possible that not enough data is available yet to fill output
completely.
In that case, only the first frames of output
will be written to.
Conversely, if there is more data available than output
can hold, the remaining
output is kept in the PhaseVocoder
and can be retrieved with another call to
process
when more input data is available.
Remark
The synthesis_input
passed to the processor_function
is currently initialised to empty
bins. This behaviour may change in a future release, so make sure that your implementation
does not rely on it.
pub fn phase_to_frequency(&self, bin: usize, phase: f64) -> f64
[src]
pub fn frequency_to_phase(&self, freq: f64) -> f64
[src]
Auto Trait Implementations
impl !RefUnwindSafe for PhaseVocoder
[src]
impl Send for PhaseVocoder
[src]
impl Sync for PhaseVocoder
[src]
impl Unpin for PhaseVocoder
[src]
impl !UnwindSafe for PhaseVocoder
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,