Sorting out glissando
This commit is contained in:
parent
5d6bc54653
commit
d31398ed63
|
@ -51,6 +51,7 @@ void doPlay(bool forceDisplayUpdate) {
|
||||||
updateDisplay = true;
|
updateDisplay = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diag("%d %f", pipe.keys, pipe.glissandoOpenness);
|
||||||
#if 0
|
#if 0
|
||||||
if (updateDisplay) {
|
if (updateDisplay) {
|
||||||
// Look up the note name
|
// Look up the note name
|
||||||
|
|
16
pipe.cpp
16
pipe.cpp
|
@ -47,22 +47,28 @@ void Pipe::Update() {
|
||||||
// 0x6c is actually 8 bytes, but all 8 are always the same...
|
// 0x6c is actually 8 bytes, but all 8 are always the same...
|
||||||
paj7620ReadReg(0x6c, 1, &kneeClosedness);
|
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);
|
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
|
// keys = all keys which are at least touched
|
||||||
// glissandoKeys = all keys which are fully closed
|
// glissandoKeys = all keys which are fully closed
|
||||||
// The glissando operation computes the difference.
|
// The glissando operation computes the difference.
|
||||||
if (openness < 1.0) {
|
if (keyOpen[i] < 1.0) {
|
||||||
glissandoOpenness = max(glissandoOpenness, openness);
|
glissandoOpenness = max(glissandoOpenness, keyOpen[i]);
|
||||||
bitSet(keys, i);
|
bitSet(keys, i);
|
||||||
}
|
}
|
||||||
if (openness == 0.0) {
|
if (keyOpen[i] == 0.0) {
|
||||||
bitSet(glissandoKeys, i);
|
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
|
// Look up notes in the big table
|
||||||
struct Fingering f = FingeredNote(keys);
|
struct Fingering f = FingeredNote(keys);
|
||||||
struct Fingering gf = FingeredNote(glissandoKeys);
|
struct Fingering gf = FingeredNote(glissandoKeys);
|
||||||
|
|
3
pipe.h
3
pipe.h
|
@ -6,7 +6,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "tuning.h"
|
#include "tuning.h"
|
||||||
|
|
||||||
#define NUM_KEYS 12
|
#define NUM_KEYS 8
|
||||||
|
|
||||||
enum Adjust {
|
enum Adjust {
|
||||||
ADJUST_DOWN = -1,
|
ADJUST_DOWN = -1,
|
||||||
|
@ -23,6 +23,7 @@ class Pipe {
|
||||||
// keys are which keys are being pressed.
|
// keys are which keys are being pressed.
|
||||||
uint16_t keys;
|
uint16_t keys;
|
||||||
uint16_t keysLast;
|
uint16_t keysLast;
|
||||||
|
float keyOpen[NUM_KEYS];
|
||||||
|
|
||||||
// note holds the note being played, according to the fingering chart.
|
// note holds the note being played, according to the fingering chart.
|
||||||
Note note;
|
Note note;
|
||||||
|
|
Loading…
Reference in New Issue