コード例 #1
0
 /// We send a bang when the player steps on the button (enters the collision
 /// volume).
 void OnTriggerEnter(Collider other)
 {
     //To send a bang to our PD patch, the patch needs a named receive object
     //(in this case, named VolumeUp), and then we can just use the
     //SendBang() function to send a bang to that object from Unity.
     //
     //See the BangExample.pd patch for details.
     pdPatch.SendFloat("stepStoneOn", stoneNumber);
 }
コード例 #2
0
    /// All our calculations for this class take place in MonoBehaviour's
    /// Update() function.
    void Update()
    {
        //Get the distance between the sphere and the main camera.
        float proximity      = Vector3.Distance(targetLocation.position, Camera.main.transform.position);
        float sensorDistance = sensorBounds.localScale.x;

        //We want proximity to be in the range 0 -> 1.
        // calculate the proximity based on the size of the sensor area
        proximity /= sensorDistance / 2;
        //We also want the pitch to increase as we get closer to the sphere,
        //so we invert proximity.
        proximity = 1.0f - proximity;

        if (proximity < 0.0f)
        {
            proximity = 0.0f;
        }

        //Send our frequency value to the PD patch.
        //Like in Button2Bang.cs/ButtonExample.pd, all we need to be able to
        //send floats to our PD patch is a named receive object in the patch (in
        //this case, named proximity). We can then use the SendFloat() function
        //to send our float value to that named receive object.
        pdPatch.SendFloat("proximity", proximity);
    }
コード例 #3
0
ファイル: HueAngleAudio.cs プロジェクト: osgirl/PetsAtHome2
    private void Update()
    {
        if (bird == null)
        {
            bird = GameObject.Find("Cylinder");
        }
        if (origin == null)
        {
            var go = GameObject.Find("Bird");
            if (go != null)
            {
                origin = go.transform;
            }
        }

        if (bird == null || origin == null)
        {
            return;
        }

        var direction = transform.InverseTransformDirection((origin.position - bird.transform.position).normalized);
        var azimuth   = ((Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg) + 180.0f) / 360.0f;

        angleVal = azimuth;
        pdInstance.SendFloat("hueAngle", angleVal);
    }
コード例 #4
0
    /// All our calculations for this class take place in MonoBehaviour's
    /// Update() function.
    void Update()
    {
        //Get the distance between the sphere and the main camera.
        float proximity      = Vector3.Distance(sphereTransform.position, Camera.main.transform.position);
        float sensorDistance = sensorBounds.localScale.x;

        //We want proximity to be in the range 0 -> 1.
        //Since our blue circle has a diameter of 15, its radius will be 7.5,
        //hence the following scaling.
        //	proximity /= 7.5f;
        proximity /= sensorDistance / 2;
        //We also want the pitch to increase as we get closer to the sphere,
        //so we invert proximity.
        proximity = 1.0f - proximity;

        if (proximity < 0.0f)
        {
            proximity = 0.0f;
        }

        //Send our frequency value to the PD patch.
        //Like in Button2Bang.cs/ButtonExample.pd, all we need to be able to
        //send floats to our PD patch is a named receive object in the patch (in
        //this case, named proximity). We can then use the SendFloat() function
        //to send our float value to that named receive object.
        //
        //See the FloatExample.pd patch for details.
        pdPatch.SendFloat("proximity", proximity);
    }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        if (moving)
        {
            Vector3 tempPos = new Vector3(Mathf.Sin(index) * 10.0f, 0.0f, -10.0f - Mathf.Cos(index) * 10.0f);

            sphereTransform.position = tempPos;

            index += 0.01f;
            if (index > (Mathf.PI * 2.0f))
            {
                moving = false;
                index  = 0.0f;
                spatialisePatch.SendFloat("level", 0.0f);
                spatialisePatch.SendFloat("toggle", 01.0f);
            }
        }
    }
コード例 #6
0
 public void Update()
 {
     pdInstance.SendFloat("distance", distance);
     pdInstance.SendFloat("hueAngle", hue);
     pdInstance.SendFloat("motifLayer0", motifToggle0 ? 1.0f : 0.0f);
     pdInstance.SendFloat("motifLayer1", motifToggle1 ? 1.0f : 0.0f);
     pdInstance.SendFloat("motifLayer2", motifToggle2 ? 1.0f : 0.0f);
     pdInstance.SendFloat("motifLayer3", motifToggle3 ? 1.0f : 0.0f);
     pdInstance.SendFloat("motifLayer4", motifToggle4 ? 1.0f : 0.0f);
     pdInstance.SendFloat("motifLayer5", motifToggle5 ? 1.0f : 0.0f);
 }
