Algorithms for implementing MIDI pitch bend messages

165 Views Asked by At

Are there some common algorithms for implementing MIDI pitch bend for single notes and multi voices (e.g. chords). I am implementing this in kind of an intuitive way, but I would really like to know if I am not totally off-track! For single notes I currently I am sending a pitch bend message to the channel, just before the note on message, and resetting the pitch bend by sending it the center value of 2^13, right after the note off message has been sent to keep the channel clean for the next coming note! I am specially interested in how to deal with channels for implementing the pitch bends. Any help or hint to appropriate readings is highly appreciated.

PS: here is how I have implemented pitch bend for a single note (https://github.com/teymuri/cu/blob/main/mid.py#L61)

1

There are 1 best solutions below

2
CL. On

A pitch bend message affects all sounds on the channel. So you should send it when you want the pitch to change.

The sound might not stop immediately after a note-off message. You should not reset the pitch bend until you are sure that the sound has ended. (Or don't reset it at all; the pitch of silence does not matter.)

If you want to do microtonality, you pretty much have to use one channel per note.