Esempio n. 1
0
        void osc_server_MessageReceived(object sender, OscMessageReceivedEventArgs e)
        {
            //make sure "value" doesnt already exist
            if (!(oscmessages.Contains(e.Message.Address)))
            {
                //since we've made it this far we can add it
                oscmessages.Add(e.Message.Address);

                switch (e.Message.Data.Length)
                {
                    case 1:
                        AddDataGridRow(new string[] { e.Message.Address, e.Message.Data[0].ToString() });
                        break;
                    case 2:
                        AddDataGridRow(new string[] { e.Message.Address, e.Message.Data[0].ToString(), e.Message.Data[1].ToString() });
                        break;
                    default:
                        break;
                }
             }
            else
            {
                UpdateDataGridRow(e.Message.Address, e.Message.Data); 
            }

        }
        private static void oscServer_MessageReceived(object sender, OscMessageReceivedEventArgs e)
        {
            sMessagesReceivedCount++;

            OscMessage message = e.Message;

            Console.WriteLine(string.Format("\nMessage Received [{0}]: {1}", message.SourceEndPoint.Address, message.Address));
            Console.WriteLine(string.Format("Message contains {0} objects.", message.Data.Count));

            for (int i = 0; i < message.Data.Count; i++)
            {
                string dataString;

                if (message.Data[i] == null)
                {
                    dataString = "Nil";
                }
                else
                {
                    dataString = (message.Data[i] is byte[] ? BitConverter.ToString((byte[])message.Data[i]) : message.Data[i].ToString());
                    for (int j = 0; j < device.AudioSessionManager2.Sessions.Count; j++)
                    {
                        if (device.AudioSessionManager2.Sessions[j].GetProcessID == 7068)
                        {
                            device.AudioSessionManager2.Sessions[j].SimpleAudioVolume.MasterVolume = Convert.ToSingle(dataString) / 100;
                        }
                    }
                }
                Console.WriteLine(string.Format("[{0}]: {1}", i, dataString));
            }

            Console.WriteLine("Total Messages Received: {0}", sMessagesReceivedCount);
        }
		private static void oscServer_MessageReceived(object sender, OscMessageReceivedEventArgs e)
		{
            sMessagesReceivedCount++;

            OscMessage message = e.Message;

            Console.WriteLine(string.Format("\nMessage Received [{0}]: {1}", message.SourceEndPoint.Address, message.Address));
            Console.WriteLine(string.Format("Message contains {0} objects.", message.Data.Count));

            for (int i = 0; i < message.Data.Count; i++)
            {
                string dataString;

                if (message.Data[i] == null)
                {
                    dataString = "Nil";
                }
                else
                {
                    dataString = (message.Data[i] is byte[] ? BitConverter.ToString((byte[])message.Data[i]) : message.Data[i].ToString());
                }
                Console.WriteLine(string.Format("[{0}]: {1}", i, dataString));
            }

            Console.WriteLine("Total Messages Received: {0}", sMessagesReceivedCount);
		}
        private static void sOscServer_MessageReceived(object sender, OscMessageReceivedEventArgs OSCEvent)
        {
            if (debug)
            {
                Console.WriteLine("\nMessage Length: " + OSCEvent.Message.Data.Length);
            }

            inPitch = OSCEvent.Message.At<float>(0);
            inAmplitude = OSCEvent.Message.At<float>(1);
            inLoudness = OSCEvent.Message.At<float>(2);
            inBrightness = OSCEvent.Message.At<int>(3);
            inNoise = OSCEvent.Message.At<float>(4);
            if (OSCEvent.Message.At<float>(5) != 0)
            {
                inFundamentalFrequency = OSCEvent.Message.At<float>(5);
            }
            inPeakAmplitude = OSCEvent.Message.At<float>(6);

            if (debug)
            {
                Console.WriteLine("Pitch: " + inPitch.ToString());
                Console.WriteLine("Amplitude: " + inAmplitude.ToString());
                Console.WriteLine("Loudness: " + inLoudness.ToString());
                Console.WriteLine("Brightness: " + inBrightness.ToString());
                Console.WriteLine("Noise: " + inNoise.ToString());
                Console.WriteLine("Fundamental Frequency: " + inFundamentalFrequency.ToString());
                Console.WriteLine("Peak amplitude: " + inPeakAmplitude.ToString());
            }
        }
