pub struct Onset { /* private fields */ }
Expand description
Onset detection object
The following routines compute the onset detection function and detect peaks in these functions.
When onsets are found above a given silence threshold, and after a minimum inter-onset interval,
the output vector returned by do_()
is filled with 1. Otherwise, the output vector remains 0.
The peak-picking threshold, the silence threshold, and the minimum inter-onset interval can be
adjusted during the execution of the do_()
routine using the corresponding functions.
Implementations§
Source§impl Onset
impl Onset
Sourcepub fn new(
method: OnsetMode,
buf_size: usize,
hop_size: usize,
sample_rate: u32,
) -> Result<Self>
pub fn new( method: OnsetMode, buf_size: usize, hop_size: usize, sample_rate: u32, ) -> Result<Self>
Create onset detection object
method
Onset detection typebuf_size
Buffer size for phase vocoderhop_size
Hop size for phase vocodersample_rate
Sampling rate of the input signal
Sourcepub fn with_awhitening(self, enable: bool) -> Self
pub fn with_awhitening(self, enable: bool) -> Self
Set onset detection adaptive whitening
Sourcepub fn with_compression(self, lambda: Smpl) -> Self
pub fn with_compression(self, lambda: Smpl) -> Self
Set or disable log compression
Sourcepub fn with_silence(self, silence: Smpl) -> Self
pub fn with_silence(self, silence: Smpl) -> Self
Set onset detection silence threshold
Sourcepub fn with_threshold(self, threshold: Smpl) -> Self
pub fn with_threshold(self, threshold: Smpl) -> Self
Set onset detection peak picking threshold
Sourcepub fn with_minioi(self, minioi: usize) -> Self
pub fn with_minioi(self, minioi: usize) -> Self
Set minimum inter onset interval in samples
Sourcepub fn with_minioi_s(self, minioi: Smpl) -> Self
pub fn with_minioi_s(self, minioi: Smpl) -> Self
Set minimum inter onset interval in seconds
Sourcepub fn with_minioi_ms(self, minioi: Smpl) -> Self
pub fn with_minioi_ms(self, minioi: Smpl) -> Self
Set minimum inter onset interval in milliseconds
Sourcepub fn with_delay(self, delay: usize) -> Self
pub fn with_delay(self, delay: usize) -> Self
Set delay in samples
Sourcepub fn with_delay_s(self, delay: Smpl) -> Self
pub fn with_delay_s(self, delay: Smpl) -> Self
Set delay in seconds
Sourcepub fn with_delay_ms(self, delay: Smpl) -> Self
pub fn with_delay_ms(self, delay: Smpl) -> Self
Set delay in milliseconds
Sourcepub fn do_<'i, 'o, I, O>(&mut self, input: I, onset: O) -> Status
pub fn do_<'i, 'o, I, O>(&mut self, input: I, onset: O) -> Status
Execute onset detection
When no onset was detected, the first element of the output vector onset is set to 0.
When an onset is found, the first element of the output vector onset is set to offset = 1 + a
where a
is a number in the range[0, 1].
The final onset detection time, in samples, can be obtained with Onset::get_last()
. It can also be derived from offset as follows:
t = total_frames + offset * hop_size - delay
where total_frames
is the total number of frames processed so far, and delay is the current delay of the onset object, as returned by Onset::get_delay()
.
Sourcepub fn get_last_s(&self) -> Smpl
pub fn get_last_s(&self) -> Smpl
Get the time of the latest onset detected, in seconds
Sourcepub fn get_last_ms(&self) -> Smpl
pub fn get_last_ms(&self) -> Smpl
Get the time of the latest onset detected, in milliseconds
Sourcepub fn set_awhitening(&mut self, enable: bool)
pub fn set_awhitening(&mut self, enable: bool)
Set onset detection adaptive whitening
Sourcepub fn get_awhitening(&self) -> bool
pub fn get_awhitening(&self) -> bool
Get onset detection adaptive whitening
Sourcepub fn set_compression(&mut self, lambda: Smpl)
pub fn set_compression(&mut self, lambda: Smpl)
Set or disable log compression
Sourcepub fn get_compression(&self) -> Smpl
pub fn get_compression(&self) -> Smpl
Get onset detection log compression
Sourcepub fn set_silence(&mut self, silence: Smpl)
pub fn set_silence(&mut self, silence: Smpl)
Set onset detection silence threshold
Sourcepub fn get_silence(&self) -> Smpl
pub fn get_silence(&self) -> Smpl
Get onset detection silence threshold
Sourcepub fn get_descriptor(&self) -> Smpl
pub fn get_descriptor(&self) -> Smpl
Get onset detection function
Sourcepub fn get_thresholded_descriptor(&self) -> Smpl
pub fn get_thresholded_descriptor(&self) -> Smpl
Get thresholded onset detection function
Sourcepub fn set_threshold(&mut self, threshold: Smpl)
pub fn set_threshold(&mut self, threshold: Smpl)
Set onset detection peak picking threshold
Sourcepub fn get_threshold(&self) -> Smpl
pub fn get_threshold(&self) -> Smpl
Get onset peak picking threshold
Sourcepub fn set_minioi(&mut self, minioi: usize)
pub fn set_minioi(&mut self, minioi: usize)
Set minimum inter onset interval in samples
Sourcepub fn get_minioi(&self) -> usize
pub fn get_minioi(&self) -> usize
Get minimum inter onset interval in samples
Sourcepub fn set_minioi_s(&mut self, minioi: Smpl)
pub fn set_minioi_s(&mut self, minioi: Smpl)
Set minimum inter onset interval in seconds
Sourcepub fn get_minioi_s(&self) -> Smpl
pub fn get_minioi_s(&self) -> Smpl
Get minimum inter onset interval in seconds
Sourcepub fn set_minioi_ms(&mut self, minioi: Smpl)
pub fn set_minioi_ms(&mut self, minioi: Smpl)
Set minimum inter onset interval in milliseconds
Sourcepub fn get_minioi_ms(&self) -> Smpl
pub fn get_minioi_ms(&self) -> Smpl
Get minimum inter onset interval in milliseconds
Sourcepub fn set_delay_s(&mut self, delay: Smpl)
pub fn set_delay_s(&mut self, delay: Smpl)
Set delay in seconds
Sourcepub fn get_delay_s(&self) -> Smpl
pub fn get_delay_s(&self) -> Smpl
Get delay in seconds
Sourcepub fn set_delay_ms(&mut self, delay: Smpl)
pub fn set_delay_ms(&mut self, delay: Smpl)
Set delay in milliseconds
Sourcepub fn get_delay_ms(&self) -> Smpl
pub fn get_delay_ms(&self) -> Smpl
Get delay in milliseconds
Sourcepub fn set_default_parameters(&mut self, mode: OnsetMode)
pub fn set_default_parameters(&mut self, mode: OnsetMode)
Set default parameters