Lord help me I am passing variables by reference

main
Mike Lynch 2023-12-23 14:32:05 +11:00
parent e5728416f0
commit 9ce26424a9
1 changed files with 4 additions and 3 deletions

View File

@ -72,13 +72,12 @@ void setup(void) {
void loop() { void loop() {
long now = millis(); long now = millis();
runSequencer(seq1, now); runSequencer(seq1, now);
Serial.println(seq1.noteOn);
} }
void runSequencer(sequencer seq, long now) { void runSequencer(sequencer& seq, long now) {
if( seq.noteOn ) { if( seq.noteOn ) {
if( now - seq.last > seq.rel ) { if( now - seq.last > seq.rel ) {
Serial.println("off"); Serial.println("noteOff");
noteOff(seq); noteOff(seq);
seq.last = now; seq.last = now;
seq.play = round(beat_m * seq.duration[seq.s] * (1.0 - gate)); seq.play = round(beat_m * seq.duration[seq.s] * (1.0 - gate));
@ -90,9 +89,11 @@ void runSequencer(sequencer seq, long now) {
} }
} else { } else {
if( now - seq.last > seq.play ) { if( now - seq.last > seq.play ) {
Serial.println("noteOn");
noteOn(seq, seq.melody[seq.s]); noteOn(seq, seq.melody[seq.s]);
seq.last = now; seq.last = now;
seq.rel = round(beat_m * seq.duration[seq.s] * gate); seq.rel = round(beat_m * seq.duration[seq.s] * gate);
Serial.println(seq.rel);
seq.noteOn = true; seq.noteOn = true;
} }
} }