pub struct TimeStretchProcessor { /* private fields */ }Expand description
Deterministic two-tap delay-line pitch shifter with a fixed prepared window (20 ms).
It does not change duration: a host that plays a source rate times as
fast (which also transposes it by rate) runs it through this processor
to transpose it by pitch / rate, so the result plays at rate with its
pitch scaled by pitch. Two taps read the input’s recent history at
delays that sweep one window at the transposition’s speed, half a window
apart; each fades to nothing where its sweep wraps, so neither jumps
while it is heard, and their weights sum to one. Untransposed
(pitch == rate), the output is the input delayed by exactly
Processor::latency_samples, one window, which is also the mean delay
of a transposed output and does not depend on the ratios. Hosts provide
continuous project-rate blocks and may save/restore the complete history.
Implementations§
Source§impl TimeStretchProcessor
impl TimeStretchProcessor
Sourcepub fn new(rate: f32, pitch: f32) -> Self
pub fn new(rate: f32, pitch: f32) -> Self
Creates a processor. Both ratios are clamped to 0.25 to 4.0; a non-finite ratio becomes 1.0.
Sourcepub fn set_ratios(&mut self, rate: f32, pitch: f32)
pub fn set_ratios(&mut self, rate: f32, pitch: f32)
Updates time and pitch ratios without resetting history. The latency does not change.
Sourcepub fn set_bypass(&mut self, bypass: bool)
pub fn set_bypass(&mut self, bypass: bool)
Enables latency-preserving bypass: the input delayed by
Processor::latency_samples, while the history keeps following it.
Trait Implementations§
Source§impl Clone for TimeStretchProcessor
impl Clone for TimeStretchProcessor
Source§impl Debug for TimeStretchProcessor
impl Debug for TimeStretchProcessor
Source§impl Processor for TimeStretchProcessor
impl Processor for TimeStretchProcessor
Source§fn latency_samples(&self) -> u32
fn latency_samples(&self) -> u32
One window: an untransposed output’s delay, and a transposed one’s mean, whatever the ratios.
Source§fn prepare(&mut self, sample_rate: u32, _max_block: usize)
fn prepare(&mut self, sample_rate: u32, _max_block: usize)
Source§fn process(
&mut self,
_ctx: &ProcessCtx,
inputs: &[&[f32]],
outputs: &mut [&mut [f32]],
)
fn process( &mut self, _ctx: &ProcessCtx, inputs: &[&[f32]], outputs: &mut [&mut [f32]], )
Source§fn save_state(&self) -> StateBlob
fn save_state(&self) -> StateBlob
Source§fn load_state(&mut self, state: &StateBlob) -> Result<(), StateError>
fn load_state(&mut self, state: &StateBlob) -> Result<(), StateError>
Source§fn inputs_per_output(&self) -> usize
fn inputs_per_output(&self) -> usize
crate::ProcessorChain gives each node only its own channels, so
it takes only processors that read one.