Пример #1
0
        void Start()
        {
            // Set up OscIn and OscOut for testing locally
            _oscOut = gameObject.AddComponent <OscOut>();
            _oscIn  = gameObject.AddComponent <OscIn>();
            _oscOut.Open(7000);
            _oscIn.Open(7000);

            // Forward received messages with addresses to methods.
            _oscIn.Map(address1, OnReceived1);
            _oscIn.Map(address2, OnReceived2);

            // Create a bundle and two messages.
            _bundle   = new OscBundle();
            _message1 = new OscMessage(address1);
            _message2 = new OscMessage(address2);

            // Add the two messages to the bundle.
            _bundle.Add(_message1);
            _bundle.Add(_message2);

            // Messages contained in incoming bundles are automatically unpacked,
            // and so incoming bundle objects are never exposed.
            // If you need to access time tags from incoming bundles you can set a
            // flag that will add the a time tag from contained messages when unpacking.
            //_oscIn.addTimeTagsToBundledMessages = true;
        }
Пример #2
0
        void Start()
        {
            // Set up OscIn and OscOut for local testing.
            _oscOut = gameObject.AddComponent <OscOut>();
            _oscIn  = gameObject.AddComponent <OscIn>();
            _oscOut.Open(7000);
            _oscIn.Open(7000);

            // OPTIMISATION #1
            // Ensure that outgoing messages will be bundled automatically.
            // You can also bundle messages yourself; check the Bundles example.
            _oscOut.bundleMessagesOnEndOfFrame = true;

            // OPTIMISATION #2
            // Instantiate outgoing messages once and cache them locally.
            // If you are sending a single argument that is neither a string
            // nor a blob, then you can use the optimised method
            // Send( address, value ) instead.
            _outgoingMessage = new OscMessage(address);

            // OPTIMISATION #3
            // When receving strings and blobs then handle the message yourself.
            // Otherwise new strings and byte arrays will be generated continously.
            _oscIn.Map(address, OnMessageReceived);
        }
Пример #3
0
 // Use this for initialization
 void Start()
 {
     generalMagnager = MRPM_GeneralManager._instance;
     oscIn           = GetComponent <OscIn>();
     oscOut          = GetComponent <OscOut>();
     authStream      = oscIn.onAnyMessage.AsObservable();
 }
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Displays connected: " + Display.displays.Length);

        if (Display.displays.Length > 1)
        {
            Display.displays[1].Activate();
        }
        if (Display.displays.Length > 2)
        {
            Display.displays[2].Activate();
        }

        _oscIn  = gameObject.AddComponent <OscIn>();
        _oscOut = gameObject.AddComponent <OscOut>();

        _oscIn.Open(8000);
        _oscOut.Open(8000, "255.255.255.255");

        command.Select();
        command.ActivateInputField();

        _oscIn.MapInt("/amsie", AMSIceEarthCounterSetter);
        _oscIn.MapInt("/amsim", AMSIceMarsCounterSetter);
        _oscIn.MapInt("/amst", AMSTeethCounterSetter);
        _oscIn.MapInt("/amsr", AMSRingCounterSetter);
        _oscIn.MapInt("/amscn", AMSNoCarbonCounterSetter);
        _oscIn.MapInt("/amslun", AMSNoPbUCounterSetter);
        _oscIn.MapInt("/bdc", BDCCounterSetter);
        _oscIn.MapBool("/dosreport", ReportActivator);
        _oscIn.MapInt("/crate", OpenCrates);
    }
        void Start()
        {
            // Create objects for sending and receiving
            oscOut = gameObject.AddComponent<OscOut>();
            oscIn = gameObject.AddComponent<OscIn>();

            // Prepare for multicasting messages to devices with applications that have joined the
            // multicast group with address 224.0.1.0 and are listening on port 7000.
            oscOut.Open( 7000, multicastAddress );

            // Technically multicasting addresses must be between 224.0.0.0 to 239.255.255.255,
            // but 224.0.0.0 to 224.0.0.255 is reserved for routing info so you should really
            // only use 224.0.1.0 to 239.255.255.255.

            // Prepare for receiving messages that are send to multicast group with address 224.0.1.0
            // on port 7000. We will also be receiving unicasted and broadcasted messages.
            oscIn.Open( 7000, multicastAddress );

            // If you only want messages from the multicast group that have been send from other
            // applications, then set the multicastLoopback property on OscOut to false.
            //oscOut.multicastLoopback = false;

            // Forward recived messages with address to method
            oscIn.Map( oscAddress, OnMessageReceived );

            // Show UI
            uiWrapper.SetActive( true );
        }
