Skip to content

Instantly share code, notes, and snippets.

@polyclick
Last active January 10, 2018 13:49
Show Gist options
  • Save polyclick/34bcc062a3883a96e16b0d4615e339fa to your computer and use it in GitHub Desktop.
Save polyclick/34bcc062a3883a96e16b0d4615e339fa to your computer and use it in GitHub Desktop.
float timeDiff = ofGetElapsedTimef() - lastPitchChangeTime;
if(roundedCurrPitch != roundedPrevPitch && pitchConfidence > minimumConf && timeDiff > pitchRelease) {
// first, send [off note] for previous note
midiOut.sendNoteOff(channel, roundedPrevPitch);
// send current note value over midi
// scale the ascii values to midi velocity range 0-127
// see an ascii table: http://www.asciitable.com/
velocity = 127 * pitch.pitchConfidence;
midiOut.sendNoteOn(channel, roundedCurrPitch, velocity);
prevPitch = currPitch;
lastPitchChangeTime = ofGetElapsedTimef();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment