Hi Guys,
hope someone can give me a hint, whats runnig in the false direction with my MIDI/Synth Project. I've startet to build an Audio Sythesizer (first with Arduino, but since a few weeks with a Teensy 3.5). I'm realy impressed about the sound quality an possitbilities of the Audio library. Big Thanks to Paul! But at the moment i'm very fucked up.
I've added 2 LED Rotary Pots to the Project, 8 analog Pots + 1 RGB LED for each (maybe for some sequencer stuff later), 2 Neopixel 12er Rings (to help througth the navigation via the Rotary Encoders) and a MIDI input Circuit. Output is via DAC0 and into my Mixer. So far all this works very well.
Last Thing i wanted to add, is a LCD Display (20x4, HD44780 controlled, 5V) witch i connected via I2C. I took a wihle to get the LCD running, because on the arduion i could use it directly and on teensy i have to use a level shifter (5V to 3.3V, bidirectional), but finally also this works pretty nice. (By the way, the Liquid Crystal library and the i2c_3t library seems not work together, getting compiling errors with that, so i use the standard wire.h library and New Liquid Cristal library.)
So far, so good. But now i addead all these things together and discovert a "strange" behaviour. (i have no idea, why this happens). If i connect the LCD on SCL0 + SAD0, PIN19, 18, via the Level Shifter, Teensy didn`t read the MIDI-Inputs (RX1, PIN0) correctly. Sounds like there are some bits comming throught at the startup, (it plays 1-2 Notes) but after that, no further MIDI Data arrives. If I unwire the SDA0 (and it works only while unwiring this, not the SCL0) the MIDI Data comes in as it should. But obviously the LCD isn`t working.
What i´ve tried:
- Other Serial Inputs for MIDI 1-3 -> Same result, 4 -> False MIDI Reading
- Running the MIDI Circuit also on 5V and sending the Signal also througth the Level Shifter -> Same Result
- Other SCL, SDA Ports wanted to try out, ut dit not know how to reach them (is there a description for that anywhere?)
- Tested the single Elements separatly -> they work fine
- thougth about some grounding problems and testet serval connections with the 3.3V and 5V -> on its own, the LCD and MIDI in work without errors, i can only reproduce the problem as described, with the SDA connection on or off
What i´ve also detected:
- the LCD will also work, when i connect the SCL0, SDA0 directly to the teensy and only the Level Shifter is connected to GND, V 3.3+ @ Teensy and GND, 5V from external
- if i plug or unplug the SDA while Sketch is runnig nothing changes. means: if i startet without connected SDA MIDI continous playing as i plug in and if i start with connected SDA and unplug it while running, MIDI stays silent.
As you wanna see my code, here is the complete uncleaned:
I realy hope someonehast a clue, whats going on there and can say; hey! you simply have to edit line xy and everything will work fine!
Thx
hope someone can give me a hint, whats runnig in the false direction with my MIDI/Synth Project. I've startet to build an Audio Sythesizer (first with Arduino, but since a few weeks with a Teensy 3.5). I'm realy impressed about the sound quality an possitbilities of the Audio library. Big Thanks to Paul! But at the moment i'm very fucked up.
I've added 2 LED Rotary Pots to the Project, 8 analog Pots + 1 RGB LED for each (maybe for some sequencer stuff later), 2 Neopixel 12er Rings (to help througth the navigation via the Rotary Encoders) and a MIDI input Circuit. Output is via DAC0 and into my Mixer. So far all this works very well.
Last Thing i wanted to add, is a LCD Display (20x4, HD44780 controlled, 5V) witch i connected via I2C. I took a wihle to get the LCD running, because on the arduion i could use it directly and on teensy i have to use a level shifter (5V to 3.3V, bidirectional), but finally also this works pretty nice. (By the way, the Liquid Crystal library and the i2c_3t library seems not work together, getting compiling errors with that, so i use the standard wire.h library and New Liquid Cristal library.)
So far, so good. But now i addead all these things together and discovert a "strange" behaviour. (i have no idea, why this happens). If i connect the LCD on SCL0 + SAD0, PIN19, 18, via the Level Shifter, Teensy didn`t read the MIDI-Inputs (RX1, PIN0) correctly. Sounds like there are some bits comming throught at the startup, (it plays 1-2 Notes) but after that, no further MIDI Data arrives. If I unwire the SDA0 (and it works only while unwiring this, not the SCL0) the MIDI Data comes in as it should. But obviously the LCD isn`t working.
What i´ve tried:
- Other Serial Inputs for MIDI 1-3 -> Same result, 4 -> False MIDI Reading
- Running the MIDI Circuit also on 5V and sending the Signal also througth the Level Shifter -> Same Result
- Other SCL, SDA Ports wanted to try out, ut dit not know how to reach them (is there a description for that anywhere?)
- Tested the single Elements separatly -> they work fine
- thougth about some grounding problems and testet serval connections with the 3.3V and 5V -> on its own, the LCD and MIDI in work without errors, i can only reproduce the problem as described, with the SDA connection on or off
What i´ve also detected:
- the LCD will also work, when i connect the SCL0, SDA0 directly to the teensy and only the Level Shifter is connected to GND, V 3.3+ @ Teensy and GND, 5V from external
- if i plug or unplug the SDA while Sketch is runnig nothing changes. means: if i startet without connected SDA MIDI continous playing as i plug in and if i start with connected SDA and unplug it while running, MIDI stays silent.
As you wanna see my code, here is the complete uncleaned:
Code:
const float tune_frequencies2_PGM[128] =
{
};
const float velocity2amplitude[127] = {
};
#include <Audio.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
/
//AudioSynthWaveform *Waveforms[] = {&waveform1, &waveform2, &waveform3,
// &waveform4, &waveform5, &waveform6,
// &waveform7, &waveform8, &waveform9,
// &waveform10, &waveform11, &waveform12
// };
AudioEffectEnvelope *Envelopes[] = {&envelope1, &envelope2, &envelope3,
&envelope4, &envelope5, &envelope6,
&envelope7, &envelope8
};
AudioFilterStateVariable *Filters[] = {&filter1, &filter2, &filter3,
&filter4, &filter5, &filter6,
&filter7, &filter8
};
AudioMixer4 *Mixers1[] = {&mixer4, &mixer9, &mixer14, &mixer19,
&mixer25, &mixer30, &mixer35, &mixer40
};
AudioMixer4 *Mixers2[] = {&mixer5, &mixer10, &mixer15, &mixer20,
&mixer26, &mixer31, &mixer36, &mixer41
};
short wave_type[] = {
WAVEFORM_SINE,
WAVEFORM_SINE,
WAVEFORM_TRIANGLE,
WAVEFORM_SQUARE,
WAVEFORM_SAWTOOTH,
WAVEFORM_SAWTOOTH_REVERSE,
WAVEFORM_PULSE,
WAVEFORM_SAMPLE_HOLD
};
//#include <i2c_t3.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
//// set the LCD address to 0x20 for a 20 chars 4 line display
//// Set the pins on the I2C chip used for LCD connections:
//// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
//LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define NUMRing1 12
#define PIXELPIN 34
#define PIXELPIN2 33
Adafruit_NeoPixel Ring1 = Adafruit_NeoPixel(NUMRing1, PIXELPIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel Ring2 = Adafruit_NeoPixel(NUMRing1, PIXELPIN2, NEO_GRB + NEO_KHZ800);
#include <Bounce.h>
#define ROT1_BUT 8
#define ROT2_BUT 9
const byte Rot1_R = 7, Rot1_G = 6, Rot1_B = 5,
Rot2_R = 4, Rot2_G = 3, Rot2_B = 2;
Bounce bouncer = Bounce( ROT2_BUT, 16 );
Bounce bouncer2 = Bounce( ROT1_BUT, 16 );
#include <Encoder.h>
#define ROT1_D1 38
#define ROT1_D2 39
//
#define ROT2_D1 12
#define ROT2_D2 11
//
////Encoder ROT2_DATA(33, 34);
Encoder ROT1_DATA(ROT1_D1, ROT1_D2);
Encoder ROT2_DATA(ROT2_D1, ROT2_D2);
//Encoder ROT2_DATA(22, 23);
//Encoder ROT1_DATA(ROT1_D1, ROT1_D2);
long positionLeft = -999;
long positionRight = -999;
int16_t last, value, last2, value2, last3, value3, last4, value4;
#define LED 13
#define SEQ_LED_1 31
#define SEQ_LED_2 30
#define SEQ_LED_3 29
#define SEQ_LED_4 28
#define SEQ_LED_5 27
#define SEQ_LED_6 26
#define SEQ_LED_7 25
#define SEQ_LED_8 24
#define SerialMIDI Serial1
#include <MIDI.h>
//MIDI_CREATE_DEFAULT_INSTANCE();
MIDI_CREATE_INSTANCE(HardwareSerial, SerialMIDI, MIDI);
unsigned long bouncer_millis_last, bouncer2_millis_last, bouncer_millis_now, bouncer2_millis_now, POTs_millis;
byte SEQ_LEDs[] = {SEQ_LED_1, SEQ_LED_2, SEQ_LED_3, SEQ_LED_4, SEQ_LED_5, SEQ_LED_6, SEQ_LED_7, SEQ_LED_8};
const byte SEQ_LED_G = 35, SEQ_LED_R = 36, SEQ_LED_B = 37;
#include <EEPROM.h>
//short wave_type2[] = {
//
// WAVEFORM_TRIANGLE,
// WAVEFORM_SAWTOOTH_REVERSE,
// WAVEFORM_SINE,
// WAVEFORM_SQUARE,
// WAVEFORM_SAWTOOTH,
// WAVEFORM_PULSE,
// WAVEFORM_SAMPLE_HOLD
//};
int POT0, POT1, POT2, POT3, POT4, POT5, POT6, POT7,
POT0_Last, POT1_Last, POT2_Last, POT3_Last, POT4_Last, POT5_Last, POT6_Last, POT7_Last,
POT0_Read, POT1_Read, POT2_Read, POT3_Read, POT4_Read, POT5_Read, POT6_Read, POT7_Read;
byte Wave_Select1 = 0, Wave_Select2 = 3, Wave_Select3 = 0, Wave_Select4 = 3, Wave_Select5 = 1, Wave_Select6 = 4,
Wave_Select13, Edit_Count = 1, Edit_Level = 0, Save_Space = 0, Current_Note, Last_Note, Current_Velocity, Note_On, Array_Nr,
Prev_Edit_Count, Prev_Array_Nr, Button_hold, Last_Save_Space, Notes[8], Pitches[8];
int16_t Count1;
int16_t Count2;
int long last_value, last_value2, last_value3, last_value4, newRight_Speed, newRight2_Speed;
int
Shift_Switch = 0, Option_Select, Prev_Option_Select, Prev_Current_Rot1_Val, Current_Rot1_Val,
Prev_Ring2_Scale, Ring2_Scale, Voice_Counter, newRight_Last, First_Random;
float level1 = 1.0, Volume_Split = 0.00, Mixed_Volume = 1.00, level2 = 0.6, level3 = 0.8, level4 = 0.4, level5 = 0.4, level6 = 0.5,
level13, pitch1, pitch2, pitch3, pitch4, pitch5 , pitch6, pitch13,
pwm1, pwm2, pwm3,
mixer2_0, mixer2_1, mixer2_2, mixer2_3, mixer3_0, mixer3_1, mixer3_2, mixer3_3,
filter1_res, filter2_res,
del = 0, att = 10, hol = 0, dec = 20, sust = 1.0, rel = 400,
del2 = 0, att2 = 10, hol2 = 0, dec2 = 20, sust2 = 1.0, rel2 = 400;
long previousMillis = 0, Voices_millis, interval1, LastByte, StartByte, Data_Size, newLeft, newRight, newRight_Raw, Prev_MIDI_Millis, MIDI_Millis; // will store last time LED was updated
byte MIDI_On = 2, SEQ_Counter = 1, SEQ_Counter_Last, Voices = 6;
boolean Harmonics = 0;
#define Max_Edit_Count 8
#define POTI_Sum 16
int POT0_Array[Max_Edit_Count] = {512, 512, 512, 512, 512, 512, 512, 512};
int POT1_Array[Max_Edit_Count] = {512, 512, 512, 512, 512, 512, 512, 512};
int POT2_Array[Max_Edit_Count] = {512, 512, 512, 512, 512, 512, 512, 512};
int POT3_Array[Max_Edit_Count] = {512, 512, 512, 512, 512, 512, 512, 512};
int POT4_Array[Max_Edit_Count] = {512, 512, 512, 512, 512, 512, 512, 512};
int POT5_Array[Max_Edit_Count] = {512, 512, 512, 512, 512, 512, 512, 512};
int POT6_Array[Max_Edit_Count] = {512, 512, 512, 512, 512, 512, 512, 512};
int POT7_Array[Max_Edit_Count] = {512, 512, 512, 512, 512, 512, 512, 512};
int POT8_Array[Max_Edit_Count] = {512, 512, 512, 512, 512, 512, 512, 512};
int POT9_Array[Max_Edit_Count] = {512, 512, 512, 512, 512, 512, 512, 512};
int POT10_Array[Max_Edit_Count] = {512, 512, 512, 512, 512, 512, 512, 512};
int POT11_Array[Max_Edit_Count] = {512, 512, 512, 512, 512, 512, 512, 512};
int POT12_Array[Max_Edit_Count] = {512, 512, 512, 512, 512, 512, 512, 512};
int POT13_Array[Max_Edit_Count] = {512, 512, 512, 512, 512, 512, 512, 512};
int POT14_Array[Max_Edit_Count] = {512, 512, 512, 512, 512, 512, 512, 512};
int POT15_Array[Max_Edit_Count] = {512, 512, 512, 512, 512, 512, 512, 512};
//#define WIRE2_PINS I2C_PINS_3_4
// ============================================ SETUP =================================
// ====================================================================================
//#define USE_SERIAL_PORT Serial4
void setup() {
// Serial.begin(115200);
SerialMIDI.begin(31250);
// Wire2.begin(I2C_MASTER, 0x00, WIRE2_PINS, I2C_PULLUP_EXT, 400000);
lcd.begin(20, 4); // initialize the lcd for 20 chars 4 lines and turn on backlight
delay(100);
Serial.println(" Good Morning... ");
lcd.setCursor(0, 0);
lcd.print("Good Morning...");
delay(200);
//
//
// // lcd.backlight(); // finish with backlight on
Ring1.begin();
Ring2.begin();
pinMode(ROT2_BUT, INPUT);
pinMode(ROT1_BUT, INPUT);
randomSeed(analogRead(2));
// lcd.clear();
// Initiate MIDI communications, listen to all channels
MIDI.begin(MIDI_CHANNEL_OMNI);
// Connect the HandleNoteOn function to the library, so it is called upon reception of a NoteOn.
MIDI.setHandleNoteOn(HandleNoteOn); // Put only the name of the function
MIDI.setHandleNoteOff(HandleNoteOff);
Save_Space = EEPROM.read(0);
EEPROM_READ(Save_Space);
SAVE_SPACE_UPDATE();
// Initialize processor and memory measurements
AudioProcessorUsageMaxReset();
AudioMemoryUsageMaxReset();
POT0_Last = analogRead(A0);
POT1_Last = analogRead(A1);
POT2_Last = analogRead(A2);
POT3_Last = analogRead(A3);
// }
// else {
// analogWrite(SEQ_LED_1, 0);
//
POT4_Last = analogRead(A4);
POT5_Last = analogRead(A5);
POT6_Last = analogRead(A6);
POT7_Last = analogRead(A7);
// }
for (int i = 0; i < 4; i++) {
mixer1.gain(i, 0.3);
mixer2.gain(i, 0.3);
mixer3.gain(i, 0.6);
mixer6.gain(i, 0.3);
mixer7.gain(i, 0.3);
mixer8.gain(i, 0.6);
mixer11.gain(i, 0.3);
mixer12.gain(i, 0.3);
mixer13.gain(i, 0.6);
mixer16.gain(i, 0.3);
mixer17.gain(i, 0.3);
mixer18.gain(i, 0.6);
mixer22.gain(i, 0.3);
mixer23.gain(i, 0.3);
mixer24.gain(i, 0.6);
mixer27.gain(i, 0.3);
mixer28.gain(i, 0.3);
mixer29.gain(i, 0.6);
mixer32.gain(i, 0.3);
mixer33.gain(i, 0.3);
mixer34.gain(i, 0.6);
mixer37.gain(i, 0.3);
mixer38.gain(i, 0.3);
mixer39.gain(i, 0.6);
mixer21.gain(i, 0.4);
mixer42.gain(i, 0.4);
mixer43.gain(i, 0.6);
}
SOUNDS();
delay(100);
Serial.print("Ready!");
lcd.setCursor(0, 2);
lcd.print("Let´s Rock!");
delay(200);
lcd.clear();
// lcd.setCursor(0,0);
// lcd.print("POT0:");
// lcd.setCursor(0,0);
// lcd.print("POT0:");
MIDI_On = 1;
}
// ============================== Generating Sounds =======================
void SOUNDS() {
Harmonics = 0;
if (MIDI_On == 0) Current_Note = 64;
pitch1 = tune_frequencies2_PGM[Current_Note];
pitch3 = tune_frequencies2_PGM[Current_Note];
if (Harmonics == 1) pitch2 = tune_frequencies2_PGM[constrain(Current_Note + (64 - (POT2_Array[0] / 8)), 0, 128)]; //(POT5_Array[1] / 1.1625);
else pitch2 = constrain(tune_frequencies2_PGM[Current_Note] + (3069 - POT2_Array[0] * 4), 1.00, 13000.00);
if (Harmonics == 1) pitch4 = tune_frequencies2_PGM[constrain(Current_Note + (64 - (POT6_Array[0] / 8)), 0, 128)]; //(POT5_Array[1] / 1.1625);
else pitch4 = constrain(tune_frequencies2_PGM[Current_Note] + (3069 - POT6_Array[0] * 4), 1.00, 13000.00);
pitch5 = (63.00 - POT9_Array[0] * (63.00 / 1023.00)) + (63.00 / 1023.00); //+(Current_Note/10);
Wave_Select1 = 5 - constrain((POT0_Array[0] / 170), 0, 5);
Wave_Select2 = 5 - constrain((POT1_Array[0] / 170), 0, 5);
Wave_Select3 = 5 - constrain((POT4_Array[0] / 170), 0, 5);
Wave_Select4 = 5 - constrain((POT5_Array[0] / 170), 0, 5);
Wave_Select5 = 7 - constrain((POT8_Array[0] / 127), 0, 7);
level1 = 0.8 ;
level3 = 0.8 ;
level2 = 0.8 - POT3_Array[0] * (0.8 / 1023.00);
level4 = 0.8 - POT7_Array[0] * (0.8 / 1023.00);
level5 = 0.8 - POT10_Array[0] * (0.8 / 1023.00); //+(Current_Note/50);
if (Wave_Select1 == 0) level1 = 0.0;
if (Wave_Select2 == 0) level2 = 0.0;
if (Wave_Select3 == 0) level3 = 0.0;
if (Wave_Select4 == 0) level4 = 0.0;
if (Wave_Select5 == 0) level5 = 0.0;
del = 200 - constrain(POT4_Array[1] / 5, 0, 200);
att = 100 - constrain(POT0_Array[1] / 10, 0.5, 100);
hol = 100 - constrain( POT5_Array[1] / 10, 0.5, 100);
dec = 200 - constrain( POT1_Array[1] / 5, 0, 200);
sust = 1.0 - POT2_Array[1] * (1.00 / 1023.00);
rel = 240 - constrain(POT3_Array[1] / 4.26, 2, 240);
for (int i = 0; i < Voices; i++) {
Envelopes[i]->delay(del);
Envelopes[i]->attack(att);
Envelopes[i]->hold(hol);
Envelopes[i]->decay(dec);
Envelopes[i]->sustain(sust);
Envelopes[i]->release(rel);
}
float filter1_freq = (4400.00 - POT12_Array[0] * (4400.00 / 1023.00)) + (4400.00 / 1023.00);
float filter1_res = 3.71 - POT13_Array[0] * (3.00 / 1023.00);
float filter1_oct = 7 - POT14_Array[0] * (7.00 / 1023.00);
for (int i = 0; i < 8; i++) {
Filters[i]->resonance(filter1_res);
Filters[i]->frequency(filter1_freq);
Filters[i]->octaveControl(filter1_oct);
}
float crossmix1 = POT11_Array[0] * (1.0 / 1023.0);
float crossmix2 = POT15_Array[0] * (1.0 / 1023.0);
for (int i = 0; i < Voices; i++) {
Mixers1[i]->gain(0, crossmix1);
Mixers1[i]->gain(1, 1.0 - ((crossmix1 + crossmix2) / 2));
Mixers1[i]->gain(2, crossmix2);
}
float crossmix3 = POT7_Array[1] * (1.0 / 1023.0);
for (int i = 0; i < Voices; i++) {
Mixers2[i]->gain(0, crossmix3);
Mixers2[i]->gain(1, 1.0 - crossmix3);
}
}
void SETTINGS() {
// Setting Harmonics On/Off
Harmonics = constrain(POT1_Array[7] / 512, 0, 1);
// Switching between MIDI only, Pulse Trigger via ADSR-Loop, booth
MIDI_On = constrain(POT2_Array[7] / 340, 0, 2);
}
// ================================== MIDI ==================================
byte velocity_last;
void HandleNoteOff(byte channel, byte note, byte velocity) {
Serial.println(" === HandleNoteOff === ");
if (MIDI_On == 1 || MIDI_On == 2) {
// made for a keyboard where noteoff is expressed as velocity==0
// finds the calling note, shuts it off and sets it to 0, meaning it's available
if (velocity == 0)
{
Prev_MIDI_Millis = millis();
// Current_Note = 0;
Current_Velocity = 0;
Note_On = 0;
if (note == Notes[0] && Pitches[0] != 0) {
Serial.print(" === 1. Note Off === ");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
AudioNoInterrupts();
envelope1.noteOff();
AudioInterrupts();
Pitches[0] = 0;
Volume_Split = 0;
Voice_Counter--;
}
else if (note == Notes[1] && Pitches[1] != 0) {
Serial.print(" === 2. Note Off === ");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
AudioNoInterrupts();
envelope2.noteOff();
AudioInterrupts();
Pitches[1] = 0;
Volume_Split = 2;
Voice_Counter--;
}
else if (note == Notes[2] && Pitches[2] != 0) {
Serial.print(" === 3. Note Off === ");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
AudioNoInterrupts();
envelope3.noteOff();
AudioInterrupts();
Pitches[2] = 0;
Volume_Split = 2;
Voice_Counter--;
}
else if (note == Notes[3] && Pitches[3] != 0) {
Serial.print(" === 4. Note Off === ");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
AudioNoInterrupts();
envelope4.noteOff();
AudioInterrupts();
Pitches[3] = 0;
Volume_Split--;
Voice_Counter--;
}
else if (note == Notes[4] && Pitches[4] != 0) {
Serial.print(" === 5. Note Off === ");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
AudioNoInterrupts();
envelope5.noteOff();
AudioInterrupts();
Pitches[4] = 0;
Volume_Split = 0;
Voice_Counter--;
}
else if (note == Notes[5] && Pitches[5] != 0) {
Serial.print(" === 6. Note Off === ");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
AudioNoInterrupts();
envelope6.noteOff();
AudioInterrupts();
Pitches[5] = 0;
Volume_Split = 2;
Voice_Counter--;
}
else if (note == Notes[6] && Pitches[6] != 0) {
if (Voices > 6) {
Serial.print(" === 7. Note Off === ");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
AudioNoInterrupts();
envelope7.noteOff();
AudioInterrupts();
Pitches[6] = 0;
Volume_Split = 2;
Voice_Counter--;
}
else if (note == Notes[7] && Pitches[7] != 0) {
if (Voices > 7) {
Serial.print(" === 8. Note Off === ");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
AudioNoInterrupts();
envelope8.noteOff();
AudioInterrupts();
Pitches[7] = 0;
Volume_Split--;
Voice_Counter--;
}
}
}
//
}
}
//Volume_Split = constrain(Volume_Split,0,3);
}
void HandleNoteOn(byte channel, byte note, byte velocity) {
Serial.println(" === HandleNoteOn === ");
if (MIDI_On == 1 || MIDI_On == 2) {
if (velocity == 0)
{
Prev_MIDI_Millis = millis();
// Current_Note = 0;
Current_Velocity = 0;
Note_On = 0;
if (note == Notes[0] && Pitches[0] != 0) {
Serial.print(" === 1. Note Off === ");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
AudioNoInterrupts();
envelope1.noteOff();
AudioInterrupts();
Pitches[0] = 0;
Volume_Split = 0;
Voice_Counter--;
}
else if (note == Notes[1] && Pitches[1] != 0) {
Serial.print(" === 2. Note Off === ");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
AudioNoInterrupts();
envelope2.noteOff();
AudioInterrupts();
Pitches[1] = 0;
Volume_Split = 2;
Voice_Counter--;
}
else if (note == Notes[2] && Pitches[2] != 0) {
Serial.print(" === 3. Note Off === ");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
AudioNoInterrupts();
envelope3.noteOff();
AudioInterrupts();
Pitches[2] = 0;
Volume_Split = 2;
Voice_Counter--;
}
else if (note == Notes[3] && Pitches[3] != 0) {
Serial.print(" === 4. Note Off === ");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
AudioNoInterrupts();
envelope4.noteOff();
AudioInterrupts();
Pitches[3] = 0;
Volume_Split--;
Voice_Counter--;
}
else if (note == Notes[4] && Pitches[4] != 0) {
Serial.print(" === 5. Note Off === ");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
AudioNoInterrupts();
envelope5.noteOff();
AudioInterrupts();
Pitches[4] = 0;
Volume_Split = 0;
Voice_Counter--;
}
else if (note == Notes[5] && Pitches[5] != 0) {
Serial.print(" === 6. Note Off === ");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
AudioNoInterrupts();
envelope6.noteOff();
AudioInterrupts();
Pitches[5] = 0;
Volume_Split = 2;
Voice_Counter--;
}
else if (note == Notes[6] && Pitches[6] != 0) {
if (Voices > 6) {
Serial.print(" === 7. Note Off === ");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
AudioNoInterrupts();
envelope7.noteOff();
AudioInterrupts();
Pitches[6] = 0;
Volume_Split = 2;
Voice_Counter--;
}
else if (note == Notes[7] && Pitches[7] != 0) {
if (Voices > 7) {
Serial.print(" === 8. Note Off === ");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
AudioNoInterrupts();
envelope8.noteOff();
AudioInterrupts();
Pitches[7] = 0;
Volume_Split--;
Voice_Counter--;
}
}
}
//
}
else {
// Initialize processor and memory measurements
MIDI_Millis = millis() - Prev_MIDI_Millis;
// Serial.print(" ===== MIDI MILILIS =========== :");
// Serial.println(MIDI_Millis);
Current_Note = note;
Current_Velocity = velocity;
Note_On = 1;
SOUNDS();
if (Pitches[0] == 0) {
Notes[0] = note;
Pitches[0] = velocity;
Voice_Counter++;
digitalWrite(LED, HIGH );
Serial.print(" === 1. Note On ===");
Serial.print(" Note ");
Serial.print(note);
Serial.print(" // Voice_Counter ");
Serial.println(Voice_Counter);
// Serial.print(Notes[0] );
// Serial.print(" / ");
// Serial.print(pitch1);
// Serial.print(" / ");
// Serial.print((int) pitch2);
Serial.println();
velocity_last = velocity;
// Current_Note = note;
Volume_Split++;
AudioNoInterrupts();
//
waveform1.begin(level1, pitch1 , (short) wave_type[Wave_Select1]);
waveform1.phase(0);
waveform1.pulseWidth(pwm1);
waveform2.begin(level2, pitch2, (short) wave_type[Wave_Select2]);//
waveform2.phase(0);
waveform2.pulseWidth(pwm2);
waveform3.begin(level3, pitch3, (short) wave_type[Wave_Select3]);
waveform3.phase(0);
waveform3.pulseWidth(pwm3);
waveform4.begin(level4, pitch4 , (short) wave_type[Wave_Select4]);
waveform4.phase(0);
waveform4.pulseWidth(0.5);
waveform5.begin(level5, pitch5 , (short) wave_type[Wave_Select5]);
waveform5.phase(0);
waveform5.pulseWidth(0.5);
envelope1.noteOn();
AudioInterrupts();
}
else if (Pitches[1] == 0) {
digitalWrite(LED, HIGH );
Serial.print(" === 2. Note On ===");
Serial.print(" Note ");
Serial.println(note);
velocity_last = velocity;
Current_Velocity = velocity;
Volume_Split++;
// envelope3.noteOn();
// envelope4.noteOn();
// envelope3.noteOn();
Notes[1] = note;
Pitches[1] = velocity;
Voice_Counter++;
AudioNoInterrupts();
//
waveform6.begin(level1, pitch1 , (short) wave_type[Wave_Select1]);
waveform6.phase(0);
waveform6.pulseWidth(pwm1);
waveform7.begin(level2, pitch2, (short) wave_type[Wave_Select2]);//
waveform7.phase(0);
waveform7.pulseWidth(pwm2);
waveform8.begin(level3, pitch3, (short) wave_type[Wave_Select3]);
waveform8.phase(0);
waveform8.pulseWidth(pwm3);
waveform9.begin(level4, pitch4 , (short) wave_type[Wave_Select4]);
waveform9.phase(0);
waveform9.pulseWidth(0.5);
waveform10.begin(level5, pitch5 , (short) wave_type[Wave_Select5]);
waveform10.phase(0);
waveform10.pulseWidth(0.5);
envelope2.noteOn();
// envelope2.noteOn();
// drum1.noteOn();
AudioInterrupts();
}
else if (Pitches[2] == 0) {
digitalWrite(LED, HIGH );
Serial.print(" === 3. Note On ===");
Serial.print(" Note ");
Serial.println(note);
velocity_last = velocity;
// Current_Note = note;
Current_Velocity = velocity;
Volume_Split++;
Notes[2] = note;
Pitches[2] = velocity;
Voice_Counter++;
AudioNoInterrupts();
//
waveform11.begin(level1, pitch1 , (short) wave_type[Wave_Select1]);
waveform11.phase(0);
waveform11.pulseWidth(pwm1);
waveform12.begin(level2, pitch2, (short) wave_type[Wave_Select2]);//
waveform12.phase(0);
waveform12.pulseWidth(pwm2);
waveform13.begin(level3, pitch3, (short) wave_type[Wave_Select3]);
waveform13.phase(0);
waveform13.pulseWidth(pwm3);
waveform14.begin(level4, pitch4 , (short) wave_type[Wave_Select4]);
waveform14.phase(0);
waveform14.pulseWidth(0.5);
waveform15.begin(level5, pitch5 , (short) wave_type[Wave_Select5]);
waveform15.phase(0);
waveform15.pulseWidth(0.5);
envelope3.noteOn();
// envelope2.noteOn();
// drum1.noteOn();
AudioInterrupts();
}
else if (Pitches[3] == 0) {
digitalWrite(LED, HIGH );
Serial.println(" === 4. Note On ===");
velocity_last = velocity;
// Current_Note = note;
Current_Velocity = velocity;
Volume_Split++;
Notes[3] = note;
Pitches[3] = velocity;
Voice_Counter++;
AudioNoInterrupts();
//
waveform16.begin(level1, pitch1 , (short) wave_type[Wave_Select1]);
waveform16.phase(0);
waveform16.pulseWidth(pwm1);
waveform17.begin(level2, pitch2, (short) wave_type[Wave_Select2]);//
waveform17.phase(0);
waveform17.pulseWidth(pwm2);
waveform18.begin(level3, pitch3, (short) wave_type[Wave_Select3]);
waveform18.phase(0);
waveform18.pulseWidth(pwm3);
waveform19.begin(level4, pitch4 , (short) wave_type[Wave_Select4]);
waveform19.phase(0);
waveform19.pulseWidth(0.5);
waveform20.begin(level5, pitch5 , (short) wave_type[Wave_Select5]);
waveform20.phase(0);
waveform20.pulseWidth(0.5);
envelope4.noteOn();
// envelope2.noteOn();
// drum1.noteOn();
AudioInterrupts();
}
else if (Pitches[4] == 0) {
Notes[4] = note;
Pitches[4] = velocity;
Voice_Counter++;
digitalWrite(LED, HIGH );
Serial.print(" === 5. Note On ===");
Serial.print(Notes[0] );
Serial.print(" / ");
Serial.print(pitch1);
Serial.print(" / ");
Serial.print((int) pitch2);
Serial.println();
velocity_last = velocity;
Current_Velocity = velocity;
// Current_Note = note;
Volume_Split++;
AudioNoInterrupts();
//
waveform21.begin(level1, pitch1 , (short) wave_type[Wave_Select1]);
waveform21.phase(0);
waveform21.pulseWidth(pwm1);
waveform22.begin(level2, pitch2, (short) wave_type[Wave_Select2]);//
waveform22.phase(0);
waveform22.pulseWidth(pwm2);
waveform23.begin(level3, pitch3, (short) wave_type[Wave_Select3]);
waveform23.phase(0);
waveform23.pulseWidth(pwm3);
waveform24.begin(level4, pitch4 , (short) wave_type[Wave_Select4]);
waveform24.phase(0);
waveform24.pulseWidth(0.5);
waveform25.begin(level5, pitch5 , (short) wave_type[Wave_Select5]);
waveform25.phase(0);
waveform25.pulseWidth(0.5);
envelope5.noteOn();
// envelope2.noteOn();
// drum1.noteOn();
AudioInterrupts();
}
else if (Pitches[5] == 0) {
if (Voices > 6) {
Notes[5] = note;
Pitches[5] = velocity;
Voice_Counter++;
digitalWrite(LED, HIGH );
Serial.print(" === 6. Note On ===");
Serial.print(Notes[0] );
Serial.print(" / ");
Serial.print(pitch1);
Serial.print(" / ");
Serial.print((int) pitch2);
Serial.println();
velocity_last = velocity;
Current_Velocity = velocity;
// Current_Note = note;
Volume_Split++;
AudioNoInterrupts();
//
waveform26.begin(level1, pitch1 , (short) wave_type[Wave_Select1]);
waveform26.phase(0);
waveform26.pulseWidth(pwm1);
waveform27.begin(level2, pitch2, (short) wave_type[Wave_Select2]);//
waveform27.phase(0);
waveform27.pulseWidth(pwm2);
waveform28.begin(level3, pitch3, (short) wave_type[Wave_Select3]);
waveform28.phase(0);
waveform28.pulseWidth(pwm3);
waveform29.begin(level4, pitch4 , (short) wave_type[Wave_Select4]);
waveform29.phase(0);
waveform29.pulseWidth(0.5);
waveform30.begin(level5, pitch5 , (short) wave_type[Wave_Select5]);
waveform30.phase(0);
waveform30.pulseWidth(0.5);
envelope6.noteOn();
// envelope2.noteOn();
// drum1.noteOn();
AudioInterrupts();
}
else if (Pitches[6] == 0) {
if (Voices > 7) {
Notes[6] = note;
Pitches[6] = velocity;
Voice_Counter++;
digitalWrite(LED, HIGH );
Serial.print(" === 7. Note On ===");
Serial.print(Notes[0] );
Serial.print(" / ");
Serial.print(pitch1);
Serial.print(" / ");
Serial.print((int) pitch2);
Serial.println();
velocity_last = velocity;
Current_Velocity = velocity;
// Current_Note = note;
Volume_Split++;
AudioNoInterrupts();
//
waveform31.begin(level1, pitch1 , (short) wave_type[Wave_Select1]);
waveform31.phase(0);
waveform31.pulseWidth(pwm1);
waveform32.begin(level2, pitch2, (short) wave_type[Wave_Select2]);//
waveform32.phase(0);
waveform32.pulseWidth(pwm2);
waveform33.begin(level3, pitch3, (short) wave_type[Wave_Select3]);
waveform33.phase(0);
waveform33.pulseWidth(pwm3);
waveform34.begin(level4, pitch4 , (short) wave_type[Wave_Select4]);
waveform34.phase(0);
waveform34.pulseWidth(0.5);
waveform35.begin(level5, pitch5 , (short) wave_type[Wave_Select5]);
waveform35.phase(0);
waveform35.pulseWidth(0.5);
envelope7.noteOn();
// envelope2.noteOn();
// drum1.noteOn();
AudioInterrupts();
}
}
}
else if (Pitches[7] == 0) {
Notes[7] = note;
Pitches[7] = velocity;
Voice_Counter++;
digitalWrite(LED, HIGH );
Serial.print(" === 8. Note On ===");
Serial.print(Notes[0] );
Serial.print(" / ");
Serial.print(pitch1);
Serial.print(" / ");
Serial.print((int) pitch2);
Serial.println();
velocity_last = velocity;
Current_Velocity = velocity;
// Current_Note = note;
Volume_Split++;
AudioNoInterrupts();
//
waveform36.begin(level1, pitch1 , (short) wave_type[Wave_Select1]);
waveform36.phase(0);
waveform36.pulseWidth(pwm1);
waveform37.begin(level2, pitch2, (short) wave_type[Wave_Select2]);//
waveform37.phase(0);
waveform37.pulseWidth(pwm2);
waveform38.begin(level3, pitch3, (short) wave_type[Wave_Select3]);
waveform38.phase(0);
waveform38.pulseWidth(pwm3);
waveform39.begin(level4, pitch4 , (short) wave_type[Wave_Select4]);
waveform39.phase(0);
waveform39.pulseWidth(0.5);
waveform40.begin(level5, pitch5 , (short) wave_type[Wave_Select5]);
waveform40.phase(0);
waveform40.pulseWidth(0.5);
envelope8.noteOn();
// envelope2.noteOn();
// drum1.noteOn();
AudioInterrupts();
}
else {
Notes[0] = 0;
Pitches[0] = 0;
}
if (Pitches[0] != 0 && Pitches[1] != 0 && Pitches[2] != 0 && Pitches[3] != 0
&& Pitches[4] != 0 && Pitches[5] != 0 && Pitches[6] != 0 && Pitches[7] != 0) {
AudioNoInterrupts();
envelope1.noteOff();
envelope2.noteOff();
envelope3.noteOff();
envelope4.noteOff();
envelope5.noteOff();
envelope6.noteOff();
envelope7.noteOff();
envelope8.noteOff();
AudioInterrupts();
Notes[0] = 0;
Pitches[0] = 0;
}
if (Pitches[0] == 0 && Pitches[1] == 0 && Pitches[2] == 0 && Pitches[3] == 0
&& Pitches[4] == 0 && Pitches[5] == 0 && Pitches[6] == 0 && Pitches[7] == 0 ) {
Volume_Split = 0;
Current_Note = 0;
}
}
Volume_Split = constrain(Volume_Split, 0, 3);
}
// ===================== EEPROM ================================
int EEPROM_WRITE(byte SAVE_PLACE) {
Serial.println("Saving... ");
Data_Size = POTI_Sum * Max_Edit_Count * 2; //Data_Size = POTI_Sum *sizeof(POT0_Array); //
EEPROM.put(0, SAVE_PLACE);
int NextByte = (SAVE_PLACE * Data_Size) + 2;
StartByte = NextByte;
for (int i = 0; i < Max_Edit_Count; i++) {
EEPROM.put(NextByte, highByte(POT0_Array[i]));
NextByte++;
EEPROM.put(NextByte, lowByte(POT0_Array[i]));
NextByte++;
EEPROM.put(NextByte, highByte(POT1_Array[i]));
NextByte++;
EEPROM.put(NextByte, lowByte(POT1_Array[i]));
NextByte++;
EEPROM.put(NextByte, highByte(POT2_Array[i]));
NextByte++;
EEPROM.put(NextByte, lowByte(POT2_Array[i]));
NextByte++;
EEPROM.put(NextByte, highByte(POT3_Array[i]));
NextByte++;
EEPROM.put(NextByte, lowByte(POT3_Array[i]));
NextByte++;
EEPROM.put(NextByte, highByte(POT4_Array[i]));
NextByte++;
EEPROM.put(NextByte, lowByte(POT4_Array[i]));
NextByte++;
LastByte = NextByte;
EEPROM.put(NextByte, highByte(POT5_Array[i]));
NextByte++;
EEPROM.put(NextByte, lowByte(POT5_Array[i]));
NextByte++;
LastByte = NextByte;
EEPROM.put(NextByte, highByte(POT6_Array[i]));
NextByte++;
EEPROM.put(NextByte, lowByte(POT6_Array[i]));
NextByte++;
LastByte = NextByte;
EEPROM.put(NextByte, highByte(POT7_Array[i]));
NextByte++;
EEPROM.put(NextByte, lowByte(POT7_Array[i]));
NextByte++;
EEPROM.put(NextByte, highByte(POT8_Array[i]));
NextByte++;
EEPROM.put(NextByte, lowByte(POT8_Array[i]));
NextByte++;
EEPROM.put(NextByte, highByte(POT9_Array[i]));
NextByte++;
EEPROM.put(NextByte, lowByte(POT9_Array[i]));
NextByte++;
EEPROM.put(NextByte, highByte(POT10_Array[i]));
NextByte++;
EEPROM.put(NextByte, lowByte(POT10_Array[i]));
NextByte++;
EEPROM.put(NextByte, highByte(POT11_Array[i]));
NextByte++;
EEPROM.put(NextByte, lowByte(POT11_Array[i]));
NextByte++;
EEPROM.put(NextByte, highByte(POT12_Array[i]));
NextByte++;
EEPROM.put(NextByte, lowByte(POT12_Array[i]));
NextByte++;
LastByte = NextByte;
EEPROM.put(NextByte, highByte(POT13_Array[i]));
NextByte++;
EEPROM.put(NextByte, lowByte(POT13_Array[i]));
NextByte++;
LastByte = NextByte;
EEPROM.put(NextByte, highByte(POT14_Array[i]));
NextByte++;
EEPROM.put(NextByte, lowByte(POT14_Array[i]));
NextByte++;
LastByte = NextByte;
EEPROM.put(NextByte, highByte(POT15_Array[i]));
NextByte++;
EEPROM.put(NextByte, lowByte(POT15_Array[i]));
NextByte++;
LastByte = NextByte;
// if (LastByte == StartByte + Data_Size+2) break;
}
// }
Serial.print(" Data_Size ");
Serial.print(Data_Size);
Serial.print(" / SB ");
Serial.print(StartByte);
Serial.print(" / LB ");
Serial.println(LastByte);
Serial.println("Done. ");
}
int EEPROM_READ(byte SAVE_PLACE) {
Data_Size = POTI_Sum * Max_Edit_Count * 2; //Data_Size = POTI_Sum *sizeof(POT0_Array); //
int NextByte = (SAVE_PLACE * Data_Size) + 2;
StartByte = NextByte;
for (int i = 0; i < Max_Edit_Count; i++) {
int tmp_high = EEPROM.read(NextByte);
NextByte++;
int tmp_low = EEPROM.read(NextByte);
NextByte++;
POT0_Array[i] = word(tmp_high, tmp_low);
tmp_high = EEPROM.read(NextByte);
NextByte++;
tmp_low = EEPROM.read(NextByte);
NextByte++;
POT1_Array[i] = word(tmp_high, tmp_low);
tmp_high = EEPROM.read(NextByte);
NextByte++;
tmp_low = EEPROM.read(NextByte);
NextByte++;
POT2_Array[i] = word(tmp_high, tmp_low);
tmp_high = EEPROM.read(NextByte);
NextByte++;
tmp_low = EEPROM.read(NextByte);
NextByte++;
POT3_Array[i] = word(tmp_high, tmp_low);
tmp_high = EEPROM.read(NextByte);
NextByte++;
tmp_low = EEPROM.read(NextByte);
NextByte++;
POT4_Array[i] = word(tmp_high, tmp_low);
tmp_high = EEPROM.read(NextByte);
NextByte++;
tmp_low = EEPROM.read(NextByte);
NextByte++;
POT5_Array[i] = word(tmp_high, tmp_low);
tmp_high = EEPROM.read(NextByte);
NextByte++;
tmp_low = EEPROM.read(NextByte);
NextByte++;
POT6_Array[i] = word(tmp_high, tmp_low);
tmp_high = EEPROM.read(NextByte);
NextByte++;
tmp_low = EEPROM.read(NextByte);
NextByte++;
POT7_Array[i] = word(tmp_high, tmp_low);
tmp_high = EEPROM.read(NextByte);
NextByte++;
tmp_low = EEPROM.read(NextByte);
NextByte++;
POT8_Array[i] = word(tmp_high, tmp_low);
tmp_high = EEPROM.read(NextByte);
NextByte++;
tmp_low = EEPROM.read(NextByte);
NextByte++;
POT9_Array[i] = word(tmp_high, tmp_low);
tmp_high = EEPROM.read(NextByte);
NextByte++;
tmp_low = EEPROM.read(NextByte);
NextByte++;
POT10_Array[i] = word(tmp_high, tmp_low);
tmp_high = EEPROM.read(NextByte);
NextByte++;
tmp_low = EEPROM.read(NextByte);
NextByte++;
POT11_Array[i] = word(tmp_high, tmp_low);
tmp_high = EEPROM.read(NextByte);
NextByte++;
tmp_low = EEPROM.read(NextByte);
NextByte++;
POT12_Array[i] = word(tmp_high, tmp_low);
tmp_high = EEPROM.read(NextByte);
NextByte++;
tmp_low = EEPROM.read(NextByte);
NextByte++;
POT13_Array[i] = word(tmp_high, tmp_low);
tmp_high = EEPROM.read(NextByte);
NextByte++;
tmp_low = EEPROM.read(NextByte);
NextByte++;
POT14_Array[i] = word(tmp_high, tmp_low);
tmp_high = EEPROM.read(NextByte);
NextByte++;
tmp_low = EEPROM.read(NextByte);
NextByte++;
POT15_Array[i] = word(tmp_high, tmp_low);
// if (LastByte == StartByte + Data_Size+2) break;
}
// }
}
// for (int i = 0; i < OSC1_Size; i++) {
//
// // First Byte to Store Values After Setting
// int tmp_high = EEPROM.read(NextByte);
// NextByte++;
// int tmp_low = EEPROM.read(NextByte);
// NextByte++;
// OSC1_Array[i] = word(tmp_high, tmp_low) ;
// }
//}
// =============================================== DISPLAY FUNCTIONS ============================
// Printing a max 6 Letter Number, COL = last Colum, ARRAY_NR = 255 to switch between Array Values and single Values
int PRINT_VALUE(byte COL, byte ROW, long ARRAY_NR, bool ARRAY_TRUE = true, int* ARRAY = POT0_Array) {
int value_to_set;
if (ARRAY_TRUE == true) value_to_set = ARRAY[ARRAY_NR];
else value_to_set = ARRAY_NR;
bool err = false;
// lcd.setCursor(COL, ROW);
if (value_to_set >= 0 && value_to_set < 10) {
lcd.setCursor(COL - 1, ROW);
lcd.print(" ");
}
else if (value_to_set >= 10 && value_to_set < 100 || value_to_set <= -1 && value_to_set > -10) {
lcd.setCursor(constrain(COL - 2, 0, 19), ROW);
lcd.print(" ");
}
else if (value_to_set >= 100 && value_to_set < 1000 || value_to_set <= -10 && value_to_set > -100) {
lcd.setCursor(constrain(COL - 3, 0, 19), ROW);
lcd.print(" ");
}
else if (value_to_set >= 1000 && value_to_set < 10000 || value_to_set <= -100 && value_to_set > -1000) {
lcd.setCursor(constrain(COL - 4, 0, 19), ROW);
lcd.print(" ");
}
else if (value_to_set >= 10000 && value_to_set < 100000 || value_to_set <= -1000 && value_to_set > -10000) {
lcd.setCursor(constrain(COL - 5, 0, 19), ROW);
lcd.print(" ");
}
else if (value_to_set >= 100000 && value_to_set < 1000000 || value_to_set <= -10000 && value_to_set > -100000) {
lcd.setCursor(constrain(COL - 6, 0, 19), ROW);
lcd.print(" ");
}
else if (value_to_set >= 1000000 || value_to_set <= -100000 ) {
lcd.setCursor(constrain(COL - 6, 0, 19), ROW);
err = true;
}
if (err == false) lcd.print(value_to_set);
if (err == true) {
lcd.print("!LARGE!");
err = false;
}
}
// ================================================ NeoPixel Function ==================================
int CLEAR_RING(byte RINGNUMBER) {
if (RINGNUMBER == 1) {
for (int i = 1; i <= NUMRing1; i++) {
Ring1.setPixelColor(i, Ring1.Color(0, 0, 0));
}
}
else if (RINGNUMBER == 2) {
for (int i = 1; i <= NUMRing1; i++) {
Ring2.setPixelColor(i, Ring2.Color(0, 0, 0));
}
}
}
byte Option_Select_Last;
// ================================================ L O O P ==================================
// ===========================================================================================
unsigned long last_time = millis();
void loop()
{
// Serial4.read();
MIDI.read();
// delay(20);
// SOUNDS();
// SETTINGS();
if (1) {
if (millis() - last_time >= 1000) {
Serial.print("Proc = ");
Serial.print(AudioProcessorUsage());
Serial.print(" (");
Serial.print(AudioProcessorUsageMax());
Serial.print("), Mem = ");
Serial.print(AudioMemoryUsage());
Serial.print(" (");
Serial.print(AudioMemoryUsageMax());
Serial.println(")");
Serial.print("pitch3: ");
Serial.println(pitch3);
last_time = millis();
}
}
// Should prevent MIDI Input Overkill at fast Speed & End eventually "unOffed" Notes
if (Voice_Counter > Voices - 1) {
envelope1.noteOff();
Voice_Counter--;
if (millis() - Voices_millis < 20) {
envelope2.noteOff();
Voice_Counter--;
envelope3.noteOff();
Voice_Counter--;
envelope4.noteOff();
Voice_Counter--;
envelope5.noteOff();
Voice_Counter--;
envelope6.noteOff();
Voice_Counter--;
envelope7.noteOff();
Voice_Counter--;
envelope8.noteOff();
Voice_Counter--;
}
Voices_millis = millis();
}
// Button 1
bouncer.update ( );
int value = bouncer.read();
// button not pressed
if (value == HIGH) {
Button_hold = 1;
// at the moment button ist pressed
if (bouncer.risingEdge()) {
Shift_Switch = !Shift_Switch;
Serial.print("Button push - ");
Serial.println(Shift_Switch);
}
}
//while pressing button
else {
Button_hold = 0;
}
// Rot1 Button
int bouncer2_Press_Delay = 400;
bouncer2.update ( );
int value2 = bouncer2.read();
if (value2 == HIGH) {
if (bouncer2.risingEdge()) {
bouncer2_millis_last = millis();
Serial.print("Rot1 push - ");
Edit_Level++;
if (Edit_Level > 2) Edit_Level = 0;
}
if (millis() - bouncer2_millis_last > bouncer2_Press_Delay) {
if (Edit_Count == 8 ) {
if (Save_Space != Last_Save_Space) {
EEPROM_READ(Save_Space);
Last_Save_Space = Save_Space;
}
}
else {
Edit_Level--;
int Blink1_Delay = 100;
Serial.print("Saving...");
analogWrite(SEQ_LED_1, 255);
delay(Blink1_Delay);
analogWrite(SEQ_LED_1, 0);
delay(Blink1_Delay);
analogWrite(SEQ_LED_1, 255);
delay(Blink1_Delay);
analogWrite(SEQ_LED_1, 0);
analogWrite(SEQ_LED_1, 255);
delay(Blink1_Delay);
analogWrite(SEQ_LED_1, 0);
delay(Blink1_Delay);
bouncer2_millis_last = millis();
EEPROM_WRITE(Save_Space);
EEPROM_READ(Save_Space);
}
}
}
// newLeft = ROT2_DATA.read() / 4;
// newRight = ROT1_DATA.read() / 4;
// if (newRight != newRight_Last) {
// newRight_Speed = micros();
// newRight_Last = newRight;
// if (newRight != newRight_Last) {
// newRight2_Speed = micros();
// newRight_Last = newRight;
// int newRight_Accel = 200;
// if (newRight2_Speed - newRight_Speed < newRight_Accel) {
// newRight = ROT1_DATA.read();
// }
// else newRight = ROT1_DATA.read() / 4;
//
// newRight_Speed = micros();
// }
// }
newLeft = ROT2_DATA.read() / 4;
newRight = ROT1_DATA.read() / 4;
if (Edit_Level == 0) {
analogWrite(Rot1_R, 255);
analogWrite(Rot1_G, 255);
analogWrite(Rot1_B, 0);
if (newRight != last) {
last = newRight;
last2 = newRight ;
last3 = newRight ;
if (last_value > newRight) {
Prev_Edit_Count = Edit_Count;
Prev_Array_Nr = Array_Nr;
Edit_Count--;
if (Edit_Count < 1 ) Edit_Count = Max_Edit_Count;
}
if (last_value < newRight) {
Prev_Edit_Count = Edit_Count;
Prev_Array_Nr = Array_Nr;
Edit_Count++;
if (Edit_Count > Max_Edit_Count) Edit_Count = 1;
}
}
//
Array_Nr = Edit_Count - 1;
}
// newLeft2 = ROT2_DATA.read() / 4;
// newRight2 = ROT1_DATA.read() / 4;
int Col_Val_B;
if (Edit_Level == 1) {
analogWrite(Rot1_R, 0);
analogWrite(Rot1_G, 255);
analogWrite(Rot1_B, 255);
if (newRight != last2) {
last = newRight;
last2 = newRight ;
last3 = newRight ;
if (last_value2 > newRight) {
Prev_Option_Select = Option_Select;
Option_Select--;
Current_Rot1_Val = 0;
if (Option_Select < 0 ) Option_Select = POTI_Sum - 1;
CLEAR_RING(2);
}
if (last_value2 < newRight) {
Prev_Option_Select = Option_Select;
Option_Select++;
Current_Rot1_Val = 0;
if (Option_Select > POTI_Sum - 1) Option_Select = 0;
CLEAR_RING(2);
}
}
//
for (int i = -1; i <= Ring2_Scale - 1; i++) {
Col_Val_B = i * 8;
Ring2.setPixelColor(i, Ring2.Color( 255, 96 - Col_Val_B, 0)); // Moderately bright green color.
// Ring2.setPixelColor(i + 1, Ring2.Color(0, 0, 0));
}
Ring2.show();
// if (newRight != newRight) Edit_Count++;
//
POT0_Last = POT0_Read;
POT1_Last = POT1_Read;
POT2_Last = POT2_Read;
POT3_Last = POT3_Read;
POT4_Last = POT4_Read;
POT5_Last = POT5_Read;
POT6_Last = POT6_Read;
POT7_Last = POT7_Read;
}
if (Edit_Level == 2) {
analogWrite(Rot1_R, 0);
analogWrite(Rot1_G, 0);
analogWrite(Rot1_B, 255);
//newLeft3 = ROT2_DATA.read() / 4;
// newRight3 = ROT1_DATA.read() / 4;
//
if (newRight != last3) {
last = newRight;
last2 = newRight ;
last3 = newRight ;
if (last_value3 > newRight) {
Prev_Current_Rot1_Val = Current_Rot1_Val;
if (Button_hold == 1)
Current_Rot1_Val++;//
else Current_Rot1_Val = Current_Rot1_Val + 48;
}
if (last_value3 < newRight) {
Prev_Current_Rot1_Val = Current_Rot1_Val;
if (Button_hold == 1) Current_Rot1_Val--; //
else Current_Rot1_Val = Current_Rot1_Val - 48;
}
Current_Rot1_Val = constrain(Current_Rot1_Val, -1023, 1023);
}
// Ring2 Array Value Scale
for (int i = -1; i <= Ring2_Scale - 1; i++) {
Col_Val_B = i * 8;
Ring2.setPixelColor(i, Ring2.Color( 255, 96 - Col_Val_B, 0)); // Moderately bright green color.
Ring2.setPixelColor(i + 1, Ring2.Color(0, 0, 0));
}
Ring2.show();
}
last_value = newRight;
last_value3 = newRight ;
last_value2 = newRight ;
// =============== playing constant tone depending on ADSR Values ========================
// /*
if (MIDI_On == 0 || MIDI_On == 2) {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > interval1) {
// save the last time you blinked the LED
previousMillis = currentMillis;
if (Note_On == 1) {
digitalWrite(LED, HIGH );
// drum1.noteOn();
Note_On = 0;
interval1 = (att + hol + dec + att2 + hol2 + dec2);
SOUNDS();
AudioNoInterrupts();
//
waveform1.begin(level1, pitch1 , (short) wave_type[Wave_Select1]);
waveform1.phase(0);
waveform1.pulseWidth(pwm1);
waveform2.begin(level2, pitch2, (short) wave_type[Wave_Select2]);//
waveform2.phase(0);
waveform2.pulseWidth(pwm2);
waveform3.begin(level3, pitch3, (short) wave_type[Wave_Select3]);
waveform3.phase(0);
waveform3.pulseWidth(pwm3);
waveform4.begin(level4, pitch4 , (short) wave_type[Wave_Select4]);
waveform4.phase(0);
waveform4.pulseWidth(0.5);
waveform5.begin(level5, pitch5 , (short) wave_type[Wave_Select5]);
waveform5.phase(0);
waveform5.pulseWidth(0.5);
envelope1.noteOn();
envelope2.noteOn();
envelope3.noteOn();
envelope4.noteOn();
envelope5.noteOn();
AudioInterrupts();
// return;
Serial.println();
}
else {
// delay(att + hol + dec + att2 + hol2 + dec2);
envelope1.noteOff();
envelope2.noteOff();
envelope3.noteOff();
envelope4.noteOff();
envelope5.noteOff();
// delay(del + rel);
digitalWrite(LED, LOW );
Note_On = 1;
interval1 = (del + rel + del2 + rel2);
}
}
}
// */
// ===============================EDIT COUNT =======================
switch (Edit_Count) {
// =====OSC1 =====
case 1: {
RING1_BLUE();
lcd.setCursor(0, 0);
lcd.print("OSCILLATORS");
if (Edit_Level == 2) {
}
}
break;
// =====OSC2 =====
case 2: {
RING1_BLUE();
if (Edit_Level == 2) {
}
}
break;
// =====FILTER OSC 1=====
case 3: {
RING1_BLUE();
if (Edit_Level == 2) {
}
}
break;
// =====FILTER OSC 2=====
case 4: {
RING1_BLUE();
if (Edit_Level == 2) {
}
}
break;
// =====Drum/Pink Noise =====
case 5: {
RING1_BLUE();
if (Edit_Level == 2) {
}
}
break;
// =====Other Envelope OSC 1 & OSC 2 =====
case 6: {
RING1_BLUE();
if (Edit_Level == 2) {
}
}
break;
// =====unused=====
case 7: {
RING1_BLUE();
if (Edit_Level == 2) {
}
}
break;
// =====Options & Saving=====
case 8: {
Ring1.setPixelColor(Array_Nr, Ring1.Color(255, 128, 0)); // Moderately bright green color.
Ring1.setPixelColor(Prev_Array_Nr, Ring1.Color(0, 0, 0));
Ring1.show();
byte Max_Save_Spaces = 16;
if (Edit_Level == 2) {
// Setting Current Memory Place
Save_Space = constrain(POT0_Array[Array_Nr] / (1023 / (Max_Save_Spaces - 1)), 0, Max_Save_Spaces - 1);
}
SAVE_SPACE_UPDATE();
}
break;
}
// if (Save_Space != Save_Space) {
// }
// ===============================OPTION SELECT =======================
switch (Option_Select) {
// =====POT0 =====
case 0: {
RING1_RED();
Ring2_Scale = (1023 - POT0_Array[Array_Nr]) / 73, Prev_Ring2_Scale, Col_Val_B;
if (Edit_Level == 2 ) {
if (Current_Rot1_Val != Prev_Current_Rot1_Val) {
POT0_Array[Array_Nr] += Current_Rot1_Val;
POT0_Array[Array_Nr] = constrain(POT0_Array[Array_Nr], 0, 1023);
Prev_Current_Rot1_Val = Current_Rot1_Val;
Current_Rot1_Val = 0;
}
}
}
break;
// =====POT1 =====
case 1: {
RING1_RED();
Ring2_Scale = (1023 - POT1_Array[Array_Nr]) / 73, Prev_Ring2_Scale, Col_Val_B;
if (Edit_Level == 2 ) {
if (Current_Rot1_Val != Prev_Current_Rot1_Val) {
POT1_Array[Array_Nr] += Current_Rot1_Val;
POT1_Array[Array_Nr] = constrain(POT1_Array[Array_Nr], 0, 1023);
Prev_Current_Rot1_Val = Current_Rot1_Val;
Current_Rot1_Val = 0;
}
}
}
break; //
// =====POT2 =====
case 2: {
RING1_RED();
Ring2_Scale = (1023 - POT2_Array[Array_Nr]) / 73, Prev_Ring2_Scale, Col_Val_B;
if (Edit_Level == 2 ) {
if (Current_Rot1_Val != Prev_Current_Rot1_Val) {
POT2_Array[Array_Nr] += Current_Rot1_Val;
POT2_Array[Array_Nr] = constrain(POT2_Array[Array_Nr], 0, 1023);
Prev_Current_Rot1_Val = Current_Rot1_Val;
Current_Rot1_Val = 0;
}
}
}
break; //
// =====POT3 =====
case 3: {
RING1_RED();
Ring2_Scale = (1023 - POT3_Array[Array_Nr]) / 73, Prev_Ring2_Scale, Col_Val_B;
if (Edit_Level == 2 ) {
if (Current_Rot1_Val != Prev_Current_Rot1_Val) {
POT3_Array[Array_Nr] += Current_Rot1_Val;
POT3_Array[Array_Nr] = constrain(POT3_Array[Array_Nr], 0, 1023);
Prev_Current_Rot1_Val = Current_Rot1_Val;
Current_Rot1_Val = 0;
}
}
}
break; //
// =====POT4 =====
case 4: {
RING1_RED();
Ring2_Scale = (1023 - POT4_Array[Array_Nr]) / 73, Prev_Ring2_Scale, Col_Val_B;
if (Edit_Level == 2 ) {
if (Current_Rot1_Val != Prev_Current_Rot1_Val) {
POT4_Array[Array_Nr] += Current_Rot1_Val;
POT4_Array[Array_Nr] = constrain(POT4_Array[Array_Nr], 0, 1023);
Prev_Current_Rot1_Val = Current_Rot1_Val;
Current_Rot1_Val = 0;
}
}
}
break;
// =====POT5 =====
case 5: {
RING1_RED();
Ring2_Scale = (1023 - POT5_Array[Array_Nr]) / 73, Prev_Ring2_Scale, Col_Val_B;
if (Edit_Level == 2 ) {
if (Current_Rot1_Val != Prev_Current_Rot1_Val) {
POT5_Array[Array_Nr] += Current_Rot1_Val;
POT5_Array[Array_Nr] = constrain(POT5_Array[Array_Nr], 0, 1023);
Prev_Current_Rot1_Val = Current_Rot1_Val;
Current_Rot1_Val = 0;
}
}
}
break; //
// =====POT6 =====
case 6: {
RING1_RED();
Ring2_Scale = (1023 - POT6_Array[Array_Nr]) / 73, Prev_Ring2_Scale, Col_Val_B;
if (Edit_Level == 2 ) {
if (Current_Rot1_Val != Prev_Current_Rot1_Val) {
POT6_Array[Array_Nr] += Current_Rot1_Val;
POT6_Array[Array_Nr] = constrain(POT6_Array[Array_Nr], 0, 1023);
Prev_Current_Rot1_Val = Current_Rot1_Val;
Current_Rot1_Val = 0;
}
}
}
break; //
// =====POT7 =====
case 7: {
RING1_RED();
Ring2_Scale = (1023 - POT7_Array[Array_Nr]) / 73, Prev_Ring2_Scale, Col_Val_B;
if (Edit_Level == 2 ) {
if (Current_Rot1_Val != Prev_Current_Rot1_Val) {
POT7_Array[Array_Nr] += Current_Rot1_Val;
POT7_Array[Array_Nr] = constrain(POT7_Array[Array_Nr], 0, 1023);
Prev_Current_Rot1_Val = Current_Rot1_Val;
Current_Rot1_Val = 0;
}
}
}
break;
}
// pitch1 = tune_frequencies2_PGM[Current_Note];
// pitch3 = tune_frequencies2_PGM[Current_Note + 12];
// if (Shift_Switch == 1) {
// analogWrite(SEQ_LED_1, 255);
POT0_Read = analogRead(A0);
POT1_Read = analogRead(A1);
POT2_Read = analogRead(A2);
POT3_Read = analogRead(A3);
// }
// else {
// analogWrite(SEQ_LED_1, 0);
//
POT4_Read = analogRead(A6);
POT5_Read = analogRead(A7);
POT6_Read = analogRead(A8);
POT7_Read = analogRead(A9);
// }
// if (Button_hold == 1) {
unsigned long current_POTs_Millis = millis();
byte voices = 2;
if (current_POTs_Millis - POTs_millis > 20) {
// save the last time you blinked the LED
POTs_millis = current_POTs_Millis;
// not that time critical tasks
First_Random = random(0, 1024);
// SOUNDS();
SETTINGS();
byte Tolerance = 12;
switch (Shift_Switch) {
case 0: {
analogWrite(Rot2_R, 0);
analogWrite(Rot2_G, 255);
analogWrite(Rot2_B, 255);
lcd.setCursor(14, 0);
lcd.print("Tab 1");
// lcd.setCursor(1,1);
PRINT_VALUE(4, 1, Array_Nr, true, POT0_Array);
// lcd.print(POT0_Array[Array_Nr]);
// lcd.setCursor(4,1);
PRINT_VALUE(9, 1, Array_Nr, true, POT1_Array);
// lcd.print(POT1_Array[Array_Nr]);
// lcd.setCursor(9,1);
PRINT_VALUE(14, 1, Array_Nr, true, POT2_Array);
//lcd.print(POT2_Array[Array_Nr]);
// lcd.setCursor(14,1);
PRINT_VALUE(19, 1, Array_Nr, true, POT3_Array);
//lcd.print(POT3_Array[Array_Nr]);
// lcd.setCursor(1,2);
PRINT_VALUE(4, 2, Array_Nr, true, POT4_Array);
//lcd.print(POT4_Array[Array_Nr]);
// lcd.setCursor(4,2);
PRINT_VALUE(9, 2, Array_Nr, true, POT5_Array);
//lcd.print(POT5_Array[Array_Nr]);
// lcd.setCursor(9,2);
PRINT_VALUE(14, 2, Array_Nr, true, POT6_Array);
// lcd.print(POT6_Array[Array_Nr]);
// lcd.setCursor(14,2);
PRINT_VALUE(19, 2, Array_Nr, true, POT7_Array);
//lcd.print(POT7_Array[Array_Nr]);
// if (Edit_Level == 2 ) {
if (POT0_Read > POT0_Last + Tolerance || POT0_Read < POT0_Last - Tolerance) {
POT0_Array[Array_Nr] = POT0_Read;
POT0_Last = POT0_Read;
}
else POT0_Array[Array_Nr] = POT0_Array[Array_Nr];
if (POT1_Read > POT1_Last + Tolerance || POT1_Read < POT1_Last - Tolerance) {
POT1_Array[Array_Nr] = POT1_Read;
POT1_Last = POT1_Read;
}
else POT1_Array[Array_Nr] = POT1_Array[Array_Nr];
if (POT2_Read > POT2_Last + Tolerance || POT2_Read < POT2_Last - Tolerance) {
POT2_Array[Array_Nr] = POT2_Read;
POT2_Last = POT2_Read;
}
else POT2_Array[Array_Nr] = POT2_Array[Array_Nr];
if (POT3_Read > POT3_Last + Tolerance || POT3_Read < POT3_Last - Tolerance) {
POT3_Array[Array_Nr] = POT3_Read;
POT3_Last = POT3_Read;
}
else POT3_Array[Array_Nr] = POT3_Array[Array_Nr];
if (POT4_Read > POT4_Last + Tolerance || POT4_Read < POT4_Last - Tolerance) {
POT4_Array[Array_Nr] = POT4_Read;
POT4_Last = POT4_Read;
}
else POT4_Array[Array_Nr] = POT4_Array[Array_Nr];
if (POT5_Read > POT5_Last + Tolerance || POT5_Read < POT5_Last - Tolerance) {
POT5_Array[Array_Nr] = POT5_Read;
POT5_Last = POT5_Read;
}
else POT5_Array[Array_Nr] = POT5_Array[Array_Nr];
if (POT6_Read > POT6_Last + Tolerance || POT6_Read < POT6_Last - Tolerance) {
POT6_Array[Array_Nr] = POT6_Read;
POT6_Last = POT6_Read;
}
else POT6_Array[Array_Nr] = POT6_Array[Array_Nr];
if (POT7_Read > POT7_Last + Tolerance || POT7_Read < POT7_Last - Tolerance) {
POT7_Array[Array_Nr] = POT7_Read;
POT7_Last = POT7_Read;
}
else POT7_Array[Array_Nr] = POT7_Array[Array_Nr];
}
break;
case 1: {
analogWrite(Rot2_R, 255);
analogWrite(Rot2_G, 0);
analogWrite(Rot2_B, 255);
lcd.setCursor(14, 0);
lcd.print("Tab 2");
// lcd.setCursor(1,1);
PRINT_VALUE(4, 1, Array_Nr, true, POT8_Array);
// lcd.print(POT0_Array[Array_Nr]);
// lcd.setCursor(4,1);
PRINT_VALUE(9, 1, Array_Nr, true, POT9_Array);
// lcd.print(POT1_Array[Array_Nr]);
// lcd.setCursor(9,1);
PRINT_VALUE(14, 1, Array_Nr, true, POT10_Array);
//lcd.print(POT2_Array[Array_Nr]);
// lcd.setCursor(14,1);
PRINT_VALUE(19, 1, Array_Nr, true, POT11_Array);
//lcd.print(POT3_Array[Array_Nr]);
// lcd.setCursor(1,2);
PRINT_VALUE(4, 2, Array_Nr, true, POT12_Array);
//lcd.print(POT4_Array[Array_Nr]);
// lcd.setCursor(4,2);
PRINT_VALUE(9, 2, Array_Nr, true, POT13_Array);
//lcd.print(POT5_Array[Array_Nr]);
// lcd.setCursor(9,2);
PRINT_VALUE(14, 2, Array_Nr, true, POT14_Array);
// lcd.print(POT6_Array[Array_Nr]);
// lcd.setCursor(14,2);
PRINT_VALUE(19, 2, Array_Nr, true, POT15_Array);
//lcd.print(POT7_Array[Array_Nr]);
if (POT0_Read > POT0_Last + Tolerance || POT0_Read < POT0_Last - Tolerance) {
POT8_Array[Array_Nr] = POT0_Read;
POT0_Last = POT0_Read;
}
else POT8_Array[Array_Nr] = POT8_Array[Array_Nr];
if (POT1_Read > POT1_Last + Tolerance || POT1_Read < POT1_Last - Tolerance) {
POT9_Array[Array_Nr] = POT1_Read;
POT1_Last = POT1_Read;
}
else POT9_Array[Array_Nr] = POT9_Array[Array_Nr];
if (POT2_Read > POT2_Last + Tolerance || POT2_Read < POT2_Last - Tolerance) {
POT10_Array[Array_Nr] = POT2_Read;
POT2_Last = POT2_Read;
}
else POT10_Array[Array_Nr] = POT10_Array[Array_Nr];
if (POT3_Read > POT3_Last + Tolerance || POT3_Read < POT3_Last - Tolerance) {
POT11_Array[Array_Nr] = POT3_Read;
POT3_Last = POT3_Read;
}
else POT11_Array[Array_Nr] = POT11_Array[Array_Nr];
if (POT4_Read > POT4_Last + Tolerance || POT4_Read < POT4_Last - Tolerance) {
POT12_Array[Array_Nr] = POT4_Read;
POT4_Last = POT4_Read;
}
else POT12_Array[Array_Nr] = POT12_Array[Array_Nr];
if (POT5_Read > POT5_Last + Tolerance || POT5_Read < POT5_Last - Tolerance) {
POT13_Array[Array_Nr] = POT5_Read;
POT5_Last = POT5_Read;
}
else POT13_Array[Array_Nr] = POT13_Array[Array_Nr];
if (POT6_Read > POT6_Last + Tolerance || POT6_Read < POT6_Last - Tolerance) {
POT14_Array[Array_Nr] = POT6_Read;
POT6_Last = POT6_Read;
}
else POT14_Array[Array_Nr] = POT14_Array[Array_Nr];
if (POT7_Read > POT7_Last + Tolerance || POT7_Read < POT7_Last - Tolerance) {
POT15_Array[Array_Nr] = POT7_Read;
POT7_Last = POT7_Read;
}
else POT15_Array[Array_Nr] = POT15_Array[Array_Nr];
}
break;
}
}
// }
// }
} // LOOP End
void RING1_BLUE() {
Ring1.setPixelColor(Array_Nr, Ring1.Color(0, 0, 255)); // Moderately bright green color.
Ring1.setPixelColor(Prev_Array_Nr, Ring1.Color(0, 0, 0));
Ring1.show();
}
void RING1_RED() {
Ring1.setPixelColor(Prev_Option_Select, Ring1.Color(0, 0, 0));
Ring1.setPixelColor(Option_Select, Ring1.Color(255, 0, 0)); // Moderately bright green color.
Ring1.show();
}
void SAVE_SPACE_UPDATE() {
byte Ring_Save_Step = Save_Space % 4;
if (Save_Space < 4) {
for (int i = 0; i < 4; i++) {
Ring1.setPixelColor(NUMRing1 - 1 - i, Ring1.Color(5, 5, 5)); // Moderately bright green color.
}
Ring1.setPixelColor(NUMRing1 - 1 - Ring_Save_Step, Ring1.Color(255, 255, 255)); // Moderately bright green color.
}
else if (Save_Space < 8) {
for (int i = 0; i < 4; i++) {
Ring1.setPixelColor(NUMRing1 - 1 - i, Ring1.Color(8, 4, 0)); // Moderately bright green color.
}
Ring1.setPixelColor(NUMRing1 - 1 - Ring_Save_Step, Ring1.Color(255, 128, 0)); // Moderately bright green color.
}
else if (Save_Space < 12) {
for (int i = 0; i < 4; i++) {
Ring1.setPixelColor(NUMRing1 - 1 - i, Ring1.Color(8, 0, 0)); // Moderately bright green color.
}
Ring1.setPixelColor(NUMRing1 - 1 - Ring_Save_Step, Ring1.Color(255, 0, 0)); // Moderately bright green color.
}
else {
for (int i = 0; i < 4; i++) {
Ring1.setPixelColor(NUMRing1 - 1 - i, Ring1.Color(0, 0, 8)); // Moderately bright green color.
}
Ring1.setPixelColor(NUMRing1 - 1 - Ring_Save_Step, Ring1.Color(0, 0, 255)); // Moderately bright green color.
}
Ring1.show();
}
I realy hope someonehast a clue, whats going on there and can say; hey! you simply have to edit line xy and everything will work fine!
Thx