GetKnob() 공개 정적인 메소드

public static GetKnob ( MidiChannel channel, int knobNumber ) : float
channel MidiChannel
knobNumber int
리턴 float
예제 #1
0
    public void checkDials(bool refresh)
    {
        int q = -1;

        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 9; j++)
            {
                ++q;
                if (refresh || !(MidiInput.GetKnob(dialID [q], MidiInput.Filter.Realtime) * mult).Equals(prevDials [i, j]))
                {
                    dials [i, j]     = (prevDials[i, j] * 10 + MidiInput.GetKnob(dialID [q], MidiInput.Filter.Realtime) * mult) / 11;
                    prevDials [i, j] = dials[i, j];
                }
                if (refresh || !(MidiInput.GetKnob(knobID [q], MidiInput.Filter.Realtime) * mult).Equals(prevKnobs [i, j]))
                {
                    knobs [i, j]     = (prevKnobs[i, j] * 10 + MidiInput.GetKnob(knobID [q], MidiInput.Filter.Realtime) * mult) / 11;
                    prevKnobs [i, j] = knobs[i, j];
                }
                if (i < 2)
                {
                    buttons [i, j] =
                        MidiInput.GetKey(buttonID[q]);
                }
            }
        }
    }
예제 #2
0
    void Update()
    {
        var input    = MidiInput.GetKnob(channel, knobNumber);
        var position = transform.localPosition;

        position.y = (input - 0.5f) * 10.0f;
        transform.localPosition = position;
    }
예제 #3
0
 void CheckKnob()
 {
     for (int i = 0; i < knobs.Length; i++)
     {
         float f = MidiInput.GetKnob(i, MidiInput.Filter.Fast);
         if (f != knobs[i])
         {
             knobs[i] = f;
             Messenger.Broadcast <float>((string)(knobEventPrefix + "" + i), f);
         }
     }
 }
예제 #4
0
 private void getMidi()
 {
     for (int i = 0; i < 9; i++)
     {
         if (MidiInput.GetKnob(i) >= 0)
         {
             c.knobs[i] = MidiInput.GetKnob(i);
         }
     }
     for (int i = 0; i < 9; i++)
     {
         if (MidiInput.GetPad(i) == 1)
         {
             c.pads[i] = true;
         }
         else
         {
             c.pads[i] = false;
         }
     }
 }
예제 #5
0
 // Update is called once per frame
 void Update()
 {
     source.pitch = MidiInput.GetKnob(midiChannel, MidiInput.Filter.Fast) * (maxPitch - minPitch) + minPitch;
 }