Пример #6
0
        void Start()
        {
            // Create objects for sending and receiving.
            oscOut = gameObject.AddComponent <OscOut>();
            oscIn  = gameObject.AddComponent <OscIn>();

            // Prepare for multicasting messages to devices with applications that have joined the
            // multicast group with address 224.0.1.0 and are listening on port 7000.
            oscOut.Open(7000, multicastAddress);

            // NOTE: Technically, multicasting addresses must be between 224.0.0.0 to 239.255.255.255,
            // but addresses 224.0.0.0 to 224.0.0.255 are reserved for routing info so you should really
            // only use 224.0.1.0 to 239.255.255.255.

            // Prepare for receiving messages that are send to multicast group with address 224.0.1.0
            // on port 7000. We will also be receiving unicasted and broadcasted messages.
            oscIn.Open(7000, multicastAddress);

            // If you only want messages from the multicast group that have been send from other
            // applications, then set the multicastLoopback property on OscOut to false.
            //oscOut.multicastLoopback = false;

            // Forward recived messages with address to method.
            oscIn.Map(oscAddress, OnMessageReceived);

            // Show UI
            uiWrapper.SetActive(true);
        }
        void Start()
        {
            // Ensure that we have a OscIn component.
            if( !oscIn ) oscIn = gameObject.AddComponent<OscIn>();

            // Start receiving from unicast and broadcast sources on port 7000.
            oscIn.Open( 7000 );
        }
Пример #8
0
 void OnEnable()
 {
     if (!oscInScript)
     {
         oscInScript = GameObject.Find("osc").GetComponent <OscIn>();
         oscInScript.Open(8000);
     }
     ReceiveOsc();
 }
Пример #9
0
 void Start()
 {
     // Ensure that we have a OscIn component and start receiving on port 7000.
     if (!_oscIn)
     {
         _oscIn = gameObject.AddComponent <OscIn>();
     }
     _oscIn.Open(7000);
 }
Пример #10
0
        void Start()
        {
            // Set up OscIn and OscOut for local testing.
            _oscOut = gameObject.AddComponent <OscOut>();
            _oscIn  = gameObject.AddComponent <OscIn>();
            _oscOut.Open(7000);
            _oscIn.Open(7000);

            // Forward received messages with address to method.
            _oscIn.MapTimeTag(address, OnReceived);
        }
Пример #11
0
        void Start()
        {
            // Ensure that we have a OscIn component.
            if (!oscIn)
            {
                oscIn = gameObject.AddComponent <OscIn>();
            }

            // Start receiving from unicast and broadcast sources on port 7000.
            oscIn.Open(8000);
        }
Пример #12
0
    void Start()
    {
        GameObject osc = GameObject.Find("osc");

        oscOut = osc.GetComponent <OscOut>();
        oscIn  = osc.GetComponent <OscIn>();

        oscOut.Open(7000);
        oscIn.Open(8000);

        // Debug.Log( "!!! Make sure Max udpsend is set to IPAddress " + OscIn.ipAddress );
        Debug.Log("!!! If orbits aren't working, in Max, try banging 'init_sound_libraries' and then restart the Scene");
    }
