Struct Onset

Source
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

Source

pub fn new( method: OnsetMode, buf_size: usize, hop_size: usize, sample_rate: u32, ) -> Result<Self>

Create onset detection object

  • method Onset detection type
  • buf_size Buffer size for phase vocoder
  • hop_size Hop size for phase vocoder
  • sample_rate Sampling rate of the input signal
Source

pub fn with_awhitening(self, enable: bool) -> Self

Set onset detection adaptive whitening

Source

pub fn with_compression(self, lambda: Smpl) -> Self

Set or disable log compression

Source

pub fn with_silence(self, silence: Smpl) -> Self

Set onset detection silence threshold

Source

pub fn with_threshold(self, threshold: Smpl) -> Self

Set onset detection peak picking threshold

Source

pub fn with_minioi(self, minioi: usize) -> Self

Set minimum inter onset interval in samples

Source

pub fn with_minioi_s(self, minioi: Smpl) -> Self

Set minimum inter onset interval in seconds

Source

pub fn with_minioi_ms(self, minioi: Smpl) -> Self

Set minimum inter onset interval in milliseconds

Source

pub fn with_delay(self, delay: usize) -> Self

Set delay in samples

Source

pub fn with_delay_s(self, delay: Smpl) -> Self

Set delay in seconds

Source

pub fn with_delay_ms(self, delay: Smpl) -> Self

Set delay in milliseconds

Source

pub fn do_<'i, 'o, I, O>(&mut self, input: I, onset: O) -> Status
where I: Into<FVec<'i>>, O: Into<FVecMut<'o>>,

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().

Source

pub fn do_result<'i, I>(&mut self, input: I) -> Result<Smpl>
where I: Into<FVec<'i>>,

Execute onset detection

Source

pub fn get_hop(&self) -> usize

Get hop size

Source

pub fn get_last(&self) -> usize

Get the time of the latest onset detected, in samples

Source

pub fn get_last_s(&self) -> Smpl

Get the time of the latest onset detected, in seconds

Source

pub fn get_last_ms(&self) -> Smpl

Get the time of the latest onset detected, in milliseconds

Source

pub fn set_awhitening(&mut self, enable: bool)

Set onset detection adaptive whitening

Source

pub fn get_awhitening(&self) -> bool

Get onset detection adaptive whitening

Source

pub fn set_compression(&mut self, lambda: Smpl)

Set or disable log compression

Source

pub fn get_compression(&self) -> Smpl

Get onset detection log compression

Source

pub fn set_silence(&mut self, silence: Smpl)

Set onset detection silence threshold

Source

pub fn get_silence(&self) -> Smpl

Get onset detection silence threshold

Source

pub fn get_descriptor(&self) -> Smpl

Get onset detection function

Source

pub fn get_thresholded_descriptor(&self) -> Smpl

Get thresholded onset detection function

Source

pub fn set_threshold(&mut self, threshold: Smpl)

Set onset detection peak picking threshold

Source

pub fn get_threshold(&self) -> Smpl

Get onset peak picking threshold

Source

pub fn set_minioi(&mut self, minioi: usize)

Set minimum inter onset interval in samples

Source

pub fn get_minioi(&self) -> usize

Get minimum inter onset interval in samples

Source

pub fn set_minioi_s(&mut self, minioi: Smpl)

Set minimum inter onset interval in seconds

Source

pub fn get_minioi_s(&self) -> Smpl

Get minimum inter onset interval in seconds

Source

pub fn set_minioi_ms(&mut self, minioi: Smpl)

Set minimum inter onset interval in milliseconds

Source

pub fn get_minioi_ms(&self) -> Smpl

Get minimum inter onset interval in milliseconds

Source

pub fn set_delay(&mut self, delay: usize)

Set delay in samples

Source

pub fn get_delay(&self) -> usize

Get delay in samples

Source

pub fn set_delay_s(&mut self, delay: Smpl)

Set delay in seconds

Source

pub fn get_delay_s(&self) -> Smpl

Get delay in seconds

Source

pub fn set_delay_ms(&mut self, delay: Smpl)

Set delay in milliseconds

Source

pub fn get_delay_ms(&self) -> Smpl

Get delay in milliseconds

Source

pub fn set_default_parameters(&mut self, mode: OnsetMode)

Set default parameters

Source

pub fn reset(&mut self)

Reset onset detection

Trait Implementations§

Source§

impl Drop for Onset

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Onset

§

impl RefUnwindSafe for Onset

§

impl !Send for Onset

§

impl !Sync for Onset

§

impl Unpin for Onset

§

impl UnwindSafe for Onset

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.