Skip to content

Analysis

Traits

trait GetFloat64Featurable

GetFloat64Featurable Required Methods

trait GetFloat64Featurable . fn get_features

Signature

get_features(self: _Self) -> List[Float64]

Returns

Type: List


trait GetBoolFeaturable

GetBoolFeaturable Required Methods

trait GetBoolFeaturable . fn get_features

Signature

get_features(self: _Self) -> List[Bool]

Returns

Type: List


Structs

struct YIN

Monophonic Frequency ('F0') Detection using the YIN algorithm (FFT-based, O(N log N) version).

Traits: AnyType, BufferedProcessable, Copyable, GetFloat64Featurable, ImplicitlyDestructible, Movable


YIN Functions

struct YIN . fn init

Initialize the YIN pitch detector.

fn init Signature

__init__(out self, sr: Float64, window_size: Int = 1024, min_freq: Float64 = 20, max_freq: Float64 = 2.0E+4)

fn init Arguments

Name Type Default Description
sr Float64 The sample rate from the MMMWorld.
window_size Int 1024 The size of the analysis window in samples.
min_freq Float64 20 The minimum frequency to consider for pitch detection.
max_freq Float64 2.0E+4 The maximum frequency to consider for pitch detection.

fn init Returns : Self An initialized YIN struct.

Static Method

This is a static method.

struct YIN . fn get_features

Return the current pitch and confidence as a List of Float64.

fn get_features Signature

get_features(self) -> List[Float64]

fn get_features Returns : List

struct YIN . fn next_window

Compute the YIN pitch estimate for the given frame of audio samples.

fn next_window Signature

next_window(mut self, mut frame: List[Float64])

fn next_window Arguments

Name Type Default Description
frame List The input audio frame of size window_size. This List gets passed from BufferedProcess.

struct SpectralCentroid

Spectral Centroid analysis.

Based on the Peeters (2003)

Traits: AnyType, Copyable, FFTProcessable, GetFloat64Featurable, ImplicitlyDestructible, Movable


SpectralCentroid Functions

struct SpectralCentroid . fn init

Initialize the Spectral Centroid analyzer. Args: sr: The sample rate from the MMMWorld. min_freq: The minimum frequency to consider when computing the spectral centroid. max_freq: The maximum frequency to consider when computing the spectral centroid. power_mag: Whether to use power magnitudes (mags^2) instead of linear magnitudes when computing the centroid.

fn init Signature

__init__(out self, sr: Float64, min_freq: Float64 = 20, max_freq: Float64 = 20000, power_mag: Bool = False)

fn init Arguments

Name Type Default Description
sr Float64
min_freq Float64 20
max_freq Float64 20000
power_mag Bool False

fn init Returns : Self An initialized SpectralCentroid struct.

Static Method

This is a static method.

struct SpectralCentroid . fn get_features

Return the current spectral centroid value as a List of Float64.

fn get_features Signature

get_features(self) -> List[Float64]

fn get_features Returns : List

struct SpectralCentroid . fn next_frame

Compute the spectral centroid for a given FFT analysis. This function is to be used by FFTProcess if SpectralCentroid is passed as the "process".

fn next_frame Signature

next_frame(mut self, mut mags: List[Float64], mut phases: List[Float64])

fn next_frame Arguments

Name Type Default Description
mags List The input magnitudes as a List of Float64.
phases List The input phases as a List of Float64.

struct SpectralCentroid . fn from_mags

Compute the spectral centroid for the given magnitudes of an FFT frame. This static method is useful when there is an FFT already computed, perhaps as part of a custom struct that implements the FFTProcessable trait.

fn from_mags Signature

from_mags(mags: List[Float64], sample_rate: Float64, min_freq: Float64 = 20, max_freq: Float64 = 20000, power_mag: Bool = False) -> Float64

fn from_mags Arguments

Name Type Default Description
mags List The input magnitudes as a List of Float64.
sample_rate Float64 The sample rate of the audio signal.
min_freq Float64 20 The minimum frequency to consider when computing the spectral centroid.
max_freq Float64 20000 The maximum frequency to consider when computing the spectral centroid.
power_mag Bool False Whether to use power magnitudes (mags^2) instead of linear magnitudes when computing the centroid.

