public MainWindow() { InitializeComponent(); OscServer oscServer; oscServer = new OscServer(TransportType.Udp, IPAddress.Loopback, Port); oscServer.FilterRegisteredMethods = false; oscServer.RegisterMethod(AliveMethod); oscServer.RegisterMethod(TestMethod); oscServer.BundleReceived += new EventHandler<OscBundleReceivedEventArgs>(oscServer_BundleReceived); oscServer.MessageReceived += new EventHandler<OscMessageReceivedEventArgs>(oscServer_MessageReceived); oscServer.ReceiveErrored += new EventHandler<Bespoke.Common.ExceptionEventArgs>(oscServer_ReceiveErrored); oscServer.ConsumeParsingExceptions = false; oscServer.Start(); Console.WriteLine("Server started."); //Start playing audio string audioFileName = "/file/path"; mp = new MediaPlayer(); mp.MediaOpened += new EventHandler(mp_MediaOpened); bool isPaused = false; bool isPlaying = false; }
public InputServer(ILog log, IInputController inputController) { this.log = log; this.inputController = inputController; server = new OscServer(TransportType.Udp, IPAddress.Any, DEFAULT_VIP_PORT); server.RegisterMethod(JOYPAD_BUTTON_EVENT); server.RegisterMethod(MOUSE_EVENT); server.RegisterMethod(SCROLL_EVENT); server.RegisterMethod(KEYBOARD_EVENT); server.RegisterMethod(VOLUME_EVENT); server.MessageReceived += new OscMessageReceivedHandler(server_MessageReceived); server.Start(); log.Log(LogLevel.Info, "Starting Input Server"); }
public void Initialise() { var server = new OscServer(TransportType.Udp, IPAddress.Loopback, Convert.ToInt32(ConfigurationManager.AppSettings["ListenOnPort"])); server.RegisterMethod("/"); server.MessageReceived += MessageReceived; server.Start(); }
public MainWindow() { InitializeComponent(); MMDeviceEnumerator DevEnum = new MMDeviceEnumerator(); device = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia); OscServer oscServer; oscServer = new OscServer(TransportType.Udp, IPAddress.Any, Port); oscServer.FilterRegisteredMethods = false; oscServer.RegisterMethod(AliveMethod); oscServer.RegisterMethod(TestMethod); oscServer.BundleReceived += new EventHandler<OscBundleReceivedEventArgs>(oscServer_BundleReceived); oscServer.MessageReceived += new EventHandler<OscMessageReceivedEventArgs>(oscServer_MessageReceived); oscServer.ReceiveErrored += new EventHandler<Bespoke.Common.ExceptionEventArgs>(oscServer_ReceiveErrored); oscServer.ConsumeParsingExceptions = false; oscServer.Start(); }
private void init() { sOscServer = new OscServer(TransportType.Udp, IPAddress.Loopback, ServerPort, ServerAddress, Bespoke.Common.Net.TransmissionType.Multicast); sOscServer.RegisterMethod("/test"); sOscServer.MessageReceived += new OscMessageReceivedHandler(sOscServer_MessageReceived); OscPacket.LittleEndianByteOrder = false; sOscServer.Start(); if (debug) { Console.WriteLine("OSC Client: " + sOscServer.TransmissionType.ToString()); } }
public static void Main() { var server = new OscServer(TransportType.Udp, IPAddress.Loopback, Convert.ToInt32(ConfigurationManager.AppSettings["ListenOnPort"])); server.RegisterMethod("/"); server.MessageReceived += MessageReceived; server.Start(); Console.WriteLine("Dummy Receiver started."); Console.WriteLine("Awaiting messages..."); Console.WriteLine("Press any key to exit."); Console.ReadKey(); server.Stop(); }
public static void Main(string[] args) { OscServer oscServer; DemoType demoType = GetDemoType(); switch (demoType) { case DemoType.Udp: oscServer = new OscServer(TransportType.Udp, IPAddress.Loopback, Port); break; case DemoType.Tcp: oscServer = new OscServer(TransportType.Tcp, IPAddress.Loopback, Port); break; case DemoType.Multicast: oscServer = new OscServer(IPAddress.Parse("224.25.26.27"), Port); break; default: throw new Exception("Unsupported receiver type."); } oscServer.FilterRegisteredMethods = false; oscServer.RegisterMethod(AliveMethod); oscServer.RegisterMethod(TestMethod); oscServer.BundleReceived += new EventHandler<OscBundleReceivedEventArgs>(oscServer_BundleReceived); oscServer.MessageReceived += new EventHandler<OscMessageReceivedEventArgs>(oscServer_MessageReceived); oscServer.ReceiveErrored += new EventHandler<ExceptionEventArgs>(oscServer_ReceiveErrored); oscServer.ConsumeParsingExceptions = false; oscServer.Start(); Console.WriteLine("Osc Receiver: " + demoType.ToString()); Console.WriteLine("Press any key to exit."); Console.ReadKey(); oscServer.Stop(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); comms_connect.Content = "Connect"; Port = MySettings.Default.portSetting; kinectFrontIP.Address = IPAddress.Parse(MySettings.Default.kinectFrontIPSetting); kinectFrontIP.Port = Port; kinectBackIP.Address = IPAddress.Parse(MySettings.Default.kinectBackIPSetting); kinectBackIP.Port = Port; limboViewerIP.Address = IPAddress.Parse(MySettings.Default.limboViewerIPSetting); limboViewerIP.Port = Port; imageServerIP.Address = IPAddress.Parse(MySettings.Default.imageServerIPSetting); imageServerIP.Port = Port; limboStandIP.Address = IPAddress.Parse(MySettings.Default.limboStandIPSetting); limboStandIP.Port = Port; ipadIP.Address = IPAddress.Parse(MySettings.Default.iPadIPSetting); ipadIP.Port = Port; portInput.Text = Port.ToString(); kinectFrontIPInput.Text = MySettings.Default.kinectFrontIPSetting; kinectBackIPInput.Text = MySettings.Default.kinectBackIPSetting; limboViewerIPInput.Text = MySettings.Default.limboViewerIPSetting; imageServerIPInput.Text = MySettings.Default.imageServerIPSetting; limboStandIPInput.Text = MySettings.Default.limboStandIPSetting; ipadIPInput.Text = MySettings.Default.iPadIPSetting; userCount = MySettings.Default.userCountSetting; userCountDisplay.Text = userCount.ToString(); CellPhoneNumberDisplayBox.Text = "User Cell Phone Numeber"; myIPAddrText.Text = LocalIPAddress(); iPadLED.Fill = new SolidColorBrush(Colors.Gray); limboViewerLED.Fill = new SolidColorBrush(Colors.Gray); limboStandLED.Fill = new SolidColorBrush(Colors.Gray); imageServerLED.Fill = new SolidColorBrush(Colors.Gray); kinectFrontLED.Fill = new SolidColorBrush(Colors.Gray); kinectBackLED.Fill = new SolidColorBrush(Colors.Gray); remoteLED.Fill = new SolidColorBrush(Colors.Gray); //sourceEndPoint.Address = IPAddress.Parse("192.168.0.114"); //sourceEndPoint.Port = Convert.ToInt32(12345); oscCmdServer = new OscServer(TransportType.Udp, IPAddress.Parse(LocalIPAddress()), 10000); //oscCmdServer = new OscServer(IPAddress.Parse("224.25.26.27"), Port); oscCmdServer.FilterRegisteredMethods = false; //oscCmdServer.RegisterMethod(oscCmd); oscCmdServer.RegisterMethod(kinectFrontCmd); oscCmdServer.RegisterMethod(kinectBackCmd); //oscCmdServer.RegisterMethod(TestMethod); oscCmdServer.BundleReceived += new EventHandler<OscBundleReceivedEventArgs>(oscCmdServer_BundleReceived); oscCmdServer.MessageReceived += new EventHandler<OscMessageReceivedEventArgs>(oscCmdServer_MessageReceived); oscCmdServer.ReceiveErrored += new EventHandler<ExceptionEventArgs>(oscCmdServer_ReceiveErrored); oscCmdServer.ConsumeParsingExceptions = false; oscCmdServer.Start(); updateUserStatus(); }
public static Boolean Initialize() { try { if (!m_boolInitialized && !m_boolInitError) { // Check if Muse-IO is running // Launch Muse-IO String musePath = ""; if (File.Exists(@"C:\Program Files (x86)\Muse\muse-io.exe")) { musePath = @"C:\Program Files (x86)\Muse\muse-io.exe"; } else if (File.Exists(@"C:\Program Files\Muse\muse-io.exe")) { musePath = @"C:\Program Files\Muse\muse-io.exe"; } else { if (MessageBox.Show("Could not find Muse-IO. Would you like to install it?", "Install Muse SDK", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { System.Diagnostics.Process.Start("http://storage.googleapis.com/musesdk/musesdk-2.4.2-windows-installer.exe"); } else { MessageBox.Show("You can manually launch Muse-IO with this command: \r\nmuse-io --preset 14 --device Muse --osc osc.tcp://localhost:5000", "Muse IO Command Line", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } } if (musePath != "") { museIO = Process.Start(musePath, "muse-io --preset 14 --osc osc.tcp://localhost:5000"); } oscServer = new OscServer(TransportType.Tcp, IPAddress.Loopback, 5000); oscServer.FilterRegisteredMethods = false; oscServer.RegisterMethod(AliveMethod); oscServer.RegisterMethod(TestMethod); oscServer.BundleReceived += oscServer_BundleReceived; oscServer.MessageReceived += oscServer_MessageReceived; oscServer.ConsumeParsingExceptions = false; oscServer.Start(); m_boolInitialized = true; return true; } if (m_boolInitialized) return true; } catch (Exception ex) { m_boolInitError = true; throw (new Exception("The 'Muse' plugin failed to initialize: " + ex.Message)); } return false; }
/// <summary> /// Execute startup tasks /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void WindowLoaded(object sender, RoutedEventArgs e) { inFlag = false; outFlag = false; dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); kinectServerIP.Address = IPAddress.Parse(MySettings.Default.kinectServerIPSetting); kinectServerIP.Port = MySettings.Default.kinectServerPortSetting; cmdServerIP.Address = IPAddress.Parse(MySettings.Default.cmdServerIPSetting); cmdServerIP.Port = MySettings.Default.cmdServerPortSetting; kinectIpInput.Text = kinectServerIP.Address.ToString(); kinectPortInput.Text = kinectServerIP.Port.ToString(); cmdIpInput.Text = cmdServerIP.Address.ToString(); cmdPortInput.Text = cmdServerIP.Port.ToString(); kinectHeight = MySettings.Default.kinectHeightSetting; startPosition = MySettings.Default.startPositionSetting; endPosition = MySettings.Default.endPositionSetting; kinectOffset = MySettings.Default.kinectOffsetSetting; kinectHeightInput.Text = kinectHeight.ToString(); startPositionInput.Text = startPosition.ToString(); endPositionInput.Text = endPosition.ToString(); kinectOffsetInput.Text = kinectOffset.ToString(); // show my ip address ipShowTextBlock.Text = LocalIPAddress(); frameCount = 0; userPosition = -100; currentPosition = 0; pastPosition = 0; //moveStep = 0.005; kinectID = MySettings.Default.kinectIDSetting; if (kinectID == 1) { kinectIDText.Text = "Front"; } else if (kinectID == 2) { kinectIDText.Text = "Back"; } kinectIDInput.Text = kinectID.ToString(); kinectMsgAddr = "/kinect/" + kinectID.ToString(); // Create the drawing group we'll use for drawing this.drawingGroup = new DrawingGroup(); // Create an image source that we can use in our image control this.imageSource = new DrawingImage(this.drawingGroup); // Display the drawing using our image control Image.Source = this.imageSource; // Look through all sensors and start the first connected one. // This requires that a Kinect is connected at the time of app startup. // To make your app robust against plug/unplug, // it is recommended to use KinectSensorChooser provided in Microsoft.Kinect.Toolkit (See components in Toolkit Browser). foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { this.sensor = potentialSensor; break; } } if (null != this.sensor) { // smoothing parameter /* // Some smoothing with little latency (defaults). // Only filters out small jitters. // Good for gesture recognition in games. TransformSmoothParameters smoothingParam = new TransformSmoothParameters(); { smoothingParam.Smoothing = 0.5f; smoothingParam.Correction = 0.5f; smoothingParam.Prediction = 0.5f; smoothingParam.JitterRadius = 0.05f; smoothingParam.MaxDeviationRadius = 0.04f; }; */ // Smoothed with some latency. // Filters out medium jitters. // Good for a menu system that needs to be smooth but // doesn't need the reduced latency as much as gesture recognition does. TransformSmoothParameters smoothingParam = new TransformSmoothParameters(); { smoothingParam.Smoothing = 0.5f; smoothingParam.Correction = 0.1f; smoothingParam.Prediction = 0.5f; smoothingParam.JitterRadius = 0.1f; smoothingParam.MaxDeviationRadius = 0.1f; }; // Very smooth, but with a lot of latency. // Filters out large jitters. // Good for situations where smooth data is absolutely required // and latency is not an issue. //TransformSmoothParameters smoothingParam = new TransformSmoothParameters(); //{ // smoothingParam.Smoothing = 0.7f; // smoothingParam.Correction = 0.3f; // smoothingParam.Prediction = 1.0f; // smoothingParam.JitterRadius = 1.0f; // smoothingParam.MaxDeviationRadius = 1.0f; //}; // Turn on the skeleton stream to receive skeleton frames //this.sensor.SkeletonStream.Enable(); this.sensor.SkeletonStream.Enable(smoothingParam); // Add an event handler to be called whenever there is new color frame data this.sensor.SkeletonFrameReady += this.SensorSkeletonFrameReady; // Start the sensor! try { this.sensor.Start(); kinectAngle = this.sensor.ElevationAngle; angleText.Text = kinectAngle.ToString(); //this.sensor.ElevationAngle = -23; ResetFrameRateCounters(); } catch (IOException) { this.sensor = null; } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } } if (null == this.sensor) { this.statusBarText.Text = Properties.Resources.NoKinectReady; } //oscCmdReceiver = new OscServer(TransportType.Udp, IPAddress.Loopback, cmdServerPort); oscCmdReceiver = new OscServer(TransportType.Udp, IPAddress.Parse(LocalIPAddress()), cmdServerPort); //oscCmdReceiver = new OscServer(IPAddress.Parse("224.25.26.27"), cmdServerPort); oscCmdReceiver.FilterRegisteredMethods = false; //oscCmdServer.RegisterMethod(oscCmd); oscCmdReceiver.RegisterMethod(kinectMsgAddr); oscCmdReceiver.BundleReceived += new EventHandler<OscBundleReceivedEventArgs>(oscCmdReceiver_BundleReceived); oscCmdReceiver.MessageReceived += new EventHandler<OscMessageReceivedEventArgs>(oscCmdReceiver_MessageReceived); oscCmdReceiver.ReceiveErrored += new EventHandler<ExceptionEventArgs>(oscCmdReceiver_ReceiveErrored); oscCmdReceiver.ConsumeParsingExceptions = false; oscCmdReceiver.Start(); }
public static void Main(string[] args) { OscServer oscServer; DemoType demoType = /*GetDemoType();*/ DemoType.Udp; switch (demoType) { case DemoType.Udp: oscServer = new OscServer(TransportType.Udp, IPAddress.Any, Port); break; case DemoType.Tcp: oscServer = new OscServer(TransportType.Tcp, IPAddress.Loopback, Port); break; case DemoType.Multicast: oscServer = new OscServer(IPAddress.Parse("224.25.26.27"), Port); break; default: throw new Exception("Unsupported receiver type."); } oscServer.FilterRegisteredMethods = false; oscServer.RegisterMethod(AliveMethod); oscServer.RegisterMethod(TestMethod); oscServer.RegisterMethod(MouseMethod); oscServer.BundleReceived += new EventHandler<OscBundleReceivedEventArgs>(oscServer_BundleReceived); oscServer.MessageReceived += new EventHandler<OscMessageReceivedEventArgs>(oscServer_MessageReceived); oscServer.ReceiveErrored += new EventHandler<ExceptionEventArgs>(oscServer_ReceiveErrored); oscServer.ConsumeParsingExceptions = false; handsets = new VirtualHandset[HANDSET_COUNT]; motorMin = new int[HANDSET_COUNT]; motorMax = new int[HANDSET_COUNT]; String[] comPorts = { "COM9", "COM4", "COM5", "COM6", "COM7", "COM8" }; for ( int i=0; i<HANDSET_COUNT; i++ ) { VirtualHandset handset = new VirtualHandset(); int result = handset.Connect(comPorts[i]); if (result != 0) { // -20 = virtual com port device not found (USB unplugged) // -30 = com port found but couldn't connect to hardware Console.WriteLine("error " + result + " opening " + comPorts[i]); continue; } VirtualHandset.ControlUnitSettings settings = new VirtualHandset.ControlUnitSettings(); result = handset.GetAllSettings( ref settings ); if (result == 0) { Console.Write(comPorts[i]+": OEM Information: "+(char)settings.OEMInformation[0]+" "+(char)settings.OEMInformation[1]+ " "+(char)settings.OEMInformation[2]+" "+(char)settings.OEMInformation[3]+" (" +(settings.OEMInformation.Length-4)+" more) "); } else { Console.WriteLine("error " + result + " getting control unit settings for " + comPorts[i]); continue; } int handsetIndex = 0; if ((char)settings.OEMInformation[0] == 'L') handsetIndex = 0; else if ((char)settings.OEMInformation[0] == 'R') handsetIndex = 3; else { Console.WriteLine(comPorts[i] + ": invalid OEMInformation[0] '" + (char)settings.OEMInformation[0] + "' (should be 'L' or 'R')"); continue; } if ((char)settings.OEMInformation[1] == '1') handsetIndex += 0; else if ((char)settings.OEMInformation[1] == '2') handsetIndex += 1; else if ((char)settings.OEMInformation[1] == '3') handsetIndex += 2; else { Console.WriteLine(comPorts[i] + ": invalid OEMInformation[1] '" + (char)settings.OEMInformation[1] + "' (should be '1', '2' or '3')"); continue; } handsets[handsetIndex] = handset; motorMin[handsetIndex] = settings.LowerLimit[0] + 1; // don't drive right to the very limit motorMax[handsetIndex] = settings.UpperLimit[0] - 1; // don't drive right to the very limit Console.WriteLine( " lower " + motorMin[handsetIndex] + " upper " + motorMax[handsetIndex] ); Console.WriteLine(" -> assigning handset to index " + handsetIndex); // add event-handler for synchronizing the PC after driving //handsets[handsetIndex].OnSynchronizeAfterDriving += new VirtualHandset.OnSynchronizeAfterDrivingDelegate(onSynchronizeAfterDriving); } for (int i = 0; i < HANDSET_COUNT; i++) { if (handsets[i] == null) { Console.WriteLine("handset " + i + " missing, filling in with dummy"); handsets[i] = new VirtualHandset(); } // moveMotorToPosition(i, INITIAL_POS); } oscServer.Start(); // figure out my ip address IPHostEntry host; string localIP = "?"; host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily.ToString() == "InterNetwork") { localIP = ip.ToString(); } } Console.WriteLine("Osc Receiver: " + demoType.ToString() + " listening on address " + localIP + " port " + Port ); Console.WriteLine("Press any key to exit."); Console.ReadKey(); oscServer.Stop(); for (int i = 0; i < HANDSET_COUNT; i++) { if (handsets[i] == null) continue; handsets[i].Disconnect(); handsets[i].Dispose(); } }