Пример #13
0
 // Use this for initialization
 void Start()
 {
     gm    = MRPM_GeneralManager._instance;
     oscIn = GetComponent <OscIn>();
     oscIn.Open(gm.PORT_OPERATOR, null);
     oscIn.Map(gm.ADDRESS_SYNC, ParseOscMessage);
     SceneVariables = new ReactiveDictionary <int, string>();
     //新しいオブジェクトを生成
     SceneVariables.ObserveAdd().Subscribe(x =>
     {
         SpawnSyncedObject(x);
     });
 }
Пример #14
0
        // public Action<string> onCommandReceived = (string s) =>
        // {};
        // public Action<string> onMessageReceived = (string s) =>
        // {};

        #endregion

        #region Unity Frameworks

        void Awake()
        {
            if (instance == null)
            {
                instance = this;
            }
            else if (instance != this)
            {
                Destroy(gameObject);
            }

            oscReceive = GetComponent <OscIn>();
            oscSend    = GetComponent <OscOut>();
        }
Пример #15
0
        void Start()
        {
            // Set up OscIn and OscOut objects for a local test.
            _oscOut = gameObject.AddComponent <OscOut>();
            _oscIn  = gameObject.AddComponent <OscIn>();
            _oscOut.Open(7000);
            _oscIn.Open(7000);

            // Request messages with 'address' to be send to 'OnMessageReceived'.
            _oscIn.Map(address, OnMessageReceived);

            // Always cache messages when possible.
            _message = new OscMessage(address);
        }
Пример #16
0
    private void initOSC()
    {
        isReceiving = false;

        oscIn  = gameObject.GetComponent <OscIn>();
        oscOut = gameObject.GetComponent <OscOut>();

        oscIn.Open(9000);
        oscOut.Open(9000, "192.168.1.85");

        // cached to avoid constantly creating the message on update
        poseMessage = new OscMessage("/setAndGoTarget", 0f, 0f, 0f, 0f, 0f, 0f, 0f);              // moves the robot to the position
        //poseMessage = new OscMessage ("/realTimeTargetPose", 0f, 0f, 0f, 0f, 0f, 0f, 0f); // requires a goToTarget/ mesage to move the robot
        velocityMessage = new OscMessage("/setVelocity", velocity, acceleration);
    }
Пример #17
0
        protected override void OnStop()
        {
            foreach (var plugin in Plugins)
            {
                plugin.HostShutdown();
            }

            MidiIn?.Close();
            MidiIn?.Dispose();

            OscOut?.Close();
            OscOut?.Dispose();

            OscIn?.Close();
            OscIn?.Dispose();
        }
Пример #18
0
    void Start()
    {
        instantiateLightDiscs_script = GameObject.Find("instantiateLightDiscs").GetComponent <InstantiateLightDiscs>();
        numDiscs = instantiateLightDiscs_script.gridX * instantiateLightDiscs_script.gridZ;

        globalEvolution_script = GameObject.Find("globalEvolution").GetComponent <GlobalEvolution>();
        oscIn_script           = GameObject.Find("osc").GetComponent <OscIn>();
        oscIn_script.MapDouble("/discsModel/funds_lowest", OscIn_setFundsLowest);

        scoreDiscs = new ScoreDiscs();
        scoreDiscs.CurrentHarmonyParams(globalEvolutionState, harmonyLookupIndex);   // <-- this line of code for initialization, else currentState_numHarmonies is 0 at init with divide by 0 errors
        makeNewModel = true;

        mixer = new Mixer();
        MixerValues_Init();
    }
    // Start is called before the first frame update
    void Start()
    {
        _oscIn  = gameObject.AddComponent <OscIn>();
        _oscOut = gameObject.AddComponent <OscOut>();

        _oscIn.Open(8000);
        _oscOut.Open(8000, "255.255.255.255");


        _oscIn.MapInt("/resetsem", ResetMachine);

        imageHolder.SetActive(false);
        dataNumber.gameObject.SetActive(false);
        scanning.SetActive(false);
        noSampleScanned.SetActive(false);
        introduction.SetActive(true);



        //MicroscopeBackgroundSource.Play();

        ScanButton.DeviceSerialNumber = 523574;
        ScanButton.Channel            = 0;
        ScanButton.IsLocal            = true;
        ScanButton.Attach            += digitalInput_Attach;
        ScanButton.StateChange       += digitalInput_StateChange;

        RFIDMicroscope.DeviceSerialNumber = 453586;
        RFIDMicroscope.Channel            = 0;
        RFIDMicroscope.IsLocal            = true;
        RFIDMicroscope.Attach            += rfid_Attach;
        RFIDMicroscope.Tag     += rfid_Tag;
        RFIDMicroscope.TagLost += rfid_TagLost;


        try
        {
            ScanButton.Open(5000);
            RFIDMicroscope.Open(5000);
        }
        catch (PhidgetException e)
        {
            Debug.Log("Failed: " + e.Message);
        }

        // StartCoroutine(TurnRFIDAntennaOff());
    }