fn from_mags Returns : Float64 Float64. The spectral centroid value.

Static Method

This is a static method.

struct SpectralSpread

Spectral Spread analysis.

Traits: AnyType, Copyable, FFTProcessable, GetFloat64Featurable, ImplicitlyDestructible, Movable


SpectralSpread Functions

struct SpectralSpread . fn init

Initialize the Spectral Spread analyzer.

fn init Signature

__init__(out self, sr: Float64, min_freq: Float64 = 20, max_freq: Float64 = 20000, log_freq: Bool = False, power_mag: Bool = False)

fn init Arguments

Name Type Default Description
sr Float64 The sample rate from the MMMWorld.
min_freq Float64 20 The minimum frequency to consider.
max_freq Float64 20000 The maximum frequency to consider.
log_freq Bool False Whether to use log-frequency (MIDI) bins.
power_mag Bool False Whether to use power magnitudes (mags^2).

fn init Returns : Self

Static Method

This is a static method.

struct SpectralSpread . fn get_features

Return the current spectral spread value as a List of Float64.

fn get_features Signature

get_features(self) -> List[Float64]

fn get_features Returns : List

struct SpectralSpread . fn next_frame

Compute the spectral spread for a given FFT analysis.

fn next_frame Signature

next_frame(mut self, mut mags: List[Float64], mut phases: List[Float64])

fn next_frame Arguments

Name Type Default Description
mags List
phases List

struct SpectralSpread . fn from_mags

fn from_mags Signature

from_mags(mags: List[Float64], sample_rate: Float64, min_freq: Float64 = 20, max_freq: Float64 = 20000, log_freq: Bool = False, power_mag: Bool = False) -> Float64

fn from_mags Arguments

Name Type Default Description
mags List
sample_rate Float64
min_freq Float64 20
max_freq Float64 20000
log_freq Bool False
power_mag Bool False

fn from_mags Returns : Float64

Static Method

This is a static method.

struct SpectralSkewness

Spectral Skewness analysis.

Traits: AnyType, Copyable, FFTProcessable, GetFloat64Featurable, ImplicitlyDestructible, Movable


SpectralSkewness Functions

struct SpectralSkewness . fn init

Initialize the Spectral Skewness analyzer.

fn init Signature

__init__(out self, sr: Float64, min_freq: Float64 = 20, max_freq: Float64 = 20000, log_freq: Bool = False, power_mag: Bool = False)

fn init Arguments

Name Type Default Description
sr Float64 The sample rate from the MMMWorld.
min_freq Float64 20 The minimum frequency to consider.
max_freq Float64 20000 The maximum frequency to consider.
log_freq Bool False Whether to use log-frequency (MIDI) bins.
power_mag Bool False Whether to use power magnitudes (mags^2).

fn init Returns : Self

Static Method

This is a static method.

struct SpectralSkewness . fn get_features

Return the current spectral skewness value as a List of Float64.

fn get_features Signature

get_features(self) -> List[Float64]

fn get_features Returns : List

struct SpectralSkewness . fn next_frame

Compute the spectral skewness for a given FFT analysis.

fn next_frame Signature

next_frame(mut self, mut mags: List[Float64], mut phases: List[Float64])

fn next_frame Arguments

Name Type Default Description
mags List
phases List

struct SpectralSkewness . fn from_mags

fn from_mags Signature

from_mags(mags: List[Float64], sample_rate: Float64, min_freq: Float64 = 20, max_freq: Float64 = 20000, log_freq: Bool = False, power_mag: Bool = False) -> Float64

fn from_mags Arguments

Name Type Default Description
mags List
sample_rate Float64
min_freq Float64 20
max_freq Float64 20000
log_freq Bool False
power_mag Bool False

fn from_mags Returns : Float64

Static Method

This is a static method.

struct SpectralKurtosis

Spectral Kurtosis analysis.

Traits: AnyType, Copyable, FFTProcessable, GetFloat64Featurable, ImplicitlyDestructible, Movable


SpectralKurtosis Functions

struct SpectralKurtosis . fn init

Initialize the Spectral Kurtosis analyzer.

fn init Signature

__init__(out self, sr: Float64, min_freq: Float64 = 20, max_freq: Float64 = 20000, log_freq: Bool = False, power_mag: Bool = False)

