SALSA Code Examples
Salsa is distributed as compiled dll's so you can write code for Salsa in your favorite unity supported language.
Include the SALSA namespace at the top of your script before you can interact with SALSA programmatically.
C#:
using CrazyMinnow.SALSA; // Import the SALSA namespace so you can refer to SALSA classes by name
import CrazyMinnow.SALSA; // Import the SALSA namespace so you can refer to SALSA classes by name
Create a public Salsa2D or Salsa3D variable in your script:
public Salsa2D salsa;
public Salsa3D salsa;
public var salsa : Salsa2D; 
public var salsa : Salsa3D;
Use GetComponent to get reference to a Salsa2D or Salsa3D instance just like you would any other component:
salsa = GameObject.Find("GameObjectWithSalsaComponent").GetComponent();
salsa = GameObject.Find("GameObjectWithSalsaComponent").GetComponent();
  
salsa = GameObject.Find("GameObjectWithSalsaComponent").GetComponent();
salsa = GameObject.Find("GameObjectWithSalsaComponent").GetComponent();
  
Use FindObjectOfType or FindObjectsOfType to get reference to one or more Salsa2D or Salsa3D instances just like you would any other component:
salsa = (Salsa2D)FindObjectOfType(typeof(Salsa2D));
salsa = (Salsa3D)FindObjectOfType(typeof(Salsa3D));
Salsa2D[] salsa = (Salsa2D)FindObjectsOfType(typeof(Salsa2D));
Salsa3D[] salsa = (Salsa3D)FindObjectsOfType(typeof(Salsa3D));
salsa = FindObjectOfType(Salsa2D);
salsa = FindObjectOfType(Salsa3D);
salsa : Salsa2D[] = FindObjectsOfType(Salsa2D);
salsa : Salsa3D[] = FindObjectsOfType(Salsa3D);
Once you have reference to your Salsa2D or Salsa3D instance, you can use that instance to access the properties and public functions detailed above. Examples are listed below, and you can see the CM_Salsa2D_Functions and CM_Salsa3D_Functions scripts in Crazy Minnow Studio/Examples/Scripts for documented code examples. Both C# and JavaScript examples are included.
using UnityEngine;
using System.Collections;
using CrazyMinnow.SALSA; // Import SALSA from the CrazyMinnow namespace
public class YourScript : MonoBehavior 
{
	public Salsa2D salsa; // Public reference to Salsa2D
	void Start()
	{
		// Get reference to the Salsa2D component
		salsa = GameObject.Find("GameObjectWithSalsaComponent").GetComponent();
		salsa.SetAudioClip(SOMEAUDIOCLIP); // Set the SALSA audio clip	
 		salsa.Play(); // Play the audio clip
		salsa.Pause(); // Pause the audio clip
		salsa.Stop(); // Stop the audio clip
		
		salsa.saySmallTrigger = 0.001f; // Adjust the small trigger value
		salsa.sayMediumTrigger = 0.002f; // Adjust the medium trigger value
		salsa.sayLargeTrigger = 0.004f; // Adjust the large trigger value
		salsa.broadcast = true; // Set broadcasting to true
		salsa.broadcastReceiversCount = 1; // Setup one receiver slot
		salsa.broadcastReceivers = new GameObject[salsa.broadcastReceiversCount]; // Setup array length
		salsa.broadcastReceivers[0] = SOMEGAMEOBJECT; // Bind some game obejct to the receiver
		salsa.propagateToChildren = true; // Propagate broadcasts to SOMEGAMEOBJECT's children
		
		salsa.audioUpdateDelay = 0.08f; // The duration between audio sample updates
	}
}
 
