pub struct PitchShifter { /* private fields */ }Expand description
Implementations§
Source§impl PitchShifter
impl PitchShifter
Sourcepub fn new(window_duration_ms: usize, sample_rate: usize) -> Self
pub fn new(window_duration_ms: usize, sample_rate: usize) -> Self
Phase Vocoding works by extracting overlapping windows from a buffer and processing them individually before merging the results into the output buffer.
You must set a duration in miliseconds for these windows; 50ms is a good value.
The sample rate argument must correspond to the sample
rate of the buffer(s) you will provide to
PitchShifter::shift_pitch, which is how many values
correspond to one second of audio in the buffer.
Sourcepub fn shift_pitch(
&mut self,
over_sampling: usize,
shift: f32,
in_b: &[f32],
out_b: &mut [f32],
)
pub fn shift_pitch( &mut self, over_sampling: usize, shift: f32, in_b: &[f32], out_b: &mut [f32], )
This is where the magic happens.
The bigger over_sampling, the longer it will take to
process, but the better the results. I put 16 in the
shift-wav binary.
shift is how many semitones to apply to the buffer.
It is signed: a negative value will lower the tone and
vice-versa.
in_b is where the input buffer goes, and you must pass
an output buffer of the same length in out_b.
Note: It’s actually not magic, sadly.