fn init Arguments

Name Type Default Description
sr Float64 The sample rate from the MMMWorld.
min_freq Float64 20 The minimum frequency to consider.
max_freq Float64 20000 The maximum frequency to consider.
log_freq Bool False Whether to use log-frequency (MIDI) bins.
power_mag Bool False Whether to use power magnitudes (mags^2).

fn init Returns : Self

Static Method

This is a static method.

struct SpectralKurtosis . fn get_features

Return the current spectral kurtosis value as a List of Float64.

fn get_features Signature

get_features(self) -> List[Float64]

fn get_features Returns : List

struct SpectralKurtosis . fn next_frame

Compute the spectral kurtosis for a given FFT analysis.

fn next_frame Signature

next_frame(mut self, mut mags: List[Float64], mut phases: List[Float64])

fn next_frame Arguments

Name Type Default Description
mags List
phases List

struct SpectralKurtosis . fn from_mags

fn from_mags Signature

from_mags(mags: List[Float64], sample_rate: Float64, min_freq: Float64 = 20, max_freq: Float64 = 20000, log_freq: Bool = False, power_mag: Bool = False) -> Float64

fn from_mags Arguments

Name Type Default Description
mags List
sample_rate Float64
min_freq Float64 20
max_freq Float64 20000
log_freq Bool False
power_mag Bool False

fn from_mags Returns : Float64

Static Method

This is a static method.

struct SpectralRolloff

Spectral Rolloff analysis.

Traits: AnyType, Copyable, FFTProcessable, GetFloat64Featurable, ImplicitlyDestructible, Movable


SpectralRolloff Functions

struct SpectralRolloff . fn init

Initialize the Spectral Rolloff analyzer.

fn init Signature

__init__(out self, sr: Float64, min_freq: Float64 = 20, max_freq: Float64 = 20000, rolloff_target: Float64 = 95, log_freq: Bool = False, power_mag: Bool = False)

fn init Arguments

Name Type Default Description
sr Float64 The sample rate from the MMMWorld.
min_freq Float64 20 The minimum frequency to consider.
max_freq Float64 20000 The maximum frequency to consider.
rolloff_target Float64 95 Percentage of spectral energy for rolloff.
log_freq Bool False Whether to use log-frequency (MIDI) bins.
power_mag Bool False Whether to use power magnitudes (mags^2).

fn init Returns : Self

Static Method

This is a static method.

struct SpectralRolloff . fn get_features

Return the current spectral rolloff value as a List of Float64.

fn get_features Signature

get_features(self) -> List[Float64]

fn get_features Returns : List

struct SpectralRolloff . fn next_frame

Compute the spectral rolloff for a given FFT analysis.

fn next_frame Signature

next_frame(mut self, mut mags: List[Float64], mut phases: List[Float64])

fn next_frame Arguments

Name Type Default Description
mags List
phases List

struct SpectralRolloff . fn from_mags

fn from_mags Signature

from_mags(mags: List[Float64], sample_rate: Float64, min_freq: Float64 = 20, max_freq: Float64 = 20000, rolloff_target: Float64 = 95, log_freq: Bool = False, power_mag: Bool = False) -> Float64

fn from_mags Arguments

Name Type Default Description
mags List
sample_rate Float64
min_freq Float64 20
max_freq Float64 20000
rolloff_target Float64 95
log_freq Bool False
power_mag Bool False

fn from_mags Returns : Float64

Static Method

This is a static method.

struct SpectralFlatness

Spectral Flatness analysis.

Traits: AnyType, Copyable, FFTProcessable, GetFloat64Featurable, ImplicitlyDestructible, Movable


SpectralFlatness Functions

struct SpectralFlatness . fn init

Initialize the Spectral Flatness analyzer.

fn init Signature

__init__(out self, sr: Float64, min_freq: Float64 = 20, max_freq: Float64 = 20000, log_freq: Bool = False, power_mag: Bool = False)

fn init Arguments

Name Type Default Description
sr Float64 The sample rate from the MMMWorld.
min_freq Float64 20 The minimum frequency to consider.
max_freq Float64 20000 The maximum frequency to consider.
log_freq Bool False Whether to use log-frequency (MIDI) bins.
power_mag Bool False Whether to use power magnitudes (mags^2).

