Temporal Features

This page lists the temporal features included in js-xtract. Please use Ctrl+F or Cmd+F to find a specific feature

Scalars

This group of features returns a single scalar value on completion

Mean

Calculates the mean of the passed array

Code

Procedural:

value = xtract_mean(data);

Object-Oriented:

TimeData().mean();

Arguments

Argument Type Mandatory Auto-calculation
data Array, TypedArray Yes None

Temporal Centroid

Calculates the center of gravity from an energy array. The time domain data must first have been processed using the vector function xtract_energy_array(...)

Code

Procedural:

value = xtract_temporal_centroid(energyArray, sample_rate, window_ms);

Object-Oriented:

TimeData().temporal_centroid();

Arguments

Argument Type Mandatory Auto-calculation
data TypedArray from xtract_energy_array Yes None
sample_rate Number greater than 0.0 Yes None
window_ms Number greater than 0.0 No window_ms = 100.0

Variance

Calculate the spread of the data

Code

Procedural:

value = xtract_variance(data, mean);

Object-Oriented:

TimeData().variance();

Arguments

Argument Type Mandatory Auto-calculation
data Array, TypedArray Yes None
mean Number No mean = xtract_mean(data)

Standard Deviation

Calculate the standard deviation

Code

Procedural:

value = xtract_standard_deviation(data, variance);

Object-Oriented:

TimeData().standard_deviation();

Arguments

Argument Type Mandatory Auto-calculation
data Array, TypedArray Yes None
variance Number No variance = xtract_variance(data, "undefined");

Average Deviation

Calculate the average spread from the mean

Code

Procedural:

value = xtract_average_deviation(data, mean);

Object-Oriented:

TimeData().average_deviation();

Arguments:

Argument Type Mandatory Auto-calculation
data Array, TypedArray Yes None
mean Number No mean = xtract_mean(data);

Skewness

Calculate the symmetry of the array about the mean

Code

Procedural:

value = xtract_skewness(data, mean, standard_deviation);

Object-Oriented:

TimeData().skewness();

Arguments

Argument Type Mandatory Auto-calculation
data Array, TypedArray Yes None
mean Number No mean = xtract_mean(data);
standard_deviation Number No standard_deviation = xtract_standard_deviation(array, xtract_variance(data, mean));

Kurtosis

Calculate the 'flatness' of the array about the mean

Code

Procedural:

value = xtract_kurtosis(data, mean, standard_deviation);

Object-Oriented:

TimeData().kurtosis();

Arguments

Argument Type Mandatory Auto-calculation
data Array, TypedArray Yes None
mean Number No mean = xtract_mean(data);
standard_deviation Number No standard_deviation = xtract_standard_deviation(array, xtract_variance(data, mean));

Zero Crossing Rate

Count the number of times the signal crosses the zero (from negative to positive and vice versa)

Code

Procedural:

value = xtract_zcr(timeArray)

Object-Oriented:

TimeData().zcr();

Arguments

Argument Type Mandatory Auto-calculation
timeArray Array, TypedArray Yes None

RMS Amplitude

Calculate the RMS value of the array

Code

Procedural:

value = xtract_rms_amplitude(timeArray);

Object-Oriented:

TimeData().rms_amplitude();

Arguments

Argument Type Mandatory Auto-calculation
timeArray Array, TypedArray Yes None

Lowest Value

Return the lowest value above a threshold

Code

Procedural:

value = xtract_lowest_value(data, threshold);

Object-Oriented:

TimeData().lowest_value(threshold);

Arguments

Argument Type Mandatory Auto-calculation
data Array, TypedArray Yes None
threshold Number No threshold = -Infinity

Highest Value

Return the highest value below a threshold

Code

Procedural:

value = xtract_highest_value(data, threshold);

Object-Oriented:

TimeData().highest_value(threshold);

Arguments

Argument Type Mandatory Auto-calculation
data Array, TypedArray Yes None
threshold Number No threshold = +Infinity

Sum

Return the sum of the array

Code

Procedural:

value = xtract_sum(data);

Object-Oriented:

TimeData().sum();

Arguments

Argument Type Mandatory Auto-calculation
data Array, TypedArray Yes None

Non-zero count

Count the number of elements which are not equal to zero

Code

Procedural:

value = xtract_nonzero_count(data);

Object-Oriented:

TimeData().nonzero_count();

Arguments

