So I'm working on a patch that takes audio input, and outputs MIDI messages by using the sigmund~ in coordination with makenote and noteout. I've got my thresholds set fine, and the pitch tracking and note detection is working quite well. The problem is duration - makenote anticipates a pre-determined duration, but we don't know what that is until the note has stopped, at which point we want to send our MIDI note "off" message.
First thing's first: i need a way of re-routing note "off" messages from "makenote," so that when the velocity = 0, the note value will get re-routed to the cold input on a float. Not really sure what object in Pd can do this.
Next, the patch needs a way of determining when to send the note "off." The goal is to send that message whenever there is A. a sudden change in volume, or B. a sudden change in pitch. I'm currently using unsig~ to output a real-time value every 40 ms, as well as a value that is delayed 40ms, in order to compare volume level and pitch in real time (over a period of 40ms). Whenever pitch changes, it will send a bang to the float that holds the note value, as well as to another float that holds a default "0" velocity value, which are both then sent simultaneously to the makenote object thus sending a note "off" whenever pitch changes. The same bang can also be sent whenever volume changes by a predetermined threshold (15 dB over this 40ms frame), thus sending a note "off" whenever a note is released.
At the moment, the real roadbloack is the signal re-routing I want to achieve, to send the MIDI note value from "makenote" to a float whenever velocity = 0.
If anybody has comments on how I could improve the system, I'd love to hear them.