Custom Audio Analyzers

Audio analysis is now modular. Custom code can be written and plugged into the SALSA core calls. Keep in mind, this is an advanced implementation and requires a deep knowledge of SALSA and the audio being analyzed to produce the best outcome. Unless otherwise advised, it is strongly recommended to use the default analyzer built into the SALSA engine. The default analyzer is designed for the best performance and tightest operation with the core codebase.


In order to insert a new audio analysis module into the core code, SALSA employs a delegate call to map the analysis method. The signature of the delegate expects two values.

  1. The audio channel count as an .

  2. The current segment of audio sample data as an array of floats.

Internally, SALSA sets up the default analyzer during its runtime Awake() call. This analyzer can technically be changed at any time. SALSA will only set the default module if the assigned delegate is currently null. Therefore timing of implementation is not paramount. Even if SALSA sets the module before custom code has a chance to, when a custom assignment is made, it will be in effect prior to the first SALSA tick cycle.


To assign a new audio analyzer, set the delegate to your custom method in either Start() or Awake(). One way to implement would be create a script as follows and attach it to the same GameObject as SALSA:

using CrazyMinnow.SALSA;
using UnityEngine;

public class CustomAudioAnalysisPlugin : MonoBehaviour {

    // In Start() or Awake() set the delegate (audioAnalyzer) to your custom
    // method call.
    void Start()
        GetComponent<Salsa>().audioAnalyzer = CalcSimpleMaxPeakValue;

    private float CalcSimpleMaxPeakValue(int channels, float[] audioData)
        var maxVal = 0f; // collected peak value per data slice.

        // loop through the first channel of the data slice.
        for (int i = 0; i < audioData.Length; i += channels)
            if (audioData[i] > maxVal)
                maxVal = audioData[i]; // update peak value

        return maxVal;

To confirm your analysis code has been implemented, SALSA displays the name of the current assigned method plugin in the Settings section. This information is only displayed at runtime.

salsa analyzer module display