fn init Returns : Self

Static Method

This is a static method.

struct SpectralFlatness . fn get_features

Return the current spectral flatness value (dB) as a List of Float64.

fn get_features Signature

get_features(self) -> List[Float64]

fn get_features Returns : List

struct SpectralFlatness . fn next_frame

Compute the spectral flatness for a given FFT analysis.

fn next_frame Signature

next_frame(mut self, mut mags: List[Float64], mut phases: List[Float64])

fn next_frame Arguments

Name Type Default Description
mags List
phases List

struct SpectralFlatness . fn from_mags

fn from_mags Signature

from_mags(mags: List[Float64], sample_rate: Float64, min_freq: Float64 = 20, max_freq: Float64 = 20000, log_freq: Bool = False, power_mag: Bool = False) -> Float64

fn from_mags Arguments

Name Type Default Description
mags List
sample_rate Float64
min_freq Float64 20
max_freq Float64 20000
log_freq Bool False
power_mag Bool False

fn from_mags Returns : Float64

Static Method

This is a static method.

struct SpectralCrest

Spectral Crest analysis.

Traits: AnyType, Copyable, FFTProcessable, GetFloat64Featurable, ImplicitlyDestructible, Movable


SpectralCrest Functions

struct SpectralCrest . fn init

Initialize the Spectral Crest analyzer.

fn init Signature

__init__(out self, sr: Float64, min_freq: Float64 = 20, max_freq: Float64 = 20000, log_freq: Bool = False, power_mag: Bool = False)

fn init Arguments

Name Type Default Description
sr Float64 The sample rate from the MMMWorld.
min_freq Float64 20 The minimum frequency to consider.
max_freq Float64 20000 The maximum frequency to consider.
log_freq Bool False Whether to use log-frequency (MIDI) bins.
power_mag Bool False Whether to use power magnitudes (mags^2).

fn init Returns : Self

Static Method

This is a static method.

struct SpectralCrest . fn get_features

Return the current spectral crest value (dB) as a List of Float64.

fn get_features Signature

get_features(self) -> List[Float64]

fn get_features Returns : List

struct SpectralCrest . fn next_frame

Compute the spectral crest for a given FFT analysis.

fn next_frame Signature

next_frame(mut self, mut mags: List[Float64], mut phases: List[Float64])

fn next_frame Arguments

Name Type Default Description
mags List
phases List

struct SpectralCrest . fn from_mags

fn from_mags Signature

from_mags(mags: List[Float64], sample_rate: Float64, min_freq: Float64 = 20, max_freq: Float64 = 20000, log_freq: Bool = False, power_mag: Bool = False) -> Float64

fn from_mags Arguments

Name Type Default Description
mags List
sample_rate Float64
min_freq Float64 20
max_freq Float64 20000
log_freq Bool False
power_mag Bool False

fn from_mags Returns : Float64

Static Method

This is a static method.

struct RMS

Root Mean Square (RMS) amplitude analysis.

Traits: AnyType, BufferedProcessable, Copyable, GetFloat64Featurable, ImplicitlyDestructible, Movable


RMS Functions

struct RMS . fn init

Initialize the RMS analyzer.

fn init Signature

__init__(out self)

fn init Returns : Self

Static Method

This is a static method.

struct RMS . fn get_features

Return the current RMS value as a List of Float64.

fn get_features Signature

get_features(self) -> List[Float64]

fn get_features Returns : List

struct RMS . fn next_window

Compute the RMS for the given window of audio samples. This function is to be used with a BufferedProcess.

The computed RMS value is stored in self.rms. fn next_window Signature

next_window(mut self, mut input: List[Float64])

fn next_window Arguments

Name Type Default Description
input List The input audio frame of samples. This List gets passed from BufferedProcess.

struct RMS . fn from_window

Compute the RMS for the given window of audio samples. This static method is useful when there is an audio frame already available, perhaps as part of a custom struct that implements the BufferedProcessable trait.

fn from_window Signature

from_window(mut frame: List[Float64]) -> Float64

fn from_window Arguments

Name Type Default Description
frame List The input audio frame of samples.

fn from_window Returns : Float64 Float64. The computed RMS value.