Esempio n. 5
0
        private static void MessageReceived(object sender, OscMessageReceivedEventArgs e)
        {
            foreach (var sample in e.Message.Data)
            {
                Console.Write(sample);
            }

            Console.WriteLine();
        }
Esempio n. 6
0
 void server_MessageReceived(object sender, OscMessageReceivedEventArgs e)
 {
     log.Log(LogLevel.Info, "Message Recieved");
     log.Log(LogLevel.Info, "  " + e.Message.Address);
     if (e.Message.Address == JOYPAD_BUTTON_EVENT)
     {
         JoypadButton btn = (JoypadButton)reverseEndianizeOscInt(e.Message.Data[0]);
         bool depressed = reverseEndianizeOscInt(e.Message.Data[1]) != 0;
         log.Log(LogLevel.Info, string.Format("    {0} - {1}", btn, depressed));
         inputController.JoypadEvent(btn, depressed);
     }
     else if (e.Message.Address == MOUSE_EVENT)
     {
         int btn = reverseEndianizeOscInt(e.Message.Data[0]);
         int dx = reverseEndianizeOscInt(e.Message.Data[1]);
         int dy = reverseEndianizeOscInt(e.Message.Data[2]);
         log.Log(LogLevel.Info, string.Format("    btn: {0}, dx: {1}, dy: {2}", btn, dx, dy));
         inputController.MouseEvent(btn, dx, dy);
     }
     else if (e.Message.Address == SCROLL_EVENT)
     {
         int dx = reverseEndianizeOscInt(e.Message.Data[0]);
         int dy = reverseEndianizeOscInt(e.Message.Data[1]);
         log.Log(LogLevel.Info, string.Format("    dx: {0}, dy: {1}", dx, dy));
         inputController.ScrollEvent(dx, dy);
     }
     else if (e.Message.Address == KEYBOARD_EVENT)
     {
         int code = reverseEndianizeOscInt(e.Message.Data[0]);
         bool shift = reverseEndianizeOscInt(e.Message.Data[1]) != 0;
         log.Log(LogLevel.Info, string.Format("    code: {0,2:X}, '{1}', shift: {2}", code, (char)code, shift));
         inputController.KeyboardEvent(code, shift);
     }
     else if (e.Message.Address == VOLUME_EVENT)
     {
         int d = reverseEndianizeOscInt(e.Message.Data[0]);
         log.Log(LogLevel.Info, string.Format("    d: {0}", d));
         if (UseVolumeMacros)
         {
             if (d == 1)
                 inputController.PlayKeyMacro(VolumeUpMacro);
             else
                 inputController.PlayKeyMacro(VolumeDownMacro);
         }
         else
         {
             if (d == 1)
                 inputController.VolumeUp();
             else
                 inputController.VolumeDown();
         }
     }
 }
Esempio n. 7
0
        // ToDo: This could really do with some unit tests
        private void MessageReceived(object sender, OscMessageReceivedEventArgs e)
        {
            var channelName = e.Message.Data.First().ToString();
            var channel = GetPlaybackChannel(channelName);
            var isLoopMessage = e.Message.Data.Last().ToString().ToUpper() == "LOOP";

            if (isLoopMessage)
            {
                if (channel.IsPlaying) channel.ToggleLooping();
            }
            else
            {
                var score = scoreQueue.GetNextScoreToPlay();
                if (score != null) channel.Play(score, Convert.ToInt32(e.Message.Data.Last()));
            }
        }
