I am making a midi musical instrument using an arduino controlling a Wav-Trigger SD card sample player
I wish to add vibrato using a FSR.
I am trying to achieve this by adding Vibrato MSB and LSB to the existing,
// Send a MIDI note-on message. ( Like so)
pitch_bend(channel, bendLSB, bendMSB, SerialChannels );
This is example rough idea code I am trying below;
//Read the vibrato pin - If it's changed significantly change bend value MSB and LSB
vibratoVal = analogRead(VibratoPin); // read FSR
if ( vibratoVal < MIN_PRESSURE){
int PitchBend= 8192; // No bend
} else
{
int PitchBend = map( vibratoVal, MIN_PRESSURE, MAX_PRESSURE, ,8192, 9640);//use the min 600 -max 680 pressure range I measured from FSR
PitchBend = constrain (PitchBend ,8192, 9640); // for (aprox)+1 semitone
My questions are the decimal numbers for pitch bend I use in the mapping equation for a one semitone bend correct ,( for max possible bend range+ 5 semitones) , is the basic sketch on the right track and more important I wish to convert the PitchBend to MSB and LSB to pass to a MIDI note-on message, how do I do this?
For converting my decimal PitchBend values to Binary LSB ,MSB is this the way;
byte lowValue = PitchBend & 0x7F; byte highValue = PitchBend >> 7; ?
Can someone please help with the code to achieve my aims?