Пример #20
0
        void OnEnable()
        {
            oscIn = target as OscIn;

            messageBuffer = new Queue <OscMessage>(messageBufferCapacity);

            _openOnAwake                  = serializedObject.FindProperty("_openOnAwake");
            _port                         = serializedObject.FindProperty("_port");
            _mode                         = serializedObject.FindProperty("_mode");
            _multicastAddress             = serializedObject.FindProperty("_multicastAddress");
            _filterDuplicates             = serializedObject.FindProperty("_filterDuplicates");
            _addTimeTagsToBundledMessages = serializedObject.FindProperty("_addTimeTagsToBundledMessages");
            _mappings                     = serializedObject.FindProperty("_mappings");
            _dirtyMappings                = serializedObject.FindProperty("_dirtyMappings");
            _settingsFoldout              = serializedObject.FindProperty("_settingsFoldout");
            _mappingsFoldout              = serializedObject.FindProperty("_mappingsFoldout");
            _messagesFoldout              = serializedObject.FindProperty("_messagesFoldout");

            // Store socket info for change check workaround
            tempPort             = _port.intValue;
            tempMulticastAddress = _multicastAddress.stringValue;

            // Ensure that OscIn scripts will be executed early, so it can deliver messages before we compute anything.
            MonoScript script = MonoScript.FromMonoBehaviour(target as MonoBehaviour);

            if (MonoImporter.GetExecutionOrder(script) != -5000)
            {
                MonoImporter.SetExecutionOrder(script, -5000);
            }

            // When object is selected in Edit Mode then we start listening
            if (oscIn.enabled && !Application.isPlaying && !oscIn.isOpen)
            {
                if (oscIn.mode == OscReceiveMode.UnicastBroadcast)
                {
                    oscIn.Open(oscIn.port);
                }
                else
                {
                    oscIn.Open(oscIn.port, oscIn.multicastAddress);
                }
            }

            // Subscribe to messages
            oscIn.onAnyMessage.AddListener(OnOSCMessage);
        }
        void OnEnable()
        {
            _oscIn = target as OscIn;

            _openOnAwake                  = serializedObject.FindProperty("_openOnAwake");
            _port                         = serializedObject.FindProperty("_port");
            _mode                         = serializedObject.FindProperty("_mode");
            _multicastAddress             = serializedObject.FindProperty("_multicastAddress");
            _filterDuplicates             = serializedObject.FindProperty("_filterDuplicates");
            _addTimeTagsToBundledMessages = serializedObject.FindProperty("_addTimeTagsToBundledMessages");
            _mappings                     = serializedObject.FindProperty("_mappings");
            _dirtyMappings                = serializedObject.FindProperty("_dirtyMappings");
            _udpBufferSize                = serializedObject.FindProperty("_udpBufferSize");
            _settingsFoldout              = serializedObject.FindProperty("_settingsFoldout");
            _mappingsFoldout              = serializedObject.FindProperty("_mappingsFoldout");
            _messagesFoldout              = serializedObject.FindProperty("_messagesFoldout");

            // Store socket info for change check workaround.
            _tempPort             = _port.intValue;
            _tempMulticastAddress = _multicastAddress.stringValue;

            // Ensure that OscIn scripts will be executed early, so it can deliver messages before we compute anything.
            MonoScript script = MonoScript.FromMonoBehaviour(target as MonoBehaviour);

            if (MonoImporter.GetExecutionOrder(script) != -5000)
            {
                MonoImporter.SetExecutionOrder(script, -5000);
            }

            // When object is selected in Edit Mode then we start listening.
            if (_oscIn.enabled && !Application.isPlaying && !EditorApplication.isPlayingOrWillChangePlaymode && !_oscIn.isOpen)
            {
                if (_oscIn.mode == OscReceiveMode.UnicastBroadcast)
                {
                    _oscIn.Open(_oscIn.port);
                }
                else
                {
                    _oscIn.Open(_oscIn.port, _oscIn.multicastAddress);
                }
            }

            // Subscribe to messages.
            OscEditorUI.AddInspectorMessageListener(_oscIn, OnOSCMessage, ref _inspectorMessageEventObject);
        }