using UnityEngine;
using System.Collections;
using CrazyMinnow.SALSA; // Import SALSA from the CrazyMinnow namespace
public class YourScript : MonoBehavior 
{
	public Salsa3D salsa; // Public reference to Salsa2D
	void Start()
	{
		// Get reference to the Salsa3D component
		salsa = GameObject.Find("GameObjectWithSalsaComponent").GetComponent();
		salsa.SetAudioClip(SOMEAUDIOCLIP); // Set the SALSA audio clip	
 		salsa.Play(); // Play the audio clip
		salsa.Pause(); // Pause the audio clip
		salsa.Stop(); // Stop the audio clip
		
		salsa.saySmallTrigger = 0.001f; // Adjust the small trigger value
		salsa.sayMediumTrigger = 0.002f; // Adjust the medium trigger value
		salsa.sayLargeTrigger = 0.004f; // Adjust the large trigger value
		salsa.broadcast = true; // Set broadcasting to true
		salsa.broadcastReceiversCount = 1; // Setup one receiver slot
		salsa.broadcastReceivers = new GameObject[salsa.broadcastReceiversCount]; // Setup array length
		salsa.broadcastReceivers[0] = SOMEGAMEOBJECT; // Bind some game obejct to the receiver
		salsa.propagateToChildren = true; // Propagate broadcasts to SOMEGAMEOBJECT's children
		
		salsa.audioUpdateDelay = 0.08f; // The duration between audio sample updates
		salsa.blendSpeed = 10; // Shape key transition duration
		salsa.SetRangeOfMotion(85); // The percentage of total range of motion allowed
	}
}
 
#pragma strict
import CrazyMinnow.SALSA; // Import SALSA from the CrazyMinnow namespace
public class YourScript extends MoonoBehavior {
	public var salsa : CrazyMinnow.SALSA.Salsa2D; // Public reference to Salsa2D
	function Start() {
		// Get reference to the Salsa2D component
		salsa = GameObject.Find("GameObjectWithSalsaComponent").GetComponent(Salsa2D);
		salsa.SetAudioClip(SOMEAUDIOCLIP); // Set the SALSA audio clip	
		salsa.Play(); // Play the audio clip
		salsa.Pause(); // Pause the audio clip
		salsa.Stop(); // Stop the audio clip
			
		salsa.saySmallTrigger = 0.001; // Adjust the small trigger value
		salsa.sayMediumTrigger = 0.002; // Adjust the medium trigger value
		salsa.sayLargeTrigger = 0.004; // Adjust the large trigger value
		salsa.broadcast = true; // Set broadcasting to true
		salsa.broadcastReceiversCount = 1; // Setup one receiver slot
		salsa.broadcastReceivers = new GameObject[salsa.broadcastReceiversCount]; // Setup array length
		salsa.broadcastReceivers[0] = SOMEGAMEOBJECT; // Bind some game obejct to the receiver
		salsa.propagateToChildren = true; // Propagate broadcasts to SOMEGAMEOBJECT's children
		salsa.audioUpdateDelay = 0.08; // The duration between audio sample updates
	}
}
#pragma strict
import CrazyMinnow.SALSA; // Import SALSA from the CrazyMinnow namespace
public class YourScript extends MoonoBehavior {
	public var salsa : CrazyMinnow.SALSA.Salsa3D; // Public reference to Salsa3D
	function Start() {
		// Get reference to the Salsa3D component
		salsa = GameObject.Find("GameObjectWithSalsaComponent").GetComponent(Salsa3D);
		salsa.SetAudioClip(SOMEAUDIOCLIP); // Set the SALSA audio clip	
		salsa.Play(); // Play the audio clip
		salsa.Pause(); // Pause the audio clip
		salsa.Stop(); // Stop the audio clip
			
		salsa.saySmallTrigger = 0.001; // Adjust the small trigger value
		salsa.sayMediumTrigger = 0.002; // Adjust the medium trigger value
		salsa.sayLargeTrigger = 0.004; // Adjust the large trigger value
		salsa.broadcast = true; // Set broadcasting to true
		salsa.broadcastReceiversCount = 1; // Setup one receiver slot
		salsa.broadcastReceivers = new GameObject[salsa.broadcastReceiversCount]; // Setup array length
		salsa.broadcastReceivers[0] = SOMEGAMEOBJECT; // Bind some game obejct to the receiver
		salsa.propagateToChildren = true; // Propagate broadcasts to SOMEGAMEOBJECT's children
		salsa.audioUpdateDelay = 0.08; // The duration between audio sample updates
		salsa.blendSpeed = 10; // Shape key transition duration
		salsa.SetRangeOfMotion(85); // The percentage of total range of motion allowed
	}
}
 
 