Static Method

This is a static method.

struct MelBands

Mel Bands analysis.

This implementation follows the approach used in the Librosa library.

The Mel scale is a perceptual scale of pitches that approximates the human ear's response more closely than the linear frequency scale. Mel Bands analysis involves mapping the FFT frequency bins to the Mel scale and computing the energy in each Mel band. This way the "magnitudes" of each Mel band represent a, roughly, equal amount of perceptual frequency space (unlike the FFT).

Because the definition of the mel scale is conditioned by a finite number of subjective psychoacoustical experiments, several implementations coexist in the audio signal processing literature. MMMAudio replicates the default of Librosa, which replicates the behavior of the well-established MATLAB "Auditory Toolbox" of Slaney (citation below). According to this implementation, the conversion from Hertz to mel is linear below 1 kHz and logarithmic above 1 kHz. Additionally, the weights are normalized such that the area under each mel filter is equal. Slaney mel filter "triangles" all have equal area (visualization), which helps to ensure that the energy in each mel band is comparable.

Slaney, M. Auditory Toolbox: A MATLAB Toolbox for Auditory Modeling Work. Technical Report, version 2, Interval Research Corporation, 1998.

Traits: AnyType, Copyable, FFTProcessable, GetFloat64Featurable, ImplicitlyDestructible, Movable


MelBands Functions

struct MelBands . fn init

Initialize the Mel Bands analyzer.

fn init Signature

__init__(out self, sr: Float64, num_bands: Int = 40, min_freq: Float64 = 20, max_freq: Float64 = 2.0E+4, fft_size: Int = 1024, power: Float64 = 2)

fn init Arguments

Name Type Default Description
sr Float64 The sample rate from the MMMWorld.
num_bands Int 40 The number of mel bands to compute.
min_freq Float64 20 The minimum frequency (in Hz) to consider when computing the mel bands.
max_freq Float64 2.0E+4 The maximum frequency (in Hz) to consider when computing the mel bands.
fft_size Int 1024 The size of the FFT being used to compute the mel bands.
power Float64 2 Exponent applied to magnitudes before mel filtering (librosa default is 2.0 for power).

fn init Returns : Self An initialized MelBands struct.

Static Method

This is a static method.

struct MelBands . fn get_features

Return the current mel band values as a List of Float64.

fn get_features Signature

get_features(self) -> List[Float64]

fn get_features Returns : List

struct MelBands . fn next_frame

Compute the mel bands for a given FFT analysis. This function is to be used by FFTProcess if MelBands is passed as the "process".

Nothing is returned from this function, but the computed mel band values are stored in self.bands.

fn next_frame Signature

next_frame(mut self, mut mags: List[Float64], mut phases: List[Float64])

fn next_frame Arguments

Name Type Default Description
mags List The input magnitudes as a List of Float64.
phases List The input phases as a List of Float64.

struct MelBands . fn from_mags

Compute the mel bands for a given list of magnitudes. This function is useful when there is an FFT already computed, perhaps as part of a custom struct that implements the FFTProcessable trait.

fn from_mags Signature

from_mags(mut self, ref mags: List[Float64])

fn from_mags Arguments

Name Type Default Description
mags List The input magnitudes as a List of Float64.

struct MelBands . fn mel_frequencies

Compute an array of acoustic frequencies tuned to the mel scale. This implementation is based on Librosa's eponymous function. For more information on mel frequencies space see the MelBands documentation.

fn mel_frequencies Signature

mel_frequencies(n_mels: Int = 128, fmin: Float64 = 0, fmax: Float64 = 2.0E+4) -> List[Float64]

fn mel_frequencies Arguments

Name Type Default Description
n_mels Int 128 The number of mel bands to generate.
fmin Float64 0 The lowest frequency (in Hz).
fmax Float64 2.0E+4 The highest frequency (in Hz).

fn mel_frequencies Returns : List A List of Float64 representing the center frequencies of each mel band.

Static Method

This is a static method.

struct MelBands . fn hz_to_mel

Convert Hz to Mels. This implementation is based on Librosa's eponymous function. For more information on mel frequencies space see the MelBands documentation.

fn hz_to_mel Signature

hz_to_mel[num_chans: Int = 1](freq: SIMD[DType.float64, num_chans]) -> SIMD[DType.float64, num_chans]