Пример #22
0
        void Start()
        {
            // Create objects for sending and receiving.
            oscOut = gameObject.AddComponent <OscOut>();
            oscIn  = gameObject.AddComponent <OscIn>();

            // Prepare for sending messages on port 7000.
            oscOut.Open(7000);

            // Prepare for receiving messages on port 7000.
            oscIn.Open(7000);

            // Forward received messages with address to method.
            oscIn.Map(address, OnMessageReceived);

            // Show UI.
            uiWrapper.SetActive(true);
        }
Пример #23
0
        void Start()
        {
            // Create objects for sending and receiving.
            oscOut = gameObject.AddComponent<OscOut>();
            oscIn = gameObject.AddComponent<OscIn>();

            // Prepare for sending messages on port 7000.
            oscOut.Open( 7000 );

            // Prepare for receiving messages on port 7000.
            oscIn.Open( 7000 );

            // Forward recived messages with address to method.
            oscIn.Map( address, OnMessageReceived );

            // Show UI.
            uiWrapper.SetActive( true );
        }
Пример #24
0
        void Start()
        {
            // Create objects for sending and receiving
            oscOut = gameObject.AddComponent <OscOut>();
            oscIn  = gameObject.AddComponent <OscIn>();

            // Prepare for sending messages to applications on this device on port 7000.
            oscOut.Open(7000);

            // Prepare for receiving messages on port 7000.
            oscIn.Open(7000);

            // Forward recived messages with addresses to methods.
            oscIn.Map(address1, OnMessage1Received);
            oscIn.Map(address2, OnMessage2Received);

            // Show UI.
            uiWrapper.SetActive(true);
        }
Пример #25
0
        void Start()
        {
            // Create objects for sending and receiving
            oscOut = gameObject.AddComponent<OscOut>();
            oscIn = gameObject.AddComponent<OscIn>();

            // Prepare for sending messages to applications on this device on port 7000.
            oscOut.Open( 7000 );

            // Prepare for receiving messages on port 7000.
            oscIn.Open( 7000 );

            // Forward recived messages with addresses to methods.
            oscIn.Map( address1, OnMessage1Received );
            oscIn.Map( address2, OnMessage2Received );

            // Show UI.
            uiWrapper.SetActive( true );
        }
