I am trying to create a theremin-like program, that plays continuous notes based on mouse cursor position. I am using Carl Franklin's MIDI Tools library to do this.
This is the code snippet I am using to play the notes.
byte pitch = 0;
while (exit == false)
{
byte newpitch = (byte)(32 + ((float)Cursor.Position.X / (float)SystemParameters.PrimaryScreenWidth) * 64);
if (newpitch != pitch)
{
instrument.StopNote(pitch,0);
instrument.PlayNote(newpitch, 53);
pitch = newpitch;
}
};
The problem is that the notes that are played out this way sound distinct; there is a clear transition from one note to another.
How do I play a continuous theremin like sound that shifts the pitch continuously?