예제 #6
0
    void Update()
    {
        if (!playing)
        {
            d.checkDials(false);
        }
        if (Input.GetKeyUp(KeyCode.U) && recordMode || MidiInput.GetKnob(45, MidiInput.Filter.Realtime) > .5f)
        {
            recordMode = false;
            Debug.Log(recordMode);
        }
        else if (Input.GetKeyUp(KeyCode.I) || MidiInput.GetKnob(44, MidiInput.Filter.Realtime) > .5f)
        {
            recordMode = true;
            Debug.Log(recordMode);
        }
        if (MidiInput.GetKnob(47, MidiInput.Filter.Realtime) > .5f)
        {
            for (int i = 0; i < 8; i++)
            {
                string s = texts [i].text;      // System.IO.File.ReadAllText ("Assets/athon/data/data_" + i + ".txt");
                print(s);
                presets [i] = s;                //(System.IO.File.ReadAllText ("Assets/athon/data/data_" + i + ".txt"));
                d.readDials(s);                 //(System.IO.File.ReadAllText ("Assets/athon/data/data_" + i + ".txt"));
            }
        }
        if (Input.GetKeyUp(KeyCode.P) || MidiInput.GetKnob(48, MidiInput.Filter.Realtime) > .5f)
        {
            for (int i = 0; i < 8; i++)
            {
                System.IO.File.WriteAllText("Assets/athon/data/data_" + sessionName + i + ".txt", presets[i]);
                Debug.Log(presets[i]);
            }
            Debug.Log("saved");
        }
//		if (Input.any) {
        for (int i = 0; i < 8; i++)
        {
//				Debug.Log (keyCodes [i]);
            if (Input.GetKeyUp(keyCodes [i]))
            {
                if (recordMode)
                {
                    presets [i] = d.recordDials();
                }
                else
                {
                    d.readDials(presets [i]);
                    Menu.GetComponent <UIMidi> ().setSliders();
                }
//					Debug.Log (presets [i]);
            }
        }
//		}
        if (Input.GetKeyUp(keyCodes[0]))
        {
            print("poop");
        }
        if (Input.GetKeyUp(KeyCode.R))
        {
            recording = !recording;
            audiM.Play();
//			d.checkDials (true);
            Debug.Log(recording);
        }
        if (Input.GetKeyUp(KeyCode.M))
        {
            if (!Menu.transform.parent.gameObject.activeInHierarchy)
            {
                Menu.transform.parent.gameObject.SetActive(true);
            }
            else
            {
                Menu.transform.parent.gameObject.SetActive(false);
            }
        }
        if (recording)
        {
            recordCounter += Time.deltaTime;
            if (recordCounter > recordFrequency)
            {
                recordCounter = 0;
                d.makeBuffer(audiM.GetBands(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }));
            }
            d.makeAudioBuffer(audiM.GetBands(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }));
        }
        if (Input.GetKeyUp(KeyCode.S))
        {
            System.IO.File.WriteAllText("Assets/athon/data/session_" + sessionName + ".txt", d.buffer);
            System.IO.File.WriteAllText("Assets/athon/data/sessionAudio_" + sessionName + ".txt", d.audioBuffer);
        }
        if (Input.GetKeyUp(KeyCode.P))
        {
            if (!buffered)
            {
                d.readBuffer(System.IO.File.ReadAllText("Assets/athon/data/session_" + sessionName + ".txt"));
                d.readAudioBuffer(System.IO.File.ReadAllText("Assets/athon/data/sessionAudio_" + sessionName + ".txt"));
                buffered = true;
            }
            playing         = !playing;
            startTime       = Time.time;
            startBufferTime = d.timeBuffer [0];
            audiM.Play();
        }
        if (playing)
        {
            if (playCounter < d.timeBuffer.Length - 1)
            {
                if (Time.time - startTime > d.timeBuffer [playCounter] - startBufferTime)
                {
                    float diff = (d.timeBuffer[playCounter] - startBufferTime - Time.time - startTime) /
                                 (d.timeBuffer[playCounter] - startBufferTime -
                                  d.timeBuffer[playCounter - 1] - startBufferTime);
                    d.readDials(d.presetBuffer [playCounter - 1], d.presetBuffer [playCounter], diff);
                }
                while (d.timeBuffer [playCounter] - startBufferTime < Time.time - startTime)
                {
                    playCounter++;
                }
                while (d.timeAudioBuffer [audioPlayCounter] - startBufferTime < Time.time - startTime)
                {
                    audioPlayCounter++;
                }
            }
            else
            {
                playing = false;
                Debug.Log("playtime is OVER!");
                //Camera.main.gameObject.GetComponent<CaptureStandard> ().enabled = false;
            }
            if (Input.GetKeyUp(KeyCode.O))
            {
                playing = !playing;
                //Camera.main.gameObject.GetComponent<CaptureStandard> ().enabled = false;
            }
        }
        if (Input.GetKeyUp(KeyCode.B))
        {
            audiM.Play();
        }

        float t = Time.deltaTime;

        //Camera.main.transform.parent.transform.localPosition = new Vector3 (0, 0, Mathf.Pow(d.knobs[1,2]*.1f,3) * -5f);
        //Camera.main.transform.parent.transform.parent.transform.Rotate (0, d.knobs[1,3] * -.1f*t*60,0);

        objSwitcher();
        things [whichThing].transform.Rotate(d.knobs[1, 4] * -.1f * t * 60, d.knobs[1, 5] * -.1f * t * 60, d.knobs[1, 6] * -.1f * t * 60);
        // noise.GetComponent<Renderer>().sharedMaterial.SetColor("_Color", new Color(1, 1, 1, d.dials[0, 0] * .1f * (1f + gn(1, d.knobs[0, 0], 10))));

        if (ViveWand.pad)
        {
            noise.GetComponent <Renderer> ().sharedMaterial.SetColor("_Color", new Color(1, 1, 1, .1f));
        }
        else
        {
            noise.GetComponent <Renderer>().sharedMaterial.SetColor("_Color", new Color(1, 1, 1, 0));
        }

        A.GetComponent <Renderer>().sharedMaterial.SetFloat("_Amount", d.dials[0, 1] * gn(2, d.knobs[0, 1], 10) * .01f * (1 + d.dials [0, 2] * 2f) * gn(3, d.knobs[0, 2], 10));
        C.GetComponent <Renderer>().sharedMaterial.SetFloat("_Speed", d.dials[0, 3] * .1f * gn(4, d.knobs[0, 3], 10));
        C.GetComponent <Renderer>().sharedMaterial.SetFloat("_Freq", d.dials[0, 4] * .01f * gn(5, d.knobs[0, 4], 10) * (1 + d.dials[0, 5]) * 3f * gn(6, d.knobs[0, 5], 10));
        C.GetComponent <Renderer>().sharedMaterial.SetFloat("_Which", d.dials[0, 6] * .1f);

        for (int i = 0; i < 8; i++)
        {
            if (d.buttons [1, i] > .3f)
            {
                if (recordMode)
                {
                    presets [i] = d.recordDials();
//					System.IO.File.WriteAllText ("Assets/athon/data/data_" + i + ".txt", d.recordDials ());
                    print("Saved: " + i);
                }
                else
                {
                    d.readDials(presets [i]);
//					d.readDials (System.IO.File.ReadAllText ("Assets/athon/data/data_" + i + ".txt"));
                }
            }
        }


        C.GetComponent <Renderer>().sharedMaterial.SetVector("_Pos",
                                                             new Vector4(
                                                                 controller.transform.position.x,
                                                                 controller.transform.position.y,
                                                                 controller.transform.position.z,
                                                                 //Mathf.Sin(Mathf.Pow(d.dials[1,0],2)*Time.time*3f)*d.dials[1,3]*.2f,
                                                                 //Mathf.Cos(Mathf.Pow(d.dials[1,1],2)*Time.time*3f)*d.dials[1,3]*.2f,
                                                                 //Mathf.Sin(Mathf.Pow(d.dials[1,2],2)*Time.time*3f)*d.dials[1,3]*.2f,
                                                                 0));
        C.GetComponent <Renderer>().sharedMaterial.SetVector("_Speeds",
                                                             new Vector4(
                                                                 d.dials[1, 5],
                                                                 d.dials[1, 6],
                                                                 d.dials[1, 7], 0));
        initial.GetComponent <Renderer>().sharedMaterial.SetColor("_Color", new Color(1, 1, 1, d.dials [0, 7] * .1f * gn(8, d.knobs[0, 7], 10)));
        C.GetComponent <Renderer>().sharedMaterial.SetFloat("_SinAdd", d.dials[0, 8] * .1f * gn(9, d.knobs[0, 8], 10));
        // C.GetComponent<Renderer>().sharedMaterial.SetFloat("_Gravity", d.dials[1, 4] * .1f);
        if (ViveWand.click)
        {
            C.GetComponent <Renderer>().sharedMaterial.SetFloat("_Gravity", 1);
        }
        else
        {
            C.GetComponent <Renderer>().sharedMaterial.SetFloat("_Gravity", 0);
        }
        Debug.Log(ViveWand.click);
        wire.GetComponent <wireFrameAthon>().lineWidth = d.knobs[1, 0] * .005f;
        wire.GetComponent <Renderer>().sharedMaterial.SetColor("_Color", new Color(1, 1, 1, d.knobs[1, 1] * .02f));
    }
예제 #7
0
 void Update()
 {
     transform.localPosition = Vector3.up * (moveWidth * (MidiInput.GetKnob(channel) - 0.5f));
 }
예제 #8
0
파일: midiLaserer.cs 프로젝트: dlobser/prt
    void Update()
    {
        float t = Time.deltaTime;

        for (int i = 0; i < nob.Length; i++)
        {
            nob[i]  = MidiInput.GetKnob(i + 14, MidiInput.Filter.Realtime) * mult;
            nob2[i] = MidiInput.GetKnob(i, MidiInput.Filter.Realtime) * mult;
            //			print (nob[i]);
        }
        for (int i = 0; i < trails.Length; i++)
        {
            trails[i].time       = nob2[3];
            trails[i].startWidth = (nob2[2] * .4f) + .05f;
        }
        Camera.main.transform.localPosition = new Vector3(0, 0, Mathf.Pow(nob2 [50] * .1f, 2) * -5f);
        Camera.main.transform.parent.transform.Rotate(0, nob2 [51] * -.1f * t * 60, 0);

        objSwitcher();
        things [whichThing].transform.Rotate(nob2 [52] * -.1f * t * 60, nob2 [53] * -.1f * t * 60, nob2 [54] * -.1f * t * 60);
        //		print (nob2 [9]+","+nob2[12]);

        //2,3,4,5,6,8,9,12,13
        //42,43,50,51,52,53,54,55,56
        int q  = -1;
        int qq = 1;

//		print (audiM.GetBands(new int[]{1,2,3,4,5,6}));
//		initial.transform.position = new Vector3 (0, 0, nob [++q])+initInit;
        noise.GetComponent <Renderer> ().sharedMaterial.SetColor("_Color", new Color(1, 1, 1, nob [++q] * .1f * (1f + gn(1, 2, 10))));
        A.GetComponent <Renderer>().sharedMaterial.SetFloat("_Amount", nob [++q] * gn(2, 3, 10) * .01f * (1 + nob [++q] * 2f) * gn(3, 4, 10));
        C.GetComponent <Renderer>().sharedMaterial.SetFloat("_Speed", nob [++q] * .1f * gn(4, 5, 10));
        C.GetComponent <Renderer>().sharedMaterial.SetFloat("_Freq", nob [++q] * .01f * gn(5, 6, 10) * (1 + nob [++q]) * 3f * gn(6, 8, 10));
        C.GetComponent <Renderer>().sharedMaterial.SetFloat("_Which", nob [++q] * .1f);

        C.GetComponent <Renderer>().sharedMaterial.SetVector("_Pos",
                                                             new Vector4(
                                                                 Mathf.Sin(nob2[57] * Time.time * 3f) * nob2[60] * .2f,
                                                                 Mathf.Cos(nob2[58] * Time.time * 3f) * nob2[60] * .2f,
                                                                 Mathf.Sin(nob2[59] * Time.time * 3f) * nob2[60] * .2f, 0));
        C.GetComponent <Renderer>().sharedMaterial.SetVector("_Speeds",
                                                             new Vector4(
                                                                 nob2[62] * .4f,
                                                                 nob2[63] * .4f,
                                                                 nob2[65] * .4f, 0));
        initial.GetComponent <Renderer>().sharedMaterial.SetColor("_Color", new Color(1, 1, 1, nob [++q] * .1f * gn(8, 12, 10)));
        C.GetComponent <Renderer>().sharedMaterial.SetFloat("_SinAdd", nob [++q] * .1f * gn(9, 13, 10));
        C.GetComponent <Renderer>().sharedMaterial.SetFloat("_Gravity", nob2[61] * .1f);

//		print (nob2 [2]);
        wire.GetComponent <wireFrameAthon>().lineWidth = nob2 [42] * .005f;
        wire.GetComponent <Renderer>().sharedMaterial.SetColor("_Color", new Color(1, 1, 1, nob2 [43] * .01f));
//		print (nob [57 - 14]);
//		Vector3 baseRot = new Vector3 (nob [q] * t * 60, nob [++q] * t * 60, nob [++q] * t * 60);
//		kids[0].transform.parent.transform.parent.transform.Rotate (baseRot);
//		kids[0].transform.parent.transform.Rotate (new Vector3 (nob [++q]*t*60, nob[++q]*t*60, nob[++q]*t*60));
//		kids[0].transform.localPosition = new Vector3 (0,15.5f+nob2[6],0);
//		//		kids [0].GetComponent<AudioSource> ().pitch = (nob [0]*.1f)+.8f;
//		kids[1].transform.Rotate (new Vector3 ( 0,nob[++q]*t*60,0));
//		kids[1].transform.localPosition = new Vector3 (0,nob2[6]*2,0);
//		//		kids [1].GetComponent<AudioSource> ().pitch = (nob [3]*.1f)+.8f;
//		kids[2].transform.Rotate (new Vector3 (nob [++q]*t*60, nob[++q]*t*60, 0));
//		kids[2].transform.localPosition = new Vector3 (nob2[13],nob2[6]*2,0);
//		kids[2].transform.localScale = new Vector3 (.1f+nob2[8]*.2f,.1f+nob2[8]*.2f,.1f+nob2[8]*.2f);
//		kids [2].GetComponent<AudioSource> ().pitch = (nob [19]*.1f)+.8f;
//		kids [2].GetComponent<AudioSource> ().maxDistance = (nob2 [9]*3)+10;
//		kids [2].GetComponent<AudioSource> ().dopplerLevel = (nob2 [12]*.5f);
    }