Пример #26
0
        void Start()
        {
            // Create objects for sending and receiving.
            oscOut = gameObject.AddComponent <OscOut>();
            oscIn  = gameObject.AddComponent <OscIn>();

            // Prepare for broadcasting messages to devices on the local network to be received by applications listening on port 7000.
            oscOut.Open(7000, "255.255.255.255");

            // For the hardcode haters, you can get the broadcast address like this System.Net.IPAddress.Broadcast.ToString().

            // Prepare for receiving unicasted and broadcasted messages from this and other devices on port 7000.
            oscIn.Open(7000);

            // Forward recived messages with address to method.
            oscIn.Map(address, OnMessageReceived);

            // Show UI
            uiWrapper.SetActive(true);
        }
        void Start()
        {
            // Create objects for sending and receiving
            oscOut = gameObject.AddComponent<OscOut>();
            oscIn = gameObject.AddComponent<OscIn>();

            // Prepare for broadcasting messages to devices on the local network to be received by applications listening on port 7000.
            oscOut.Open( 7000, "255.255.255.255" );

            // For the hardcode haters, you can get the broadcast address like this System.Net.IPAddress.Broadcast.ToString().

            // Prepare for receiving unicasted and broadcasted messages from this and other devices on port 7000.
            oscIn.Open( 7000 );

            // Forward recived messages with address to method
            oscIn.Map( address, OnMessageReceived );

            // Show UI
            uiWrapper.SetActive( true );
        }
Пример #28
0
        void Start()
        {
            // Create objects for sending and receiving
            oscOut = gameObject.AddComponent<OscOut>();
            oscIn = gameObject.AddComponent<OscIn>();

            // Prepare for unicasting messages to this (same) device to be received by applications listening on port 7000.
            oscOut.Open( 7000 );

            // Alternatively, prepare for unicasting messages to device with IP address to be received by applications listening on port 7000.
            //oscOut.Open( 7000, "192.168.1.101" );

            // Prepare for receiving unicasted and broadcasted messages from this and other devices on port 7000
            oscIn.Open( 7000 );

            // Forward recived messages with address to method
            oscIn.Map( address, OnMessageReceived );

            // Show UI
            uiWrapper.SetActive( true );
        }
Пример #29
0
        void Start()
        {
            // Create objects for sending and receiving.
            oscOut = gameObject.AddComponent <OscOut>();
            oscIn  = gameObject.AddComponent <OscIn>();

            // Prepare for unicasting messages to this (same) device to be received by applications listening on port 7000.
            oscOut.Open(7000);

            // Alternatively, prepare for unicasting messages to device with IP address to be received by applications listening on port 7000.
            //oscOut.Open( 7000, "192.168.1.101" );

            // Prepare for receiving unicasted and broadcasted messages from this and other devices on port 7000
            oscIn.Open(7000);

            // Forward recived messages with address to method.
            oscIn.Map(address, OnMessageReceived);

            // Show UI.
            uiWrapper.SetActive(true);
        }