Esempio n. 8
0
        private void oscCmdServer_MessageReceived(object sender, OscMessageReceivedEventArgs e)
        {
            sMessagesReceivedCount++;

            OscMessage message = e.Message;

            Console.WriteLine(string.Format("\nMessage Received [{0}]: {1}", message.SourceEndPoint.Address, message.Address));
            Console.WriteLine(string.Format("Message contains {0} objects.", message.Data.Count));

            iPadMsgReceive(message);
            limboViewerMsgReceive(message);
            limboStandMsgReceive(message);
            imageServerMsgReceive(message);
            kinectMsgReceive(kinectFront, message);
            kinectMsgReceive(kinectBack, message);

            /*
            if (message.Address == "/ipad")
            {
                if (message.Data[0].ToString() == "ok")
                {
                    iPadOK = true;

                }

            }

            if (message.Address == kinectFrontCmd)
            {
                if (message.Data[0].ToString() == "IN")
                {
                    this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                    {
                        frontStatus.Fill = new SolidColorBrush(Colors.Red);
                    }));
                }

                if (message.Data[0].ToString() == "OUT")
                {
                    this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                    {
                        frontStatus.Fill = new SolidColorBrush(Colors.Blue);
                    }));
                    msg = new OscMessage(kinectFrontIP, kinectFrontCmd);
                    msg.Append("STOP");
                    msg.Send(kinectFrontIP);

                    msg = new OscMessage(kinectBackIP, kinectBackCmd);
                    msg.Append("START");
                    msg.Send(kinectBackIP);
                }
            }

            if (message.Address == kinectBackCmd)
            {
                if (message.Data[0].ToString() == "IN")
                {
                    this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                    {
                        backStatus.Fill = new SolidColorBrush(Colors.Red);
                        msg = new OscMessage(kinectBackIP, kinectBackCmd);
                        msg.Append("STOP");
                        msg.Send(kinectBackIP);

                        msg = new OscMessage(kinectFrontIP, kinectFrontCmd);
                        msg.Append("START");
                        msg.Send(kinectFrontIP);
                    }));
                }

                if (message.Data[0].ToString() == "OUT")
                {
                    this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                    {
                        backStatus.Fill = new SolidColorBrush(Colors.Blue);

                        msg = new OscMessage(kinectBackIP, kinectBackCmd);
                        msg.Append("STOP");
                        msg.Send(kinectBackIP);

                        msg = new OscMessage(kinectFrontIP, kinectFrontCmd);
                        msg.Append("START");
                        msg.Send(kinectFrontIP);
                    }));
                }

            }*/
            for (int i = 0; i < message.Data.Count; i++)
            {
                string dataString;

                if (message.Data[i] == null)
                {
                    dataString = "Nil";
                }
                else
                {
                    dataString = (message.Data[i] is byte[] ? BitConverter.ToString((byte[])message.Data[i]) : message.Data[i].ToString());
                }
                Console.WriteLine(string.Format("[{0}]: {1}", i, dataString));
            }

            Console.WriteLine("Total Messages Received: {0}", sMessagesReceivedCount);
        }
        private static void oscServer_MessageReceived(object sender, OscMessageReceivedEventArgs e)
        {
            sMessagesReceivedCount++;

              OscMessage message = e.Message;

              if (message.Address == "/muse/acc" | message.Address == "/muse/eeg" | message.Address == "/muse/elements/blink" | message.Address == "/muse/elements/jaw_clench")
              {
            for (int i = 0; i < message.Data.Count; i++)
            {
              string dataString;

              if (message.Data[i] == null)
              {
            dataString = "Nil";
              }
              else
              {
            dataString = (message.Data[i] is byte[] ? BitConverter.ToString((byte[])message.Data[i]) : message.Data[i].ToString());
              }

              if (message.Address == "/muse/acc")
              {
            if (i == 0)
            {
              ACC1 = Convert.ToDouble(dataString);
            }
            if (i == 1)
            {
              ACC2 = Convert.ToDouble(dataString);
            }
            if (i == 3)
            {
              ACC3 = Convert.ToDouble(dataString);
            }
              }
              else if (message.Address == "/muse/eeg")
              {
            if (i == 0)
            {
              EEG1 = Convert.ToDouble(dataString);
            }
            if (i == 1)
            {
              EEG2 = Convert.ToDouble(dataString);
            }
            if (i == 2)
            {
              EEG3 = Convert.ToDouble(dataString);
            }
            if (i == 3)
            {
              EEG4 = Convert.ToDouble(dataString);
            }
              }
              else if (message.Address == "/muse/elements/blink")
              {
            if (dataString == "1")
            {
              Blink = 888;
            }
            else
            {
              Blink = 0;
            }
              }
              else if (message.Address == "/muse/elements/jaw_clench")
              {
            if (dataString == "1")
            {
              JawClench = 888;
            }
            else
            {
              JawClench = 0;
            }
              }
            }
              }

              if (message.Address == "/muse/dsp/elements/raw_fft0")
              {
            if (FFT0Received != null)
            {
              FFT0Received(sender, e);
            }
              }
              else if (message.Address == "/muse/dsp/elements/raw_fft1")
              {
            if (FFT1Received != null)
            {
              FFT1Received(sender, e);
            }
              }
              else if (message.Address == "/muse/dsp/elements/raw_fft2")
              {
            if (FFT2Received != null)
            {
              FFT2Received(sender, e);
            }
              }
              else if (message.Address == "/muse/dsp/elements/raw_fft3")
              {
            if (FFT3Received != null)
            {
              FFT3Received(sender, e);
            }
              }
        }
