// Use this for initialization
    void Start()
    {
        myChuck = GetComponent <ChuckSubInstance>();
        myChuck.RunCode(@"
			TriOsc myOsc;
			[60] @=> global int myNotes[];
			global Event playMyNotes;
			
			while( true )
			{
				playMyNotes => now;
				myOsc => dac;
				for( 0 => int i; i < myNotes.size(); i++ )
				{
					myNotes[i] => Math.mtof => myOsc.freq;
					100::ms => now;
				}
				<<< myNotes[""numPlayed""], ""played so far"" >>>;
				myOsc =< dac;
			}
		"        );

        myIntArrayCallback = myChuck.CreateGetIntArrayCallback(GetInitialArrayCallback);
        myIntCallback      = myChuck.CreateGetIntCallback(GetANumberCallback);
    }
Ejemplo n.º 2
0
 public bool GetInt(string chuckName, string variableName, Chuck.IntCallback callback)
 {
     if (ids.ContainsKey(chuckName))
     {
         return(GetInt(ids[chuckName], variableName, callback));
     }
     else
     {
         Debug.Log(chuckName + " has not been initialized as a ChucK instance");
         return(false);
     }
 }
Ejemplo n.º 3
0
    public bool GetInt(System.UInt32 chuckId, string variableName, Chuck.IntCallback callback)
    {
        // save a copy of the delegate so it doesn't get garbage collected!
        string internalKey = chuckId.ToString() + "$" + variableName;

        intCallbacks[internalKey] = callback;
        // register the callback with ChucK
        if (!getChuckInt(chuckId, variableName, intCallbacks[internalKey]))
        {
            return(false);
        }
        return(true);
    }
Ejemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        myChuck             = GetComponent <ChuckInstance>();
        myGetTheIntCallback = myChuck.CreateGetIntCallback(GetTheInt);

        myChuck.RunCode(@"
			external int myExternalInt;
			while( true )
			{
				Math.random2( 300, 1000 ) => myExternalInt;
				10::ms => now;
			}
		"        );

        myChuck.GetInt("myExternalInt", myGetTheIntCallback);
    }
Ejemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        newRound        = true;
        otherReady      = false;
        startTheTicker  = false;
        sent1000        = false;
        goToNextStep    = false;
        instructionMesh = (TextMesh)instructionText.GetComponent(typeof(TextMesh));

        prevBeat       = 0;
        beat           = 0;
        timeOfLastBeat = 0;
        beatBufferTime = .09f;
        prevBeatLength = 0;

        currLetter = 0;
        linePos    = 0.0f;

        topColor     = new Color32(255, 56, 129, 255);
        bottomColor  = new Color32(63, 56, 255, 255);
        correctColor = new Color32(56, 224, 101, 255);

        myChuck          = GetComponent <ChuckInstance> ();
        myGetIntCallback = Chuck.CreateGetIntCallback(GetIntCallback);
        myCallback       = Chuck.CreateVoidCallback(NewMessageReceived);
        message          = -1;
        newMessage       = false;

        mainScript = main.GetComponent <MainController> ();

        initialTickerX = ticker.transform.position.x;

        for (int i = 0; i < acceptableKeys.GetLength(0); i++)
        {
            acceptableKeys[i, 2] = (i + 72).ToString();
        }
        //set space to none
        acceptableKeys[acceptableKeys.GetLength(0) - 1, 2] = "0";

        //create container to have new keys added
        currKeysTop = new GameObject("currKeysTop");
        currKeysTop.AddComponent <MeshFilter>();
        currKeysTop.AddComponent <MeshRenderer>();
        currKeysBottom = new GameObject("currKeysBottom");
        currKeysBottom.AddComponent <MeshFilter>();
        currKeysBottom.AddComponent <MeshRenderer>();
    }
Ejemplo n.º 6
0
 // ----------------------------------------------------
 // name: GetInt
 // desc: eventually call the callback with the value
 //       of global int variableName
 // ----------------------------------------------------
 public bool GetInt(string variableName, Chuck.IntCallback callback)
 {
     return(chuckMainInstance.GetInt(variableName, callback));
 }
Ejemplo n.º 7
0
 // ----------------------------------------------------
 // name: GetAssociativeIntArrayValue
 // desc: get the value of global int variableName[key]
 // ----------------------------------------------------
 public bool GetAssociativeIntArrayValue(string variableName, string key, Chuck.IntCallback callback)
 {
     return(chuckMainInstance.GetAssociativeIntArrayValue(variableName, key, callback));
 }
Ejemplo n.º 8
0
 // ----------------------------------------------------
 // name: GetIntArrayValue
 // desc: get the value of global int variableName[index]
 // ----------------------------------------------------
 public bool GetIntArrayValue(string variableName, uint index, Chuck.IntCallback callback)
 {
     return(chuckMainInstance.GetIntArrayValue(variableName, index, callback));
 }
Ejemplo n.º 9
0
 public bool GetAssociativeIntArrayValue(System.UInt32 chuckId, string variableName, string key, Chuck.IntCallback callback)
 {
     return(getGlobalAssociativeIntArrayValue(chuckId, variableName, key, callback));
 }
Ejemplo n.º 10
0
 public bool GetIntArrayValue(System.UInt32 chuckId, string variableName, uint index, Chuck.IntCallback callback)
 {
     return(getGlobalIntArrayValue(chuckId, variableName, index, callback));
 }
Ejemplo n.º 11
0
 // ----------------------------------------------------
 // name: GetInt
 // desc: eventually call the callback with the value
 //       of global int variableName
 // ----------------------------------------------------
 public bool GetInt(string variableName, Chuck.IntCallback callback)
 {
     return(Chuck.Manager.GetInt(myChuckId, variableName, callback));
 }
Ejemplo n.º 12
0
 // ----------------------------------------------------
 // name: GetAssociativeIntArrayValue
 // desc: get the value of global int variableName[key]
 // ----------------------------------------------------
 public bool GetAssociativeIntArrayValue(string variableName, string key, Chuck.IntCallback callback)
 {
     return(Chuck.Manager.GetAssociativeIntArrayValue(myChuckId, variableName, key, callback));
 }
Ejemplo n.º 13
0
 // ----------------------------------------------------
 // name: GetIntArrayValue
 // desc: get the value of global int variableName[index]
 // ----------------------------------------------------
 public bool GetIntArrayValue(string variableName, uint index, Chuck.IntCallback callback)
 {
     return(Chuck.Manager.GetIntArrayValue(myChuckId, variableName, index, callback));
 }