コード例 #7
0
    // Update is called once per frame
    void Update()
    {
        if (barbelithTransform.localScale != lastSize)
        {
            //1 -> 5 in first scene.
            //(previously 50 -> 40).
            barbelithPatch.SendFloat("size", barbelithTransform.localScale.x);

            lastSize = barbelithTransform.localScale;
        }
    }
コード例 #8
0
    // Update is called once per frame
    void Update()
    {
        Pillars = GameObject.FindGameObjectsWithTag("Pillar").ToList();
        int count = Pillars.Count();

        switch (count)
        {
        case 5:
            pdInstance.SendFloat("motifLayer1", 1);
            break;

        case 10:
            pdInstance.SendFloat("motifLayer2", 1);
            break;

        case 15:
            pdInstance.SendFloat("motifLayer3", 1);
            break;

        case 20:
            pdInstance.SendFloat("motifLayer4", 1);
            break;

        case 25:
            pdInstance.SendFloat("motifLayer5", 1);
            break;

        default:
            pdInstance.SendFloat("motifLayer0", 1);
            break;
        }
    }
コード例 #9
0
    // Update is called once per frame
    public void Update()
    {
        if (bird == null)
        {
            bird = GameObject.Find("Bird");
        }

        if (bird == null)
        {
            return;
        }

        speed = BirdController.speedReference;
        pdInstance.SendFloat("movementSpeed", speed);
    }
コード例 #10
0
    private void Update()
    {
        if (pdPatch && (signal != ""))
        {
            float dist = Vector3.Distance(new Vector3(playerPos.position.x, 0.0f, playerPos.position.z),
                                          new Vector3(transform.position.x, 0.0f, transform.position.z));
            float value = 0.0f;

            if (dist < radius)
            {
                value = 1.0f - (dist / radius);
            }

            if (value != lastValue)
            {
                pdPatch.SendFloat(signal, value);

                lastValue = value;
            }
        }
    }
コード例 #11
0
    // Update is called once per frame
    public void Update()
    {
        if (bird == null)
        {
            bird = GameObject.Find("Bird");
        }
        if (origin == null)
        {
            var go = GameObject.Find("Cylinder");
            if (go != null)
            {
                origin = go.transform;
            }
        }

        if (bird == null || origin == null)
        {
            return;
        }

        distance      = Vector3.Distance(origin.position, bird.transform.position);
        distanceValue = Mathf.InverseLerp(0, maxDistance, distance);
        pdInstance.SendFloat("distance", distanceValue);
    }
コード例 #12
0
 public void playCNote()
 {
     pdPatch.SendFloat("midi", 60);
     pdPatch.SendFloat("bang", ampVal);
 }
コード例 #13
0
    //C Note

    public void playSineCNote()
    {
        Debug.Log("SINE C");
        pdPatch.SendFloat("midi", 60);
        pdPatch.SendFloat("bang", amp);
    }
