Kinect MIDI Controller
- Posted: Jul 15, 2011 at 6:00 AM
- 7,206 Views
- 1 Comment
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Today's post comes via TWC9: Office 365, Internet Explorer 10 PP2, Choosing the Right collection class, ToneCheck and shows us how to turn a Kinect into a MUI (Music NUI)
This tool allows you to use a Microsoft Kinect sensor as a MIDI Controller. The project uses Microsoft Kinect SDK to track the skeletal data.
The Kinect SDK provides the logic to detect the X and Y Co-ordinates of a user's hands. The X & Y Co-ordinates are then scaled and converted to MIDI messages.
These MIDI messages are then sent to the MIDI output port. The tool contains a .NET Wrapper for the MIDI interfacing methods provided by winmm.dll Win32 API.
The tool requires a virtual MIDI Cable software to create virtual MIDI ports. ...
Project Information URL: http://kinectmidicontroller.codeplex.com/
Project Source URL: http://kinectmidicontroller.codeplex.com/SourceControl/list/changesets
private void SendMIDISignals(SkeletonFrameReadyEventArgs frameArgs)
{
SkeletonData skeletonData = (from sd in frameArgs.SkeletonFrame.Skeletons where sd.TrackingState == SkeletonTrackingState.Tracked select sd).FirstOrDefault();
if (skeletonData == null)
{
return;
}
if (skeletonData.TrackingState == SkeletonTrackingState.Tracked)
{
if (skeletonData.Joints[JointID.HandLeft].TrackingState == JointTrackingState.Tracked &&
skeletonData.Joints[JointID.HandRight].TrackingState == JointTrackingState.Tracked)
{
// get the left and right hand Joints
Joint jointRight, scaledRight;
if (skeletonData.Joints[JointID.HandLeft].TrackingState == JointTrackingState.Tracked)
{
Joint scaledLeft;
Joint jointLeft = skeletonData.Joints[JointID.HandLeft];
scaledLeft = jointLeft.ScaleTo((int)SystemParameters.PrimaryScreenWidth, (int)SystemParameters.PrimaryScreenHeight, SkeletonMaxX, SkeletonMaxY);
byte newValueLX = (byte)(((float)scaledLeft.Position.X / (float)SystemParameters.PrimaryScreenWidth) * 127);
byte newValueLY = (byte)(127 - ((float)scaledLeft.Position.Y / (float)SystemParameters.PrimaryScreenHeight) * 127);
if (newValueLX != valueLX && ChannelLX != 0 &&ControllerLX != 0)
{
instrument.OutputChannel = ChannelLX;
instrument.SendMessage(MIDIStatusMessages.ControllerChange, ref ControllerLX, valueLX);
valueLX = newValueLX;
sliderLX.Value = newValueLX;
}
if (newValueLY != valueLY && ChannelLY != 0 && ControllerLY != 0)
{
instrument.OutputChannel = ChannelLY;
instrument.SendMessage(MIDIStatusMessages.ControllerChange, ref ControllerLY, valueLY);
valueLY = newValueLY;
sliderLY.Value = newValueLY;
}
}
if (skeletonData.Joints[JointID.HandRight].TrackingState == JointTrackingState.Tracked)
{
jointRight = skeletonData.Joints[JointID.HandRight];
scaledRight = jointRight.ScaleTo((int)SystemParameters.PrimaryScreenWidth, (int)SystemParameters.PrimaryScreenHeight, SkeletonMaxX, SkeletonMaxY);
byte newValueRX = (byte)(((float)scaledRight.Position.X / (float)SystemParameters.PrimaryScreenWidth) * 127);
byte newValueRY = (byte)(127 - ((float)scaledRight.Position.Y / (float)SystemParameters.PrimaryScreenHeight) * 127);
if (newValueRX != valueRX && ChannelRX != 0 && ControllerRX != 0)
{
instrument.OutputChannel = ChannelRX;
instrument.SendMessage(MIDIStatusMessages.ControllerChange, ref ControllerRX, valueRX);
valueRX = newValueRX;
sliderRX.Value = newValueRX;
}
if (newValueRY != valueRY && ChannelRY != 0 && ControllerRY != 0)
{
instrument.OutputChannel = ChannelRY;
instrument.SendMessage(MIDIStatusMessages.ControllerChange, ref ControllerRY, valueRY);
valueRY = newValueRY;
sliderRY.Value = newValueRY;
}
}
}
}
}
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
Fantastic, I left a question on your other demo of this about how it's done but hadn't seen this which I think provide the answers. Look forward to giving this a go - I'll update on how I get on.
Remove this comment
Remove this thread
close