BeatDetect is a free add-on for Amplitude that allows you to easily create amplitude level event triggers. You can use these events to respond to sounds or music on the WebGL platform.
Amplitude (Required)
https://crazyminnowstudio.com/unity-3d/amplitude-webgl/
04/10/2018 - (1.1.1) Fixed component menu listing. Requires Amplitude 1.1.0+, includes UI prefabs for testing and tuning your results within a WebGL build. Amplitude 1.1.0 added frequency processing, which works fantastic with Beat Detect.
webgl demos:
Installation Instructions
The zip file below contains a Unity package that can be imported into your project.
- Install Amplitude into your project.
- Select [Window] -> [Asset Store]
- Once the Asset Store window opens, select the download icon, and download and import [Amplitude].
- Select [Window] -> [Asset Store]
- Install the BeatDetect add-on into your project.
- Select [Assets] -> [Import Package] -> [Custom Package...]
- Browse to the BeatDetect_X.X.X.unitypackage you downloaded from the download link below.
- Select [Assets] -> [Import Package] -> [Custom Package...]
Usage Instructions
- Setup Amplitude as you normally would.
- Add the BeatDetect component.
- Link your Amplitude component to the BeatDetect [Amplitude] field.
- Add as many event triggers as you wish and set their amplitude trigger value.
- Setup an event listener script to recieve a Trigger parameter (see the included BeatDetectTester.cs script). BeatDetect amplitude level events emit when the amplitude rises above the trigger value, and when the amplitude dips below the trigger value. The Trigger event parameter includes the following information:
- Trigger.average (bool)
- When checked this trigger monitors the average output.
- Trigger.index
- The index of the trigger.
- Trigger.sampleIndex
- The sample index to monitor.
- Trigger.currentDir
- The triggered direction of the event.
- Trigger.triggerDir
- The monitored direction fo the event.
- Trigger.value
- Amplitude trigger value
- Trigger.clipName
- Amplitude.audioSource.clip.name
- Trigger.clipLength
- Amplitude.audioSource.clip.length
- Trigger.clipTime
- Amplitude.audioSource.time
Code Example
using UnityEngine;
using CrazyMinnow.AmplitudeWebGL;
namespace CrazyMinnow.AmplitudeWebGL
{
public class BeatDetectLog : MonoBehaviour
{
public void TriggerEventListener(Trigger trigger)
{
switch (trigger.currentDir)
{
case BeatDetect.CurrentDir.Over: // Amplitude/frequency is over trigger
Debug.Log(
trigger.index + ", " +
trigger.sampleIndex + ", " +
trigger.currentDir + ", " +
trigger.value + ", " +
trigger.clipName + ", " +
trigger.clipLength + ", " +
trigger.clipTime);
break;
case BeatDetect.CurrentDir.Under: // Amplitude/frequency is under trigger
Debug.Log(
trigger.index + ", " +
trigger.sampleIndex + ", " +
trigger.currentDir + ", " +
trigger.value + ", " +
trigger.clipName + ", " +
trigger.clipLength + ", " +
trigger.clipTime);
break;
}
}
}
}
NOTE: While every attempt has been made to ensure the safe content and operation of these files, they are provided as-is, without warranty or guarantee of any kind. By downloading and using these files you are accepting any and all risks associated and release Crazy Minnow Studio, LLC of any and all liability.
Download FilesAmplitude for WebGL
~ Make your web audio move! ~
Categories: Amplitude
Comments: No comments yet