weezah / Unity-Beat-Detection

Musical beat detection and audio spectrum analysis for use with the Unity game engine.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unity-Beat-Detection

Musical beat detection and audio spectrum analysis for use with the Unity game engine.

The AudioProcessor class contains an interface that can be implemented on your GameObject.

Usage

Add the AudioProcessor script to your Main Camera object and adjust the threshold parameter to change the sensitivity. Then simply implement the AudioCallbacks interface on any object you'd like to be notified when a beat is detected.
public class Example : MonoBehaviour, AudioProcessor.AudioCallbacks{
void Start()
    {
        //Select the instance of AudioProcessor and pass a reference
        //to this object
        AudioProcessor processor = FindObjectOfType<AudioProcessor>();
        processor.addAudioCallback(this);
    }

    
    void Update()
    {
        
    }

    public void onOnbeatDetected()
    {
        Debug.Log("Beat!!!");
    }

    public void onSpectrum(float[] spectrum)
    {
       
    }
}

About

Musical beat detection and audio spectrum analysis for use with the Unity game engine.


Languages

Language:C# 100.0%