Argument Type Mandatory Auto-calculation
data Array, TypedArray Yes None

Fundamental Frequency

Calculate the fundamental frequency

Code

Procedural

value = xtract_f0(timeArray, sampleRate);

Object-Oriented

TimeData().f0();

Arguments

Argument Type Mandatory Auto-calculation
data Array, TypedArray Yes None
sampleRate Number Yes None

Fundamental Frequency (wavelet)

Compute the frequency using wavelets and a history

Code

Procedural:

value = xtract_wavelet_f0(timeArray, sampleRate, pitchtracker);
// `pitchtracker` is created by calling `xtract_init_wavelet()`

Object-Oriented:

TimeData().wavelet_f0();

Arguments

Argument Type Mandatory Auto-calculation
data Array, TypedArray Yes None
sampleRate Number Yes None
pitchtracker Object Yes None

Vector Features

These features return vectors

Temporal Energy

Compute the energy of the array, decimated by the given window size

Code

Procedural:

Float64Array = xtract_energy(array, sample_rate, window_ms);

Object-Oriented:

TimeData().energy(window_ms);

Arguments

Argument Type Mandatory Auto-calculation
data Array, TypedArray Yes None
sampleRate Number Yes None
window_ms Number No window_ms = 100.0;

Spectrum

Perform the FFT on the data to generate the Magnitude Spectrum and corresponding bin frequencies

Code

Procedural:

Float64Array = xtract_spectrum(array, sample_rate, withDC, normalise);

Object-Oriented:

// Creates a new SpectrumData() object
TimeData().spectrum(widthDC, normalise);

Arguments

Argument Type Mandatory Auto-calculation
array Array, TypedArray Yes None
sample_rate Number Yes None
withDC Number No withDC = false;
normalise Number No normalise = false;

Complex Spectrum

For some data the complex spectrum is required. This performs the complex spectrum:

Code

Procedural:

Float64Array = xtract_complex_spectrum(array, sample_rate, withDC, normalise);

Arguments

Argument Type Mandatory Auto-calculation
array Array, TypedArray Yes None
sample_rate Number Yes None
withDC Number No withDC = false;
normalise Number No normalise = false;

DCT

Calculate the Discrete Cosine Transform

Code

Procedural:

Float64Array = xtract_dct(array);

// A faster form of the DCT using pre-computed coefficients
// calling xtract_init_dct(N); where N = array.length
// Requires more memory to store dct object but faster per iteration.
Float64Array = xtract_dct_2(array, dct);

Object-Oriented:

TimeData().dct();

Arguments

Argument Type Mandatory Auto-calculation
array Array, TypedArray Yes None

Autocorrelation

Calculate the autocorrelation

Code

Procedural:

Float64Array = xtract_autocorrelation(array);

Object-Oriented:

TimeData().autocrrelation();

Arguments

Argument Type Mandatory Auto-calculation
array Array, TypedArray Yes None

AMDF

Perform thge Average Magnitude Difference

Code

Procedural:

Float64Array = xtract_amdf(array);

Object-Oriented:

TimeData().amdf();

Arguments

Argument Type Mandatory Auto-calculation
array Array, TypedArray Yes None

ASDF

Perform the Average Squared Difference

Code

Procedural:

Float64Array = xtract_asdf(array);

Object-Oriented:

TimeData().asdf();

Arguments

Argument Type Mandatory Auto-calculation
array Array, TypedArray Yes None

YIN

Perform the YIN pitch detector

Code

Procedural:

Float64Array = xtract_yin(array);

Arguments

Argument Type Mandatory Auto-calculation
array Array, TypedArray Yes None

Onset

Detect Onsets using the Complex Domain function. Only available in the offline version. Performs frame decimation based on frameSize and returns timeData.length/frameSize values indicating onset.

Code

Procedural:

Float64Array = xtract_onset(timeData, frameSize);

Arguments

Argument Type Mandatory Auto-calculation
timeData Array, TypedArray Yes None
frameSize Number Yes None

Resample

Resample the vector by a ratio of p/q using FIR filters of order n;

Code:

Procedural:

Float64Array = xtract_resample(data, p, q, n);

Object-Oriented

// Creates a new TimeData() object with the resampled data. Internal sample rate must be defined.
TimeData() = TimeData().resample(q, n);
Argument Type Mandatory Auto-calculation
data Array, TypedArray Yes None
p Number Yes None
q Number Yes None
n Number No n = 512