コード例 #14
0
ファイル: inputHandler.cs プロジェクト: AmitAshar72/Synthmuse
    public void playC()
    {
        //freqVal = (freqVal * 100) / 100;
        //indexVal = (indexVal * 100) / 100;
        pdPatch.SendFloat("midi", 60);
        pdPatch.SendFloat("bang", 0.5f);
        pdPatch.SendFloat("freq", freqVal);
        Debug.Log("FREQVAL:" + freqVal);
        pdPatch.SendFloat("index", indexVal);
        Debug.Log("INDVAL: " + indexVal);

        //ch

        if (isTestInitiated)
        {
            if (!isFirstTestComplete)
            {
                if (freqVal == frequency[order[0]] && indexVal == index[order[0]])
                {
                    Debug.Log("RIGHT GUESS");
                    isFirstTestComplete = true;
                    //stop timer1
                    T.stoptimer();
                }
                if (freqVal == frequency[order[0]])
                { //prompt on screen
                }
                if (indexVal == index[order[0]])
                {
                    //prompt on screen
                }
                //{ Debug.Log("WRONG GUESS, TRY AGAIN"); }
            }
            if (isFirstTestComplete && !isSecondTestComplete)
            {
                if (freqVal == frequency[order[1]] && indexVal == index[order[1]])
                {
                    Debug.Log("RIGHT GUESS");
                    isSecondTestComplete = true;

                    //stop timer 2
                    T.stoptimer();
                }
                if (freqVal == frequency[order[1]])
                { //prompt on screen
                }
                if (indexVal == index[order[1]])
                {
                    //prompt on screen
                }
                //else
                //{ Debug.Log("WRONG GUESS, TRY AGAIN"); }
            }
            if (isSecondTestComplete && !isThirdTestComplete)
            {
                if (freqVal == frequency[order[2]] && indexVal == index[order[2]])
                {
                    Debug.Log("RIGHT GUESS");
                    isThirdTestComplete = true;

                    T.stoptimer();
                    //stop timer 3
                    //level complete prompt and fade out to scene2
                }
                if (freqVal == frequency[order[2]])
                { //prompt on screen
                }
                if (indexVal == index[order[2]])
                {
                    //prompt on screen
                }
                //else
                //{ Debug.Log("WRONG GUESS, TRY AGAIN"); }
            }
        }
    }
コード例 #15
0
    void Update()
    {
        note1 = notes[0].GetComponent <MidiNoteValue>().midiNote;
        note2 = notes[1].GetComponent <MidiNoteValue>().midiNote;
        note3 = notes[2].GetComponent <MidiNoteValue>().midiNote;
        note4 = notes[3].GetComponent <MidiNoteValue>().midiNote;
        note5 = notes[4].GetComponent <MidiNoteValue>().midiNote;
        note6 = notes[5].GetComponent <MidiNoteValue>().midiNote;
        note7 = notes[6].GetComponent <MidiNoteValue>().midiNote;
        note8 = notes[7].GetComponent <MidiNoteValue>().midiNote;

        vol1 = volumes[0].GetComponent <UpDown>().percentage;
        vol2 = volumes[1].GetComponent <UpDown>().percentage;
        vol3 = volumes[2].GetComponent <UpDown>().percentage;
        vol4 = volumes[3].GetComponent <UpDown>().percentage;
        vol5 = volumes[4].GetComponent <UpDown>().percentage;
        vol6 = volumes[5].GetComponent <UpDown>().percentage;
        vol7 = volumes[6].GetComponent <UpDown>().percentage;
        vol8 = volumes[7].GetComponent <UpDown>().percentage;

        speed  = metro.GetComponent <rotate>().angle;
        volume = volu.GetComponent <MidiNoteValue>().midiNote;

        pdPatch.SendFloat("note1", note1);
        pdPatch.SendFloat("note2", note2);
        pdPatch.SendFloat("note3", note3);
        pdPatch.SendFloat("note4", note4);
        pdPatch.SendFloat("note5", note5);
        pdPatch.SendFloat("note6", note6);
        pdPatch.SendFloat("note7", note7);
        pdPatch.SendFloat("note8", note8);

        pdPatch.SendFloat("vol1", vol1);
        pdPatch.SendFloat("vol2", vol2);
        pdPatch.SendFloat("vol3", vol3);
        pdPatch.SendFloat("vol4", vol4);
        pdPatch.SendFloat("vol5", vol5);
        pdPatch.SendFloat("vol6", vol6);
        pdPatch.SendFloat("vol7", vol7);
        pdPatch.SendFloat("vol8", vol8);

        pdPatch.SendFloat("volume", volume);
        pdPatch.SendFloat("speed_pd", speed);
    }
コード例 #16
0
 public void quit()
 {
     pdInstance.SendFloat("pdReset", 1);
     SceneManager.LoadScene("Menu 3D");
 }
コード例 #17
0
 public void Test()
 {
     pdPatch.SendFloat("variable", num);
 }
コード例 #18
0
 //--------------------------------------------------------------------------
 // Called when we drag the float slider.
 private void SliderCallback(float value)
 {
     WriteInputText("Sent floatIn: ", value.ToString());
     mainPatch.SendFloat("floatIn", value);
 }
コード例 #19
0
 public void LoadScene()
 {
     pdInstance.SendFloat("introStart", 1);
     SceneManager.LoadScene("Main");
 }