Go Down

Topic: tone() on 2 different pins and 2 different frequencies (Read 557 times) previous topic - next topic

roujesky

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...)?

thanks!

pjrc

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

shawnlg

https://code.google.com/archive/p/rogue-code/wikis/ToneLibraryDocumentation.wiki
Shawn Gordhamer

shawnlg

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.

https://github.com/shawnlg/arduino-6voice-midi

Shawn


Shawn Gordhamer

pjrc

#4
Mar 02, 2016, 04:24 pm Last Edit: Mar 02, 2016, 04:26 pm by Paul Stoffregen
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.

https://github.com/PaulStoffregen/Audio/blob/master/examples/Synthesis/PlaySynthMusic/PlaySynthMusic.ino

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.

shawnlg

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.
Shawn Gordhamer

Go Up