Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Commit

Permalink
Added filters
Browse files Browse the repository at this point in the history
The X,Y,Z measurements are a little off.
Also, it does it whenever you are playing, so that could get very
annoying very fast.
  • Loading branch information
ahollenbach committed Dec 19, 2014
1 parent e7b23aa commit 41f4ad7
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
33 changes: 33 additions & 0 deletions Filter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Microsoft.Kinect;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ventuz.OSC;

namespace GesturalMusic
{
class Filter
{
private String instrumentName;

public Filter(String instrumentName)
{
this.instrumentName = instrumentName;
}

public void SendFilterData(Body body)
{
CameraSpacePoint rWrist = body.Joints[JointType.WristRight].Position;
CameraSpacePoint rShoulder = body.Joints[JointType.ShoulderRight].Position;

// X works fairly well
// Y is somewhat bad
// Z is bad
MainWindow.osc.Send(new OscElement("/" + instrumentName + "/filterX", rWrist.X - rShoulder.X));
MainWindow.osc.Send(new OscElement("/" + instrumentName + "/filterY", rWrist.Y));
MainWindow.osc.Send(new OscElement("/" + instrumentName + "/filterZ", rShoulder.Z - rWrist.Z));
}
}
}
1 change: 1 addition & 0 deletions GesturalMusic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Filter.cs" />
<Compile Include="Instrument.cs" />
<Compile Include="KinectStageArea.cs" />
<Compile Include="LooperOSC.cs" />
Expand Down
6 changes: 5 additions & 1 deletion Instrument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class Instrument
public readonly static String INSTRUMENT = "Instrument";



public string name;
private Filter filter;

// For rate limiting
private DateTime lastNotePlayed;
Expand All @@ -29,6 +29,7 @@ class Instrument
public Instrument(string name)
{
this.name = name;
filter = new Filter(this.name);

lastNotePlayed = DateTime.Now;
handStateLast = HandState.Unknown;
Expand Down Expand Up @@ -58,6 +59,9 @@ public void PlayNote(int pitch, int velocity = 127, int duration = 500, int midi
}
public bool CheckAndPlayNote(Body body)
{
// first thing, send filters
filter.SendFilterData(body);

double rightThreshold = 0.2;
double leftThreshold = 0.1;

Expand Down
2 changes: 1 addition & 1 deletion MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public MainWindow()
{
instruments[i] = new Instrument("instr" + i);
}
instruments[2] = new MidiPad("pad0");
//instruments[2] = new MidiPad("pad0");


///////////////////////////////////////////////////////////////////////
Expand Down
Binary file modified Other/test Project/test.als
Binary file not shown.

0 comments on commit 41f4ad7

Please sign in to comment.