Tried integer durations -it's worse!

main
Mike Lynch 2023-12-23 16:06:05 +11:00
parent b5b4c3bdd3
commit 0468c427d8
1 changed files with 5 additions and 6 deletions

View File

@ -9,9 +9,9 @@ float tuning[16];
// 0 = A, 8 = F (tonic)
int m1[] = { 3, 8, 8, 10, 8, 7, 5, 5, 5, 10, 10, 12, 10, 8, 7, 3, 7, 12, 12, 13, 12, 10, 8, 5, 3, 3, 5, 10, 7, 8, 3, 8, 8, 8, 7, 7, 8, 7, 5, 3, 10, 12, 10, 10, 8, 8, 15, 3, 3, 3, 5, 10, 7, 8 };
float d1[] = { 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 4, 2, 2, 2, 2, 4, 2, 2, 2, 2, 4, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 4 };
int d1[] = { 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 4, 2, 2, 2, 2, 4, 2, 2, 2, 2, 4, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 4 };
int m2[] = { -1, 8, 1, 2, 3, 4, 5, 0, 1, 3, 8, 8, 3, 5, 7, 8, 7, 0, 1, 3, 8 };
float d2[] = { 2, 6, 6, 6, 6, 6, 4, 2, 4, 2, 6, 6, 6, 6, 6, 6, 4, 2, 4, 2, 4 };
int d2[] = { 2, 6, 6, 6, 6, 6, 4, 2, 4, 2, 6, 6, 6, 6, 6, 6, 4, 2, 4, 2, 4 };
float gate = 0.5;
int bpm = 240;
float beat_s = 60.0 / (float)bpm;
@ -28,7 +28,7 @@ typedef struct {
long last = 0;
long init = 0;
int *melody;
float *duration;
int *duration;
int len = 0;
MCP4728_channel_t pitch;
MCP4728_channel_t gate;
@ -85,7 +85,7 @@ void runSequencer(sequencer& seq, long now) {
if( now - seq.last > seq.rel ) {
noteOff(seq);
seq.last = now;
seq.play = round(beat_m * seq.duration[seq.s] * (1.0 - gate));
seq.play = 0; // no gate for now
seq.noteOn = false;
seq.s += 1;
if( seq.s > seq.len ) {
@ -96,8 +96,7 @@ void runSequencer(sequencer& seq, long now) {
if( now - seq.last > seq.play ) {
noteOn(seq, seq.melody[seq.s]);
seq.last = now;
seq.rel = round(beat_m * seq.duration[seq.s] * gate);
Serial.println(seq.rel);
seq.rel = beat_m * seq.duration[seq.s];
seq.noteOn = true;
}
}