I'm working on a project where I take a MIDI file, extract relevant musical information (eg. notes, channels, velocity, duration, etc.), send them to the Arduino and have the Arduino play the music. To play the music, I have tried using the tone() command and multiple piezo buzzers (one for each channel of the MIDI file), but my issue is that you can not call multiple tone() commands at once, meaning you can only play one channel at a time. Is there some way to use the tone() command to control multiple buzzers at the same time or is there better, more specific hardware I can use to play multiple sounds at once? Thank you
How many channels do you need? Normally the 'tone()' command generates only 1 output at a time. For more channels you may need a several chips with DDS functionality such as AD9833 or SI5351.
Edit. Ops, SI5351 maybe is not appropriate for audio frequencies.
polyphonic
I need to play 3 channels at the same time. Thank you for your reply, I'm going to look into the AD9833 now
Would a MIDI keyboard and the MIDI library work?
GitHub - FortySevenEffects/arduino_midi_library: MIDI for Arduino
Thank you! I will look into this.
Well tone() uses a timer to generate the frequency, and there are 3 timers you can use.
here you can find more information on how to do it using register manipulation.
You may even be able to some kind of result using micros() and elapsed time to generate 3 signals, but higher frequencies would be an issue.
I am not to good at this timer stuff really, i've never really done any of it, Some notes may also be hard to generate.
It will be quite a bit of math to work out how to get the best accuracy.
But it should work.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.