public string update_leave(Dictionary <string, object> parameters) { try { double dur = (double)parameters["dur"]; int state = (int)parameters["state"]; string label = (string)parameters["label"]; string scheme = (string)parameters["scheme"]; double time = (double)parameters["time"]; if (library == OSCLibrary.SharpOSC) { var message = new SharpOSC.OscMessage("/evnt", scheme, label, (Int32)(time * 1000), (Int32)(dur * 1000), (Int32)state, (Int32)0); sharposcclient.Send(message); } else { OscElement message = new OscElement("/evnt", scheme, label, (Int32)(time * 1000), (Int32)(dur * 1000), (Int32)state, (Int32)0); ventuzclient.Send(message); } } catch (Exception ex) { return(ex.ToString()); } return(null); }
/// <summary> /// Sends a signal with the given value. /// </summary> /// <param name="value">The value to send. Should be between 0 and 1. The controller will handle scaling.</param> public override void Send(float value) { Console.WriteLine(this.controlName + ": " + value); OscElement elem = new OscElement(controlName, value); osc.Send(elem); }
// This function sends both how many skeletons are in the frame, and where they are private void sendOSCSkeletonPositions(object sender, SkeletonFrameReadyEventArgs e) { sendOSCSkeletonCount(); List <Skeleton> skeletonList = kinectGroup.getMasterSkeletons(); OscBundle oscBundle = new OscBundle(); int skeletonNum = 0; float xScale = sanitizeTextToFloat(XScaleTextBox.Text); float xOffset = sanitizeTextToFloat(XOffsetTextBox.Text); float yScale = sanitizeTextToFloat(YScaleTextBox.Text); float yOffset = sanitizeTextToFloat(YOffsetTextBox.Text); foreach (Skeleton s in skeletonList) { var oscMessage = new OscElement("/skeletonPosition", skeletonNum, (float)(s.Position.X * SCREEN_WIDTH_PX_M_RATIO * xScale + xOffset), (float)(s.Position.Y * SCREEN_HEIGHT_PX_M_RATIO * yScale + yOffset), (float)(s.Position.Z * SCREEN_WIDTH_PX_M_RATIO * xScale + xOffset), (int)(s.TrackingId)); oscBundle.AddElement(oscMessage); skeletonNum++; } oscWriter.Send(oscBundle); }
new public void PlayNote(int pitch, int velocity = 127, int duration = 5000, int midiChannel = 1) { Console.WriteLine("Playing: " + this.name + " " + pitch + " " + velocity + " " + duration + " " + midiChannel); OscElement elem = new OscElement("/" + this.name, pitch, velocity, duration, midiChannel); MainWindow.osc.Send(elem); }
public void Send(int channel, float peakToPeak) { OscElement msg = new OscElement( "/PeakToPeak", (int)(DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds, channel, peakToPeak ); writer.Send(msg); }
public void stop() { if (!isStop) { OscElement o = new OscElement("/Looper/0/State", "Stop"); oscLoop.Send(o); isRecd = false; isOvdb = false; isPlay = false; isStop = true; } }
public void play() { if (!isPlay) { OscElement o = new OscElement("/Looper/0/State", "Play"); oscLoop.Send(o); isRecd = false; isOvdb = false; isPlay = true; isStop = false; } }
public void Send(OscElement element) { var json = JSONFactory.buildJSONElement(element); var bytes = Encoding.UTF8.GetBytes(json); #if (DEBUG) if (!client.Client.Connected) //Try to reconnect -> Only for debug purposes { client.Connect(host, port); } #endif client.Send(bytes, bytes.Length); }
public void SendBoxes(List<ShippingDataSort> shippingData) { int capacity = shippingData.Capacity; OscElement boxesMSG; // Will return the instance of the settings, not new settings RuntimeSettings settings = RuntimeSettings.Instance; int synthType = (int)settings.synthType; double volume = settings.volume / 100.0; if (capacity == 3) boxesMSG = new OscElement("/boxes3", synthType, volume, (int)shippingData[0].sonochromaticColour, (int)shippingData[1].sonochromaticColour, (int)shippingData[2].sonochromaticColour, ColourTools.GetColourVolume(shippingData[0].sonochromaticColour), ColourTools.GetColourVolume(shippingData[1].sonochromaticColour), ColourTools.GetColourVolume(shippingData[2].sonochromaticColour)); else if (capacity == 5) boxesMSG = new OscElement("/boxes5", synthType, volume, (int)shippingData[0].sonochromaticColour, (int)shippingData[1].sonochromaticColour, (int)shippingData[2].sonochromaticColour, (int)shippingData[3].sonochromaticColour, (int)shippingData[4].sonochromaticColour, ColourTools.GetColourVolume(shippingData[0].sonochromaticColour), ColourTools.GetColourVolume(shippingData[1].sonochromaticColour), ColourTools.GetColourVolume(shippingData[2].sonochromaticColour), ColourTools.GetColourVolume(shippingData[3].sonochromaticColour), ColourTools.GetColourVolume(shippingData[4].sonochromaticColour)); else boxesMSG = new OscElement("/boxes7", synthType, volume, (int)shippingData[0].sonochromaticColour, (int)shippingData[1].sonochromaticColour, (int)shippingData[2].sonochromaticColour, (int)shippingData[3].sonochromaticColour, (int)shippingData[4].sonochromaticColour, (int)shippingData[5].sonochromaticColour, (int)shippingData[6].sonochromaticColour, ColourTools.GetColourVolume(shippingData[0].sonochromaticColour), ColourTools.GetColourVolume(shippingData[1].sonochromaticColour), ColourTools.GetColourVolume(shippingData[2].sonochromaticColour), ColourTools.GetColourVolume(shippingData[3].sonochromaticColour), ColourTools.GetColourVolume(shippingData[4].sonochromaticColour), ColourTools.GetColourVolume(shippingData[5].sonochromaticColour), ColourTools.GetColourVolume(shippingData[6].sonochromaticColour)); writer.Send(boxesMSG); }
void ParseElement(OscElement oscElement) { string[] addresses = oscElement.Address.Split('/'); string identifier = addresses[1]; int bodyIndex = (int)oscElement.Args[0]; JointType jointType = (JointType)oscElement.Args[1]; Vector3 position = new Vector3((float)oscElement.Args[2], (float)oscElement.Args[3], (float)oscElement.Args[4]); Quaternion rotation = new Quaternion((float)oscElement.Args[5], (float)oscElement.Args[6], (float)oscElement.Args[7], (float)oscElement.Args[8]); TrackingState trackingState = (TrackingState)oscElement.Args[9]; if (OnPsychoFrameDataReceived != null) { OnPsychoFrameDataReceived(this, identifier, bodyIndex, jointType, position, rotation, trackingState); } }
private void startUp() { hook = new UserActivityHook(); hook.KeyDown += (s, keycode, isCtrl) => { OscElement msg = new OscElement(textOSC.Text, textId.Text, keycode.ToString()); OscBundle bundle = new OscBundle(); bundle.AddElement(msg); oscmanager.Send(bundle); textIndata.Text = keycode.ToString(); }; }
public void PlayNote(float pitch, int octave) { if (lastNotePlayed + rateLimit <= DateTime.Now) { Console.WriteLine("Playing: " + this.name + " " + pitch + " " + octave + " (demo mode)"); OscElement pitchElem = new OscElement("/" + this.name + "/pitch", pitch); OscElement octaveElem = new OscElement("/" + this.name + "/octave", octave); MainWindow.osc.Send(pitchElem); MainWindow.osc.Send(octaveElem); lastNotePlayed = DateTime.Now; } }
public void overdub() { if (!isOvdb) { OscElement o = new OscElement("/Looper/0/State", "Overdub"); oscLoop.Send(o); isRecd = false; isOvdb = true; isPlay = false; isStop = false; } else { return; } }
public static String buildJSONElement(OscElement element) { String json = "["; var counter = 0; json += "\"" + element.Address.ToString() + "\","; foreach (object obj in element.Args) { json += "\"" + String.Format(CultureInfo.InvariantCulture, "{0}", obj) + "\""; json += counter == (element.Args.Length - 1) ? "]" : ","; counter++; } return(json); }
public void record() { if (!isRecd) { Console.WriteLine("Recording"); OscElement o = new OscElement("/Looper/0/State", "Record"); oscLoop.Send(o); isRecd = true; isOvdb = false; isPlay = false; isStop = false; } else { return; } //Console.WriteLine("msg sent maybe??"); }
public void OnRecieve(OscDispatcher dispatcher, OscBundle bundle) { //Parsing the OSC Message if (bundle != null) { foreach (var element in bundle.Elements) { OscElement message = (OscElement)element; foreach (var arg in message.Args) { argument = (string)arg; } //Raising the event if (argument != null) { OnMessageRecieved(); } } } }
public void sendOsc(string channel, FaceTrackFrame faceFrame, UdpWriter oscWriter) { TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1); String time = ((long)t.TotalMilliseconds).ToString(); var shape = faceFrame.Get3DShape(); float[][] arr = shape .Select(x => new float[3] { x.X, x.Y, x.Z }) .ToArray(); OscBundle b = new OscBundle(0); int i = 0; foreach (var v in shape) { var el = new OscElement("/kinect" + i++, v.X, v.Y, v.Z); b.AddElement(el); } oscWriter.Send(b); }
public void SendFFTData(float[] peeksFreqAndIntensity) { if (FFTDataRecorder != null) { FFTDataRecorder.WriteEvent(m_EventTimeStamp, peeksFreqAndIntensity); m_EventTimeStamp++; } m_PacketCount++; if (m_Connected == true) { if (temp == null || temp.Length != peeksFreqAndIntensity.Length) { temp = new object[peeksFreqAndIntensity.Length]; } for (int i = 0; i < peeksFreqAndIntensity.Length; i++) { temp[i] = peeksFreqAndIntensity[i]; } OscElement message = new OscElement("/fft", temp); OSCWriter.Send(message); } }
private void sendFloatButton_Click(object sender, RoutedEventArgs e) { OscElement fmsg = new OscElement(floatAdressTextBox.Text, floatTextBox.Text); m.sendOscMessage(fmsg); }
private void sendStringButton_Click(object sender, RoutedEventArgs e) { OscElement smsg = new OscElement(stringAddressTextBox.Text, stringTextBox.Text); m.sendOscMessage(smsg); }
// Sender Methods private void sendIntButton_Click(object sender, RoutedEventArgs e) { OscElement imsg = new OscElement(integerAddressTextBox.Text, integerTextBox.Text); //Typkonvertierung beachten m.sendOscMessage(imsg); }
public void SendLFOValue(float lfoValue) { m_PacketCount++; if (m_Connected == true) { OscElement message = new OscElement("/lfo", lfoValue); OSCWriter.Send(message); } }
static void Main(string[] args) { // 1. Instantiate BT connection to NXT // You can peek in the class file for more documentation NXTBluetooth bt = new NXTBluetooth(@"Tox NXT"); // 2. Instantiate the OSC receiver NetReader stream = new UdpReader(8000); // this is the main handler when an OSC message is recieved, per 100ms to not clog the BT Timer events = new Timer(new TimerCallback( delegate(object state) { object o; o = stream.Receive(); // 3. receive the info if (o != null) { // 4. convert the information OscElement element = (OscElement)o; //Console.WriteLine(string.Format("Message Received [{0}]: {1}", // element.Address, // element.Args[0])); object arg; // get the value passed if (element.Args != null && element.Args.Length > 0 && (arg = element.Args[0]) != null) { // 5. check on which value it is then send the message to BT int value = 0; switch (element.Address) { case "/1/leftTrack": value = 10000 + (int)((float)element.Args[0] * 100); bt.SendString(value.ToString()); break; case "/1/rightTrack": value = 20000 + (int)((float)element.Args[0] * 100); bt.SendString(value.ToString()); break; case "/1/turret": value = 30000 + (int)((float)element.Args[0] * 100); bt.SendString(value.ToString()); break; case "/1/stop": value = 40000; bt.SendString(value.ToString()); break; default: // ignore break; } Console.WriteLine(value.ToString()); } } }), null, 0, 1); // timer starts immediately, ticks every 1ms Console.ReadKey(); // press any key to quit }
static void Main(string[] args) {//UDP writer for OSC UdpWriter udpWrite = new UdpWriter("127.0.0.1", 7000); try { Nuitrack.Init(""); } catch (Exception exception) { Console.WriteLine("Cannot initialize Nuitrack."); throw exception; } try { // Create and setup all required modules _depthSensor = DepthSensor.Create(); _userTracker = UserTracker.Create(); _skeletonTracker = SkeletonTracker.Create(); } catch (Exception exception) { Console.WriteLine("Cannot create Nuitrack module."); Console.WriteLine(exception.Message); throw exception; } // Add event handlers for all modules _depthSensor.OnUpdateEvent += OnDepthSensorUpdate; _userTracker.OnNewUserEvent += OnUserTrackerNewUser; _userTracker.OnLostUserEvent += OnUserTrackerLostUser; _skeletonTracker.OnSkeletonUpdateEvent += OnSkeletonUpdate; // Add an event handler for the IssueUpdate event Nuitrack.onIssueUpdateEvent += OnIssueDataUpdate; try { Nuitrack.Run(); Console.WriteLine(DateTime.Now.ToString()); } catch (Exception exception) { Console.WriteLine("Cannot start Nuitrack."); throw exception; } bool a = true; while (a) { int start = (int)DateTime.Now.TimeOfDay.TotalMilliseconds; // Update Nuitrack data. Data will be synchronized with skeleton time stamps. try { Nuitrack.Update(_skeletonTracker); } catch (LicenseNotAcquiredException exception) { Console.WriteLine(DateTime.Now.ToString()); Console.WriteLine("LicenseNotAcquired exception. Exception: {0}", exception); throw exception; } catch (Exception exception) { Console.WriteLine("Nuitrack update failed. Exception: ", exception); } if (_skeletonData != null) { //Create new bundle for each time skeleton data is refreshed OscBundle bundle = new OscBundle(); //const int jointSize = 10; foreach (var skeleton in _skeletonData.Skeletons) { foreach (var joint in skeleton.Joints) { float[] rotationMatrix = joint.Orient.Matrix; //Ignore joints that are not currently used by Nuitrack if (joint.Type == JointType.None || joint.Type == JointType.LeftFingertip || joint.Type == JointType.RightFingertip || joint.Type == JointType.LeftFoot || joint.Type == JointType.RightFoot) { continue; } //Create new message element for joint containing joint type and rotation matrix OscElement jointMessage = new OscElement("/" + joint.Type, joint.Real.X, joint.Real.Y, joint.Real.Z, rotationMatrix[0], rotationMatrix[1], -1 * rotationMatrix[2], rotationMatrix[3], rotationMatrix[4], -1 * rotationMatrix[5], -1 * rotationMatrix[6], -1 * rotationMatrix[7], rotationMatrix[8]); Console.WriteLine(joint.Real.X + " " + joint.Real.Y + " " + joint.Real.Z); bundle.AddElement(jointMessage); } //Send the message bundle with the data udpWrite.Send(bundle); int difference = delay - start - (int)DateTime.Now.TimeOfDay.TotalMilliseconds; System.Threading.Thread.Sleep(delay); } } } Nuitrack.Release(); Console.ReadLine(); }
public void SendPacket(float x, float y, float type, float speed) { // packet filtering to go here if (m_CollisionPacketCount > 100) { return; } m_PacketCount++; m_CollisionPacketCount++; if (m_Connected == true) { //OscElement message = new OscElement("/c", x, y, type, speed); int modulateVelocity = (int)speed; if (modulateVelocity < 0) { modulateVelocity = 0; } else if (modulateVelocity > 127) { modulateVelocity = 127; } OscElement message = new OscElement("/renoise/trigger/note_on", (int)type, (int)type, (int)60, modulateVelocity); OSCWriter.Send(message); } if (ColisionEventRecorder != null) { ColisionEventRecorder.WriteEvent(m_EventTimeStamp, x, y, type, speed); } }
public void SendPacket(Vector4 data) { // packet filtering to go here if (m_CollisionPacketCount > 100) { return; } m_PacketCount++; if (m_Connected == true) { //OscElement message = new OscElement("/c", data.X, data.Y, data.Z, data.W); int modulateVelocity = (int)data.W; if (modulateVelocity < 0) { modulateVelocity = 0; } else if (modulateVelocity > 127) { modulateVelocity = 127; } OscElement message = new OscElement("/renoise/trigger/note_on", (int)data.Z, (int)data.Z, (int)60, modulateVelocity); OSCWriter.Send(message); } if (ColisionEventRecorder != null) { ColisionEventRecorder.WriteEvent(m_EventTimeStamp, data.X, data.Y, data.Z, data.W); } }
public override void Send(int pointScale, JSONWriter osc, StreamWriter fileWriter) { if (body == null) { return; } if (body.Joints == null) { return; } if (body.Joints.Count < 20) { return; } if (body.JointOrientations == null) { return; } if (body.JointOrientations.Count < 20) { return; } if (!body.IsTracked) { return; } try { if (handsOnly) { ProcessHandStateInformation(1, body.Joints[JointType.HandLeft], body.JointOrientations[JointType.HandLeft], body.HandLeftState, body.HandLeftConfidence, time, pointScale); ProcessHandStateInformation(2, body.Joints[JointType.HandRight], body.JointOrientations[JointType.HandRight], body.HandRightState, body.HandRightConfidence, time, pointScale); } else { var elements = new OscElement[] { ProcessJointInformation(1, body.Joints[JointType.Head], body.JointOrientations[JointType.Head], time, pointScale), ProcessJointInformation(2, body.Joints[JointType.SpineShoulder], body.JointOrientations[JointType.SpineShoulder], time, pointScale), ProcessJointInformation(3, body.Joints[JointType.SpineMid], body.JointOrientations[JointType.SpineMid], time, pointScale), ProcessJointInformation(4, body.Joints[JointType.SpineBase], body.JointOrientations[JointType.SpineBase], time, pointScale), // ProcessJointInformation(5, body.Joints[JointType.], body.JointOrientations[JointType.], time, pointScale, osc, fileWriter); ProcessJointInformation(6, body.Joints[JointType.ShoulderLeft], body.JointOrientations[JointType.ShoulderLeft], time, pointScale), ProcessJointInformation(7, body.Joints[JointType.ElbowLeft], body.JointOrientations[JointType.ElbowLeft], time, pointScale), ProcessJointInformation(8, body.Joints[JointType.WristLeft], body.JointOrientations[JointType.WristLeft], time, pointScale), ProcessJointInformation(9, body.Joints[JointType.HandLeft], body.JointOrientations[JointType.HandLeft], time, pointScale), // ProcessJointInformation(10, body.Joints[JointType.], body.JointOrientations[JointType.], time, pointScale, osc, fileWriter); // ProcessJointInformation(11, body.Joints[JointType.], body.JointOrientations[JointType.], time, pointScale, osc, fileWriter); ProcessJointInformation(12, body.Joints[JointType.ShoulderRight], body.JointOrientations[JointType.ShoulderRight], time, pointScale), ProcessJointInformation(13, body.Joints[JointType.ElbowRight], body.JointOrientations[JointType.ElbowRight], time, pointScale), ProcessJointInformation(14, body.Joints[JointType.WristRight], body.JointOrientations[JointType.WristRight], time, pointScale), ProcessJointInformation(15, body.Joints[JointType.HandRight], body.JointOrientations[JointType.HandRight], time, pointScale), // ProcessJointInformation(16, body.Joints[JointType.], body.JointOrientations[JointType.], time, pointScale, osc, fileWriter); ProcessJointInformation(17, body.Joints[JointType.HipLeft], body.JointOrientations[JointType.HipLeft], time, pointScale), ProcessJointInformation(18, body.Joints[JointType.KneeLeft], body.JointOrientations[JointType.KneeLeft], time, pointScale), ProcessJointInformation(19, body.Joints[JointType.AnkleLeft], body.JointOrientations[JointType.AnkleLeft], time, pointScale), ProcessJointInformation(20, body.Joints[JointType.FootLeft], body.JointOrientations[JointType.FootLeft], time, pointScale), ProcessJointInformation(21, body.Joints[JointType.HipRight], body.JointOrientations[JointType.HipRight], time, pointScale), ProcessJointInformation(22, body.Joints[JointType.KneeRight], body.JointOrientations[JointType.KneeRight], time, pointScale), ProcessJointInformation(23, body.Joints[JointType.AnkleRight], body.JointOrientations[JointType.AnkleRight], time, pointScale), ProcessJointInformation(24, body.Joints[JointType.FootRight], body.JointOrientations[JointType.FootRight], time, pointScale) }; //ProcessHandStateInformation(1, body.Joints[JointType.HandLeft], body.JointOrientations[JointType.HandLeft], body.HandLeftState, body.HandLeftConfidence, time, pointScale, osc, fileWriter); //ProcessHandStateInformation(2, body.Joints[JointType.HandRight], body.JointOrientations[JointType.HandRight], body.HandRightState, body.HandRightConfidence, time, pointScale, osc, fileWriter); osc.Send("/skeleton", new OscBundle(0, elements)); } } catch (NullReferenceException ex) { // Happens sometimes. Probably because we should copy body before processing it in another thread. Console.WriteLine(ex.Message); } }
public void SendMsg(string message) { OscElement msg = new OscElement("/chat", message); writer.Send(msg); }
//Methods public void sendOscMessage(OscElement messageElement) { bundle.AddElement(messageElement); writer.Send(bundle); }
/// <summary> /// Handles the body frame data arriving from the sensor /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void Reader_FrameArrived(object sender, BodyFrameArrivedEventArgs e) { bool dataReceived = false; using (BodyFrame bodyFrame = e.FrameReference.AcquireFrame()) { if (bodyFrame != null) { if (this.bodies == null) { this.bodies = new Body[bodyFrame.BodyCount]; } // The first time GetAndRefreshBodyData is called, Kinect will allocate each Body in the array. // As long as those body objects are not disposed and not set to null in the array, // those body objects will be re-used. bodyFrame.GetAndRefreshBodyData(this.bodies); dataReceived = true; } } if (dataReceived) { using (DrawingContext dc = this.drawingGroup.Open()) { // Draw a transparent background to set the render size dc.DrawRectangle(Brushes.Black, null, new Rect(0.0, 0.0, this.displayWidth, this.displayHeight)); int penIndex = 0; int bodyIndex = 0; OscBundle oscBundle = new OscBundle(DateTime.Now); foreach (Body body in this.bodies) { Pen drawPen = this.bodyColors[penIndex++]; if (body.IsTracked) { bodyIndex++; this.DrawClippedEdges(body, dc); IReadOnlyDictionary <JointType, Joint> joints = body.Joints; // convert the joint points to depth (display) space Dictionary <JointType, Point> jointPoints = new Dictionary <JointType, Point>(); foreach (JointType jointType in joints.Keys) { // sometimes the depth(Z) of an inferred joint may show as negative // clamp down to 0.1f to prevent coordinatemapper from returning (-Infinity, -Infinity) CameraSpacePoint position = joints[jointType].Position; if (position.Z < 0) { position.Z = InferredZPositionClamp; } // add all joints data to osc bundle Object[] args = new Object[10]; args[0] = bodyIndex; args[1] = (int)jointType; args[2] = position.X; args[3] = position.Y; args[4] = position.Z; args[5] = body.JointOrientations[jointType].Orientation.X; args[6] = body.JointOrientations[jointType].Orientation.Y; args[7] = body.JointOrientations[jointType].Orientation.Z; args[8] = body.JointOrientations[jointType].Orientation.W; args[9] = (int)joints[jointType].TrackingState; // JointType: https://msdn.microsoft.com/en-us/library/microsoft.kinect.jointtype.aspx foreach (OscConnection oscConnection in oscConnectionList) { if (oscConnection.OscUdpWriter != null) { string oscAddress = "/" + kinectSensor.UniqueKinectId; if (oscConnection.Identifier != null) { if (oscConnection.Identifier != "") { oscAddress = "/" + oscConnection.Identifier; } } OscElement oscElement = new OscElement(oscAddress, args); oscConnection.OscUdpWriter.Send(oscElement); oscBundle.AddElement(oscElement); } } DepthSpacePoint depthSpacePoint = this.coordinateMapper.MapCameraPointToDepthSpace(position); jointPoints[jointType] = new Point(depthSpacePoint.X, depthSpacePoint.Y); } this.DrawBody(joints, jointPoints, dc, drawPen); this.DrawHand(body.HandLeftState, jointPoints[JointType.HandLeft], dc); this.DrawHand(body.HandRightState, jointPoints[JointType.HandRight], dc); } } // send osc bundle // if (oscUdpWriter != null) // oscUdpWriter.SendBundle(oscBundle); // prevent drawing outside of our render area this.drawingGroup.ClipGeometry = new RectangleGeometry(new Rect(0.0, 0.0, this.displayWidth, this.displayHeight)); } } }
private void KinectSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) { var skeletons = new Skeleton[0]; using (var skeletonFrame = e.OpenSkeletonFrame()) { if (skeletonFrame != null) { skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength]; skeletonFrame.CopySkeletonDataTo(skeletons); } } if (skeletons.Length == 0) { return; } var skel = skeletons.FirstOrDefault(x => x.TrackingState == SkeletonTrackingState.Tracked); if (skel == null) { return; } var rightHand = skel.Joints[JointType.WristRight]; XValueRight.Text = rightHand.Position.X.ToString(CultureInfo.InvariantCulture); YValueRight.Text = rightHand.Position.Y.ToString(CultureInfo.InvariantCulture); ZValueRight.Text = rightHand.Position.Z.ToString(CultureInfo.InvariantCulture); var leftHand = skel.Joints[JointType.WristLeft]; XValueLeft.Text = leftHand.Position.X.ToString(CultureInfo.InvariantCulture); YValueLeft.Text = leftHand.Position.Y.ToString(CultureInfo.InvariantCulture); ZValueLeft.Text = leftHand.Position.Z.ToString(CultureInfo.InvariantCulture); var centreHip = skel.Joints[JointType.HipCenter]; /* * Below this is where the code edit was made. * ******************* */ //creates the var manager = new OscManager(); //Sets up the IP address and Port to which the bundle is sending to. //Edit DestIP to the laptop your communicating with. manager.DestIP = "192.168.0.26"; manager.DestPort = 12000; //Creates the message and bundle. This is what will send the data. OscElement message; OscBundle bundle; if (leftHand.Position.Y > .2) { //Lower octave message = new OscElement("/octave", 0); bundle = new OscBundle(); bundle.AddElement(message); manager.Send(bundle); } else if ((leftHand.Position.Y > .2) && (leftHand.Position.Y < .45)) { //Mid octave message = new OscElement("/octave", 1); bundle = new OscBundle(); bundle.AddElement(message); manager.Send(bundle); } else if (leftHand.Position.Y > .50) { //High octave message = new OscElement("/octave", 2); bundle = new OscBundle(); bundle.AddElement(message); manager.Send(bundle); } /******** * This ends where the code was edited */ if (rightHand.Position.Y > 0.3) { RightRaised.Text = "Raised"; } else if (leftHand.Position.Y > 0.3) { LeftRaised.Text = "Raised"; } else { LeftRaised.Text = "Lowered"; RightRaised.Text = "Lowered"; } //Pauses system so not too many signals are being sent. Thread.Sleep(10); }
// This function sends both how many skeletons are in the frame, and where they are private void sendOSCSkeletonPositions(object sender, SkeletonFrameReadyEventArgs e) { sendOSCSkeletonCount(); List<Skeleton> skeletonList = kinectGroup.getMasterSkeletons(); OscBundle oscBundle = new OscBundle(); int skeletonNum = 0; float xScale = sanitizeTextToFloat(XScaleTextBox.Text); float xOffset = sanitizeTextToFloat(XOffsetTextBox.Text); float yScale = sanitizeTextToFloat(YScaleTextBox.Text); float yOffset = sanitizeTextToFloat(YOffsetTextBox.Text); foreach (Skeleton s in skeletonList){ var oscMessage = new OscElement("/skeletonPosition", skeletonNum, (float)(s.Position.X * SCREEN_WIDTH_PX_M_RATIO * xScale + xOffset), (float)(s.Position.Y * SCREEN_HEIGHT_PX_M_RATIO * yScale + yOffset), (float)(s.Position.Z * SCREEN_WIDTH_PX_M_RATIO * xScale + xOffset), (int)(s.TrackingId)); oscBundle.AddElement(oscMessage); skeletonNum++; } oscWriter.Send(oscBundle); }