Hi guys.
I am just starting on this Teensy/Arduino thing.
I have a sketch to send usbmidi joystick for my Korg M3 module. It works for the joystick part. If i only needed that I would have my small midi controller ready, but I also need to send Sysex with 2 push buttons and that is where I am not having success with it.
The Sysex messages I need to send are dependent on the High (off) or Low (on) state of the momentary switches I have in Digital pins 0 and 1. These on/off states must be controlled by changing sequencialy everytime the buttons are pressed.
For Pin 0 the messages are:
For Pin 1 the messages are:
I thing there should be Bouce and fallingEdge ou RaisingEdge involved, but for now it is giving me a good fight to succeed.
This is my sketch with only usbmidi joystick
Oh: I'm using Teensy ++2 and should be receiving a 3.6 this week.
Thank you
I am just starting on this Teensy/Arduino thing.
I have a sketch to send usbmidi joystick for my Korg M3 module. It works for the joystick part. If i only needed that I would have my small midi controller ready, but I also need to send Sysex with 2 push buttons and that is where I am not having success with it.
The Sysex messages I need to send are dependent on the High (off) or Low (on) state of the momentary switches I have in Digital pins 0 and 1. These on/off states must be controlled by changing sequencialy everytime the buttons are pressed.
For Pin 0 the messages are:
in ON state:
0xF0, 0x42, 0x30, 0x75, 0x41, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF7
in OFF state:
0xF0, 0x42, 0x30, 0x75, 0x41, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF7
For Pin 1 the messages are:
in ON state:
0xF0, 0x42, 0x30, 0x75, 0x41, 0x00, 0x00, 0x01, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF7
in OFF state:
0xF0, 0x42, 0x30, 0x75, 0x41, 0x00, 0x00, 0x01, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF7
I thing there should be Bouce and fallingEdge ou RaisingEdge involved, but for now it is giving me a good fight to succeed.
This is my sketch with only usbmidi joystick
Can you please guide me on this?// include the ResponsiveAnalogRead library for analog smoothing
#include <ResponsiveAnalogRead.h>
// ******CONSTANT VALUES******** - customize code behaviour here!
// SET THESE FOUR VALUES!
const int pitchPin = 0; // PIN numbers ** MUST CHANGE!
const int modPin = 1;
const int pitchMaxRaw = 1019; // Max reading with full bend up... as raw 10-bit value
const int modMaxRaw = 1019; // Max reading full mod down
const int channel = 1; // MIDI channel
const int MIDIdelay = 5; // will update MIDI only if this many milliseconds have passed
//******VARIABLES***********
// data variables and a lagged copy to compare before updating MIDI value
int pitch;
int mod;
int pitchRaw;
int modRaw;
int pitchLag;
int modLag;
elapsedMillis pitchUpdate;
elapsedMillis modUpdate;
// ititialize the ReponsiveAnalogRead objects
ResponsiveAnalogRead readPitch = {pitchPin,true};
ResponsiveAnalogRead readMod = {modPin,true};
void setup() {
}
void loop() {
getAnalogData();
while (usbMIDI.read()) {
}
}
//************ANALOG SECTION**************
void getAnalogData(){
readPitch.update();
if(readPitch.hasChanged()) {
pitchRaw = readPitch.getValue();
// remap to output data and send if changed and MIDIdelay has lapsed since last update for that parameter
pitch = map(pitchRaw,4,1019,0,16383);
pitch = max(pitch,0); // need this now that the bottom isn't zero
pitch = min(pitch,16383); // cap to avoid overflow
if (abs(pitch - pitchLag)>0 && pitchUpdate > MIDIdelay ){
pitchLag = pitch;
usbMIDI.sendPitchBend( pitch, channel);
pitchUpdate = 0;
}
}
readMod.update();
if(readMod.hasChanged()) {
modRaw = readMod.getValue();
// remap to output data and send if changed and MIDIdelay has lapsed since last update for that parameter
mod = map(modRaw,4,1019,0,127); // N.B. - map does not limit values
mod = max(mod,0); // minimum could overflow is modRaw is greater than calabrated
//mod = min(mod,127);
if (mod != modLag && modUpdate > MIDIdelay ){ // resolution reduction should be enough wi
modLag = mod;
usbMIDI.sendControlChange(1, mod, channel); // CC = 1 is mod wheel in standard MIDI
modUpdate = 0;
}
}
}
Oh: I'm using Teensy ++2 and should be receiving a 3.6 this week.
Thank you
Last edited: