Tone icon indicating copy to clipboard operation
Tone copied to clipboard

No tone, or "rest"

Open pdr0663 opened this issue 3 years ago • 2 comments

I am using your library to score music rendered as chords, and I need all three timers on an ATMEGA 328 (Arduino Nano). Problem is, as all timers are occupied, what do I do when I want to rest? I can't seem to use delay() any more.

I use 20000Hz for rests, but I get some clicking artifacts.

Can you add code to deal with perhaps "0" frequency, which would correspond to "no sound", for the specified tone() period? That way I can use the tone() command for sounds and rests.

Thanks for the great library!

Paul

pdr0663 avatar Nov 04 '21 00:11 pdr0663

Brute force idea: use a function that effectively does nothing, like changing digital level on an unused pin, time it, and loop that as long as you need to achieve the delay. E.g.:

void bruteDelay(int iterations){ For (int i, i <= iterations, I++){ digitalWrite(unusedPin, !digitalRead(unusedPin)); } } bruteDelay(200); //delays 200 cycles

AuxiliaryPanther avatar May 19 '22 10:05 AuxiliaryPanther

I am using your library to score music rendered as chords, and I need all three timers on an ATMEGA 328 (Arduino Nano). Problem is, as all timers are occupied, what do I do when I want to rest? I can't seem to use delay() any more.

I use 20000Hz for rests, but I get some clicking artifacts.

Can you add code to deal with perhaps "0" frequency, which would correspond to "no sound", for the specified tone() period? That way I can use the tone() command for sounds and rests.

Thanks for the great library!

Paul

You could use noTone for that I believe.

Blargian avatar Dec 21 '23 13:12 Blargian