pyACA: Documentation 0.3.1
Source Code for Audio Content Analysis
Loading...
Searching...
No Matches
Functions
pyACA.FeatureSpectralFlux Namespace Reference

Functions

 FeatureSpectralFlux (X, f_s)
 computes the spectral flux from the magnitude spectrum
 

Function Documentation

◆ FeatureSpectralFlux()

FeatureSpectralFlux ( X,
f_s )

computes the spectral flux from the magnitude spectrum

Parameters
Xspectrogram (dimension FFTLength X Observations)
f_ssample rate of audio data
Returns
vsf: spectral flux

Definition at line 12 of file FeatureSpectralFlux.py.

12def FeatureSpectralFlux(X, f_s):
13
14 isSpectrum = X.ndim == 1
15 if isSpectrum:
16 X = np.expand_dims(X, axis=1)
17
18 # difference spectrum (set first diff to zero)
19 X = np.c_[X[:, 0], X]
20
21 afDeltaX = np.diff(X, 1, axis=1)
22
23 # flux
24 vsf = np.sqrt((afDeltaX**2).sum(axis=0)) / X.shape[0]
25
26 return np.squeeze(vsf) if isSpectrum else vsf