Code:
// MIDI Elements MIDI
// by Tomash Ghz
// www.tomashg.com
// ghz.tomash@gmail.com
// Code written by Nickolas Boyer
#include <MIDIElements.h>
boolean debug=false; // print to serial instead of midi
boolean secondary=false; // enable secondary midi messages
int midiChannel=1; // midi channel number
// declare all your components here
MIDIEncoder *enc1;
MIDIEncoder *enc2;
Button *encBut1;
Button *encBut2;
Potentiometer *pot1;//(14, controlChannel, 17, false, debug); // knob on pin 45 (A7)
Potentiometer *pot2;//(15, controlChannel, 18, false, debug); // knob on pin 44 (A6)
Potentiometer *pot3;//(16, controlChannel, 19, false, debug); // knob on pin 45 (A7)
Potentiometer *pot4;//(17, controlChannel, 20, false, debug); // knob on pin 44 (A6)
Potentiometer *pot5;
Potentiometer *pot6;
Potentiometer *pot7;
Potentiometer *pot8;
Potentiometer *pot9;
Potentiometer *pot10;
Potentiometer *pot11;
Potentiometer *pot12;
void setup(){
enc1=new MIDIEncoder(2,3,midiChannel,1,false, debug); // setup an encoder on pins 1 and 2
enc2=new MIDIEncoder(4,5,midiChannel,2,false, debug); // setup an encoder on pins 1 and 2
pot1=new Potentiometer(A0, midiChannel, 17, false, debug); // knob on pin A0
pot2=new Potentiometer(A1, midiChannel, 18, false, debug); // knob on pin A1
pot3=new Potentiometer(A2, midiChannel, 19, false, debug); // knob on pin A2
pot4=new Potentiometer(A3, midiChannel, 20, false, debug); // knob on pin A3
pot5=new Potentiometer(A4, midiChannel, 21, false, debug);
pot6=new Potentiometer(A5, midiChannel, 22, false, debug);
pot7=new Potentiometer(A6, midiChannel, 23, false, debug);
pot8=new Potentiometer(A7, midiChannel, 24, false, debug);
pot9=new Potentiometer(A8, midiChannel, 25, false, debug);
pot10=new Potentiometer(A9, midiChannel, 26, false, debug);
pot11=new Potentiometer(A10, midiChannel, 27, false, debug);
pot12=new Potentiometer(A11, midiChannel, 28, false, debug);
encBut1=new Button(6, midiChannel, 10, false, debug); // encoder buttons
encBut2=new Button(7, midiChannel, 11, false, debug); // encoder buttons
usbMIDI.setHandleNoteOff(OnNoteOff); //set event handler for note off
usbMIDI.setHandleNoteOn(OnNoteOn); //set event handler for note on
usbMIDI.setHandleControlChange(OnControlChange); // set event handler for CC
}
void loop(){
// add here all the input component reads
pot1->read();
pot2->read();
pot3->read();
pot4->read();
pot5->read();
pot6->read();
pot7->read();
pot8->read();
pot9->read();
pot10->read();
pot11->read();
pot12->read();
enc1->read();
enc2->read();
encBut1->read();
encBut2->read();
usbMIDI.read(); // read all the incoming midi messages
}
//====================================================================
// event handlers
void OnNoteOn(byte channel, byte note, byte velocity){
// add all your output component sets that will trigger with note ons
}
void OnNoteOff(byte channel, byte note, byte velocity){
// add all your output component sets that will trigger with note ons
}
void OnControlChange(byte channel, byte control, byte value){
// add all your output component sets that will trigger with cc
}
Bookmarks