fn hz_to_mel Parameters

Name Type Default Description
num_chans Int 1 Size of the SIMD vector. This parameter is inferred by the values passed to the function.

fn hz_to_mel Arguments

Name Type Default Description
freq SIMD The frequencies in Hz to convert.

fn hz_to_mel Returns : SIMD The corresponding mel frequencies.

Static Method

This is a static method.

struct MelBands . fn mel_to_hz

Convert mel bin numbers to frequencies. This implementation is based on Librosa's eponymous function. For more information on mel frequencies space see the MelBands documentation. fn mel_to_hz Signature

mel_to_hz[num_chans: Int = 1](mel: SIMD[DType.float64, num_chans]) -> SIMD[DType.float64, num_chans]

fn mel_to_hz Parameters

Name Type Default Description
num_chans Int 1

fn mel_to_hz Arguments

Name Type Default Description
mel SIMD

fn mel_to_hz Returns : SIMD

Static Method

This is a static method.

struct MFCC

Mel-Frequency Cepstral Coefficients (MFCC) analysis.

This implementation follows the approach used in the Librosa library.

Learn more about MFCCs on the FluCoMa learn page and with this interactive demonstration.

Traits: AnyType, Copyable, FFTProcessable, GetFloat64Featurable, ImplicitlyDestructible, Movable


MFCC Functions

struct MFCC . fn init

Initialize the MFCC analyzer.

fn init Signature

__init__(out self, sr: Float64, num_coeffs: Int = 13, num_bands: Int = 40, min_freq: Float64 = 20, max_freq: Float64 = 2.0E+4, fft_size: Int = 1024)

fn init Arguments

Name Type Default Description
sr Float64 The sample rate for the mel band computation.
num_coeffs Int 13 The number of MFCC coefficients to compute (including the 0th coefficient).
num_bands Int 40 The number of mel bands to use when computing the MFCCs.
min_freq Float64 20 The minimum frequency (in Hz) to consider when computing the mel bands for the MFCCs.
max_freq Float64 2.0E+4 The maximum frequency (in Hz) to consider when computing the mel bands for the MFCCs.
fft_size Int 1024 The size of the FFT being used to compute the mel bands for the MFCCs.

fn init Returns : Self An initialized MFCC struct.

Static Method

This is a static method.

struct MFCC . fn get_features

Return the current MFCC values as a List of Float64.

fn get_features Signature

get_features(self) -> List[Float64]

fn get_features Returns : List

struct MFCC . fn next_frame

Compute the MFCCs for a given FFT analysis. This function is to be used by FFTProcess if MFCC is passed as the "process".

Nothing is returned from this function, but the computed MFCC values are stored in self.coeffs.

fn next_frame Signature

next_frame(mut self, mut mags: List[Float64], mut phases: List[Float64])

fn next_frame Arguments

Name Type Default Description
mags List The input magnitudes as a List of Float64.
phases List The input phases as a List of Float64.

struct MFCC . fn from_mags

Compute the MFCCs for a given list of magnitudes. This function is useful when there is an FFT already computed, perhaps as part of a custom struct that implements the FFTProcessable trait.

Nothing is returned from this function, but the computed MFCC values are stored in self.coeffs.

fn from_mags Signature

from_mags(mut self, ref mags: List[Float64])

fn from_mags Arguments

Name Type Default Description
mags List The input magnitudes as a List of Float64.

struct MFCC . fn from_mel_bands

Compute the MFCCs for a given list of mel band energies. This function is useful when there is a mel band analysis already computed, perhaps as part of a custom struct that implements the FFTProcessable trait.

Nothing is returned from this function, but the computed MFCC values are stored in self.coeffs.

fn from_mel_bands Signature

from_mel_bands(mut self, ref mbands: List[Float64])

fn from_mel_bands Arguments

Name Type Default Description
mbands List The input mel band energies as a List of Float64.

struct MFCC . fn buf_analysis

fn buf_analysis Signature

buf_analysis(buf: Buffer, chan: Int = 0, start_frame: Int = 0, var num_frames: Int = -1, num_coeffs: Int = 13, num_bands: Int = 40, min_freq: Float64 = 20, max_freq: Float64 = 2.0E+4, fft_size: Int = 1024, hop_size: Int = 512) -> List[List[Float64]]

fn buf_analysis Arguments

Name Type Default Description
buf Buffer
chan Int 0
start_frame Int 0
num_frames Int -1
num_coeffs Int 13
num_bands Int 40
min_freq Float64 20
max_freq Float64 2.0E+4
fft_size Int 1024
hop_size Int 512

fn buf_analysis Returns : List

Raises

Static Method

This is a static method.

struct DCT

Compute the Discrete Cosine Transform (DCT).

Traits: AnyType, Copyable, ImplicitlyDestructible, Movable


DCT Functions

struct DCT . fn init

fn init Signature

__init__(out self, input_size: Int, output_size: Int)

fn init Arguments

Name Type Default Description
input_size Int
output_size Int

fn init Returns : Self

Static Method

This is a static method.

struct DCT . fn process

Compute the first output_size DCT-II coefficients for input. Nothing is returned from this function, but the computed DCT coefficients are stored in the output List passed as an argument.

fn process Signature

process(mut self, ref input: List[Float64], mut output: List[Float64])

fn process Arguments

Name Type Default Description
input List Input vector of length input_size.
output List Output vector of length output_size.

struct SpectralFlux

Spectral Flux analysis.

This implementation computes the squared difference between the magnitudes of the current frame and the previous frame, summed across all frequency bins.

Args:

    num_mags: The number of magnitude bins in the input to expect. This is typically the FFT size divided by 2, but could also be the number of mel bands or another spectral summary that produces a list of values.
    positive_only: Whether to only consider positive differences (increases in energy) when computing the spectral flux. If `False`, spectral flux is the average of squared differences between the magnitudes. If `True`, spectral flux is the average of (non-squared to match FluCoMa) differences between the magnitudes, but negative differences are set to 0. Using `positive_only=True` is a common approach when using spectral flux for onset detection, as onsets are typically characterized by increases in energy.

Traits: AnyType, Copyable, FFTProcessable, GetFloat64Featurable, ImplicitlyDestructible, Movable


SpectralFlux Functions

struct SpectralFlux . fn init

Initialize the Spectral Flux analyzer.

fn init Signature

__init__(out self, num_mags: Int, positive_only: Bool = False)

fn init Arguments

Name Type Default Description
num_mags Int The number of magnitude bins in the input to expect. This is typically the FFT size divided by 2, but could also be the number of mel bands or another spectral summary that produces a list of values.
positive_only Bool False Whether to only consider positive differences (increases in energy) when computing the spectral flux. If False, spectral flux is the average of squared differences between the magnitudes. If True, spectral flux is the average of (non-squared to match FluCoMa) differences between the magnitudes, but negative differences are set to 0. Using positive_only=True is a common approach when using spectral flux for onset detection, as onsets are typically characterized by increases in energy.

fn init Returns : Self

Static Method

This is a static method.

struct SpectralFlux . fn next_frame

Compute the spectral flux onset value for a given FFT analysis. This function is to be used by FFTProcess if SpectralFluxOnsets is passed as the "process".

Nothing is returned from this function, but the computed spectral flux value is stored in self.flux.

fn next_frame Signature

next_frame(mut self, mut mags: List[Float64], mut phases: List[Float64])

fn next_frame Arguments

Name Type Default Description
mags List The input magnitudes as a List of Float64.
phases List The input phases as a List of Float64.

struct SpectralFlux . fn get_features

Return the current spectral flux value as a List of Float64.

fn get_features Signature

get_features(self) -> List[Float64]

fn get_features Returns : List

struct SpectralFlux . fn from_mags

Compute the spectral flux onset value for a given list of magnitudes. This function is useful when there is an FFT already computed, perhaps as part of a custom struct that implements the FFTProcessable trait.

Nothing is returned from this function, but the computed spectral flux value is stored in self.flux.

fn from_mags Signature

from_mags(mut self, ref mags: List[Float64]) -> Float64

fn from_mags Arguments

Name Type Default Description
mags List The input magnitudes as a List of Float64.

fn from_mags Returns : Float64

struct SpectralFluxOnsets

Spectral Flux Onset analysis.

