Divooka Reference

Signal Processing

25 nodes

On this page 25

Apply Filter

Function

Runs a clip through a filter, once, forward - the way any real-time filter would.

Signature
ApplyFilter -> AudioBuffer
    audio: AudioBuffer
    filter: Digital Filter
AudioBuffer ApplyFilter(AudioBuffer audio, DigitalFilter filter)

Parameters

nametypedefaultdescription
audioAudioBuffer—The clip.
filterDigital Filter—A filter designed at the clip's sample rate.

Returns

AudioAudioBuffer
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Apply Zero-Phase Filter

Function

Runs a clip through a filter forward and then backward, so nothing is delayed or phase-shifted and the magnitude response is squared - MATLAB's filtfilt.

Signature
ApplyZeroPhaseFilter -> AudioBuffer
    audio: AudioBuffer
    filter: Digital Filter
AudioBuffer ApplyZeroPhaseFilter(
    AudioBuffer audio,
    DigitalFilter filter)

Parameters

nametypedefaultdescription
audioAudioBuffer—The clip.
filterDigital Filter—A filter designed at the clip's sample rate.

Returns

AudioAudioBuffer
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Audio Features

Function

A table of the features audio analysis starts from, one row per frame: level, zero-crossing rate, spectral centroid, spread, rolloff, flatness and flux, and the MFCCs - ready for statistics, plotting or a classifier.

Signature
AudioFeatures -> Table
    audio: AudioBuffer
    frameSize: Integer
    hop: Integer
    coefficients: Integer
Table AudioFeatures(
    AudioBuffer audio,
    int frameSize = 2048,
    int hop = 512,
    int coefficients = 13)

Parameters

nametypedefaultdescription
audioAudioBuffer—The clip; several channels are averaged.
frameSizeInteger2048Samples per frame, a power of two.
hopInteger512Samples between frames.
coefficientsInteger13How many MFCC columns to add; 0 for none.

Returns

FeaturesTable
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Cross Correlate

Function

How alike two clips are at every relative shift - their cross-correlation - MATLAB's xcorr.

Signature
CrossCorrelate(a: AudioBuffer, b: AudioBuffer) -> Table
Table CrossCorrelate(AudioBuffer a, AudioBuffer b)

Parameters

nametypedefaultdescription
aAudioBuffer—The first clip; several channels are averaged.
bAudioBuffer—The second clip, at the first's sample rate.

Returns

CorrelationTable
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Design Filter

Function

Designs an IIR filter - Butterworth, Chebyshev I or II, elliptic or Bessel - as a cascade of second-order sections, by the bilinear transform with prewarped edges.

Signature
DesignFilter -> Digital Filter
    family: FilterFamily
    band: FilterBand
    order: Integer
    edge: Number
    upperEdge: Number
    sampleRate: Integer
    ripple: Number
    attenuation: Number
DigitalFilter DesignFilter(
    FilterFamily family = FilterFamily.Butterworth,
    FilterBand band = FilterBand.LowPass,
    int order = 4,
    double edge = 1000,
    double upperEdge = 0,
    int sampleRate = 44100,
    double ripple = 1,
    double attenuation = 40)

Parameters

nametypedefaultdescription
familyFilterFamilyButterworthButterworth is flat; Chebyshev I trades passband ripple for steepness; Chebyshev II is flat with ripple in the stopband; elliptic ripples in both for the steepest edge of all; Bessel keeps a waveform's shape with the gentlest edge.
bandFilterBandLow passWhat it keeps.
orderInteger41 to 24; band-pass and band-stop filters have twice as many poles.
edgeNumber1000The cutoff, or the band's lower edge, in Hz. For Chebyshev II, where the stopband attenuation is first reached; for Bessel, the frequency its phase is normalized to, as SciPy's norm='phase', which is above the -3 dB point at every order past 1: at order 4 the edge is 7.6 dB down and -3 dB falls at two thirds of it, at order 8 12.6 dB and about half.
upperEdgeNumber0The band's upper edge, in Hz, for band-pass and band-stop.
sampleRateInteger44100The rate of the audio it will filter.
rippleNumber1Chebyshev I's and elliptic's passband ripple, in dB, up to 300.
attenuationNumber40Chebyshev II's and elliptic's stopband attenuation, in dB, up to 300.

Returns

FilterDigital Filter
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Design FIR Filter