Пример #30
0
    void Start()
    {
        // with a spawned GO...
        // instantiate frame = the GO does nothing
        // frame 2 = Start(), not Update() yet
        // frame 3 = the first Update()
        floorWidth  = GameObject.Find("floor").GetComponent <Renderer>().bounds.size.x;
        floorHeight = GameObject.Find("floor").GetComponent <Renderer>().bounds.size.z;

        delaunayScript        = GameObject.Find("delaunayTriangulation").GetComponent <DelaunayTriangulation>();
        boundingQbits_allInfo = self_voidAllInfo.boundingQbits_allInfo;
        self_id = self_voidAllInfo.id;

        mouseRaycast_script = GameObject.Find("mouseRaycast").GetComponent <MouseRaycast>();

        trackingAreaThresh = delaunayScript.voidTrackingAreaThresh;
        xfadeAreaThresh    = delaunayScript.voidXfadeAreaThresh;

        // these interestingly have to be here in the Start() or the DelaunayTriangulation script
        // won't be able to check the centroid of this mesh until the 3rd frame after instantiation,
        // and you'd get two GOs spawned per void centroid
        meshCentroid = self_voidAllInfo.centroid;
        meshArea     = self_voidAllInfo.area;

        firstMeshFrame = true;

        oscOutScript = GameObject.Find("osc").GetComponent <OscOut>();
        oscInScript  = GameObject.Find("osc").GetComponent <OscIn>();
        oscInScript.MapInt("/void/" + (self_id + 1) + "/igniterEvent/click", OscIn_IgniterClick);
        oscInScript.MapInt("/void/" + (self_id + 1) + "/igniterEvent/end", OscIn_IgniterEnd);

        swarmParams_script = GameObject.Find("swarmParams").GetComponent <SwarmParams>();

        springJoint   = GetComponent <SpringJoint>();
        voidRigidbody = GetComponent <Rigidbody>();

        mixer = new Mixer();
        MixerValues_Init();
        localPosPrev = transform.position;
    }
        void Start()
        {
            // Create objects for sending and receiving.
            _oscOut = gameObject.AddComponent <OscOut>();
            _oscIn  = gameObject.AddComponent <OscIn>();

            // If the concepts of unicast, broadcast and multicast makes no sense
            // then please read the Underlying Concepts section in the manual.

            // SEND UNICAST
            // To unicast locally on this device, just provide a port.
            _oscOut.Open(7000);
            // To unicast to a specific remote target, provide an IP address
            //_oscOut.Open( 7000, "192.168.1.60" );

            // SEND BROADCAST
            // To broadcast, provide the broadcast IP. You can hardcode it like
            // here, or obtain it from System.Net.IPAddress.Broadcast.ToString().
            //_oscOut.Open( 7000, "255.255.255.255" );

            // SEND MULTICAST
            // To multicast, provide a multicast IP. Multicast addresses must be
            // between 224.0.0.0 to 239.255.255.255, but addresses 224.0.0.0 to
            // 224.0.0.255 are reserved for routing info so you should really
            // only use 224.0.1.0 to 239.255.255.255.
            //_oscOut.Open( 7000, "224.1.2.3" );

            // RECEIVE UNICAST AND BROADCAST
            // To receive unicast and broadcast messages send locally on this device
            // and from remote transmitters, just provide a port. Note that if you
            // are offline, you won't receive broadcasted messages.
            _oscIn.Open(7000);

            // RECEIVE MULTICAST
            // Provide a multicast address.
            //_oscIn.Open( 7000, "224.1.2.3" );

            // Forward recived messages with address to method.
            _oscIn.MapFloat(address, OnReceived);
        }
Пример #32
0
        void Start()
        {
            // This should be familiar to you by now.
            oscOut = gameObject.AddComponent <OscOut>();
            oscIn  = gameObject.AddComponent <OscIn>();
            oscOut.Open(7000);
            oscIn.Open(7000);
            oscIn.MapFloat(floatAddress, OnCachedReceived);
            oscIn.MapBlob(blobAddress, OnBlobReceived);

            bundle = new OscBundle();

            // OPTIMISATION #2: Cache outgoing messages.
            // If you are sending the same number of arguments to the same
            // address every update then you can cache a message to avoid
            // calling the constructor continuously.
            floatMessage = new OscMessage(floatAddress, 0f);
            blobMessage  = new OscMessage(blobAddress, new byte[0]);

            // Show UI
            uiWrapper.SetActive(true);
        }
        void OnEnable()
        {
            oscIn = target as OscIn;

            messageBuffer = new Queue<OscMessage>( messageBufferCapacity );

            _openOnAwake = serializedObject.FindProperty("_openOnAwake");
            _port = serializedObject.FindProperty("_port");
            _mode = serializedObject.FindProperty("_mode");
            _multicastAddress = serializedObject.FindProperty("_multicastAddress");
            _filterDuplicates = serializedObject.FindProperty("_filterDuplicates");
            _addTimeTagsToBundledMessages = serializedObject.FindProperty("_addTimeTagsToBundledMessages");
            _mappings = serializedObject.FindProperty("_mappings");
            _dirtyMappings = serializedObject.FindProperty("_dirtyMappings");
            _settingsFoldout = serializedObject.FindProperty("_settingsFoldout");
            _mappingsFoldout = serializedObject.FindProperty("_mappingsFoldout");
            _messagesFoldout = serializedObject.FindProperty("_messagesFoldout");

            // Store socket info for change check workaround
            tempPort = _port.intValue;
            tempMulticastAddress = _multicastAddress.stringValue;

            // Ensure that OscIn scripts will be executed early, so it can deliver messages before we compute anything.
            MonoScript script = MonoScript.FromMonoBehaviour( target as MonoBehaviour );
            if( MonoImporter.GetExecutionOrder( script ) != -5000 ) MonoImporter.SetExecutionOrder( script, -5000 );

            // When object is selected in Edit Mode then we start listening
            if( oscIn.enabled && !Application.isPlaying && !oscIn.isOpen ){
                if( oscIn.mode == OscReceiveMode.UnicastBroadcast ) oscIn.Open( oscIn.port );
                else oscIn.Open( oscIn.port, oscIn.multicastAddress );
            }

            // Subscribe to messages
            oscIn.onAnyMessage.AddListener( OnOSCMessage );
        }