Esempio n. 10
0
 private void MessageReceived(object sender, OscMessageReceivedEventArgs e)
 {
     enabled = e.Message.Data.First().ToString().ToUpper() == "PLAY";
 }
Esempio n. 11
0
        private void oscCmdReceiver_MessageReceived(object sender, OscMessageReceivedEventArgs e)
        {
            sMessagesReceivedCount++;

            OscMessage message = e.Message;

            Console.WriteLine(string.Format("\nMessage Received [{0}]: {1}", message.SourceEndPoint.Address, message.Address));
            Console.WriteLine(string.Format("Message contains {0} objects.", message.Data.Count));

            if (kinectID == 1)
            {
                if (message.Address == "/kinect/1")
                {
                    if (message.Data[0].ToString() == "on")
                    {
                        this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                        {
                            InfraredEmitterCheckbox.IsChecked = false;
                            this.sensor.ForceInfraredEmitterOff = false;
                        }));

                    }
                    else
                        if (message.Data[0].ToString() == "off")
                        {
                            this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                            {
                                InfraredEmitterCheckbox.IsChecked = true;
                                this.sensor.ForceInfraredEmitterOff = true;
                            }));

                        }
                        else
                            if (message.Data[0].ToString() == "test")
                            {
                                OscMessage msg = new OscMessage(cmdServerIP, "/kinect/1");
                                msg.Append("ok");
                                msg.Send(cmdServerIP);
                            }
                }
            }

            if (kinectID == 2)
            {
                if (message.Address == "/kinect/2")
                {
                    if (message.Data[0].ToString() == "on")
                    {
                        this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                        {
                            InfraredEmitterCheckbox.IsChecked = false;
                            this.sensor.ForceInfraredEmitterOff = false;
                        }));

                    }
                    else
                    if (message.Data[0].ToString() == "off")
                    {
                        this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                        {
                            InfraredEmitterCheckbox.IsChecked = true;
                            this.sensor.ForceInfraredEmitterOff = true;
                        }));

                    }
                    else if (message.Data[0].ToString() == "test")
                    {
                        OscMessage msg = new OscMessage(cmdServerIP, "/kinect/2");
                        msg.Append("ok");
                        msg.Send(cmdServerIP);
                    }

                }
            }

            for (int i = 0; i < message.Data.Count; i++)
            {
                string dataString;

                if (message.Data[i] == null)
                {
                    dataString = "Nil";
                }
                else
                {
                    dataString = (message.Data[i] is byte[] ? BitConverter.ToString((byte[])message.Data[i]) : message.Data[i].ToString());
                }
                Console.WriteLine(string.Format("[{0}]: {1}", i, dataString));
            }

            Console.WriteLine("Total Messages Received: {0}", sMessagesReceivedCount);
        }
Esempio n. 12
0
        private static void Server_MessageReceived(object sender, OscMessageReceivedEventArgs e)
        {
            if (OnAmpmMessage == null)
            {
                return;
            }

            string name = e.Message.Address.Replace("/", string.Empty);
            string json = e.Message.Data.FirstOrDefault() as string;
            JToken data = null;
            if (json != null)
            {
                data = JObject.Parse(json);
            }

            Dispatcher.BeginInvoke(new Action(() =>
            {
                OnAmpmMessage(null, new Tuple<string, JToken>(name, data));
            }));
        }
