Onset Detection
struct OnsetMetric¶
Distance metrics for onset detection.
The values match FluidOnsetDetection's metric parameter.
Traits: AnyType, Copyable, Deinitable, Equatable, ImplicitlyCopyable, Movable, Writable
OnsetMetric Functions¶
struct OnsetMetric . fn write_to¶
fn write_to Signature
fn write_to Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| writer | T |
— | — |
struct OnsetDetectionFeature¶
Onset detection feature analysis.
This struct is to be used as the process of a BufferedProcess. It should use WindowType.hann for the input window shape.
This struct creates a time series of spectral differences based on a provided metric.
This struct implements the ten FluidOnsetSlice metrics.
Traits: AnyType, Copyable, Deinitable, FFTProcessable, GetFloat64Featurable, Movable
OnsetDetectionFeature Functions¶
struct OnsetDetectionFeature . fn init¶
Initialize an onset detection function.
fn init Signature
def __init__(out self, metric: OnsetMetric = OnsetMetric.complex_domain, window_size: Int = Int(1024), filter_size: Int = Int(5), frame_delta: Int = Int(0))
fn init Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| metric | OnsetMetric |
OnsetMetric.complex_domain |
The onset metric to calculate. |
| window_size | Int |
Int(1024) |
Analysis window size in samples. |
| filter_size | Int |
Int(5) |
Median-filter size. Values below 3 use a first difference. |
| frame_delta | Int |
Int(0) |
Offset in analysis frames (hops) for Flux, MKL, and Itakura-Saito. |
fn init Returns
: Self
Static Method
This is a static method.
struct OnsetDetectionFeature . fn get_features¶
Return the filtered onset detection-function value.
fn get_features Signature
fn get_features Returns
: List[Float64]
A one-element List containing the current filtered descriptor value.
struct OnsetDetectionFeature . fn next_frame¶
Process an unwindowed audio region and return its filtered value.
fn next_frame Signature
fn next_frame Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| mags | List[Float64] |
— | The magnitude spectrum of the input audio frame. This should be a List of Float64 with length equal to window_size // 2 + 1. |
| phases | List[Float64] |
— | The phase spectrum of the input audio frame. This should be a List of Float64 with length equal to window_size // 2 + 1. |
struct OnsetDetectionFeature . fn buf_analysis¶
Analyze a buffer for OnsetDetectionFeature values. The output is a List of Lists, where each inner List contains one Float64 value (the onset detection function value) for each analysis hop.
Note the output is not onset times or a time series of onset triggers. To get onset times or triggers, use OnsetDetection.
fn buf_analysis Signature
def buf_analysis(buf: Buffer, chan: Int = Int(0), start_frame: Int = Int(0), var num_frames: Optional[Int] = None, metric: OnsetMetric = OnsetMetric.complex_domain, window_size: Int = Int(1024), hop_size: Int = Int(512), filter_size: Int = Int(5), frame_delta: Int = Int(0)) -> List[List[Float64]]
fn buf_analysis Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| buf | Buffer |
— | Source audio buffer. |
| chan | Int |
Int(0) |
Source channel to analyze. |
| start_frame | Int |
Int(0) |
First frame in the source buffer. |
| num_frames | Optional[Int] |
None |
Number of source frames to analyze. A negative value analyzes to the end of the buffer. |
| metric | OnsetMetric |
OnsetMetric.complex_domain |
Onset metric to calculate. |
| window_size | Int |
Int(1024) |
Analysis window size in samples. |
| hop_size | Int |
Int(512) |
Number of samples between analysis frames. |
| filter_size | Int |
Int(5) |
Median-filter size. |
| frame_delta | Int |
Int(0) |
Offset in analysis frames (hops) used by Flux, MKL, and Itakura-Saito. |
fn buf_analysis Returns
: List[List[Float64]]
One filtered onset detection-function value for each analysis hop.
Raises Error: If onset analysis or buffered processing fails.
Static Method
This is a static method.
struct OnsetDetection¶
Detect spectral onsets in a time series of audio samples.
This struct implements the ten FluidOnsetSlice metrics.
Traits: AnyType, Copyable, Deinitable, Movable
OnsetDetection Functions¶
struct OnsetDetection . fn init¶
Initialize an onset slicer.
fn init Signature
def __init__(out self, world: Pointer[MMMWorld, MutUntrackedOrigin], metric: OnsetMetric = OnsetMetric.complex_domain, threshold: Float64 = 0.5, debounce: Float64 = 0.10000000000000001, window_size: Int = Int(1024), hop_size: Int = Int(512), filter_size: Int = Int(5), frame_delta: Int = Int(0))
fn init Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| world | Pointer[MMMWorld, MutUntrackedOrigin] |
— | The MMMWorld used for buffered processing. |
| metric | OnsetMetric |
OnsetMetric.complex_domain |
The onset metric to calculate. |
| threshold | Float64 |
0.5 |
Threshold crossing required to emit an onset. |
| debounce | Float64 |
0.10000000000000001 |
Minimum time duration (in seconds) between onsets. |
| window_size | Int |
Int(1024) |
Analysis window size in samples. |
| hop_size | Int |
Int(512) |
Number of samples between analysis frames. |
| filter_size | Int |
Int(5) |
Median-filter size. |
| frame_delta | Int |
Int(0) |
Offset in analysis frames (hops) used by Flux, MKL, and Itakura-Saito. |
fn init Returns
: Self
Static Method
This is a static method.
struct OnsetDetection . fn next¶
Process one sample and return whether this sample is an onset.
fn next Signature
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| input | Float64 |
— | The input audio sample to analyze. |
fn next Returns
: Bool
True if this sample is an onset, False otherwise.
struct OnsetDetection . fn buf_analysis¶
Return onset sample indices for a buffer.
fn buf_analysis Signature
def buf_analysis(world: Pointer[MMMWorld, MutUntrackedOrigin], buf: Buffer, chan: Int = Int(0), start_frame: Int = Int(0), var num_frames: Optional[Int] = None, metric: OnsetMetric = OnsetMetric.complex_domain, threshold: Float64 = 0.5, debounce: Float64 = 0.10000000000000001, window_size: Int = Int(1024), hop_size: Int = Int(512), filter_size: Int = Int(5), frame_delta: Int = Int(0)) -> List[Int]
fn buf_analysis Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| world | Pointer[MMMWorld, MutUntrackedOrigin] |
— | The MMMWorld used for buffered processing. |
| buf | Buffer |
— | Source audio buffer. |
| chan | Int |
Int(0) |
Source channel to analyze. |
| start_frame | Int |
Int(0) |
First frame in the source buffer. |
| num_frames | Optional[Int] |
None |
Number of source frames to analyze. A negative value analyzes to the end of the buffer. |
| metric | OnsetMetric |
OnsetMetric.complex_domain |
The onset metric to calculate. |
| threshold | Float64 |
0.5 |
Threshold crossing required to emit an onset. |
| debounce | Float64 |
0.10000000000000001 |
Minimum time duration (in seconds) between onsets. |
| window_size | Int |
Int(1024) |
Analysis window size in samples. |
| hop_size | Int |
Int(512) |
Number of samples between analysis frames. |
| filter_size | Int |
Int(5) |
Median-filter size. |
| frame_delta | Int |
Int(0) |
Offset in analysis frames (hops) used by Flux, MKL, and Itakura-Saito. |
fn buf_analysis Returns
: List[Int]
A List of Int sample indices where onsets were detected.
Static Method
This is a static method.
Documentation generated with mojo doc from Mojo version 1.0.0