Пример #34
0
    /********************************************************************
    *  Unity Engine
    ********************************************************************/

    void Start()
    {
        if (!oscIn)
        {
            oscIn = gameObject.AddComponent <OscIn>();
        }
        oscIn.Open(MusePort);

        oscIn.Map("/muse/elements/horseshoe", OnHorseShoe);
        oscIn.Map("/muse/elements/is_good", OnSignalStatus);

        oscIn.Map("/muse/acc", OnAccselerometer);
        oscIn.Map("/muse/elements/touching_forehead", OnForehead);
        oscIn.Map("/muse/elements/blink", OnBlink);
        oscIn.Map("/muse/elements/jaw_clench", OnJaw);

        oscIn.Map("/muse/eeg", OnEEG);
        oscIn.Map("/muse/eeg/quantization", OnEEGQuantization);
        oscIn.Map("/muse/elements/low_freqs_absolute", OnLowAbsolute);

        oscIn.Map("/muse/elements/raw_fft0", OnFastFourier0);
        oscIn.Map("/muse/elements/raw_fft1", OnFastFourier1);
        oscIn.Map("/muse/elements/raw_fft2", OnFastFourier2);
        oscIn.Map("/muse/elements/raw_fft3", OnFastFourier3);

        oscIn.Map("/muse/elements/delta_absolute", OnDeltaAbsolute);
        oscIn.Map("/muse/elements/theta_absolute", OnThetaAbsolute);
        oscIn.Map("/muse/elements/alpha_absolute", OnAlphaAbsolute);
        oscIn.Map("/muse/elements/beta_absolute", OnBetaAbsolute);
        oscIn.Map("/muse/elements/gamma_absolute", OnGammaAbsolute);

        oscIn.Map("/muse/elements/delta_relative", OnDeltaRelative);
        oscIn.Map("/muse/elements/theta_relative", OnThetaRelative);
        oscIn.Map("/muse/elements/alpha_relative", OnAlphaRelative);
        oscIn.Map("/muse/elements/beta_relative", OnBetaRelative);
        oscIn.Map("/muse/elements/gamma_relative", OnGammaRelative);

        oscIn.Map("/muse/elements/delta_session_score", OnDeltaScore);
        oscIn.Map("/muse/elements/theta_session_score", OnThetaScore);
        oscIn.Map("/muse/elements/alpha_session_score", OnAlphaScore);
        oscIn.Map("/muse/elements/beta_session_score", OnBetaScore);
        oscIn.Map("/muse/elements/gamma_session_score", OnGammaScore);


        for (int i = 0; i < 4; i++)
        {
            FastFourier [i] = new float[129];
            for (int j = 0; j < 129; j++)
            {
                FastFourier [i] [j] = 0f;
            }
        }

        for (int i = 0; i < 5; i++)
        {
            Absolute [i] = new float[4];
            Relative [i] = new float[4];
            Score [i]    = new float[4];
            for (int j = 0; j < 4; j++)
            {
                Absolute [i] [j] = 0f;
                Relative [i] [j] = 0f;
                Score [i] [j]    = 0f;
            }
        }
    }
Пример #35
0
 //  230.230.230.1   7000
 private void Awake()
 {
     oscIN  = GetComponent <OscIn>();
     oscOUT = GetComponent <OscOut>();
 }