Esempio n. 13
0
		static void sOscServer_MessageReceived(object sender, OscMessageReceivedEventArgs e)
		{
            Console.WriteLine(string.Format("Message Received [{0}]: {1}", e.Message.SourceEndPoint.Address, e.Message.Address));            
		}
Esempio n. 14
0
 private void oscServerMessageReceived(object sender, OscMessageReceivedEventArgs e)
 {
     handleOSCMessage(e.Message);
 }
Esempio n. 15
0
        // The Bespoke library thread will call this. Messages can be received very rapidly when
        //  the user is adjusting a knob or slider continuously -- much more rapidly than the GUI
        //  can update. So, we need to queue only the most recent message for each OSC address.
        private void m_oscUdpServer_MessageReceived(object sender, OscMessageReceivedEventArgs e)
        {
            NumMessagesEverReceived++;

            bool consumeMore = false;
            lock (m_incomingQueue)
            {
                int oldCount = m_incomingQueue.Count;
                m_incomingQueue[e.Message.Address] = e.Message;
                if (m_incomingQueue.Count > oldCount)
                    consumeMore = true;
            }

            if (consumeMore)
            {
                if (MainForm != null)
                    MainForm.BeginInvoke(new Action(ConsumeMessages), null);
                else
                    ConsumeMessages();
            }
        }
Esempio n. 16
0
		static void sOscServer_MessageReceived(object sender, OscMessageReceivedEventArgs e)
		{
            Console.Write(string.Format("Message Received [{0}]: {1} ", e.Message.SourceEndPoint.Address, e.Message.Address));
            e.Message.Data.ToList().ForEach(i => Console.Write("{0} ", i));
            Console.WriteLine();
		}
        private void osc_MessageReceived(object sender, OscMessageReceivedEventArgs e)
        {
            int id = int.Parse(e.Message.Address.Split(new string[1] { "/" }, StringSplitOptions.RemoveEmptyEntries)[1]);
            float x = (float)e.Message.Data[0];
            float y = (float)e.Message.Data[1];
            float z = (float)e.Message.Data[2];

            MotionData md = new MotionData(id, new Vector3(x, y, z));
            if (DataReceived != null)
            {
                DataReceived(this, md);
            }
        }
Esempio n. 18
0
 private void Server_MessageReceived(object sender, OscMessageReceivedEventArgs e)
 {
     debug("Unhandled Message Received");
 }
Esempio n. 19
0
		private static void oscServer_MessageReceived(object sender, OscMessageReceivedEventArgs e)
		{
            sMessagesReceivedCount++;

            OscMessage message = e.Message;

            //Console.WriteLine(string.Format("\nMessage Received [{0}]: {1}", message.SourceEndPoint.Address, message.Address));
            //Console.WriteLine(string.Format("Message contains {0} objects.", message.Data.Count));

            if (message.Address == "/teleskop/moveTo")
            {
                int skopIndex = (int)message.Data[0];
                float positionFloat = (float)message.Data[1];

                if (skopIndex >= 0 && skopIndex < 6 && positionFloat >= 0.0f && positionFloat <= 1.0f)
                {
                    moveMotorToPosition(skopIndex, positionFloat);

                }
            }
            else if (message.Address == "/teleskop/stop")
            {
                int skopIndex = (int)message.Data[0];
                if (skopIndex >= 0 && skopIndex < 6)
                {
                    stopMotor(skopIndex);
                }
            }

            /*for (int i = 0; i < message.Data.Count; i++)
            {
                string dataString;

                if (message.Data[i] == null)
                {
                    dataString = "Nil";
                }
                else
                {
                    dataString = (message.Data[i] is byte[] ? BitConverter.ToString((byte[])message.Data[i]) : message.Data[i].ToString());
                }
                Console.WriteLine(string.Format("[{0}]: {1}", i, dataString));
            }

            Console.WriteLine("Total Messages Received: {0}", sMessagesReceivedCount);
             */
		}