Move MIDI functions into separate files

This commit is contained in:
John Stäck 2019-03-01 13:51:14 +01:00
parent a63ac4e3b9
commit 1d8cd1a3ef
3 changed files with 231 additions and 217 deletions

290
NuEVI.ino
View file

@ -7,6 +7,8 @@
#include <Adafruit_SSD1306.h>
#include <Filters.h> // for the breath signal LP filtering, https://github.com/edgar-bonet/Filters
#include "midi.h"
/*
NAME: NuEVI
WRITTEN BY: JOHAN BERGLUND
@ -579,6 +581,7 @@ byte breathLedBrightness = 2000; // up to 4095, PWM
byte portamLedBrightness = 2000; // up to 4095, PWM
Adafruit_MPR121 touchSensor = Adafruit_MPR121(); // This is the 12-input touch sensor
FilterOnePole breathFilter;
//_______________________________________________________________________________________________ SETUP
@ -719,6 +722,8 @@ void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)
// init done
breathFilter.setFilter(LOWPASS, filterFreq, 0.0); // create a one pole (RC) lowpass filter
// Show image buffer on the display hardware.
// Since the buffer is intialized with an Adafruit splashscreen
// internally, this will display the splashscreen.
@ -784,22 +789,18 @@ void setup() {
//_______________________________________________________________________________________________ MAIN LOOP
void loop() {
mainLoop();
}
void mainLoop() {
FilterOnePole breathFilter( LOWPASS, filterFreq ); // create a one pole (RC) lowpass filter
while (1){
breathFilter.input(analogRead(breathSensorPin));
pressureSensor = constrain((int)breathFilter.output(),0,4095); // Get the filtered pressure sensor reading from analog pin A0, input from sensor MP3V5004GP
//pressureSensor = analogRead(A0);
//pressureSensor = smooth(analogRead(0), filterVal, smoothedVal); // second parameter determines smoothness - 0 is off, .9999 is max smooth
if (mainState == NOTE_OFF) {
if (activeMIDIchannel != MIDIchannel) activeMIDIchannel = MIDIchannel; // only switch channel if no active note
if (activeMIDIchannel != MIDIchannel) {
activeMIDIchannel = MIDIchannel; // only switch channel if no active note
midiSetChannel(activeMIDIchannel);
}
if ((activePatch != patch) && doPatchUpdate){
activePatch = patch;
usbMIDI.sendProgramChange(activePatch-1,activeMIDIchannel);
dinMIDIsendProgramChange(activePatch-1,activeMIDIchannel-1);
midiSendProgramChange(activePatch);
slurSustain = 0;
parallelChord = 0;
subOctaveDouble = 0;
@ -864,11 +865,10 @@ void mainLoop() {
else if (!K1 && K2 && !K3 && K4) {patch = patch +10; doPatchUpdate = 1; } //f#30 send patch change +10
else if (!K1 && !K2 && !K3 &&K4) { patch++; doPatchUpdate = 1; } //g31 increment and send patch change
if (!K1 && !K2 && K3 &&!K4) { //send reverb pitchlatch value
reverb = ((pitchlatch - 36) * 2);
if (reverb > 127) {reverb = 127;}
if (reverb < 0) {reverb = 0;}
usbMIDI.sendControlChange(91,reverb, activeMIDIchannel);
dinMIDIsendControlChange(91,reverb, activeMIDIchannel - 1);
reverb = ((pitchlatch - 36) * 2);
if (reverb > 127) {reverb = 127;}
if (reverb < 0) {reverb = 0;}
midiSendControlChange(91,reverb);
}
}
@ -876,47 +876,35 @@ void mainLoop() {
// breathCC value is from cclist[] which assigns controller number
if (K1) { //turn on midi volume
breathCC = 3;
usbMIDI.sendControlChange(7,0, activeMIDIchannel); //midi vol to 0
dinMIDIsendControlChange(7,0, activeMIDIchannel - 1);
usbMIDI.sendControlChange(11,127, activeMIDIchannel); //midi expression to 127
dinMIDIsendControlChange(11,127, activeMIDIchannel - 1);
midiSendControlChange(7,0); //midi vol to 0
midiSendControlChange(11,127); //midi expression to 127
}
if (K3) { //turn on midi breath controller
breathCC = 2;
usbMIDI.sendControlChange(7,127, activeMIDIchannel); //midi vol to 127
dinMIDIsendControlChange(7,127, activeMIDIchannel - 1);
usbMIDI.sendControlChange(11,127, activeMIDIchannel); //midi expression to 127
dinMIDIsendControlChange(11,127, activeMIDIchannel - 1);
midiSendControlChange(7,127); //midi vol to 127
midiSendControlChange(11,127); //midi expression to 127
}
if (K4) { //sb turn on midi expression
breathCC = 4;
usbMIDI.sendControlChange(7,127, activeMIDIchannel); //midi vol to 127
dinMIDIsendControlChange(7,127, activeMIDIchannel - 1);
usbMIDI.sendControlChange(11,0, activeMIDIchannel); //midi expression to 0
dinMIDIsendControlChange(11,0, activeMIDIchannel - 1);
midiSendControlChange(7,127); //midi vol to 127
midiSendControlChange(11,0); //midi expression to 0
}
if (K2) { //2v turn on aftertouch
breathAT = 1;
usbMIDI.sendControlChange(7,127, activeMIDIchannel); //midi vol to 127
dinMIDIsendControlChange(7,127, activeMIDIchannel - 1);
usbMIDI.sendControlChange(11,127, activeMIDIchannel); //midi expression to 0
dinMIDIsendControlChange(11,127, activeMIDIchannel - 1);
midiSendControlChange(7,127); //midi vol to 127
midiSendControlChange(11,127); //midi expression to 0
}
else { breathAT = 0; }
if (K5) { //1tr turn on velocity
velocity = 0;
usbMIDI.sendControlChange(7,127, activeMIDIchannel); //midi vol to 127
dinMIDIsendControlChange(7,127, activeMIDIchannel - 1);
usbMIDI.sendControlChange(11,127, activeMIDIchannel); //midi expression to 0
dinMIDIsendControlChange(11,127, activeMIDIchannel - 1);
midiSendControlChange(7,127); //midi vol to 127
midiSendControlChange(11,127); //midi expression to 0
}
else { velocity = 127; }
if (!K1 && !K3 && !K4) {
breathCC = 0;
usbMIDI.sendControlChange(7,127, activeMIDIchannel); //midi vol to 127
dinMIDIsendControlChange(7,127, activeMIDIchannel - 1);
usbMIDI.sendControlChange(11,127, activeMIDIchannel); //midi expression to 127
dinMIDIsendControlChange(11,127, activeMIDIchannel - 1);
midiSendControlChange(7,127); //midi vol to 127
midiSendControlChange(11,127); //midi expression to 127
}
}
}
@ -986,41 +974,33 @@ void mainLoop() {
breath(); // send breath data
fingeredNote=noteValueCheck(fingeredNote);
if (priority){ // mono prio to last chord note
usbMIDI.sendNoteOn(fingeredNote, velocitySend, activeMIDIchannel); // send Note On message for new note
dinMIDIsendNoteOn(fingeredNote, velocitySend, activeMIDIchannel - 1);
midiSendNoteOn(fingeredNote, velocitySend); // send Note On message for new note
}
if (parallelChord){
for (int i=0; i < addedIntervals; i++){
usbMIDI.sendNoteOn(noteValueCheck(fingeredNote+slurInterval[i]), velocitySend, activeMIDIchannel); // send Note On message for new note
dinMIDIsendNoteOn(noteValueCheck(fingeredNote+slurInterval[i]), velocitySend, activeMIDIchannel - 1);
midiSendNoteOn(noteValueCheck(fingeredNote+slurInterval[i]), velocitySend); // send Note On message for new note
}
}
if (slurSustain){
usbMIDI.sendControlChange(64,127, activeMIDIchannel);
dinMIDIsendControlChange(64,127, activeMIDIchannel - 1);
midiSendControlChange(64,127);
slurBase = fingeredNote;
addedIntervals = 0;
}
if (subOctaveDouble){
usbMIDI.sendNoteOn(noteValueCheck(fingeredNote-12), velocitySend, activeMIDIchannel);
dinMIDIsendNoteOn(noteValueCheck(fingeredNote-12), velocitySend, activeMIDIchannel - 1);
midiSendNoteOn(noteValueCheck(fingeredNote-12), velocitySend);
if (parallelChord){
for (int i=0; i < addedIntervals; i++){
usbMIDI.sendNoteOn(noteValueCheck(fingeredNote+slurInterval[i]-12), velocitySend, activeMIDIchannel); // send Note On message for new note
dinMIDIsendNoteOn(noteValueCheck(fingeredNote+slurInterval[i]-12), velocitySend, activeMIDIchannel - 1);
midiSendNoteOn(noteValueCheck(fingeredNote+slurInterval[i]-12), velocitySend); // send Note On message for new note
}
}
}
if (rotatorOn){
usbMIDI.sendNoteOn(noteValueCheck(fingeredNote+parallel), velocitySend, activeMIDIchannel); // send Note On message for new note
dinMIDIsendNoteOn(noteValueCheck(fingeredNote+parallel), velocitySend, activeMIDIchannel - 1);
midiSendNoteOn(noteValueCheck(fingeredNote+parallel), velocitySend); // send Note On message for new note
if (currentRotation < 3) currentRotation++; else currentRotation = 0;
usbMIDI.sendNoteOn(noteValueCheck(fingeredNote+rotations[currentRotation]), velocitySend, activeMIDIchannel); // send Note On message for new note
dinMIDIsendNoteOn(noteValueCheck(fingeredNote+rotations[currentRotation]), velocitySend, activeMIDIchannel - 1);
midiSendNoteOn(noteValueCheck(fingeredNote+rotations[currentRotation]), velocitySend); // send Note On message for new note
}
if (!priority){ // mono prio to base note
usbMIDI.sendNoteOn(fingeredNote, velocitySend, activeMIDIchannel); // send Note On message for new note
dinMIDIsendNoteOn(fingeredNote, velocitySend, activeMIDIchannel - 1);
midiSendNoteOn(fingeredNote, velocitySend); // send Note On message for new note
}
activeNote=fingeredNote;
mainState = NOTE_ON;
@ -1035,38 +1015,30 @@ void mainLoop() {
// Value has fallen below threshold - turn the note off
activeNote=noteValueCheck(activeNote);
if (priority){
usbMIDI.sendNoteOff(activeNote, velocitySend, activeMIDIchannel); // send Note Off message
dinMIDIsendNoteOff(activeNote, velocitySend, activeMIDIchannel - 1);
midiSendNoteOff(activeNote); // send Note Off message
}
if (parallelChord){
for (int i=0; i < addedIntervals; i++){
usbMIDI.sendNoteOff(noteValueCheck(activeNote+slurInterval[i]), velocitySend, activeMIDIchannel); // send Note On message for new note
dinMIDIsendNoteOff(noteValueCheck(activeNote+slurInterval[i]), velocitySend, activeMIDIchannel - 1);
midiSendNoteOff(noteValueCheck(activeNote+slurInterval[i])); // send Note On message for new note
}
}
if (subOctaveDouble){
usbMIDI.sendNoteOff(noteValueCheck(activeNote-12), velocitySend, activeMIDIchannel);
dinMIDIsendNoteOff(noteValueCheck(activeNote-12), velocitySend, activeMIDIchannel - 1);
midiSendNoteOff(noteValueCheck(activeNote-12));
if (parallelChord){
for (int i=0; i < addedIntervals; i++){
usbMIDI.sendNoteOff(noteValueCheck(activeNote+slurInterval[i]-12), velocitySend, activeMIDIchannel); // send Note On message for new note
dinMIDIsendNoteOff(noteValueCheck(activeNote+slurInterval[i]-12), velocitySend, activeMIDIchannel - 1);
midiSendNoteOff(noteValueCheck(activeNote+slurInterval[i]-12)); // send Note On message for new note
}
}
}
if (rotatorOn){
usbMIDI.sendNoteOff(noteValueCheck(activeNote+parallel), velocitySend, activeMIDIchannel); // send Note Off message for old note
dinMIDIsendNoteOff(noteValueCheck(activeNote+parallel), velocitySend, activeMIDIchannel - 1);
usbMIDI.sendNoteOff(noteValueCheck(activeNote+rotations[currentRotation]), velocitySend, activeMIDIchannel); // send Note Off message for old note
dinMIDIsendNoteOff(noteValueCheck(activeNote+rotations[currentRotation]), velocitySend, activeMIDIchannel - 1);
midiSendNoteOff(noteValueCheck(activeNote+parallel)); // send Note Off message for old note
midiSendNoteOff(noteValueCheck(activeNote+rotations[currentRotation])); // send Note Off message for old note
}
if (!priority){
usbMIDI.sendNoteOff(activeNote, velocitySend, activeMIDIchannel); // send Note Off message
dinMIDIsendNoteOff(activeNote, velocitySend, activeMIDIchannel - 1);
midiSendNoteOff(activeNote); // send Note Off message
}
if (slurSustain){
usbMIDI.sendControlChange(64,0, activeMIDIchannel);
dinMIDIsendControlChange(64,0, activeMIDIchannel - 1);
midiSendControlChange(64,0);
}
breathLevel=0;
mainState = NOTE_OFF;
@ -1091,75 +1063,60 @@ void mainLoop() {
}
activeNote=noteValueCheck(activeNote);
if ((parallelChord || subOctaveDouble || rotatorOn) && priority){ // poly playing, send old note off before new note on
usbMIDI.sendNoteOff(activeNote, velocitySend, activeMIDIchannel); // send Note Off message for old note
dinMIDIsendNoteOff(activeNote, velocitySend, activeMIDIchannel - 1);
midiSendNoteOff(activeNote); // send Note Off message for old note
}
if (parallelChord){
for (int i=0; i < addedIntervals; i++){
usbMIDI.sendNoteOff(noteValueCheck(activeNote+slurInterval[i]), velocitySend, activeMIDIchannel); // send Note Off message for old note
dinMIDIsendNoteOff(noteValueCheck(activeNote+slurInterval[i]), velocitySend, activeMIDIchannel - 1);
midiSendNoteOff(noteValueCheck(activeNote+slurInterval[i])); // send Note Off message for old note
}
}
if (subOctaveDouble){
usbMIDI.sendNoteOff(noteValueCheck(activeNote-12), velocitySend, activeMIDIchannel); // send Note Off message for old note
dinMIDIsendNoteOff(noteValueCheck(activeNote-12), velocitySend, activeMIDIchannel - 1);
midiSendNoteOff(noteValueCheck(activeNote-12)); // send Note Off message for old note
if (parallelChord){
for (int i=0; i < addedIntervals; i++){
usbMIDI.sendNoteOff(noteValueCheck(activeNote+slurInterval[i]-12), velocitySend, activeMIDIchannel); // send Note Off message for old note
dinMIDIsendNoteOff(noteValueCheck(activeNote+slurInterval[i]-12), velocitySend, activeMIDIchannel - 1);
midiSendNoteOff(noteValueCheck(activeNote+slurInterval[i]-12)); // send Note Off message for old note
}
}
}
if (rotatorOn){
usbMIDI.sendNoteOff(noteValueCheck(activeNote+parallel), velocitySend, activeMIDIchannel); // send Note Off message for old note
dinMIDIsendNoteOff(noteValueCheck(activeNote+parallel), velocitySend, activeMIDIchannel - 1);
usbMIDI.sendNoteOff(noteValueCheck(activeNote+rotations[currentRotation]), velocitySend, activeMIDIchannel); // send Note Off message for old note
dinMIDIsendNoteOff(noteValueCheck(activeNote+rotations[currentRotation]), velocitySend, activeMIDIchannel - 1);
midiSendNoteOff(noteValueCheck(activeNote+parallel)); // send Note Off message for old note
midiSendNoteOff(noteValueCheck(activeNote+rotations[currentRotation])); // send Note Off message for old note
}
if ((parallelChord || subOctaveDouble || rotatorOn) && !priority){ // poly playing, send old note off before new note on
usbMIDI.sendNoteOff(activeNote, velocitySend, activeMIDIchannel); // send Note Off message for old note
dinMIDIsendNoteOff(activeNote, velocitySend, activeMIDIchannel - 1);
midiSendNoteOff(activeNote); // send Note Off message for old note
}
fingeredNote=noteValueCheck(fingeredNote);
if (priority){
usbMIDI.sendNoteOn(fingeredNote, velocitySend, activeMIDIchannel); // send Note On message for new note
dinMIDIsendNoteOn(fingeredNote, velocitySend, activeMIDIchannel - 1);
midiSendNoteOn(fingeredNote, velocitySend); // send Note On message for new note
}
if (parallelChord){
for (int i=0; i < addedIntervals; i++){
usbMIDI.sendNoteOn(noteValueCheck(fingeredNote+slurInterval[i]), velocitySend, activeMIDIchannel); // send Note On message for new note
dinMIDIsendNoteOn(noteValueCheck(fingeredNote+slurInterval[i]), velocitySend, activeMIDIchannel - 1);
midiSendNoteOn(noteValueCheck(fingeredNote+slurInterval[i]), velocitySend); // send Note On message for new note
}
}
if (subOctaveDouble){
usbMIDI.sendNoteOn(noteValueCheck(fingeredNote-12), velocitySend, activeMIDIchannel); // send Note On message for new note
dinMIDIsendNoteOn(noteValueCheck(fingeredNote-12), velocitySend, activeMIDIchannel - 1);
midiSendNoteOn(noteValueCheck(fingeredNote-12), velocitySend); // send Note On message for new note
if (parallelChord){
for (int i=0; i < addedIntervals; i++){
usbMIDI.sendNoteOn(noteValueCheck(fingeredNote+slurInterval[i]-12), velocitySend, activeMIDIchannel); // send Note On message for new note
dinMIDIsendNoteOn(noteValueCheck(fingeredNote+slurInterval[i]-12), velocitySend, activeMIDIchannel - 1);
midiSendNoteOn(noteValueCheck(fingeredNote+slurInterval[i]-12), velocitySend); // send Note On message for new note
}
}
}
if (rotatorOn){
usbMIDI.sendNoteOn(noteValueCheck(fingeredNote+parallel), velocitySend, activeMIDIchannel); // send Note On message for new note
dinMIDIsendNoteOn(noteValueCheck(fingeredNote+parallel), velocitySend, activeMIDIchannel - 1);
midiSendNoteOn(noteValueCheck(fingeredNote+parallel), velocitySend); // send Note On message for new note
if (currentRotation < 3) currentRotation++; else currentRotation = 0;
usbMIDI.sendNoteOn(noteValueCheck(fingeredNote+rotations[currentRotation]), velocitySend, activeMIDIchannel); // send Note On message for new note
dinMIDIsendNoteOn(noteValueCheck(fingeredNote+rotations[currentRotation]), velocitySend, activeMIDIchannel - 1);
midiSendNoteOn(noteValueCheck(fingeredNote+rotations[currentRotation]), velocitySend); // send Note On message for new note
}
if (!priority){
usbMIDI.sendNoteOn(fingeredNote, velocitySend, activeMIDIchannel); // send Note On message for new note
dinMIDIsendNoteOn(fingeredNote, velocitySend, activeMIDIchannel - 1);
midiSendNoteOn(fingeredNote, velocitySend); // send Note On message for new note
}
if (!parallelChord && !subOctaveDouble && !rotatorOn){ // mono playing, send old note off after new note on
usbMIDI.sendNoteOff(activeNote, velocitySend, activeMIDIchannel); // send Note Off message
dinMIDIsendNoteOff(activeNote, velocitySend, activeMIDIchannel - 1);
midiSendNoteOff(activeNote); // send Note Off message
}
if (slurSustain){
@ -1204,7 +1161,6 @@ void mainLoop() {
lastFingering=fingeredNote;
//do menu stuff
menu();
}
}
//_______________________________________________________________________________________________ FUNCTIONS
@ -1329,86 +1285,6 @@ int patchLimit(int value){
if (value < 1) return 1; else if (value > 128) return 128; else return value;
}
void midiPanic(){ // all notes off
usbMIDI.sendControlChange(123, 0, activeMIDIchannel);
dinMIDIsendControlChange(123, 0, activeMIDIchannel - 1);
for (int i = 0; i < 128; i++){
usbMIDI.sendNoteOff(i,0,activeMIDIchannel);
dinMIDIsendNoteOff(i,0,activeMIDIchannel - 1);
delay(2);
}
}
//**************************************************************
void midiReset(){ // reset controllers
usbMIDI.sendControlChange(7, 100, activeMIDIchannel);
dinMIDIsendControlChange(7, 100, activeMIDIchannel - 1);
usbMIDI.sendControlChange(11, 127, activeMIDIchannel);
dinMIDIsendControlChange(11, 127, activeMIDIchannel - 1);
}
//**************************************************************
// Send a three byte din midi message
void midiSend3B(byte midistatus, byte data1, byte data2) {
Serial3.write(midistatus);
Serial3.write(data1);
Serial3.write(data2);
}
//**************************************************************
// Send a two byte din midi message
void midiSend2B(byte midistatus, byte data) {
Serial3.write(midistatus);
Serial3.write(data);
}
//**************************************************************
// Send din pitchbend
void dinMIDIsendPitchBend(int pb, byte ch) {
int pitchLSB = pb & 0x007F;
int pitchMSB = (pb >>7) & 0x007F;
midiSend3B((0xE0 | ch), pitchLSB, pitchMSB);
}
//**************************************************************
// Send din control change
void dinMIDIsendControlChange(byte ccNumber, int cc, byte ch) {
midiSend3B((0xB0 | ch), ccNumber, cc);
}
//**************************************************************
// Send din note on
void dinMIDIsendNoteOn(byte note, int vel, byte ch) {
midiSend3B((0x90 | ch), note, vel);
}
//**************************************************************
// Send din note off
void dinMIDIsendNoteOff(byte note, int vel, byte ch) {
midiSend3B((0x80 | ch), note, vel);
}
//**************************************************************
// Send din aftertouch
void dinMIDIsendAfterTouch(byte value, byte ch) {
midiSend2B((0xD0 | ch), value);
}
//**************************************************************
// Send din program change
void dinMIDIsendProgramChange(byte value, byte ch) {
midiSend2B((0xC0 | ch), value);
}
//**************************************************************
void statusLEDs() {
@ -1441,21 +1317,18 @@ void breath(){
if (breathCCval != oldbreath){ // only send midi data if breath has changed from previous value
if (breathCC){
// send midi cc
usbMIDI.sendControlChange(ccList[breathCC], breathCCval, activeMIDIchannel);
dinMIDIsendControlChange(ccList[breathCC], breathCCval, activeMIDIchannel - 1);
midiSendControlChange(ccList[breathCC], breathCCval);
}
if (breathAT){
// send aftertouch
usbMIDI.sendAfterTouch(breathCCval, activeMIDIchannel);
dinMIDIsendAfterTouch(breathCCval, activeMIDIchannel - 1);
midiSendAfterTouch(breathCCval);
}
oldbreath = breathCCval;
}
if (breathCCvalHires != oldbreathhires){
if ((breathCC > 4) && (breathCC < 9)){ // send high resolution midi
usbMIDI.sendControlChange(ccList[breathCC]+32, breathCCvalFine, activeMIDIchannel);
dinMIDIsendControlChange(ccList[breathCC]+32, breathCCvalFine, activeMIDIchannel - 1);
midiSendControlChange(ccList[breathCC]+32, breathCCvalFine);
}
oldbreathhires = breathCCvalHires;
}
@ -1556,12 +1429,7 @@ void pitch_bend(){
//Serial.println(oldpb);
if (pitchBend != oldpb){// only send midi data if pitch bend has changed from previous value
#if defined(NEWTEENSYDUINO)
usbMIDI.sendPitchBend(pitchBend-8192, activeMIDIchannel); // newer teensyduino "pitchBend-8192" older just "pitchBend"... strange thing to change
#else
usbMIDI.sendPitchBend(pitchBend, activeMIDIchannel);
#endif
dinMIDIsendPitchBend(pitchBend, activeMIDIchannel - 1);
midiSendPitchBend(pitchBend);
oldpb=pitchBend;
}
}
@ -1609,31 +1477,27 @@ void extraController(){
if (!extracIsOn) {
extracIsOn=1;
if (extraCT == 4){ //Sustain ON
usbMIDI.sendControlChange(64,127, activeMIDIchannel);
dinMIDIsendControlChange(64,127, activeMIDIchannel - 1);
midiSendControlChange(64, 127);
}
}
if (extraCT == 1){ //Send modulation
int extracCC = map(constrain(exSensor,extracThrVal,extracMaxVal),extracThrVal,extracMaxVal,1,127);
if (extracCC != oldextrac){
usbMIDI.sendControlChange(1,extracCC, activeMIDIchannel);
dinMIDIsendControlChange(1,extracCC, activeMIDIchannel - 1);
midiSendControlChange(1, extracCC);
}
oldextrac = extracCC;
}
if (extraCT == 2){ //Send foot pedal (CC#4)
int extracCC = map(constrain(exSensor,extracThrVal,extracMaxVal),extracThrVal,extracMaxVal,1,127);
if (extracCC != oldextrac){
usbMIDI.sendControlChange(4,extracCC, activeMIDIchannel);
dinMIDIsendControlChange(4,extracCC, activeMIDIchannel - 1);
midiSendControlChange(4, extracCC);
}
oldextrac = extracCC;
}
if ((extraCT == 3) && (breathCC != 9)){ //Send filter cutoff (CC#74)
int extracCC = map(constrain(exSensor,extracThrVal,extracMaxVal),extracThrVal,extracMaxVal,1,127);
if (extracCC != oldextrac){
usbMIDI.sendControlChange(74,extracCC, activeMIDIchannel);
dinMIDIsendControlChange(74,extracCC, activeMIDIchannel - 1);
midiSendControlChange(74, extracCC);
}
oldextrac = extracCC;
}
@ -1642,28 +1506,24 @@ void extraController(){
if (extraCT == 1){ //MW
if (oldextrac != 0){
//send modulation 0
usbMIDI.sendControlChange(1,0, activeMIDIchannel);
dinMIDIsendControlChange(1,0, activeMIDIchannel - 1);
midiSendControlChange(1, 0);
oldextrac = 0;
}
} else if (extraCT == 2){ //FP
if (oldextrac != 0){
//send foot pedal 0
usbMIDI.sendControlChange(4,0, activeMIDIchannel);
dinMIDIsendControlChange(4,0, activeMIDIchannel - 1);
midiSendControlChange(4, 0);
oldextrac = 0;
}
} else if ((extraCT == 3) && (breathCC != 9)){ //CF
if (oldextrac != 0){
//send filter cutoff 0
usbMIDI.sendControlChange(74,0, activeMIDIchannel);
dinMIDIsendControlChange(74,0, activeMIDIchannel - 1);
midiSendControlChange(74, 0);
oldextrac = 0;
}
} else if (extraCT == 4){ //SP
//send sustain off
usbMIDI.sendControlChange(64,0, activeMIDIchannel);
dinMIDIsendControlChange(64,0, activeMIDIchannel - 1);
midiSendControlChange(64, 0);
}
}
}
@ -1687,8 +1547,7 @@ void portamento_(){
void portOn(){
if (portamento == 2){ // if portamento midi switching is enabled
usbMIDI.sendControlChange(CCN_PortOnOff, 127, activeMIDIchannel);
dinMIDIsendControlChange(CCN_PortOnOff, 127, activeMIDIchannel - 1);
midiSendControlChange(CCN_PortOnOff, 127);
}
portIsOn=1;
}
@ -1699,8 +1558,7 @@ void port(){
int portCC;
portCC = map(constrain(biteSensor,portamThrVal,portamMaxVal),portamThrVal,portamMaxVal,0,127);
if (portCC!=oldport){
usbMIDI.sendControlChange(CCN_Port, portCC, activeMIDIchannel);
dinMIDIsendControlChange(CCN_Port, portCC, activeMIDIchannel - 1);
midiSendControlChange(CCN_Port, portCC);
}
oldport = portCC;
}
@ -1709,12 +1567,10 @@ void port(){
void portOff(){
if (oldport != 0){ //did a zero get sent? if not, then send one
usbMIDI.sendControlChange(CCN_Port, 0, activeMIDIchannel);
dinMIDIsendControlChange(CCN_Port, 0, activeMIDIchannel - 1);
midiSendControlChange(CCN_Port, 0);
}
if (portamento == 2){ // if portamento midi switching is enabled
usbMIDI.sendControlChange(CCN_PortOnOff, 0, activeMIDIchannel);
dinMIDIsendControlChange(CCN_PortOnOff, 0, activeMIDIchannel - 1);
midiSendControlChange(CCN_PortOnOff, 0);
}
portIsOn=0;
oldport = 0;