Introduction: Turn Your Arduino Into a 4 Voice Wavetable Synth With Only a Few Components...
Multiple synthesizer projects have been done for the Arduino, but few have been able to utilize the full power of the Arduino processor. DZL from GeekPhysical wrote a 4 voice wavetable synthesizer that is one of the more advanced software based synths for the Arduino. It has wavetables included (sine, saw, square and triangle) and envelopes to create beats.
This instructable will show you how to make a simple sequencer that plays a little melody. You can hear how it sounds here:
Or you could detect touch and convert it into sound patterns:
This instructable will show you how to make a simple sequencer that plays a little melody. You can hear how it sounds here:
It is up to you to modify the code to do many other things. Possible examples could be a midi controlled synth (sample code included), it could be a strange noise machine like this one:
Or you could detect touch and convert it into sound patterns:
Step 1: Parts
You should use the following parts:
Don't worry if you don't have the exact values. It will probably work, but might be with lower sound quality. The Arduino is not powerful enough to drive a pair of headphones so you will need some kind of preamp for that - e.g. a headphone preamp like this one.
Don't worry if you don't have the exact values. It will probably work, but might be with lower sound quality. The Arduino is not powerful enough to drive a pair of headphones so you will need some kind of preamp for that - e.g. a headphone preamp like this one.
Step 2: Add the Components to Your Breadboard
Start out with adding the components to the breadboard as the picture depicts. If you want diagram based instructions look at the third slide in this step.
Step 3: Connect to the Arduino Board
Connect one wire from pin 6 to the breadboard and one wire from ground to the breadboard.
Step 4: Connect to the Speakers
Connect the jack connector to the breadboard as shown and plugin the jack from the speakers.
Step 5: Upload Code
***Remember to read the update below (keeping the old info for consistency)***
Below are the simplified steps to uploading the code to your Arduino board. If you are brand-new to Arduino, you can find a great step-by-step guide here to help you get your board connected and up and running, it's very simple and then you can continue with the below steps.
Congratulations - you are ready to go!
Update!
A new version of the synth can be found below:
https://github.com/dzlonline/the_synth
This version works with the newest version of the Arduino Ide and the whole synth has been simplified. It should be more simple to hack and modify for ones own needs.
The output should be connected to pin 11 (Configurable to 3 as well). In the old code one should use pin 6.
Below are the simplified steps to uploading the code to your Arduino board. If you are brand-new to Arduino, you can find a great step-by-step guide here to help you get your board connected and up and running, it's very simple and then you can continue with the below steps.
- Download Arduino: www.arduino.cc
- Connect the Arduino board to the computer via usb.
- Download the code from github here: https://github.com/Illutron/ArduinoSynth (Old code - look below)
- Upload the code to the Arduino board.
Congratulations - you are ready to go!
Update!
A new version of the synth can be found below:
https://github.com/dzlonline/the_synth
This version works with the newest version of the Arduino Ide and the whole synth has been simplified. It should be more simple to hack and modify for ones own needs.
The output should be connected to pin 11 (Configurable to 3 as well). In the old code one should use pin 6.
54 Comments
6 months ago
Sorry, i am stupid. I found the tables. However, is it possible to load data of sounds close to real instruments to those tables? Like piano.
OLD POST: Why do you call it WAVETABLE? Where is the table with wave data? Wavetable allows making sound close to instruments, but this is just envelope synth with different wave forms.
8 years ago on Introduction
Excellent library! However, it would not work with any Atmega 32U4-based boards (Leornardo, Micro, Pro Micro, etc) as it uses Timer 2 for the timer output compares. Timer 2 is missing from the 32U4. I re-wrote the library using Timer 4. This has the advantage of offering a few more differential output modes that were not possible with Timer 2. This is possible because the 32U4 has two addition timer output pins that mirror the state of the primary pin. Not all pins are available on all 32U4 Arduinos, but if they are, the library mod now supports them. The pins mentioned are the standard Arduino pin mappings to the Atmega 32U4.
The new modes are:
DIFF_10_13 - Differential mode on pins 10 and 13, same as old diff. mode
CHB_9 - Single-ended mode on pin 9 (channel B)
CHB_10 - Single-ended mode on pin 10 (channel B)
CHB_DIFF_9_10 - Differential mode on pins 9 and 10 (with Channel B only!)
CHA_5 - Single-ended mode on pin 5 (channel A)
CHA_13 - Single-ended mode on pin 13 (channel A)
CHA_DIFF_5_13 (default) - Differential mode on pins 5 and 13 (with channel A only!)
Example: edgar.begin(DIFF_10_13);
New library is at:
http://projectmf.homelinux.com/Arduino/Synth/
I used the library to build an old-school phone phreak blue box, as it allows generation of multiple sine waves. See df9999999999 YouTube channel for details.
Reply 2 years ago
Hey man, this comment of yours is pretty old, but the link is not working any more and I'm trying to do the same as you did. (need to use an Leonardo so I can change the USB ID).
I already tried understanding the original lib, but it really is out of my league. Can you help me out and share your modifications?
Thanks o/
Reply 6 years ago
hello!
I can't seem to be able to access that link, it keeps 404ing, could you please upload it again?
thanks!
Reply 7 years ago
Hi df99, I am quite desperate looking for a way of making this four voices synth to work with arduino mega adk or due, I assume your codedoesn't help but do you have any suggestions?
Thanks!
Question 4 years ago
Hello Mads,
I love your synth master project and I would like to understand better the code you wrote. I am familiar with the Direct Digital Synthesis method but I am having trouble to figure the --Synthesizer/audio mixer-- part where all the waveforms are added. I guess all the bit shifting operation allows the overall signal to stay in the correct dynamic ? Could you please give us some more detail about this calculation ? Or maybe any good reads about this ?
I would appreciate that a lot ! Thank you :)
6 years ago
its not clear at all how to upload the files to the board. do I need an .ino file like in the examples? can i use any of the examples and how? and how do I get it to add a .h file as a directory. please help thank you :)
Reply 6 years ago
Download the zip archive from github, then add it to your arduino libraries as described here https://www.arduino.cc/en/Guide/Libraries ("Add .ZIP Library", then choose "the_synth" folder from the archive). Then just launch any .ino from the examples folder and upload to your arduino (song.ino will play the melody instantly after uploading). Pay attention that you should use pin 11 instead of 6 and 1K resistor instead of 2.2K. Good luck %)
Reply 6 years ago
Works like a charm on my Leonardo ( thanx df99 for the conversion !).
However, I would like to use a standard 5 pole Din midi cable at d0/rx.
Can someone help me out here to do this ?
I already have the midi interface ( 6N138 opamp & peripheral components installed on breadboard ).
Thanks in advance
7 years ago
I would really appreciate some help to make it work (as other people posted below, there is no sound) in an Arduino Mega ADK or Due.
Thanks!!
7 years ago
why no answers on the question asked the most??? how the #]%]%]< can I play the synth?? do i need to hook it up analog style and control it with midi out of a keyboard or can it be done through usb to arduino comm link?? a simple answer please! thanks ;)
Reply 7 years ago
I can try and help..
https://github.com/Qsilverrdc/the_synth/tree/maste...
This is a self playing 4 part song.
7 years ago
I made this couple of days ago, and love it! Such beefy low end :) . I'm trying to implement velocity sensitivity, but I'm kinda stuck. I passed midi_2nd from midi parser to synth like so
edgar.mTrigger(voice,parser.midi_1st,parser.midi_2nd);
Then modified mTrigger function in synth.h:
void mTrigger(unsigned char voice,unsigned char MIDInote, unsigned char velocity)
{
PITCH[voice]=pgm_read_word(&PITCHS[MIDInote]);
EPCW[voice]=0;
AMP[voice]=velocity*2;
FTW[divider] = PITCH[voice] + (int) (((PITCH[voice]>>6)*(EPCW[voice]>>6))/128)*MOD[voice];
}
It compiles fine, but doesn't change anything. Any suggestions?
7 years ago
i'm sorry, i feel a bit stupid : i built the thing and loaded the code on atmega328.... how do i play it now? I loaded the midi synth... should i play it from my daw? thanks
7 years ago on Introduction
would it be possible to use just two voices, but each on a separate PWM output to get effectively two detunable oscillators (detune realized by global pitchbend wheel and a dedicated detune knob, both read by analog inputs). Also how hard would it be to add a keyboard without using another Ardunio/uController?
Reply 7 years ago
I want to do the same thing did you ever figure out how to output different pins?
Reply 7 years ago
unfortunately no. I'm building a Meeblip Anode instead, but check out the Midimuso website, a guy sells preprogrammed atmegas that do just that, they cost about 8 pounds each
Reply 7 years ago on Introduction
unfortunately no, I just had to lower my expectations and use single pin :/
8 years ago on Introduction
Has anyone got this to compile in the 1.6.0 IDE? thanks
Reply 8 years ago on Introduction
I'm getting compilation issues as well fizz. Are you getting error messages like this?
In file included from IllutronBDemo0_2.ino:32:0:
sin256.h:4:23: error: variable 'SinTable' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
PROGMEM char SinTable[]=
^