Logo - Crazy Minnow Studio - game, asset, tool development

Welcome to Crazy Minnow Studio! We are a small indie software development team primarily focused on game development using the Unity engine. Our pipeline includes: games, game development tools and assets, and video tutorial production. Check out our Unity lip sync asset, SALSA Lip-Sync, available on the Unity Asset Store. Follow our blog for updates on our Unity asset and game development, as well as other happenings in indie game development.

Beat Detect for Amplitude

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.

  1. Install Amplitude into your project.
    • Select [Window] -> [Asset Store]
      • Once the Asset Store window opens, select the download icon, and download and import [Amplitude].
  2. 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.

Usage Instructions

  1. Setup Amplitude as you normally would.
  2. Add the BeatDetect component.
  3. Link your Amplitude component to the BeatDetect [Amplitude] field.
  4. Add as many event triggers as you wish and set their amplitude trigger value.
  5. 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 Files

Amplitude for WebGL
~ Make your web audio move! ~

Buy Amplitude on the Asset Store

 


Categories: Amplitude

Comments: No comments yet