Spectral flux is a measure of how quickly the power spectrum of a signal is changing, calculated by comparing the power spectrum for one frame against the power spectrum from the previous frame.
More precisely, it is usually calculated as the L2-norm (also known as the Euclidean distance) between the two normalised spectra. Calculated this way, the spectral flux is not dependent upon overall power (since the spectra are normalised), nor on phase considerations (since only the magnitudes are compared).
The spectral flux can be used to determine the timbre of an audio signal, or in onset detection, among other things.
Some implementations use the L1-norm rather than the L2-norm (i.e. the sum of absolute differences rather than the sum of squared differences).
Some implementations do not normalise the spectra.
For onset detection, increases in energy are important (not decreases), so some algorithms only include values calculated from bins in which the energy is increasing.
In the onset detection function of Dixon (2006), only increases in magnitude are summed over the bins of the short-time Fourier transform X(n, k) (frame n, bin k):
where N is the window size and H is the half-wave rectifier.
Conventional spectral flux can produce false onset detections when vibrato causes frequency components to shift between neighboring frequency bins. Böck and Widmer (2013) proposed a method called SuperFlux to address this problem using a maximum filter along the frequency axis.
SuperFlux compares the current spectrogram frame with a maximum-filtered earlier frame. This reduces the influence of frequency variations caused by vibrato while detecting increases in spectral magnitude associated with onsets.
In an EEG study of people listening to instrumental music, neural synchronization was stronger to spectral flux than to the amplitude envelope, its first derivative or beat times.