GestureSynth.me

Music calculator

Spectral Flux Calculator for Audio

Measure audio spectral flux between two frames using Euclidean distance or increases only. Inspect each signed change and squared contribution.

spectral flux calculator

Spectral Flux Calculator for Audio guide

Spectral flux measures how much a magnitude spectrum changes from one analysis frame to the next. Paste two lists in the same bin order, beginning with the earlier frame. Select all changes to measure movement in either direction or increases only to emphasize new energy at an onset.

Play the instrument ↑
Default result
3 spectral flux

Calculation and units

For each bin subtract the previous magnitude from the current one. In increases-only mode replace negative differences with zero before squaring. Sum the squared terms and take the square root to obtain the Euclidean distance. The table displays the original signed difference alongside the term actually included, making discarded decreases easy to identify.

Worked examples

Select a named case in the Worked example control to load these values. You can then edit any input to compare the result.

Rise and fall

Previous magnitude spectrum = 1 2 0 · Current magnitude spectrum = 3 1 2 · Change to include = All changes.

3 spectral flux. Squared sum 9 over 3 bins. Using all signed differences without frame normalization. The last column contributes to the squared sum. Table readings (Bin, Change, Squared term): (0, 2, 4) / (1, -1, 1) / (2, 2, 4).

The three signed changes are two, minus one and two. Their squares add to nine, so the Euclidean distance is three.

Ignore the falling bin

Previous magnitude spectrum = 1 2 0 · Current magnitude spectrum = 3 1 2 · Change to include = Increases only.

2.8284271 spectral flux. Squared sum 8 over 3 bins. Using increases only without frame normalization. The last column contributes to the squared sum. Table readings (Bin, Change, Squared term): (0, 2, 4) / (1, -1, 0) / (2, 2, 4).

The negative change is still visible in the table. Its squared contribution is zero when only increases are counted.

Identical frames

Previous magnitude spectrum = 2 1 3 · Current magnitude spectrum = 2 1 3 · Change to include = All changes.

0 spectral flux. Squared sum 0 over 3 bins. Using all signed differences without frame normalization. The last column contributes to the squared sum. Table readings (Bin, Change, Squared term): (0, 0, 0) / (1, 0, 0) / (2, 0, 0).

Every difference vanishes even though the signal has substantial magnitude in all three bins.

Spectral relocation

Previous magnitude spectrum = 3 0 · Current magnitude spectrum = 0 3 · Change to include = All changes.

4.2426407 spectral flux. Squared sum 18 over 2 bins. Using all signed differences without frame normalization. The last column contributes to the squared sum. Table readings (Bin, Change, Squared term): (0, -3, 9) / (1, 3, 9).

Overall magnitude sum is unchanged as energy moves between bins. The frame distance still reflects both the disappearance and the new component.

Uniform decay

Previous magnitude spectrum = 4 2 1 · Current magnitude spectrum = 2 1 0.5 · Change to include = Increases only.

0 spectral flux. Squared sum 0 over 3 bins. Using increases only without frame normalization. The last column contributes to the squared sum. Table readings (Bin, Change, Squared term): (0, -2, 0) / (1, -1, 0) / (2, -0.5, 0).

All components fall, so none contributes to the positive-change measure. Switch modes to see how much the spectrum changed overall.

Onset from silence

Previous magnitude spectrum = 0 0 0 · Current magnitude spectrum = 0 3 4 · Change to include = Increases only.

5 spectral flux. Squared sum 25 over 3 bins. Using increases only without frame normalization. The last column contributes to the squared sum. Table readings (Bin, Change, Squared term): (0, 0, 0) / (1, 3, 9) / (2, 4, 16).

The contributing magnitudes form a three-four-five triangle. Here the positive distance is the norm of the current frame itself.

Interpreting the result

Compare both modes on a decaying sound. The full distance can remain substantial while the increase-only measure drops to zero. A new peak at a different frequency can produce a strong onset score even if the total magnitude stays constant. Look at the individual rows to see whether the change was global or concentrated in one band.

Measurement and model limits

There is no per-frame normalization, smoothing, threshold or onset decision here. The same relative change in a louder recording can give a larger result. Use identical FFT lengths, windows, hops and magnitude scaling across the two frames. Other flux definitions may use a sum of absolute values or a mean instead of Euclidean distance.

Answers before you play

Common questions

Are negative inputs allowed?

Enter nonnegative linear magnitudes. Negative changes are calculated internally and can occur whenever a current bin is smaller than its predecessor.

Can the result exceed one?

Yes. An unnormalized distance has the scale of the magnitude inputs and can increase with the number of contributing bins.

Does order matter when comparing the frames?

Swapping the lists preserves full Euclidean distance. It exchanges increases and decreases, so the increases-only answer can change.

Can I use this to detect a beat?

Flux can contribute to an onset envelope. Beat timing requires a series of frames and additional decisions about peaks, periodicity and musical context.