Function

Designs a linear-phase FIR filter by the Kaiser window method, long enough to reach the attenuation over the transition width - MATLAB's kaiserord and fir1.

Signature
DesignFirFilter -> Digital Filter
    band: FilterBand
    edge: Number
    upperEdge: Number
    transitionWidth: Number
    attenuation: Number
    sampleRate: Integer
DigitalFilter DesignFirFilter(
    FilterBand band = FilterBand.LowPass,
    double edge = 1000,
    double upperEdge = 0,
    double transitionWidth = 200,
    double attenuation = 60,
    int sampleRate = 44100)

Parameters

nametypedefaultdescription
bandFilterBandLow passWhat it keeps.
edgeNumber1000The cutoff, or the band's lower edge, in Hz: the -6 dB point.
upperEdgeNumber0The band's upper edge, in Hz.
transitionWidthNumber200How wide the edges may be, in Hz; narrower needs more taps.
attenuationNumber60The stopband attenuation, in dB.
sampleRateInteger44100The rate of the audio it will filter.

Returns

FilterDigital Filter

Remarks

A linear-phase FIR filter delays every frequency by the same (taps - 1) / 2 samples, so it changes the tone without smearing transients, and Apply Filter takes that delay back out so its output lines up with its input.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Draw Constant-Q Spectrogram

Function

A picture of a clip's constant-Q spectrogram: time left to right, pitch bottom to top with the same number of rows every octave, so notes sit on evenly spaced lines - the musician's spectrogram.

Signature
DrawConstantQSpectrogram -> Pixel Image
    audio: AudioBuffer
    binsPerOctave: Integer
    lowest: Number
    width: Integer
    height: Integer
PixelImage DrawConstantQSpectrogram(
    AudioBuffer audio,
    int binsPerOctave = 12,
    double lowest = 32.703,
    int width = 800,
    int height = 256)

Parameters

nametypedefaultdescription
audioAudioBuffer—The clip; several channels are averaged.
binsPerOctaveInteger1212 is a semitone a row, 24 a quarter-tone.
lowestNumber32.703The lowest frequency, Hz: C1 by default.
widthInteger800Picture width, in pixels.
heightInteger256Picture height, in pixels.

Returns

ImagePixel Image
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Draw Frequency Response

Function

A picture of a filter's magnitude response on a logarithmic frequency axis from 20 Hz to Nyquist, 0 dB at the top and -100 dB at the bottom.

Signature
DrawFrequencyResponse -> Pixel Image
    filter: Digital Filter
    width: Integer
    height: Integer
PixelImage DrawFrequencyResponse(
    DigitalFilter filter,
    int width = 640,
    int height = 240)

Parameters

nametypedefaultdescription
filterDigital Filter—The filter.
widthInteger640Picture width, in pixels.
heightInteger240Picture height, in pixels.

Returns

ImagePixel Image
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Draw Mel Spectrogram

Function

A picture of a clip's mel spectrogram: time left to right, mel bands bottom to top, level as brightness over the top 80 dB - the picture a speech or music model sees.

Signature
DrawMelSpectrogram -> Pixel Image
    audio: AudioBuffer
    bands: Integer
    width: Integer
    height: Integer
PixelImage DrawMelSpectrogram(
    AudioBuffer audio,
    int bands = 128,
    int width = 800,
    int height = 256)

Parameters

nametypedefaultdescription
audioAudioBuffer—The clip; several channels are averaged.
bandsInteger128Mel bands, one row of pixels band each before scaling.
widthInteger800Picture width, in pixels.
heightInteger256Picture height, in pixels.

Returns

ImagePixel Image
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Envelope

Function

A clip's amplitude envelope: the magnitude of its analytic signal (the Hilbert transform), channel by channel.

Signature
Envelope(audio: AudioBuffer) -> AudioBuffer
AudioBuffer Envelope(AudioBuffer audio)

Parameters

nametypedefaultdescription
audioAudioBuffer—The clip.

Returns

EnvelopeAudioBuffer
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Estimate Delay

Function

How far one clip runs behind another - where their cross-correlation peaks - for lining up two recordings of the same thing, MATLAB's finddelay.

Signature
EstimateDelay -> Number
    reference: AudioBuffer
    delayed: AudioBuffer
double EstimateDelay(AudioBuffer reference, AudioBuffer delayed)

Parameters

nametypedefaultdescription
referenceAudioBuffer—The clip to measure from.
delayedAudioBuffer—The clip that may run behind it, at the same sample rate.

Returns

DelayNumber
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Frequency Response

Function

A filter's frequency response: magnitude in dB, phase in degrees and group delay in milliseconds, at frequencies spaced evenly from 0 to Nyquist - MATLAB's freqz and grpdelay.

Signature
FrequencyResponse -> Table
    filter: Digital Filter
    points: Integer
Table FrequencyResponse(DigitalFilter filter, int points = 512)

Parameters

nametypedefaultdescription
filterDigital Filter—The filter.
pointsInteger512How many frequencies.

Returns

ResponseTable
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Impulse Response

Function

A filter's response to a single click: how it rings - MATLAB's impz, as a clip at the filter's rate.

Signature
ImpulseResponse -> AudioBuffer
    filter: Digital Filter
    length: Integer
AudioBuffer ImpulseResponse(
    DigitalFilter filter,
    int length = 1024)

Parameters

nametypedefaultdescription
filterDigital Filter—The filter.
lengthInteger1024How many samples.

Returns

AudioAudioBuffer
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Instantaneous Frequency

Function

The frequency a clip has from moment to moment, from the rate its analytic signal's phase turns - meaningful for one tone, a sweep or an FM sound.

Signature
InstantaneousFrequency(audio: AudioBuffer) -> Number Array
double[] InstantaneousFrequency(AudioBuffer audio)

Parameters

nametypedefaultdescription
audioAudioBuffer—The clip; several channels are averaged.

Returns

FrequencyNumber Array
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Linear Prediction

Function

The all-pole model that predicts each sample from the ones before it - the vocal tract's resonances in speech - by the autocorrelation method, MATLAB's lpc.

Signature
LinearPredictionCoefficients -> Number Array
    audio: AudioBuffer
    order: Integer
double[] LinearPredictionCoefficients(
    AudioBuffer audio,
    int order = 12)

Parameters

nametypedefaultdescription
audioAudioBuffer—The clip; several channels are averaged. A short stretch - tens of milliseconds - for one set of formants.
orderInteger12How many past samples; about the sample rate in kHz plus 2 for speech.

Returns

CoefficientsNumber Array
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

MFCC

Function

Mel-frequency cepstral coefficients frame by frame, as librosa computes them by default - the timbre features speech and music classifiers start from.

Signature
Mfcc -> Table
    audio: AudioBuffer
    coefficients: Integer
    bands: Integer
    frameSize: Integer
    hop: Integer
Table Mfcc(
    AudioBuffer audio,
    int coefficients = 13,
    int bands = 128,
    int frameSize = 2048,
    int hop = 512)

Parameters

nametypedefaultdescription
audioAudioBuffer—The clip; several channels are averaged.
coefficientsInteger13How many coefficients, usually 13 or 20.
bandsInteger128Mel bands the coefficients are taken across.
frameSizeInteger2048Samples per frame, a power of two.
hopInteger512Samples between frames.

Returns

MfccTable
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Octave Band Levels

Function

A clip's level in each octave or fractional-octave band of ANSI S1.11 and IEC 61260, through sixth-order Butterworth band filters - MATLAB's octaveFilterBank, as a table.

Signature
OctaveBandLevels -> Table
    audio: AudioBuffer
    bandsPerOctave: Integer
    lowest: Number
    highest: Number
Table OctaveBandLevels(
    AudioBuffer audio,
    int bandsPerOctave = 1,
    double lowest = 31.5,
    double highest = 16000)

Parameters

nametypedefaultdescription
audioAudioBuffer—The clip; several channels are averaged.
bandsPerOctaveInteger11 for octaves, 3 for third-octaves.
lowestNumber31.5The lowest band's centre to include, Hz.
highestNumber16000The highest band's centre to include, Hz.

Returns

BandsTable
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Power Spectral Density

Function

A clip's power spectral density by Welch's method - Hann segments overlapping by half, averaged - in dB per hertz, MATLAB's pwelch.

Signature
PowerSpectralDensity -> Table
    audio: AudioBuffer
    segmentLength: Integer
Table PowerSpectralDensity(
    AudioBuffer audio,
    int segmentLength = 1024)

Parameters

