tone() on 2 different pins and 2 different frequencies

Hi all:
is it possible on an UNO to call tone() with 2 different pins and 2 different frequencies at the same time? If not, can it be done on a different Arduino board (ZERO, etc...)?


Not with the tone() function provided in the core library, but you can edit Tone.cpp to enable using other timers.

I have code to get 6 tones simultaneously, but it requires most of the CPU, so you can't have much else going on. It's meant to play music, but you could rip out the code that just plays and stops tones.


I made a similar chiptune-like player on Teensy. It synthesizes 16 waveforms of various shapes, applies ADSR envelopes to all 16, uses software mixing to merge them down to a pair of stereo channels, and sends the stereo to an audio codec by I2C. I also ran it sending it all mixed to mono to the built-in DAC a few times.

All that's done at 44100 samples/sec, using about 30% of the CPU time. It's pretty amazing how much more capable a 32 bit Cortex-M4 with the DSP extensions can be for audio stuff.

I'll take a look at that. I ordered a few 32 bit modules from AliExpress that I'd like to do sound stuff on.