Arduino Soundlab




It is incredible what a wide range of amazing sounds can be generated with the FM synthesis technique, even using a plain Arduino. In a previous instructable this was illustrated with a synthesiser that had 12 pre-programmed sounds, but a viewer suggested that it'd be much cooler to have full control of the sound parameters with potentiometers, and so it is!

In this sound lab, tones can be controlled by 8 parameters: 4 for the ADSR envelope of the loudness and 4 for the frequency modulation that determines the texture.

The addition of the 8 potentiometers did not go at the cost of the number of keys: three sets of 8 keys are readout a few microseconds one after the other, for a total of 24 keys, corresponding to two full octaves. In fact, two Arduino pins are unused and expanding to 40 keys would be possible.

Look at the video for how to make wild sounds, here's a brief overview:

* A=attack: time for a tone to reach its maximum loudness (range 8ms-2s)

* D=decay: time for a tone to go down to its steady level of loudness (range 8ms-2s)

* S=sustain: steady level of loudness (range 0-100%)

* R=release: time for a tone to die out (range 8ms-2s)

* f_m : ratio of the modulation frequency to the carrier frequency (range 0.06-16) values below 1 result in undertones, higher values in overtones

* beta1 : amplitude of the FM modulation at the beginning of the note (range 0.06-16) small values result in minor variations of the sound texture. large values result in crazy sounds

* beta2 : amplitude of the FM modulation at the end of the note (range 0.06-16) Give beta2 a different value than beta1 to make the sound texture evolves in time.

* tau : speed at which the FM amplitude evolves from beta1 to beta 2 (range 8ms-2s) Small values give a short bang at the beginning of a note, large values a long and slow evolution.

Step 1: Construction

Clearly, this is still a prototype, I hope one day me or someone else will build this big and strong and beautiful with large keys and real dials for the potentiometers in an awesome enclosure....

Needed components:

1 Arduino Nano (It won't work with the Uno, which has only 6 analog inputs)

24 push-buttons

8 potentiometers, in the 1kOhm - 100kOhm range

1 potentiometer of 10kOhm for volume control

1 capacitor - 10microfarad electrolitic

1 3.5mm earphone jack

1 LM386 audio amplifier chip

2 1000microfarad electrolitic capacitor

1 ceramic 1microfarad capacitor

1 microswitch

1 8Ohm 2Watt speaker

1 10x15cm prototype board

Make sure you understand the attached schematics. The 24 buttons get connected in 3 groups of 8, to be read out at D0-D7, and to be activated on D8, D10 and D11. The pots have +5V and ground on the end taps and the central taps are fed to the analog inputs A0-A7. D9 has the audio output and gets AC-coupled to a 10kOhm potentiometer for volume control. The sound can be directly listened to with earphones, or amplified with an LM386 audio amplifier chip.

It is all fits on a 10x15cm protoptype board, but the buttons are too close to play well, so it'd be better to construct a larger keyboard.

The circuit can be powered through the USB connection on the Arduino Nano, or with an external 5V power supply. A 2xAA battery box followed by a step-up converter is a perfect powering solution.

Step 2: Software

Upload the attached sketch to the Arduino Nano and all should work.

The code is straigthforward and easy to modify, there is no machine code and no interrupts, but there are a couple of direct interactions with the registers, to interact with the timer, to speed up the button readout and to control the behaviour of the ADC for the potentiometer readout

Step 3: Future Improvements

Ideas from the community are always welcome!

I am most bothered by the buttons: they are tiny and click hard when pushed. It'd be really nice to have larger buttons that more comfortable to push. Also, force- or speed-sensitivy buttons would allow to control the loudness of the notes. Maybe 3-way pushbuttons or touch-sensitive buttons could work?

Other nice things would be to store sound settings in EEPROM, Storing short tunes in EEPROM would also allow to make much more interesting music. Finally, more complex sounds could be generated, if anyone knows how to generate percussion sounds in a computationally efficient way, that'd be awesome...



    • Backyard Contest

      Backyard Contest
    • Fandom Contest

      Fandom Contest
    • Pets Challenge

      Pets Challenge



    23 days ago

    Cool little synth build! Thanks for sharing your diagram too!