propa
Well-known member
Hi,
Sorry the title's a bit of a mouthful! But that's the exact problem.
this code works fine, but blocks other tasks during delay:
Swapped to generic blink without delay and now I have audible clicks having their way with the sound, the weirder part is once modulated with another sound the clicks go away. Something quite strange is going on.
This is the function that's causing the clicks:
The only thing I can think of that's different between the two, is the added delay after noteOff() in the first function, reads ON Delay Off Delay, instead of ON Delay Off.
Has anyone got any thoughts about how the difference in functions is creating these clicks?
Sorry the title's a bit of a mouthful! But that's the exact problem.
this code works fine, but blocks other tasks during delay:
Code:
waveformMod1.frequency(freq);
envelope2.noteOn();
delay(knob_A4*1000.0+12.0); // Stop using delay
envelope2.noteOff();
delay(knob_A4*1000.0+12.0); // swap delay to non blocking code
Swapped to generic blink without delay and now I have audible clicks having their way with the sound, the weirder part is once modulated with another sound the clicks go away. Something quite strange is going on.
This is the function that's causing the clicks:
Code:
unsigned long delayVal = knob_A4*1000.0+12.0;
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= delayVal)
{
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW)
{
ledState = HIGH;
waveformMod1.frequency(freq);
envelope2.noteOn();
} else {
envelope2.noteOff();
ledState = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(led2, ledState);
}
The only thing I can think of that's different between the two, is the added delay after noteOff() in the first function, reads ON Delay Off Delay, instead of ON Delay Off.
Has anyone got any thoughts about how the difference in functions is creating these clicks?