Click or drag to resize

Using analysis results

Analysis results

RhythmTool has three main types of data:

  • Beats

    These represent the rhythm of the song.

  • Changes

    These represent changes in the overall intensity of the song and are useful for telling segments of the song apart.

  • AnalysisData

    These contain analysis results and detected peaks (onsets) for different frequency ranges.

There are 4 default Analyses. low, mid, high and all. Each of these looks at a specific frequency range and stores the following data:

  • magnitude

    The combined magnitude of all frequencies in the specified frequency range. Essentially the loudness.

  • magnitudeSmooth

    A smoothed variant of the magnitude.

  • magnitudeAvg

    A version of magnitudeSmooth that interpolates from trough to trough and peak to peak. This is like a smooth version of magnitude, but without big variations.

  • flux

    The difference between a frame’s and the previous frame’s magnitudes.

  • onsets

    Detected peaks that represent the beginning of a note, sound or beat.

Synchronizing results

All of the analysis results are stored in collections where the index or key is the frame index.

The main method of synchronizing analysis results is by using RhythmTool.currentFrame. This is the index of the frame that belongs to the current time in the song.

For example, finding out if an onset has been detected at the current time in the song can be done like this:

AnalysisData low = rhythmTool.low;


Onset onset;
if(low.onsets.TryGetValue(rhythmTool.currentFrame, out onset))
    Debug.Log("An onset occured with a strength of " + onset.strength);

And finding out if there is a beat:


Beat beat;
if(, out beat))
    Debug.Log("A beat occured at " + rhythmTool.currentFrame);

Or using some other data from the "all" Analysis:

AnalysisData all = rhythmTool.all;


float volume = all.magnitude[rhythmTool.currentFrame];
Synchronization issues

In most cases, the game's frame rate does not perfectly match RhythmTool's sample rate of 30 frames per second of audio data. Because of this, RhythmTool.currentFrame can be the same for multiple frames in a row, or skip some values. This can be an issue when you want to handle every beat, onset or other analysis results exactly once.

This issue can be solved by looping over every frame that has passed since the last Update(). This way, any skipped frames will be dealt with and no frames will be used twice.

RhythmTool already does this. The RhythmTool.FrameChanged and the RhythmEventProvider.FrameChanged events will occur once for every frame that has passed.