usbMIDI.sendPitchBend input values

Status
Not open for further replies.

ajnovember

New member
Hi all, I'm working on a project with my Teensy 3.1 that uses touchRead() with conductive rubber bands as MIDI triggers. The rubber bands' touchRead() readings change when you stretch the bands, which is very exciting, so I'm trying to do use that reading to input into usbMIDI.sendPitchBend and am getting super inconsistent/erratic results. Basically I just want to know what are the useful/important input values for usbMIDI.sendPitchBend, ie. what are the max and min values, what happens when you go above or below them, what is 'center' (no pitch bend), is this pitch scaling linear/log, what is the default interval range of sendPitchBend and how might I about changing that (or is that all done on the DAW side?
Any information about this would be greatly appreciated. Much thanks, everyone.
 
I bet that will sound amazing when you get it working!

You may need to do some filtering on the touchRead values to suppress noise. Haven't used the audio library, but you might also want to test it on clean predictable inputs like a slow ramp or sine wave before hooking it up to your sensors.
 
PitchBend is a 14-bit unsigned value (0 to 16383) but you can actually bend up or down, so the "no pitchbend" value is midway: 2^13 (8192).

Values outside that range are brought inside the range before being sent. The actual code is in hardware/cores/teenst/teensy3/usb_midi.h:
Code:
void sendPitchBend(uint32_t value, uint32_t channel) __attribute__((always_inline)) {
    usb_midi_write_packed(0xE00E | (((channel - 1) & 0x0F) << 8)
    | ((value & 0x7F) << 16) | ((value & 0x3F80) << 17));

PitchBend is a linear value but over an initially undefined range of semitones.

From the MIDI specification, table 2:
Pitch Bend Change. 0mmmmmmm This message is sent to indicate a change in the pitch bender (wheel or lever, typically). The pitch bender is measured by a fourteen bit value. Center (no pitch change) is 2000H. Sensitivity is a function of the transmitter. (llllll) are the least significant 7 bits. (mmmmmm) are the most significant 7 bits.

To set up a defined pitch bend range, send Registered Parameter Number (RPN) 00, 00 (see MIDI spec, table 3a) which is Pitch Bend Sensitivity. This takes a 14bit value of which the most significant 7 bits are the maximum shift in semitones and the least significant 7 bits are the maximum shift in cents. These are added together (so it you want a tiny shift of 50 cents (half a semitone), set 00 as the MSB and 50 as the LSB).
 
Status
Not open for further replies.
Back
Top