hi.
I am using a leonardo to send midi messages to ableton live.
It works well when I use it as a midi note generator using 3 potentiometers to generate 3 x (0-127) midi notes into three channels that are mapped to 'lanes' in ableton.
But when I try to 'midi map' to the volume sliders it only seems to use one channel?
Making one pot control all three - which I don't want.
Am I missing something - perhaps the way the midi message is being formulated?
#include "MIDIUSB.h"
#define POT_PIN_0 A0
#define POT_PIN_1 A1
#define POT_PIN_2 A2
int lastNote_0 = 0;
int lastNote_1 = 0;
int lastNote_2 = 0;
//USING MIDI MAPPING IN ABLETON
//
void setup() {
Serial.begin(115200);
}
void loop() {
//read analogue pin
int fader_0 = analogRead(POT_PIN_0);
int note_0 = map(fader_0, 0, 1023, 0, 127);
int fader_1 = analogRead(POT_PIN_1);
int note_1 = map(fader_1, 0, 1023, 0, 127);
int fader_2 = analogRead(POT_PIN_2);
int note_2 = map(fader_2, 0, 1023, 0, 127);
int channel_0 = 1;
int channel_1 = 2;
if(lastNote_0 != note_0){
noteOn1(channel_0, note_0, 64); // Channel 0, middle C, normal velocity
lastNote_0 = note_0;
}
if(lastNote_1 != note_1){
noteOn2(channel_1, note_1, 64); // Channel 0, middle C = 60, normal velocity
}
}
//midi
void noteOn1(byte channel, byte pitch, byte velocity) {
midiEventPacket_t noteOn = {0x09, 0x90 | channel, pitch, velocity};
MidiUSB.sendMIDI(noteOn);
}
void noteOn2(byte channel, byte pitch, byte velocity) {
midiEventPacket_t noteOn = {0x09, 0x90 | channel, pitch, velocity};
MidiUSB.sendMIDI(noteOn);
}
void noteOff(byte channel, byte pitch, byte velocity) {
midiEventPacket_t noteOff = {0x08, 0x80 | channel, pitch, velocity};
MidiUSB.sendMIDI(noteOff);
}
void controlChange(byte channel, byte control, byte value) {
midiEventPacket_t event = {0x0B, 0xB0 | channel, control, value};
MidiUSB.sendMIDI(event);
}