示例#1
0
    public void getMellowInput(OscMessage oscMessage)
    {
        OscMessage m = oscMessage;

//		Debug.Log (m.Address);
        Osc.OscMessageToString(m);

        if (m.Address == "/muse/elements/experimental/mellow")
        {
            mellowValue = (float)(m.Values [0]);
        }


        if (m.Address == "/muse/elements/touching_forehead")
        {
            touchingForehead = (int)(m.Values [0]);
        }

        if (m.Address == "/muse/batt")
        {
            batteryPercentage = (int)(m.Values [0]);
            batteryPercentage = CustomFunc.Map(batteryPercentage, 0, 10000, 0, 100);
        }

        if (m.Address == "/muse/elements/blink")
        {
            blink = (int)m.Values [0];
        }


//		Osc.OscMessageToString(oscMessage);
//		mellowValue =  (float)(oscMessage.Values[0]);
//		Debug.Log("mellow: " + inputData );
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        eegReading = oscReceiver.mellowValue;

        levelBar.GetComponent <RectTransform>().sizeDelta = new Vector2(eegReading * 100, 10);

        touchingForehead = oscReceiver.touchingForehead;



        if (touchingForehead == 1)
        {
            oceanScale = (CustomFunc.Map(eegReading, 1, 0, minOceanScale, maxOceanScale) - oceanScale) * incrementArg + oceanScale;
            waveSpeed  = (CustomFunc.Map(eegReading, 1, 0, minWaveSpeed, maxWaveSpeed) - waveSpeed) * waveSpeedIncrementArg + waveSpeed;
            sensorConnectionStatus.GetComponent <Text>().text = "Sensor Wearing: YES";
        }
        else
        {
            oceanScale = (defaultOceanScale - oceanScale) * incrementArg + oceanScale;
            waveSpeed  = (defaultWaveSpeed - waveSpeed) * waveSpeedIncrementArg + waveSpeed;
            sensorConnectionStatus.GetComponent <Text>().text = "Sensor Wearing: NO";
        }

        oceanScale = Mathf.Clamp(oceanScale, minOceanScale, maxOceanScale);
        waveSpeed  = Mathf.Clamp(waveSpeed, minWaveSpeed, maxWaveSpeed);
        vol        = CustomFunc.Map(oceanScale, minOceanScale, maxOceanScale, minVol, maxVol);
        vol        = Mathf.Clamp(vol, minVol, maxVol);

        AudioListener.volume = vol;

        if (controllingWaves)
        {
            myOcean.scale = oceanScale;
            myOcean.speed = waveSpeed;
        }
    }