Automated prettifier and tabulator
This commit is contained in:
parent
3aa427fdd5
commit
ca90f8f664
1 changed files with 541 additions and 526 deletions
429
NuEVI.ino
429
NuEVI.ino
|
@ -638,7 +638,7 @@ void setup() {
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
breathFilter.input(analogRead(breathSensorPin));
|
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 = constrain((int) breathFilter.output(), 0, 4095); // Get the filtered pressure sensor reading from analog pin A0, input from sensor MP3V5004GP
|
||||||
//pressureSensor = analogRead(A0);
|
//pressureSensor = analogRead(A0);
|
||||||
//pressureSensor = smooth(analogRead(0), filterVal, smoothedVal); // second parameter determines smoothness - 0 is off, .9999 is max smooth
|
//pressureSensor = smooth(analogRead(0), filterVal, smoothedVal); // second parameter determines smoothness - 0 is off, .9999 is max smooth
|
||||||
if (mainState == NOTE_OFF) {
|
if (mainState == NOTE_OFF) {
|
||||||
|
@ -662,10 +662,10 @@ void loop() {
|
||||||
mainState = RISE_WAIT; // Go to next state
|
mainState = RISE_WAIT; // Go to next state
|
||||||
}
|
}
|
||||||
if (legacy || legacyBrAct) {
|
if (legacy || legacyBrAct) {
|
||||||
if (((pbUp > ((pitchbMaxVal + pitchbThrVal)/2)) && (pbDn > ((pitchbMaxVal + pitchbThrVal)/2)) && legacy) || ((analogRead(0) < (breathCalZero - 800)) && legacyBrAct) && (pbUp > ((pitchbMaxVal + pitchbThrVal)/2)) && (pbDn < ((pitchbMaxVal + pitchbThrVal)/2))) { // both pb pads touched or br suck
|
if (((pbUp > ((pitchbMaxVal + pitchbThrVal) / 2)) && (pbDn > ((pitchbMaxVal + pitchbThrVal) / 2)) && legacy) || ((analogRead(0) < (breathCalZero - 800)) && legacyBrAct) && (pbUp > ((pitchbMaxVal + pitchbThrVal) / 2)) && (pbDn < ((pitchbMaxVal + pitchbThrVal) / 2))) { // both pb pads touched or br suck
|
||||||
readSwitches();
|
readSwitches();
|
||||||
fingeredNoteUntransposed=patchLimit(fingeredNoteUntransposed+1);
|
fingeredNoteUntransposed = patchLimit(fingeredNoteUntransposed + 1);
|
||||||
if (exSensor >= ((extracThrVal+extracMaxVal)/2)){ // instant midi setting
|
if (exSensor >= ((extracThrVal + extracMaxVal) / 2)) { // instant midi setting
|
||||||
if ((fingeredNoteUntransposed >= 73) && (fingeredNoteUntransposed <= 88)) {
|
if ((fingeredNoteUntransposed >= 73) && (fingeredNoteUntransposed <= 88)) {
|
||||||
MIDIchannel = fingeredNoteUntransposed - 72; // Mid C and up
|
MIDIchannel = fingeredNoteUntransposed - 72; // Mid C and up
|
||||||
digitalWrite(statusLedPin, LOW);
|
digitalWrite(statusLedPin, LOW);
|
||||||
|
@ -673,8 +673,8 @@ void loop() {
|
||||||
digitalWrite(statusLedPin, HIGH);
|
digitalWrite(statusLedPin, HIGH);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!pinkyKey){ // note number to patch number
|
if (!pinkyKey) { // note number to patch number
|
||||||
if (patch != fingeredNoteUntransposed){
|
if (patch != fingeredNoteUntransposed) {
|
||||||
patch = fingeredNoteUntransposed;
|
patch = fingeredNoteUntransposed;
|
||||||
doPatchUpdate = 1;
|
doPatchUpdate = 1;
|
||||||
digitalWrite(statusLedPin, LOW);
|
digitalWrite(statusLedPin, LOW);
|
||||||
|
@ -682,8 +682,8 @@ void loop() {
|
||||||
digitalWrite(statusLedPin, HIGH);
|
digitalWrite(statusLedPin, HIGH);
|
||||||
}
|
}
|
||||||
} else { // hi and lo patch numbers
|
} else { // hi and lo patch numbers
|
||||||
if (fingeredNoteUntransposed > 75){
|
if (fingeredNoteUntransposed > 75) {
|
||||||
if (patch != patchLimit(fingeredNoteUntransposed + 24)){
|
if (patch != patchLimit(fingeredNoteUntransposed + 24)) {
|
||||||
patch = patchLimit(fingeredNoteUntransposed + 24); // add 24 to get high numbers 108 to 127
|
patch = patchLimit(fingeredNoteUntransposed + 24); // add 24 to get high numbers 108 to 127
|
||||||
doPatchUpdate = 1;
|
doPatchUpdate = 1;
|
||||||
digitalWrite(statusLedPin, LOW);
|
digitalWrite(statusLedPin, LOW);
|
||||||
|
@ -691,7 +691,7 @@ void loop() {
|
||||||
digitalWrite(statusLedPin, HIGH);
|
digitalWrite(statusLedPin, HIGH);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (patch != patchLimit(fingeredNoteUntransposed - 36)){
|
if (patch != patchLimit(fingeredNoteUntransposed - 36)) {
|
||||||
patch = patchLimit(fingeredNoteUntransposed - 36); // subtract 36 to get low numbers 0 to 36
|
patch = patchLimit(fingeredNoteUntransposed - 36); // subtract 36 to get low numbers 0 to 36
|
||||||
doPatchUpdate = 1;
|
doPatchUpdate = 1;
|
||||||
digitalWrite(statusLedPin, LOW);
|
digitalWrite(statusLedPin, LOW);
|
||||||
|
@ -701,22 +701,36 @@ void loop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
if (pbDn > (pitchbMaxVal + pitchbThrVal) / 2 && (analogRead(0) < (breathCalZero - 800)) && programonce == false) { // down bend for suck programming button
|
||||||
if (pbDn > (pitchbMaxVal + pitchbThrVal)/2 && (analogRead(0) < (breathCalZero - 800)) && programonce == false) { // down bend for suck programming button
|
|
||||||
programonce = true;
|
programonce = true;
|
||||||
readSwitches();
|
readSwitches();
|
||||||
|
|
||||||
if (octaveR == 0) { //lowest octave position
|
if (octaveR == 0) { //lowest octave position
|
||||||
if (K1 && K2 && !K3 &&K4) { patch = patch -10; doPatchUpdate = 1; } // e28 send patch change -10
|
|
||||||
else if (K1 && !K2 && !K3 && K4) { patch--; doPatchUpdate = 1; } //f29 decrement and send patch change
|
if (K1 && K2 && !K3 && K4) { // e28 send patch change -10
|
||||||
else if (!K1 && K2 && !K3 && K4) {patch = patch +10; doPatchUpdate = 1; } //f#30 send patch change +10
|
patch = patch - 10;
|
||||||
else if (!K1 && !K2 && !K3 &&K4) { patch++; doPatchUpdate = 1; } //g31 increment and send patch change
|
doPatchUpdate = 1;
|
||||||
if (!K1 && !K2 && K3 &&!K4) { //send reverb pitchlatch value
|
} else if (K1 && !K2 && !K3 && K4) { //f29 decrement and send patch change
|
||||||
|
patch--;
|
||||||
|
doPatchUpdate = 1;
|
||||||
|
} else if (!K1 && K2 && !K3 && K4) { //f#30 send patch change +10
|
||||||
|
patch = patch + 10;
|
||||||
|
doPatchUpdate = 1;
|
||||||
|
} else if (!K1 && !K2 && !K3 && K4) { //g31 increment and send patch change
|
||||||
|
patch++;
|
||||||
|
doPatchUpdate = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!K1 && !K2 && K3 && !K4) { //send reverb pitchlatch value
|
||||||
reverb = ((pitchlatch - 36) * 2);
|
reverb = ((pitchlatch - 36) * 2);
|
||||||
if (reverb > 127) {reverb = 127;}
|
if (reverb > 127) {
|
||||||
if (reverb < 0) {reverb = 0;}
|
reverb = 127;
|
||||||
midiSendControlChange(91,reverb);
|
}
|
||||||
|
if (reverb < 0) {
|
||||||
|
reverb = 0;
|
||||||
|
}
|
||||||
|
midiSendControlChange(91, reverb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -724,35 +738,37 @@ void loop() {
|
||||||
// breathCC value is from cclist[] which assigns controller number
|
// breathCC value is from cclist[] which assigns controller number
|
||||||
if (K1) { //turn on midi volume
|
if (K1) { //turn on midi volume
|
||||||
breathCC = 3;
|
breathCC = 3;
|
||||||
midiSendControlChange(7,0); //midi vol to 0
|
midiSendControlChange(7, 0); //midi vol to 0
|
||||||
midiSendControlChange(11,127); //midi expression to 127
|
midiSendControlChange(11, 127); //midi expression to 127
|
||||||
}
|
}
|
||||||
if (K3) { //turn on midi breath controller
|
if (K3) { //turn on midi breath controller
|
||||||
breathCC = 2;
|
breathCC = 2;
|
||||||
midiSendControlChange(7,127); //midi vol to 127
|
midiSendControlChange(7, 127); //midi vol to 127
|
||||||
midiSendControlChange(11,127); //midi expression to 127
|
midiSendControlChange(11, 127); //midi expression to 127
|
||||||
}
|
}
|
||||||
if (K4) { //sb turn on midi expression
|
if (K4) { //sb turn on midi expression
|
||||||
breathCC = 4;
|
breathCC = 4;
|
||||||
midiSendControlChange(7,127); //midi vol to 127
|
midiSendControlChange(7, 127); //midi vol to 127
|
||||||
midiSendControlChange(11,0); //midi expression to 0
|
midiSendControlChange(11, 0); //midi expression to 0
|
||||||
}
|
}
|
||||||
if (K2) { //2v turn on aftertouch
|
if (K2) { //2v turn on aftertouch
|
||||||
breathAT = 1;
|
breathAT = 1;
|
||||||
midiSendControlChange(7,127); //midi vol to 127
|
midiSendControlChange(7, 127); //midi vol to 127
|
||||||
midiSendControlChange(11,127); //midi expression to 0
|
midiSendControlChange(11, 127); //midi expression to 0
|
||||||
|
} else {
|
||||||
|
breathAT = 0;
|
||||||
}
|
}
|
||||||
else { breathAT = 0; }
|
|
||||||
if (K5) { //1tr turn on velocity
|
if (K5) { //1tr turn on velocity
|
||||||
velocity = 0;
|
velocity = 0;
|
||||||
midiSendControlChange(7,127); //midi vol to 127
|
midiSendControlChange(7, 127); //midi vol to 127
|
||||||
midiSendControlChange(11,127); //midi expression to 0
|
midiSendControlChange(11, 127); //midi expression to 0
|
||||||
|
} else {
|
||||||
|
velocity = 127;
|
||||||
}
|
}
|
||||||
else { velocity = 127; }
|
|
||||||
if (!K1 && !K3 && !K4) {
|
if (!K1 && !K3 && !K4) {
|
||||||
breathCC = 0;
|
breathCC = 0;
|
||||||
midiSendControlChange(7,127); //midi vol to 127
|
midiSendControlChange(7, 127); //midi vol to 127
|
||||||
midiSendControlChange(11,127); //midi expression to 127
|
midiSendControlChange(11, 127); //midi expression to 127
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -761,10 +777,9 @@ void loop() {
|
||||||
|
|
||||||
if (analogRead(0) > (breathCalZero - 800)) programonce = false;
|
if (analogRead(0) > (breathCalZero - 800)) programonce = false;
|
||||||
|
|
||||||
|
specialKey = (touchRead(specialKeyPin) > touch_Thr); //S2 on pcb
|
||||||
specialKey=(touchRead(specialKeyPin) > touch_Thr); //S2 on pcb
|
if (lastSpecialKey != specialKey) {
|
||||||
if (lastSpecialKey != specialKey ){
|
if (specialKey) {
|
||||||
if (specialKey){
|
|
||||||
// special key just pressed, check other keys
|
// special key just pressed, check other keys
|
||||||
readSwitches();
|
readSwitches();
|
||||||
if (K4) {
|
if (K4) {
|
||||||
|
@ -787,13 +802,13 @@ void loop() {
|
||||||
rotatorOn = 0;
|
rotatorOn = 0;
|
||||||
} else subOctaveDouble = 0;
|
} else subOctaveDouble = 0;
|
||||||
}
|
}
|
||||||
if (!K1 && !K4 && !K5){
|
if (!K1 && !K4 && !K5) {
|
||||||
slurSustain = 0;
|
slurSustain = 0;
|
||||||
parallelChord = 0;
|
parallelChord = 0;
|
||||||
subOctaveDouble = 0;
|
subOctaveDouble = 0;
|
||||||
rotatorOn = 0;
|
rotatorOn = 0;
|
||||||
}
|
}
|
||||||
if (pinkyKey){
|
if (pinkyKey) {
|
||||||
if (!rotatorOn) {
|
if (!rotatorOn) {
|
||||||
rotatorOn = 1;
|
rotatorOn = 1;
|
||||||
slurSustain = 0;
|
slurSustain = 0;
|
||||||
|
@ -812,45 +827,46 @@ void loop() {
|
||||||
// Yes, so calculate MIDI note and velocity, then send a note on event
|
// Yes, so calculate MIDI note and velocity, then send a note on event
|
||||||
readSwitches();
|
readSwitches();
|
||||||
// We should be at tonguing peak, so set velocity based on current pressureSensor value unless fixed velocity is set
|
// We should be at tonguing peak, so set velocity based on current pressureSensor value unless fixed velocity is set
|
||||||
breathLevel=constrain(max(pressureSensor,initial_breath_value),breathThrVal,breathMaxVal);
|
breathLevel = constrain(max(pressureSensor, initial_breath_value), breathThrVal, breathMaxVal);
|
||||||
if (!velocity) {
|
if (!velocity) {
|
||||||
unsigned int breathValHires = breathCurve(map(constrain(breathLevel,breathThrVal,breathMaxVal),breathThrVal,breathMaxVal,0,16383));
|
unsigned int breathValHires = breathCurve(map(constrain(breathLevel, breathThrVal, breathMaxVal), breathThrVal, breathMaxVal, 0, 16383));
|
||||||
velocitySend = (breathValHires >>7) & 0x007F;
|
velocitySend = (breathValHires >> 7) & 0x007F;
|
||||||
velocitySend = constrain(velocitySend+velocitySend*.1*velBias,1,127);
|
velocitySend = constrain(velocitySend + velocitySend * .1 * velBias, 1, 127);
|
||||||
//velocitySend = map(constrain(max(pressureSensor,initial_breath_value),breathThrVal,breathMaxVal),breathThrVal,breathMaxVal,1,127);
|
//velocitySend = map(constrain(max(pressureSensor,initial_breath_value),breathThrVal,breathMaxVal),breathThrVal,breathMaxVal,1,127);
|
||||||
} else velocitySend = velocity;
|
} else velocitySend = velocity;
|
||||||
breath(); // send breath data
|
breath(); // send breath data
|
||||||
fingeredNote=noteValueCheck(fingeredNote);
|
fingeredNote = noteValueCheck(fingeredNote);
|
||||||
if (priority){ // mono prio to last chord note
|
if (priority) { // mono prio to last chord note
|
||||||
midiSendNoteOn(fingeredNote, velocitySend); // send Note On message for new note
|
midiSendNoteOn(fingeredNote, velocitySend); // send Note On message for new note
|
||||||
}
|
}
|
||||||
if (parallelChord) {
|
if (parallelChord) {
|
||||||
for (int i=0; i < addedIntervals; i++) {
|
for (int i = 0; i < addedIntervals; i++) {
|
||||||
midiSendNoteOn(noteValueCheck(fingeredNote+slurInterval[i]), velocitySend); // send Note On message for new note
|
midiSendNoteOn(noteValueCheck(fingeredNote + slurInterval[i]), velocitySend); // send Note On message for new note
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (slurSustain) {
|
if (slurSustain) {
|
||||||
midiSendControlChange(64,127);
|
midiSendControlChange(64, 127);
|
||||||
slurBase = fingeredNote;
|
slurBase = fingeredNote;
|
||||||
addedIntervals = 0;
|
addedIntervals = 0;
|
||||||
}
|
}
|
||||||
if (subOctaveDouble) {
|
if (subOctaveDouble) {
|
||||||
midiSendNoteOn(noteValueCheck(fingeredNote-12), velocitySend);
|
midiSendNoteOn(noteValueCheck(fingeredNote - 12), velocitySend);
|
||||||
if (parallelChord){
|
if (parallelChord) {
|
||||||
for (int i=0; i < addedIntervals; i++) {
|
for (int i = 0; i < addedIntervals; i++) {
|
||||||
midiSendNoteOn(noteValueCheck(fingeredNote+slurInterval[i]-12), velocitySend); // send Note On message for new note
|
midiSendNoteOn(noteValueCheck(fingeredNote + slurInterval[i] - 12), velocitySend); // send Note On message for new note
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rotatorOn) {
|
if (rotatorOn) {
|
||||||
midiSendNoteOn(noteValueCheck(fingeredNote+parallel), velocitySend); // send Note On message for new note
|
midiSendNoteOn(noteValueCheck(fingeredNote + parallel), velocitySend); // send Note On message for new note
|
||||||
if (currentRotation < 3) currentRotation++; else currentRotation = 0;
|
if (currentRotation < 3) currentRotation++;
|
||||||
midiSendNoteOn(noteValueCheck(fingeredNote+rotations[currentRotation]), velocitySend); // send Note On message for new note
|
else currentRotation = 0;
|
||||||
|
midiSendNoteOn(noteValueCheck(fingeredNote + rotations[currentRotation]), velocitySend); // send Note On message for new note
|
||||||
}
|
}
|
||||||
if (!priority) { // mono prio to base note
|
if (!priority) { // mono prio to base note
|
||||||
midiSendNoteOn(fingeredNote, velocitySend); // send Note On message for new note
|
midiSendNoteOn(fingeredNote, velocitySend); // send Note On message for new note
|
||||||
}
|
}
|
||||||
activeNote=fingeredNote;
|
activeNote = fingeredNote;
|
||||||
mainState = NOTE_ON;
|
mainState = NOTE_ON;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -861,38 +877,38 @@ void loop() {
|
||||||
} else if (mainState == NOTE_ON) {
|
} else if (mainState == NOTE_ON) {
|
||||||
if ((pressureSensor < breathThrVal) && !gateOpen) {
|
if ((pressureSensor < breathThrVal) && !gateOpen) {
|
||||||
// Value has fallen below threshold - turn the note off
|
// Value has fallen below threshold - turn the note off
|
||||||
activeNote=noteValueCheck(activeNote);
|
activeNote = noteValueCheck(activeNote);
|
||||||
if (priority){
|
if (priority) {
|
||||||
midiSendNoteOff(activeNote); // send Note Off message
|
midiSendNoteOff(activeNote); // send Note Off message
|
||||||
}
|
}
|
||||||
if (parallelChord) {
|
if (parallelChord) {
|
||||||
for (int i=0; i < addedIntervals; i++){
|
for (int i = 0; i < addedIntervals; i++) {
|
||||||
midiSendNoteOff(noteValueCheck(activeNote+slurInterval[i])); // send Note On message for new note
|
midiSendNoteOff(noteValueCheck(activeNote + slurInterval[i])); // send Note On message for new note
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (subOctaveDouble) {
|
if (subOctaveDouble) {
|
||||||
midiSendNoteOff(noteValueCheck(activeNote-12));
|
midiSendNoteOff(noteValueCheck(activeNote - 12));
|
||||||
if (parallelChord){
|
if (parallelChord) {
|
||||||
for (int i=0; i < addedIntervals; i++) {
|
for (int i = 0; i < addedIntervals; i++) {
|
||||||
midiSendNoteOff(noteValueCheck(activeNote+slurInterval[i]-12)); // send Note On message for new note
|
midiSendNoteOff(noteValueCheck(activeNote + slurInterval[i] - 12)); // send Note On message for new note
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rotatorOn) {
|
if (rotatorOn) {
|
||||||
midiSendNoteOff(noteValueCheck(activeNote+parallel)); // send Note Off message for old note
|
midiSendNoteOff(noteValueCheck(activeNote + parallel)); // send Note Off message for old note
|
||||||
midiSendNoteOff(noteValueCheck(activeNote+rotations[currentRotation])); // send Note Off message for old note
|
midiSendNoteOff(noteValueCheck(activeNote + rotations[currentRotation])); // send Note Off message for old note
|
||||||
}
|
}
|
||||||
if (!priority) {
|
if (!priority) {
|
||||||
midiSendNoteOff(activeNote); // send Note Off message
|
midiSendNoteOff(activeNote); // send Note Off message
|
||||||
}
|
}
|
||||||
if (slurSustain) {
|
if (slurSustain) {
|
||||||
midiSendControlChange(64,0);
|
midiSendControlChange(64, 0);
|
||||||
}
|
}
|
||||||
breathLevel=0;
|
breathLevel = 0;
|
||||||
mainState = NOTE_OFF;
|
mainState = NOTE_OFF;
|
||||||
} else {
|
} else {
|
||||||
readSwitches();
|
readSwitches();
|
||||||
if (fingeredNote != lastFingering){ //
|
if (fingeredNote != lastFingering) { //
|
||||||
// reset the debouncing timer
|
// reset the debouncing timer
|
||||||
lastDeglitchTime = millis();
|
lastDeglitchTime = millis();
|
||||||
}
|
}
|
||||||
|
@ -904,59 +920,59 @@ void loop() {
|
||||||
// Send a note off for the current note and a note on for
|
// Send a note off for the current note and a note on for
|
||||||
// the new note.
|
// the new note.
|
||||||
if (!velocity) {
|
if (!velocity) {
|
||||||
unsigned int breathValHires = breathCurve(map(constrain(breathLevel,breathThrVal,breathMaxVal),breathThrVal,breathMaxVal,0,16383));
|
unsigned int breathValHires = breathCurve(map(constrain(breathLevel, breathThrVal, breathMaxVal), breathThrVal, breathMaxVal, 0, 16383));
|
||||||
velocitySend = (breathValHires >>7) & 0x007F;
|
velocitySend = (breathValHires >> 7) & 0x007F;
|
||||||
velocitySend = constrain(velocitySend+velocitySend*.1*velBias,1,127);
|
velocitySend = constrain(velocitySend + velocitySend * .1 * velBias, 1, 127);
|
||||||
//velocitySend = map(constrain(pressureSensor,breathThrVal,breathMaxVal),breathThrVal,breathMaxVal,7,127); // set new velocity value based on current pressure sensor level
|
//velocitySend = map(constrain(pressureSensor,breathThrVal,breathMaxVal),breathThrVal,breathMaxVal,7,127); // set new velocity value based on current pressure sensor level
|
||||||
}
|
}
|
||||||
activeNote=noteValueCheck(activeNote);
|
activeNote = noteValueCheck(activeNote);
|
||||||
if ((parallelChord || subOctaveDouble || rotatorOn) && priority){ // poly playing, send old note off before new note on
|
if ((parallelChord || subOctaveDouble || rotatorOn) && priority) { // poly playing, send old note off before new note on
|
||||||
midiSendNoteOff(activeNote); // send Note Off message for old note
|
midiSendNoteOff(activeNote); // send Note Off message for old note
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parallelChord) {
|
if (parallelChord) {
|
||||||
for (int i=0; i < addedIntervals; i++) {
|
for (int i = 0; i < addedIntervals; i++) {
|
||||||
midiSendNoteOff(noteValueCheck(activeNote+slurInterval[i])); // send Note Off message for old note
|
midiSendNoteOff(noteValueCheck(activeNote + slurInterval[i])); // send Note Off message for old note
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (subOctaveDouble) {
|
if (subOctaveDouble) {
|
||||||
midiSendNoteOff(noteValueCheck(activeNote-12)); // send Note Off message for old note
|
midiSendNoteOff(noteValueCheck(activeNote - 12)); // send Note Off message for old note
|
||||||
if (parallelChord){
|
if (parallelChord) {
|
||||||
for (int i=0; i < addedIntervals; i++) {
|
for (int i = 0; i < addedIntervals; i++) {
|
||||||
midiSendNoteOff(noteValueCheck(activeNote+slurInterval[i]-12)); // send Note Off message for old note
|
midiSendNoteOff(noteValueCheck(activeNote + slurInterval[i] - 12)); // send Note Off message for old note
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rotatorOn) {
|
if (rotatorOn) {
|
||||||
midiSendNoteOff(noteValueCheck(activeNote+parallel)); // send Note Off message for old note
|
midiSendNoteOff(noteValueCheck(activeNote + parallel)); // send Note Off message for old note
|
||||||
midiSendNoteOff(noteValueCheck(activeNote+rotations[currentRotation])); // 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
|
if ((parallelChord || subOctaveDouble || rotatorOn) && !priority) { // poly playing, send old note off before new note on
|
||||||
midiSendNoteOff(activeNote); // send Note Off message for old note
|
midiSendNoteOff(activeNote); // send Note Off message for old note
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fingeredNote = noteValueCheck(fingeredNote);
|
||||||
fingeredNote=noteValueCheck(fingeredNote);
|
|
||||||
if (priority) {
|
if (priority) {
|
||||||
midiSendNoteOn(fingeredNote, velocitySend); // send Note On message for new note
|
midiSendNoteOn(fingeredNote, velocitySend); // send Note On message for new note
|
||||||
}
|
}
|
||||||
if (parallelChord) {
|
if (parallelChord) {
|
||||||
for (int i=0; i < addedIntervals; i++){
|
for (int i = 0; i < addedIntervals; i++) {
|
||||||
midiSendNoteOn(noteValueCheck(fingeredNote+slurInterval[i]), velocitySend); // send Note On message for new note
|
midiSendNoteOn(noteValueCheck(fingeredNote + slurInterval[i]), velocitySend); // send Note On message for new note
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (subOctaveDouble) {
|
if (subOctaveDouble) {
|
||||||
midiSendNoteOn(noteValueCheck(fingeredNote-12), velocitySend); // send Note On message for new note
|
midiSendNoteOn(noteValueCheck(fingeredNote - 12), velocitySend); // send Note On message for new note
|
||||||
if (parallelChord){
|
if (parallelChord) {
|
||||||
for (int i=0; i < addedIntervals; i++) {
|
for (int i = 0; i < addedIntervals; i++) {
|
||||||
midiSendNoteOn(noteValueCheck(fingeredNote+slurInterval[i]-12), velocitySend); // send Note On message for new note
|
midiSendNoteOn(noteValueCheck(fingeredNote + slurInterval[i] - 12), velocitySend); // send Note On message for new note
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rotatorOn) {
|
if (rotatorOn) {
|
||||||
midiSendNoteOn(noteValueCheck(fingeredNote+parallel), velocitySend); // send Note On message for new note
|
midiSendNoteOn(noteValueCheck(fingeredNote + parallel), velocitySend); // send Note On message for new note
|
||||||
if (currentRotation < 3) currentRotation++; else currentRotation = 0;
|
if (currentRotation < 3) currentRotation++;
|
||||||
midiSendNoteOn(noteValueCheck(fingeredNote+rotations[currentRotation]), velocitySend); // send Note On message for new note
|
else currentRotation = 0;
|
||||||
|
midiSendNoteOn(noteValueCheck(fingeredNote + rotations[currentRotation]), velocitySend); // send Note On message for new note
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!priority) {
|
if (!priority) {
|
||||||
|
@ -970,10 +986,10 @@ void loop() {
|
||||||
if (slurSustain) {
|
if (slurSustain) {
|
||||||
if (addedIntervals < 9) {
|
if (addedIntervals < 9) {
|
||||||
addedIntervals++;
|
addedIntervals++;
|
||||||
slurInterval[addedIntervals-1] = fingeredNote - slurBase;
|
slurInterval[addedIntervals - 1] = fingeredNote - slurBase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
activeNote=fingeredNote;
|
activeNote = fingeredNote;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -984,7 +1000,7 @@ void loop() {
|
||||||
// deal with Breath, Pitch Bend, Modulation, etc.
|
// deal with Breath, Pitch Bend, Modulation, etc.
|
||||||
if (!slowMidi) breath();
|
if (!slowMidi) breath();
|
||||||
halfTime = !halfTime;
|
halfTime = !halfTime;
|
||||||
if (halfTime){
|
if (halfTime) {
|
||||||
pitch_bend();
|
pitch_bend();
|
||||||
portamento_();
|
portamento_();
|
||||||
} else {
|
} else {
|
||||||
|
@ -995,18 +1011,18 @@ void loop() {
|
||||||
}
|
}
|
||||||
ccSendTime = millis();
|
ccSendTime = millis();
|
||||||
}
|
}
|
||||||
if (millis() - pixelUpdateTime > pixelUpdateInterval){
|
if (millis() - pixelUpdateTime > pixelUpdateInterval) {
|
||||||
// even if we just alter a pixel, the whole display is redrawn (35ms of MPU lockup) and we can't do that all the time
|
// even if we just alter a pixel, the whole display is redrawn (35ms of MPU lockup) and we can't do that all the time
|
||||||
// this is one of the big reasons the display is for setup use only
|
// this is one of the big reasons the display is for setup use only
|
||||||
drawSensorPixels(); // live sensor monitoring for the setup screens
|
drawSensorPixels(); // live sensor monitoring for the setup screens
|
||||||
if (rotatorOn || slurSustain || parallelChord || subOctaveDouble || gateOpen) {
|
if (rotatorOn || slurSustain || parallelChord || subOctaveDouble || gateOpen) {
|
||||||
digitalWrite(statusLedPin,!digitalRead(statusLedPin));
|
digitalWrite(statusLedPin, !digitalRead(statusLedPin));
|
||||||
} else if (!digitalRead(statusLedPin)) {
|
} else if (!digitalRead(statusLedPin)) {
|
||||||
digitalWrite(statusLedPin,HIGH);
|
digitalWrite(statusLedPin, HIGH);
|
||||||
}
|
}
|
||||||
pixelUpdateTime = millis();
|
pixelUpdateTime = millis();
|
||||||
}
|
}
|
||||||
lastFingering=fingeredNote;
|
lastFingering = fingeredNote;
|
||||||
//do menu stuff
|
//do menu stuff
|
||||||
menu();
|
menu();
|
||||||
}
|
}
|
||||||
|
@ -1015,22 +1031,21 @@ void loop() {
|
||||||
|
|
||||||
// non linear mapping function (http://playground.arduino.cc/Main/MultiMap)
|
// non linear mapping function (http://playground.arduino.cc/Main/MultiMap)
|
||||||
// note: the _in array should have increasing values
|
// note: the _in array should have increasing values
|
||||||
unsigned int multiMap(unsigned int val, unsigned int* _in, unsigned int* _out, uint8_t size)
|
unsigned int multiMap(unsigned int val, unsigned int * _in, unsigned int * _out, uint8_t size) {
|
||||||
{
|
|
||||||
// take care the value is within range
|
// take care the value is within range
|
||||||
// val = constrain(val, _in[0], _in[size-1]);
|
// val = constrain(val, _in[0], _in[size-1]);
|
||||||
if (val <= _in[0]) return _out[0];
|
if (val <= _in[0]) return _out[0];
|
||||||
if (val >= _in[size-1]) return _out[size-1];
|
if (val >= _in[size - 1]) return _out[size - 1];
|
||||||
|
|
||||||
// search right interval
|
// search right interval
|
||||||
uint8_t pos = 1; // _in[0] allready tested
|
uint8_t pos = 1; // _in[0] allready tested
|
||||||
while(val > _in[pos]) pos++;
|
while (val > _in[pos]) pos++;
|
||||||
|
|
||||||
// this will handle all exact "points" in the _in array
|
// this will handle all exact "points" in the _in array
|
||||||
if (val == _in[pos]) return _out[pos];
|
if (val == _in[pos]) return _out[pos];
|
||||||
|
|
||||||
// interpolate in the right segment for the rest
|
// interpolate in the right segment for the rest
|
||||||
return (val - _in[pos-1]) * (_out[pos] - _out[pos-1]) / (_in[pos] - _in[pos-1]) + _out[pos-1];
|
return (val - _in[pos - 1]) * (_out[pos] - _out[pos - 1]) / (_in[pos] - _in[pos - 1]) + _out[pos - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
//**************************************************************
|
//**************************************************************
|
||||||
|
@ -1038,22 +1053,22 @@ unsigned int multiMap(unsigned int val, unsigned int* _in, unsigned int* _out, u
|
||||||
// map breath values to selected curve
|
// map breath values to selected curve
|
||||||
unsigned int breathCurve(unsigned int inputVal) {
|
unsigned int breathCurve(unsigned int inputVal) {
|
||||||
// 0 to 16383, moving mid value up or down
|
// 0 to 16383, moving mid value up or down
|
||||||
switch (curve){
|
switch (curve) {
|
||||||
case 0:
|
case 0:
|
||||||
// -4
|
// -4
|
||||||
return multiMap(inputVal,curveIn,curveM4,17);
|
return multiMap(inputVal, curveIn, curveM4, 17);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// -3
|
// -3
|
||||||
return multiMap(inputVal,curveIn,curveM3,17);
|
return multiMap(inputVal, curveIn, curveM3, 17);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// -2
|
// -2
|
||||||
return multiMap(inputVal,curveIn,curveM2,17);
|
return multiMap(inputVal, curveIn, curveM2, 17);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
// -1
|
// -1
|
||||||
return multiMap(inputVal,curveIn,curveM1,17);
|
return multiMap(inputVal, curveIn, curveM1, 17);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
// 0, linear
|
// 0, linear
|
||||||
|
@ -1061,35 +1076,35 @@ unsigned int breathCurve(unsigned int inputVal) {
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
// +1
|
// +1
|
||||||
return multiMap(inputVal,curveIn,curveP1,17);
|
return multiMap(inputVal, curveIn, curveP1, 17);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
// +2
|
// +2
|
||||||
return multiMap(inputVal,curveIn,curveP2,17);
|
return multiMap(inputVal, curveIn, curveP2, 17);
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
// +3
|
// +3
|
||||||
return multiMap(inputVal,curveIn,curveP3,17);
|
return multiMap(inputVal, curveIn, curveP3, 17);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
// +4
|
// +4
|
||||||
return multiMap(inputVal,curveIn,curveP4,17);
|
return multiMap(inputVal, curveIn, curveP4, 17);
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
// S1
|
// S1
|
||||||
return multiMap(inputVal,curveIn,curveS1,17);
|
return multiMap(inputVal, curveIn, curveS1, 17);
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
// S2
|
// S2
|
||||||
return multiMap(inputVal,curveIn,curveS2,17);
|
return multiMap(inputVal, curveIn, curveS2, 17);
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
// Z1
|
// Z1
|
||||||
return multiMap(inputVal,curveIn,curveZ1,17);
|
return multiMap(inputVal, curveIn, curveZ1, 17);
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
// Z2
|
// Z2
|
||||||
return multiMap(inputVal,curveIn,curveZ2,17);
|
return multiMap(inputVal, curveIn, curveZ2, 17);
|
||||||
break;
|
break;
|
||||||
default: //Fallback option that should never be reached, use linear
|
default: //Fallback option that should never be reached, use linear
|
||||||
return inputVal;
|
return inputVal;
|
||||||
|
@ -1120,9 +1135,9 @@ int smooth(int data, float filterVal, float smoothedVal){
|
||||||
// MIDI note value check with out of range octave repeat
|
// MIDI note value check with out of range octave repeat
|
||||||
int noteValueCheck(int note) {
|
int noteValueCheck(int note) {
|
||||||
if (note > 127) {
|
if (note > 127) {
|
||||||
note = 115+(note-127)%12;
|
note = 115 + (note - 127) % 12;
|
||||||
} else if (note < 0) {
|
} else if (note < 0) {
|
||||||
note = 12-abs(note)%12;
|
note = 12 - abs(note) % 12;
|
||||||
}
|
}
|
||||||
return note;
|
return note;
|
||||||
}
|
}
|
||||||
|
@ -1130,7 +1145,9 @@ int noteValueCheck(int note) {
|
||||||
//**************************************************************
|
//**************************************************************
|
||||||
|
|
||||||
int patchLimit(int value) {
|
int patchLimit(int value) {
|
||||||
if (value < 1) return 1; else if (value > 128) return 128; else return value;
|
if (value < 1) return 1;
|
||||||
|
else if (value > 128) return 128;
|
||||||
|
else return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//**************************************************************
|
//**************************************************************
|
||||||
|
@ -1138,13 +1155,13 @@ int patchLimit(int value) {
|
||||||
void statusLEDs() {
|
void statusLEDs() {
|
||||||
if (breathLevel > breathThrVal) { // breath indicator LED, labeled "B" on PCB
|
if (breathLevel > breathThrVal) { // breath indicator LED, labeled "B" on PCB
|
||||||
//analogWrite(bLedPin, map(breathLevel,0,4096,5,breathLedBrightness));
|
//analogWrite(bLedPin, map(breathLevel,0,4096,5,breathLedBrightness));
|
||||||
analogWrite(bLedPin, map(constrain(breathLevel,breathThrVal,breathMaxVal),breathThrVal,breathMaxVal,5,breathLedBrightness));
|
analogWrite(bLedPin, map(constrain(breathLevel, breathThrVal, breathMaxVal), breathThrVal, breathMaxVal, 5, breathLedBrightness));
|
||||||
} else {
|
} else {
|
||||||
analogWrite(bLedPin, 0);
|
analogWrite(bLedPin, 0);
|
||||||
}
|
}
|
||||||
if (biteSensor > portamThrVal) { // portamento indicator LED, labeled "P" on PCB
|
if (biteSensor > portamThrVal) { // portamento indicator LED, labeled "P" on PCB
|
||||||
//analogWrite(pLedPin, map(biteSensor,0,4096,5,portamLedBrightness));
|
//analogWrite(pLedPin, map(biteSensor,0,4096,5,portamLedBrightness));
|
||||||
analogWrite(pLedPin, map(constrain(biteSensor,portamThrVal,portamMaxVal),portamThrVal,portamMaxVal,5,portamLedBrightness));
|
analogWrite(pLedPin, map(constrain(biteSensor, portamThrVal, portamMaxVal), portamThrVal, portamMaxVal, 5, portamLedBrightness));
|
||||||
} else {
|
} else {
|
||||||
analogWrite(pLedPin, 0);
|
analogWrite(pLedPin, 0);
|
||||||
}
|
}
|
||||||
|
@ -1153,17 +1170,17 @@ void statusLEDs() {
|
||||||
//**************************************************************
|
//**************************************************************
|
||||||
|
|
||||||
void breath() {
|
void breath() {
|
||||||
int breathCCval,breathCCvalFine;
|
int breathCCval, breathCCvalFine;
|
||||||
unsigned int breathCCvalHires;
|
unsigned int breathCCvalHires;
|
||||||
breathLevel = constrain(pressureSensor,breathThrVal,breathMaxVal);
|
breathLevel = constrain(pressureSensor, breathThrVal, breathMaxVal);
|
||||||
//breathLevel = breathLevel*0.6+pressureSensor*0.4; // smoothing of breathLevel value
|
//breathLevel = breathLevel*0.6+pressureSensor*0.4; // smoothing of breathLevel value
|
||||||
////////breathCCval = map(constrain(breathLevel,breathThrVal,breathMaxVal),breathThrVal,breathMaxVal,0,127);
|
////////breathCCval = map(constrain(breathLevel,breathThrVal,breathMaxVal),breathThrVal,breathMaxVal,0,127);
|
||||||
breathCCvalHires = breathCurve(map(constrain(breathLevel,breathThrVal,breathMaxVal),breathThrVal,breathMaxVal,0,16383));
|
breathCCvalHires = breathCurve(map(constrain(breathLevel, breathThrVal, breathMaxVal), breathThrVal, breathMaxVal, 0, 16383));
|
||||||
breathCCval = (breathCCvalHires >>7) & 0x007F;
|
breathCCval = (breathCCvalHires >> 7) & 0x007F;
|
||||||
breathCCvalFine = breathCCvalHires & 0x007F;
|
breathCCvalFine = breathCCvalHires & 0x007F;
|
||||||
|
|
||||||
if (breathCCval != oldbreath) { // only send midi data if breath has changed from previous value
|
if (breathCCval != oldbreath) { // only send midi data if breath has changed from previous value
|
||||||
if (breathCC){
|
if (breathCC) {
|
||||||
// send midi cc
|
// send midi cc
|
||||||
midiSendControlChange(ccList[breathCC], breathCCval);
|
midiSendControlChange(ccList[breathCC], breathCCval);
|
||||||
}
|
}
|
||||||
|
@ -1175,8 +1192,8 @@ void breath() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (breathCCvalHires != oldbreathhires) {
|
if (breathCCvalHires != oldbreathhires) {
|
||||||
if ((breathCC > 4) && (breathCC < 9)){ // send high resolution midi
|
if ((breathCC > 4) && (breathCC < 9)) { // send high resolution midi
|
||||||
midiSendControlChange(ccList[breathCC]+32, breathCCvalFine);
|
midiSendControlChange(ccList[breathCC] + 32, breathCCvalFine);
|
||||||
}
|
}
|
||||||
oldbreathhires = breathCCvalHires;
|
oldbreathhires = breathCCvalHires;
|
||||||
}
|
}
|
||||||
|
@ -1195,46 +1212,46 @@ void pitch_bend() {
|
||||||
halfPitchBendKey = (pinkySetting == PBD) && (touchRead(halfPitchBendKeyPin) > touch_Thr); // SENSOR PIN 1 - PCB PIN "S1" - hold for 1/2 pitchbend value
|
halfPitchBendKey = (pinkySetting == PBD) && (touchRead(halfPitchBendKeyPin) > touch_Thr); // SENSOR PIN 1 - PCB PIN "S1" - hold for 1/2 pitchbend value
|
||||||
int vibRead = touchRead(vibratoPin); // SENSOR PIN 15 - built in var cap
|
int vibRead = touchRead(vibratoPin); // SENSOR PIN 15 - built in var cap
|
||||||
calculatedPBdepth = pbDepthList[PBdepth];
|
calculatedPBdepth = pbDepthList[PBdepth];
|
||||||
if (halfPitchBendKey) calculatedPBdepth = calculatedPBdepth*0.5;
|
if (halfPitchBendKey) calculatedPBdepth = calculatedPBdepth * 0.5;
|
||||||
|
|
||||||
vibMax = vibMaxList[vibSens-1];
|
vibMax = vibMaxList[vibSens - 1];
|
||||||
|
|
||||||
if (vibRead < vibThr) {
|
if (vibRead < vibThr) {
|
||||||
if (UPWD == vibDirection) {
|
if (UPWD == vibDirection) {
|
||||||
vibSignal=vibSignal*0.5+0.5*map(constrain(vibRead,(vibZero-vibMax),vibThr),vibThr,(vibZero-vibMax),0,calculatedPBdepth*vibDepth[vibrato]);
|
vibSignal = vibSignal * 0.5 + 0.5 * map(constrain(vibRead, (vibZero - vibMax), vibThr), vibThr, (vibZero - vibMax), 0, calculatedPBdepth * vibDepth[vibrato]);
|
||||||
} else {
|
} else {
|
||||||
vibSignal=vibSignal*0.5+0.5*map(constrain(vibRead,(vibZero-vibMax),vibThr),vibThr,(vibZero-vibMax),0,(0 - calculatedPBdepth*vibDepth[vibrato]));
|
vibSignal = vibSignal * 0.5 + 0.5 * map(constrain(vibRead, (vibZero - vibMax), vibThr), vibThr, (vibZero - vibMax), 0, (0 - calculatedPBdepth * vibDepth[vibrato]));
|
||||||
}
|
}
|
||||||
} else if (vibRead > vibThrLo){
|
} else if (vibRead > vibThrLo) {
|
||||||
if (UPWD == vibDirection){
|
if (UPWD == vibDirection) {
|
||||||
vibSignal=vibSignal*0.5+0.5*map(constrain(vibRead,vibThrLo,(vibZero+vibMax)),vibThrLo,(vibZero+vibMax),0,(0 - calculatedPBdepth*vibDepth[vibrato]));
|
vibSignal = vibSignal * 0.5 + 0.5 * map(constrain(vibRead, vibThrLo, (vibZero + vibMax)), vibThrLo, (vibZero + vibMax), 0, (0 - calculatedPBdepth * vibDepth[vibrato]));
|
||||||
} else {
|
} else {
|
||||||
vibSignal=vibSignal*0.5+0.5*map(constrain(vibRead,vibThrLo,(vibZero+vibMax)),vibThrLo,(vibZero+vibMax),0,calculatedPBdepth*vibDepth[vibrato]);
|
vibSignal = vibSignal * 0.5 + 0.5 * map(constrain(vibRead, vibThrLo, (vibZero + vibMax)), vibThrLo, (vibZero + vibMax), 0, calculatedPBdepth * vibDepth[vibrato]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
vibSignal = vibSignal*0.5;
|
vibSignal = vibSignal * 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(vibRetn) { // moving baseline
|
switch (vibRetn) { // moving baseline
|
||||||
case 0:
|
case 0:
|
||||||
//keep vibZero value
|
//keep vibZero value
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
vibZero = vibZero*0.95+vibRead*0.05;
|
vibZero = vibZero * 0.95 + vibRead * 0.05;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
vibZero = vibZero*0.9+vibRead*0.1;
|
vibZero = vibZero * 0.9 + vibRead * 0.1;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
vibZero = vibZero*0.8+vibRead*0.2;
|
vibZero = vibZero * 0.8 + vibRead * 0.2;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
vibZero = vibZero*0.6+vibRead*0.4;
|
vibZero = vibZero * 0.6 + vibRead * 0.4;
|
||||||
}
|
}
|
||||||
vibThr=vibZero-vibSquelch;
|
vibThr = vibZero - vibSquelch;
|
||||||
vibThrLo=vibZero+vibSquelch;
|
vibThrLo = vibZero + vibSquelch;
|
||||||
int pbPos = map(constrain(pbUp,pitchbThrVal,pitchbMaxVal),pitchbThrVal,pitchbMaxVal,0,calculatedPBdepth);
|
int pbPos = map(constrain(pbUp, pitchbThrVal, pitchbMaxVal), pitchbThrVal, pitchbMaxVal, 0, calculatedPBdepth);
|
||||||
int pbNeg = map(constrain(pbDn,pitchbThrVal,pitchbMaxVal),pitchbThrVal,pitchbMaxVal,0,calculatedPBdepth);
|
int pbNeg = map(constrain(pbDn, pitchbThrVal, pitchbMaxVal), pitchbThrVal, pitchbMaxVal, 0, calculatedPBdepth);
|
||||||
int pbSum = 8193 + pbPos - pbNeg;
|
int pbSum = 8193 + pbPos - pbNeg;
|
||||||
int pbDif = abs(pbPos - pbNeg);
|
int pbDif = abs(pbPos - pbNeg);
|
||||||
/*
|
/*
|
||||||
|
@ -1251,24 +1268,24 @@ void pitch_bend() {
|
||||||
if (pbDif < 10) {
|
if (pbDif < 10) {
|
||||||
pitchBend = 8192;
|
pitchBend = 8192;
|
||||||
} else {
|
} else {
|
||||||
pitchBend=pitchBend*0.6+0.4*pbSum;
|
pitchBend = pitchBend * 0.6 + 0.4 * pbSum;
|
||||||
}
|
}
|
||||||
pbTouched = 1;
|
pbTouched = 1;
|
||||||
}
|
}
|
||||||
if (!pbTouched) {
|
if (!pbTouched) {
|
||||||
pitchBend = pitchBend*0.6+8192*0.4; // released, so smooth your way back to zero
|
pitchBend = pitchBend * 0.6 + 8192 * 0.4; // released, so smooth your way back to zero
|
||||||
if ((pitchBend > 8187) && (pitchBend < 8197)) pitchBend = 8192; // 8192 is 0 pitch bend, don't miss it bc of smoothing
|
if ((pitchBend > 8187) && (pitchBend < 8197)) pitchBend = 8192; // 8192 is 0 pitch bend, don't miss it bc of smoothing
|
||||||
}
|
}
|
||||||
|
|
||||||
pitchBend=pitchBend+vibSignal;
|
pitchBend = pitchBend + vibSignal;
|
||||||
|
|
||||||
pitchBend=constrain(pitchBend, 0, 16383);
|
pitchBend = constrain(pitchBend, 0, 16383);
|
||||||
|
|
||||||
if (subVibSquelch && (8192 != pitchBend)) {
|
if (subVibSquelch && (8192 != pitchBend)) {
|
||||||
digitalWrite(statusLedPin,LOW);
|
digitalWrite(statusLedPin, LOW);
|
||||||
vibLedOff = 1;
|
vibLedOff = 1;
|
||||||
} else if (vibLedOff) {
|
} else if (vibLedOff) {
|
||||||
digitalWrite(statusLedPin,HIGH);
|
digitalWrite(statusLedPin, HIGH);
|
||||||
vibLedOff = 0;
|
vibLedOff = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1276,9 +1293,9 @@ void pitch_bend() {
|
||||||
//Serial.print(" - ");
|
//Serial.print(" - ");
|
||||||
//Serial.println(oldpb);
|
//Serial.println(oldpb);
|
||||||
|
|
||||||
if (pitchBend != oldpb){// only send midi data if pitch bend has changed from previous value
|
if (pitchBend != oldpb) { // only send midi data if pitch bend has changed from previous value
|
||||||
midiSendPitchBend(pitchBend);
|
midiSendPitchBend(pitchBend);
|
||||||
oldpb=pitchBend;
|
oldpb = pitchBend;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1286,31 +1303,30 @@ void pitch_bend() {
|
||||||
|
|
||||||
void doorKnobCheck() {
|
void doorKnobCheck() {
|
||||||
int touchValue[12];
|
int touchValue[12];
|
||||||
for (byte i=0; i<12; i++){
|
for (byte i = 0; i < 12; i++) {
|
||||||
touchValue[i]=touchSensor.filteredData(i);
|
touchValue[i] = touchSensor.filteredData(i);
|
||||||
}
|
}
|
||||||
if ((touchValue[K4Pin] < ctouchThrVal) && (touchValue[R1Pin] < ctouchThrVal) && (touchValue[R2Pin] < ctouchThrVal) && (touchValue[R3Pin] < ctouchThrVal)){ // doorknob grip on canister
|
if ((touchValue[K4Pin] < ctouchThrVal) && (touchValue[R1Pin] < ctouchThrVal) && (touchValue[R2Pin] < ctouchThrVal) && (touchValue[R3Pin] < ctouchThrVal)) { // doorknob grip on canister
|
||||||
if (pbUp > ((pitchbMaxVal + pitchbThrVal)/2)) {
|
if (pbUp > ((pitchbMaxVal + pitchbThrVal) / 2)) {
|
||||||
gateOpen = 1;
|
gateOpen = 1;
|
||||||
digitalWrite(statusLedPin,LOW);
|
digitalWrite(statusLedPin, LOW);
|
||||||
delay(50);
|
delay(50);
|
||||||
digitalWrite(statusLedPin,HIGH);
|
digitalWrite(statusLedPin, HIGH);
|
||||||
delay(50);
|
delay(50);
|
||||||
}
|
} else if (pbDn > ((pitchbMaxVal + pitchbThrVal) / 2)) {
|
||||||
else if (pbDn > ((pitchbMaxVal + pitchbThrVal)/2)) {
|
|
||||||
gateOpen = 0;
|
gateOpen = 0;
|
||||||
midiPanic();
|
midiPanic();
|
||||||
digitalWrite(statusLedPin,LOW);
|
digitalWrite(statusLedPin, LOW);
|
||||||
delay(50);
|
delay(50);
|
||||||
digitalWrite(statusLedPin,HIGH);
|
digitalWrite(statusLedPin, HIGH);
|
||||||
delay(50);
|
delay(50);
|
||||||
digitalWrite(statusLedPin,LOW);
|
digitalWrite(statusLedPin, LOW);
|
||||||
delay(50);
|
delay(50);
|
||||||
digitalWrite(statusLedPin,HIGH);
|
digitalWrite(statusLedPin, HIGH);
|
||||||
delay(50);
|
delay(50);
|
||||||
digitalWrite(statusLedPin,LOW);
|
digitalWrite(statusLedPin, LOW);
|
||||||
delay(50);
|
delay(50);
|
||||||
digitalWrite(statusLedPin,HIGH);
|
digitalWrite(statusLedPin, HIGH);
|
||||||
delay(700);
|
delay(700);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1320,56 +1336,56 @@ void doorKnobCheck() {
|
||||||
|
|
||||||
void extraController() {
|
void extraController() {
|
||||||
// Extra Controller is the lip touch sensor (proportional) in front of the mouthpiece
|
// Extra Controller is the lip touch sensor (proportional) in front of the mouthpiece
|
||||||
exSensor=exSensor*0.6+0.4*touchRead(extraPin); // get sensor data, do some smoothing - SENSOR PIN 16 - PCB PIN "EC" (marked K4 on some prototype boards)
|
exSensor = exSensor * 0.6 + 0.4 * touchRead(extraPin); // get sensor data, do some smoothing - SENSOR PIN 16 - PCB PIN "EC" (marked K4 on some prototype boards)
|
||||||
if (extraCT && (exSensor >= extracThrVal)) { // if we are enabled and over the threshold, send data
|
if (extraCT && (exSensor >= extracThrVal)) { // if we are enabled and over the threshold, send data
|
||||||
if (!extracIsOn) {
|
if (!extracIsOn) {
|
||||||
extracIsOn=1;
|
extracIsOn = 1;
|
||||||
if (extraCT == 4) { //Sustain ON
|
if (extraCT == 4) { //Sustain ON
|
||||||
midiSendControlChange(64, 127);
|
midiSendControlChange(64, 127);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (extraCT == 1) { //Send modulation
|
if (extraCT == 1) { //Send modulation
|
||||||
int extracCC = map(constrain(exSensor,extracThrVal,extracMaxVal),extracThrVal,extracMaxVal,1,127);
|
int extracCC = map(constrain(exSensor, extracThrVal, extracMaxVal), extracThrVal, extracMaxVal, 1, 127);
|
||||||
if (extracCC != oldextrac){
|
if (extracCC != oldextrac) {
|
||||||
midiSendControlChange(1, extracCC);
|
midiSendControlChange(1, extracCC);
|
||||||
}
|
}
|
||||||
oldextrac = extracCC;
|
oldextrac = extracCC;
|
||||||
}
|
}
|
||||||
if (extraCT == 2) { //Send foot pedal (CC#4)
|
if (extraCT == 2) { //Send foot pedal (CC#4)
|
||||||
int extracCC = map(constrain(exSensor,extracThrVal,extracMaxVal),extracThrVal,extracMaxVal,1,127);
|
int extracCC = map(constrain(exSensor, extracThrVal, extracMaxVal), extracThrVal, extracMaxVal, 1, 127);
|
||||||
if (extracCC != oldextrac){
|
if (extracCC != oldextrac) {
|
||||||
midiSendControlChange(4, extracCC);
|
midiSendControlChange(4, extracCC);
|
||||||
}
|
}
|
||||||
oldextrac = extracCC;
|
oldextrac = extracCC;
|
||||||
}
|
}
|
||||||
if ((extraCT == 3) && (breathCC != 9)) { //Send filter cutoff (CC#74)
|
if ((extraCT == 3) && (breathCC != 9)) { //Send filter cutoff (CC#74)
|
||||||
int extracCC = map(constrain(exSensor,extracThrVal,extracMaxVal),extracThrVal,extracMaxVal,1,127);
|
int extracCC = map(constrain(exSensor, extracThrVal, extracMaxVal), extracThrVal, extracMaxVal, 1, 127);
|
||||||
if (extracCC != oldextrac){
|
if (extracCC != oldextrac) {
|
||||||
midiSendControlChange(74, extracCC);
|
midiSendControlChange(74, extracCC);
|
||||||
}
|
}
|
||||||
oldextrac = extracCC;
|
oldextrac = extracCC;
|
||||||
}
|
}
|
||||||
} else if (extracIsOn) { // we have just gone below threshold, so send zero value
|
} else if (extracIsOn) { // we have just gone below threshold, so send zero value
|
||||||
extracIsOn=0;
|
extracIsOn = 0;
|
||||||
if (extraCT == 1){ //MW
|
if (extraCT == 1) { //MW
|
||||||
if (oldextrac != 0){
|
if (oldextrac != 0) {
|
||||||
//send modulation 0
|
//send modulation 0
|
||||||
midiSendControlChange(1, 0);
|
midiSendControlChange(1, 0);
|
||||||
oldextrac = 0;
|
oldextrac = 0;
|
||||||
}
|
}
|
||||||
} else if (extraCT == 2){ //FP
|
} else if (extraCT == 2) { //FP
|
||||||
if (oldextrac != 0){
|
if (oldextrac != 0) {
|
||||||
//send foot pedal 0
|
//send foot pedal 0
|
||||||
midiSendControlChange(4, 0);
|
midiSendControlChange(4, 0);
|
||||||
oldextrac = 0;
|
oldextrac = 0;
|
||||||
}
|
}
|
||||||
} else if ((extraCT == 3) && (breathCC != 9)){ //CF
|
} else if ((extraCT == 3) && (breathCC != 9)) { //CF
|
||||||
if (oldextrac != 0){
|
if (oldextrac != 0) {
|
||||||
//send filter cutoff 0
|
//send filter cutoff 0
|
||||||
midiSendControlChange(74, 0);
|
midiSendControlChange(74, 0);
|
||||||
oldextrac = 0;
|
oldextrac = 0;
|
||||||
}
|
}
|
||||||
} else if (extraCT == 4){ //SP
|
} else if (extraCT == 4) { //SP
|
||||||
//send sustain off
|
//send sustain off
|
||||||
midiSendControlChange(64, 0);
|
midiSendControlChange(64, 0);
|
||||||
}
|
}
|
||||||
|
@ -1380,7 +1396,7 @@ void extraController() {
|
||||||
|
|
||||||
void portamento_() {
|
void portamento_() {
|
||||||
// Portamento is controlled with the bite sensor (variable capacitor) in the mouthpiece
|
// Portamento is controlled with the bite sensor (variable capacitor) in the mouthpiece
|
||||||
biteSensor=touchRead(bitePin); // get sensor data, do some smoothing - SENSOR PIN 17 - PCB PINS LABELED "BITE" (GND left, sensor pin right)
|
biteSensor = touchRead(bitePin); // get sensor data, do some smoothing - SENSOR PIN 17 - PCB PINS LABELED "BITE" (GND left, sensor pin right)
|
||||||
if (portamento && (biteSensor >= portamThrVal)) { // if we are enabled and over the threshold, send portamento
|
if (portamento && (biteSensor >= portamThrVal)) { // if we are enabled and over the threshold, send portamento
|
||||||
if (!portIsOn) {
|
if (!portIsOn) {
|
||||||
portOn();
|
portOn();
|
||||||
|
@ -1397,15 +1413,15 @@ void portOn() {
|
||||||
if (portamento == 2) { // if portamento midi switching is enabled
|
if (portamento == 2) { // if portamento midi switching is enabled
|
||||||
midiSendControlChange(CCN_PortOnOff, 127);
|
midiSendControlChange(CCN_PortOnOff, 127);
|
||||||
}
|
}
|
||||||
portIsOn=1;
|
portIsOn = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//***********************************************************
|
//***********************************************************
|
||||||
|
|
||||||
void port() {
|
void port() {
|
||||||
int portCC;
|
int portCC;
|
||||||
portCC = map(constrain(biteSensor,portamThrVal,portamMaxVal),portamThrVal,portamMaxVal,0,127);
|
portCC = map(constrain(biteSensor, portamThrVal, portamMaxVal), portamThrVal, portamMaxVal, 0, 127);
|
||||||
if (portCC!=oldport) {
|
if (portCC != oldport) {
|
||||||
midiSendControlChange(CCN_Port, portCC);
|
midiSendControlChange(CCN_Port, portCC);
|
||||||
}
|
}
|
||||||
oldport = portCC;
|
oldport = portCC;
|
||||||
|
@ -1420,7 +1436,7 @@ void portOff() {
|
||||||
if (portamento == 2) { // if portamento midi switching is enabled
|
if (portamento == 2) { // if portamento midi switching is enabled
|
||||||
midiSendControlChange(CCN_PortOnOff, 0);
|
midiSendControlChange(CCN_PortOnOff, 0);
|
||||||
}
|
}
|
||||||
portIsOn=0;
|
portIsOn = 0;
|
||||||
oldport = 0;
|
oldport = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1430,8 +1446,8 @@ void readSwitches() {
|
||||||
int qTransp;
|
int qTransp;
|
||||||
// Read touch pads (MPR121) and put value in variables
|
// Read touch pads (MPR121) and put value in variables
|
||||||
int touchValue[12];
|
int touchValue[12];
|
||||||
for (byte i=0; i<12; i++) {
|
for (byte i = 0; i < 12; i++) {
|
||||||
touchValue[i]=touchSensor.filteredData(i);
|
touchValue[i] = touchSensor.filteredData(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Octave rollers
|
// Octave rollers
|
||||||
|
@ -1446,13 +1462,13 @@ void readSwitches() {
|
||||||
lastOctaveR = octaveR;
|
lastOctaveR = octaveR;
|
||||||
|
|
||||||
// Valves and trill keys
|
// Valves and trill keys
|
||||||
K4=(touchValue[K4Pin] < ctouchThrVal);
|
K4 = (touchValue[K4Pin] < ctouchThrVal);
|
||||||
K1=(touchValue[K1Pin] < ctouchThrVal);
|
K1 = (touchValue[K1Pin] < ctouchThrVal);
|
||||||
K2=(touchValue[K2Pin] < ctouchThrVal);
|
K2 = (touchValue[K2Pin] < ctouchThrVal);
|
||||||
K3=(touchValue[K3Pin] < ctouchThrVal);
|
K3 = (touchValue[K3Pin] < ctouchThrVal);
|
||||||
K5=(touchValue[K5Pin] < ctouchThrVal);
|
K5 = (touchValue[K5Pin] < ctouchThrVal);
|
||||||
K6=(touchValue[K6Pin] < ctouchThrVal);
|
K6 = (touchValue[K6Pin] < ctouchThrVal);
|
||||||
K7=(touchValue[K7Pin] < ctouchThrVal);
|
K7 = (touchValue[K7Pin] < ctouchThrVal);
|
||||||
|
|
||||||
pinkyKey = (touchRead(halfPitchBendKeyPin) > touch_Thr); // SENSOR PIN 1 - PCB PIN "S1"
|
pinkyKey = (touchRead(halfPitchBendKeyPin) > touch_Thr); // SENSOR PIN 1 - PCB PIN "S1"
|
||||||
|
|
||||||
|
@ -1464,16 +1480,15 @@ void readSwitches() {
|
||||||
qTransp = 0;
|
qTransp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Calculate midi note number from pressed keys
|
// Calculate midi note number from pressed keys
|
||||||
#if defined(CASSIDY)
|
#if defined(CASSIDY)
|
||||||
fingeredNote=startNote-2*K1-K2-3*K3-5*K4+2*K5+K6+3*K7+octaveR*12+(octave-3)*12+transpose-12+qTransp;
|
fingeredNote = startNote - 2*K1 - K2 - 3*K3 - 5*K4 + 2*K5 + K6 + 3*K7 + octaveR*12 + (octave - 3)*12 + transpose - 12 + qTransp;
|
||||||
fingeredNoteUntransposed=startNote-2*K1-K2-3*K3-5*K4+2*K5+K6+3*K7+octaveR*12;
|
fingeredNoteUntransposed = startNote - 2*K1 - K2 - 3*K3 - 5*K4 + 2*K5 + K6 + 3*K7 + octaveR*12;
|
||||||
#else
|
#else
|
||||||
fingeredNote=startNote-2*K1-K2-3*K3-5*K4+2*K5+K6+4*K7+octaveR*12+(octave-3)*12+transpose-12+qTransp;
|
fingeredNote = startNote - 2*K1 - K2 - 3*K3 - 5*K4 + 2*K5 + K6 + 4*K7 + octaveR*12 + (octave - 3)*12 + transpose - 12 + qTransp;
|
||||||
fingeredNoteUntransposed=startNote-2*K1-K2-3*K3-5*K4+2*K5+K6+4*K7+octaveR*12;
|
fingeredNoteUntransposed = startNote - 2*K1 - K2 - 3*K3 - 5*K4 + 2*K5 + K6 + 4*K7 + octaveR*12;
|
||||||
#endif
|
#endif
|
||||||
//}
|
|
||||||
if (pinkyKey) pitchlatch = fingeredNoteUntransposed; //use pitchlatch to make settings based on note fingered
|
if (pinkyKey) pitchlatch = fingeredNoteUntransposed; //use pitchlatch to make settings based on note fingered
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue