diff --git a/main-play.h b/main-play.h index fd2b7b9..ca34163 100644 --- a/main-play.h +++ b/main-play.h @@ -51,6 +51,7 @@ void doPlay(bool forceDisplayUpdate) { updateDisplay = true; } + diag("%d %f", pipe.keys, pipe.glissandoOpenness); #if 0 if (updateDisplay) { // Look up the note name diff --git a/pipe.cpp b/pipe.cpp index e322b9e..e5c82ec 100644 --- a/pipe.cpp +++ b/pipe.cpp @@ -47,22 +47,28 @@ void Pipe::Update() { // 0x6c is actually 8 bytes, but all 8 are always the same... paj7620ReadReg(0x6c, 1, &kneeClosedness); - for (int i = 0; i < NUM_KEYS; i++) { + for (int i = 0; i < NUM_KEYS; ++i) { uint16_t val = max(capSensor.filteredData(i), CLOSEDVAL); - float openness = ((val - CLOSEDVAL) / float(GLISSANDO_STEPS)); + keyOpen[i] = ((val - CLOSEDVAL) / float(GLISSANDO_STEPS)); // keys = all keys which are at least touched // glissandoKeys = all keys which are fully closed // The glissando operation computes the difference. - if (openness < 1.0) { - glissandoOpenness = max(glissandoOpenness, openness); + if (keyOpen[i] < 1.0) { + glissandoOpenness = max(glissandoOpenness, keyOpen[i]); bitSet(keys, i); } - if (openness == 0.0) { + if (keyOpen[i] == 0.0) { bitSet(glissandoKeys, i); } } + // Compute glissando amount + glissandoOpenness = 0.0; + for (int i = 0; i < 8; ++i) { + glissandoOpenness = max(glissandoOpenness, keyOpen[i]); + } + // Look up notes in the big table struct Fingering f = FingeredNote(keys); struct Fingering gf = FingeredNote(glissandoKeys); diff --git a/pipe.h b/pipe.h index 0f2ea0f..8203b7a 100644 --- a/pipe.h +++ b/pipe.h @@ -6,7 +6,7 @@ #include #include "tuning.h" -#define NUM_KEYS 12 +#define NUM_KEYS 8 enum Adjust { ADJUST_DOWN = -1, @@ -23,6 +23,7 @@ class Pipe { // keys are which keys are being pressed. uint16_t keys; uint16_t keysLast; + float keyOpen[NUM_KEYS]; // note holds the note being played, according to the fingering chart. Note note;