Traits: AnyType, Copyable, GetBoolFeaturable, ImplicitlyDestructible, Movable


SpectralFluxOnsets Functions

struct SpectralFluxOnsets . fn init

fn init Signature

__init__(out self, world: UnsafePointer[MMMWorld, MutExternalOrigin], window_size: Int = 1024, hop_size: Int = 512, filter_size: Int = 5)

fn init Arguments

Name Type Default Description
world UnsafePointer
window_size Int 1024
hop_size Int 512
filter_size Int 5

fn init Returns : Self

Static Method

This is a static method.

struct SpectralFluxOnsets . fn get_features

fn get_features Signature

get_features(self) -> List[Bool]

fn get_features Returns : List

struct SpectralFluxOnsets . fn next

fn next Signature

next(mut self, input: Float64) -> Bool

fn next Arguments

Name Type Default Description
input Float64

fn next Returns : Bool

struct SpectralFluxOnsets . fn buf_analysis

fn buf_analysis Signature

buf_analysis(world: UnsafePointer[MMMWorld, MutExternalOrigin], buf: Buffer, chan: Int = 0, start_frame: Int = 0, var num_frames: Int = -1, thresh: Float64 = 0.5, min_slice_len: Float64 = 1, window_size: Int = 1024, hop_size: Int = 512, filter_size: Int = 5) -> List[Int]

fn buf_analysis Arguments

Name Type Default Description
world UnsafePointer
buf Buffer
chan Int 0
start_frame Int 0
num_frames Int -1
thresh Float64 0.5
min_slice_len Float64 1
window_size Int 1024
hop_size Int 512
filter_size Int 5

fn buf_analysis Returns : List

Raises

Static Method

This is a static method.

struct TopNFreqs

An FFTProcessable that identifies the top N frequency peaks in each FFT frame and provides their frequencies and amplitudes as output.

Args:

sample_rate: The sample rate of the audio signal.
window_size: The size of the FFT window. This determines the frequency resolution and the maximum number of frequency bins (window_size // 2 + 1).
num_peaks: The number of top peaks to identify in each FFT frame.
sort_by_freq: Whether to sort the output freq, amp pairs by frequency (True) or by amplitude (False).
thresh: The minimum amplitude threshold (in dB) for a peak to be considered. Peaks below this threshold will be ignored.

Traits: AnyType, Copyable, FFTProcessable, GetFloat64Featurable, ImplicitlyDestructible, Movable


TopNFreqs Functions

struct TopNFreqs . fn init

Initialize the TopNFreqs process.

fn init Signature

__init__(out self, sample_rate: Float64, window_size: Int, num_peaks: Int = 5, sort_by_freq: Bool = True, thresh: Float64 = -30)

fn init Arguments

Name Type Default Description
sample_rate Float64 The sample rate of the audio signal.
window_size Int The size of the FFT window. This determines the frequency resolution and the maximum number of frequency bins (window_size // 2 + 1).
num_peaks Int 5 The number of top peaks to identify in each FFT frame.
sort_by_freq Bool True Whether to sort the output freq, amp pairs by frequency (True) or by amplitude (False).
thresh Float64 -30 The minimum amplitude threshold (in dB) for a peak to be considered. Peaks below this threshold will be ignored.

fn init Returns : Self

Static Method

This is a static method.

struct TopNFreqs . fn get_features

fn get_features Signature

get_features(self) -> List[Float64]

fn get_features Returns : List

struct TopNFreqs . fn get_features_ptr

Return a pointer to the current List of freq, amp pairs.

fn get_features_ptr Signature

get_features_ptr(self) -> Pointer[List[Tuple[Float64, Float64]], origin_of(self.freq_amp_pairs)]

fn get_features_ptr Returns : Pointer

struct TopNFreqs . fn get_messages

fn get_messages Signature

get_messages(mut self)

struct TopNFreqs . fn next_frame

fn next_frame Signature

next_frame(mut self, mut mags: List[Float64], mut phases: List[Float64])

fn next_frame Arguments

Name Type Default Description
mags List
phases List

struct TopNFreqs . fn sort_pairs_by_freq

fn sort_pairs_by_freq Signature

sort_pairs_by_freq(mut self)

Documentation generated with mojo doc from Mojo version 0.26.1.0