Click or drag to resize

Analyzing a song

Analyzing a song

To start analyzing a song, assign an AudioClip to RhythmTool.audioClip. This will load the AudioClip and start analyzing it.

When the song has finished loading, RhythmTool.SongLoaded will be called. A song has finished loading when the initial analysis is complete. When preAnalyze is enabled, this will be after the entire song has been analyzed. Otherwise this will be when a number of frames (based on lead) has been analyzed.

With RhythmTool.DrawDebugLines() you can draw some basic graphs that show the analysis results.

Debug Lines
Note Note

A RhythmTool Component can analyze only one song at a time.

Playing a song

After a song has been loaded, use RhythmTool.Play() to start playing the song.

The RhythmTool Component has some methods and properties to control the audio playback. These are mostly the same as the AudioSource Component. These include RhythmTool.Play(), RhythmTool.Stop(), RhythmTool.Pause(), RhythmTool.UnPause(), RhythmTool.pitch and RhythmTool.volume

RhythmTool uses an AudioSource to play a song. It is possible to use this AudioSource to control playback, but this might cause unintended behaviour.

C#
using UnityEngine;

public class AnalyzeExample : MonoBehaviour
{
    public RhythmTool rhythmTool;

    public AudioClip audioClip;

    void Start ()
    {
        rhythmTool.SongLoaded += OnSongLoaded;

        rhythmTool.audioClip = audioClip;
    }

    private void OnSongLoaded()
    {
        rhythmTool.Play ();
    }

    void Update ()
    {
        rhythmTool.DrawDebugLines ();
    }
}