nametypedefaultdescription
audioAudioBuffer—The clip; several channels are averaged.
segmentLengthInteger1024Samples per segment, a power of two: longer is finer in frequency and noisier.

Returns

DensityTable
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Prediction Envelope

Function

A linear-prediction model as a filter: its all-pole resonances, whose frequency response is the spectral envelope - the formants.

Signature
PredictionEnvelope -> Digital Filter
    audio: AudioBuffer
    order: Integer
DigitalFilter PredictionEnvelope(
    AudioBuffer audio,
    int order = 12)

Parameters

nametypedefaultdescription
audioAudioBuffer—The stretch of audio to model.
orderInteger12The model's order.

Returns

FilterDigital Filter
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Real Cepstrum

Function

The real cepstrum - the spectrum of the log spectrum - whose peaks are periodicities in the spectrum: a voice's pitch period, an echo's delay. MATLAB's rceps.

Signature
RealCepstrum(audio: AudioBuffer) -> Number Array
double[] RealCepstrum(AudioBuffer audio)

Parameters

nametypedefaultdescription
audioAudioBuffer—The clip; several channels are averaged. A short stretch, for one pitch.

Returns

CepstrumNumber Array
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Spectral Descriptors

Function

The eleven spectral descriptors of MATLAB's Audio Toolbox, one row per frame of the power spectrum: centroid, spread, skewness, kurtosis, entropy, flatness, crest, flux, slope, decrease and rolloff.

Signature
SpectralDescriptorsTable -> Table
    audio: AudioBuffer
    frameSize: Integer
    hop: Integer
Table SpectralDescriptorsTable(
    AudioBuffer audio,
    int frameSize = 1024,
    int hop = 512)

Parameters

nametypedefaultdescription
audioAudioBuffer—The clip; several channels are averaged.
frameSizeInteger1024Samples per frame, a power of two.
hopInteger512Samples between frames.

Returns

DescriptorsTable
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Transfer Function

Function

The transfer function from one clip to another and how linearly they are related at each frequency - measuring a room, a speaker or an effect from what went in and what came out. MATLAB's tfestimate and mscohere.

Signature
TransferFunction -> Table
    input: AudioBuffer
    output: AudioBuffer
    segmentLength: Integer
Table TransferFunction(
    AudioBuffer input,
    AudioBuffer output,
    int segmentLength = 1024)

Parameters

nametypedefaultdescription
inputAudioBuffer—What went in.
outputAudioBuffer—What came out; resampled to the input's rate if it differs.
segmentLengthInteger1024Samples per Welch segment, a power of two.

Returns

TransferTable
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Weighted Level

Function

A clip's equivalent continuous level through a frequency weighting, in dB relative to a full-scale sine's RMS - the dB(A) or dB(C) of a sound level meter, uncalibrated: digital full scale stands for whatever level the recording chain puts there.

Signature
WeightedLevel -> Number
    audio: AudioBuffer
    weighting: FrequencyWeighting
double WeightedLevel(
    AudioBuffer audio,
    FrequencyWeighting weighting = FrequencyWeighting.A)

Parameters

nametypedefaultdescription
audioAudioBuffer—The clip; several channels are averaged.
weightingFrequencyWeightingAThe weighting.

Returns

LevelNumber
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Weighting Filter

Function

The A or C frequency weighting of IEC 61672 as a filter, 0 dB at 1 kHz - MATLAB's weightingFilter.

Signature
WeightingFilter -> Digital Filter
    weighting: FrequencyWeighting
    sampleRate: Integer
DigitalFilter WeightingFilter(
    FrequencyWeighting weighting = FrequencyWeighting.A,
    int sampleRate = 44100)

Parameters

nametypedefaultdescription
weightingFrequencyWeightingAA for the ear at moderate levels, C at high levels, Z for none.
sampleRateInteger44100The rate of the audio it will filter; 8 kHz or more.

Returns

FilterDigital Filter
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing

Zeros And Poles

Function

A filter's zeros and poles in the z-plane - MATLAB's zplane as a table: a filter is stable when every pole lies inside the unit circle.

Signature
ZerosAndPoles(filter: Digital Filter) -> Table
Table ZerosAndPoles(DigitalFilter filter)

Parameters

nametypedefaultdescription
filterDigital Filter—An IIR filter.

Returns

RootsTable
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Signal Processing
Package
Audio Processing