debugging buffer

This commit is contained in:
Oleksiy 2021-03-03 02:06:07 +02:00
parent 032d9f3e1a
commit 16c22072a1
2 changed files with 30 additions and 8 deletions

View File

@ -75,17 +75,18 @@ void updateBuffer(byte bNote, bool bGate) {
playNote();
bufferIndex++;
}
if (bGate == 0 && bufferIndex != 0) {
if (bGate == 0) { // && bufferIndex != 0
for (int i = 0; i <= bufferIndex; i++) {
if (noteBuffer[i] == bNote) {
// Removing the note from the array and shifting everything to close the gap
for (int n = i; n <= bufferIndex; n++) {
noteBuffer[n] = noteBuffer[n + 1]; // what happens if it's the last note in buffer?
}
if (i == bufferIndex) {
if (i == bufferIndex) { //this does not fire
bufferIndex--;
playNote();
} else {
gate = 1;
playNote();
} else { //this does fire
bufferIndex--;
}
}
@ -94,7 +95,7 @@ void updateBuffer(byte bNote, bool bGate) {
}
void playNote() {
byte note = noteBuffer[bufferIndex];
byte note = noteBuffer[bufferIndex];
carrier_freq = mtof((int) note);
}
@ -137,7 +138,8 @@ void updateControl(){
// set the FM oscillator frequencies
aCarrier.setFreq(carrier_freq);
aModulator.setFreq(mod_freq);
//Knob 1
int Knob1value= mozziAnalogRead(CONTROLL1); // value is 0-1023
int Knob1calibrated = kMapIntensity(Knob1value);
@ -151,7 +153,25 @@ void updateControl(){
float mod_speed = (float)kMapModSpeed(Knob2value)/1000;
kIntensityMod.setFreq(mod_speed);
//MIDI DIN
// Debugging
Serial.print("Buffer Index: ");
Serial.print(bufferIndex);
Serial.print(" | Knob1: "); //3rd on the pannel, connected to A0
Serial.print(Knob1calibrated);
Serial.print(" | Knob2: "); //2nd on the pannel, conntcted to A1
Serial.print(Knob2value);
Serial.print(" | Knob3: "); //1st on the pannel, connected to A2, unstable around 0
Serial.print(FRQ);
Serial.print(" | Knob4: "); //4th on the pannel, A3
Serial.print(knob4calibrated);
Serial.println();
// MIDI DIN
MIDI.read();
}

View File

@ -4,4 +4,6 @@ DIY Arduino-based synth built with [Mozzi library](https://sensorium.github.io/M
## ToDo:
- Add note buffer
- Tune the values, remap the knobs, clean up the code
- Tune the values, remap the knobs, clean up the code
- Update readme
- Add schematics and documentations