Auduino Granular Synthesis

The Auduino project (not a typo – AUduino as in “audio arduino”) by Peter Knight has been around a while (over 10 years!) and is many people’s introduction to digital synthesis on the Arduino, so inspired by reading about someone else’s recent build I thought it was time to take a look myself.

  • In part 2, I delve deeper into the software to really see what is going on.
  • In this part I show how to add MIDI.
  • Here is a version that is controlled with a touchscreen.
  • And here is a version that uses a wavetable as the “grain”.

2020-12-07 21.30.45

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments or gear!

These are the key Arduino tutorials for the main concepts used in this project:

If you are new to Arduino, see the Getting Started pages.

Parts list

  • Arduino Uno
  • 5x 5k to 10k potentiometers (the original project used 4.7k pots)
  • 8 ohm speaker or old headphone speaker or alternative amplification
  • Breadboard and jumper wires

The Circuit

Auduino_bb

The simplest way to use the Auduino is to link up five potentiometers to A0 to A4 and a speaker to pin 3 as shown above.  One way is to use a breadboard – alternatively you could link the potentiometers together as shown.

This should be enough to get you started making some noises – see the code for details of what the potentiometers do – or just experiment!

The output is a 0 to 5V wave with a 2.5V DC offset, which is fine for a salvaged speaker – but if you want a more usable “line out” then you really ought to add some extra components.  There are a few options:

The basic idea is to create a simple RC filter to filter out any high frequencies due to the PWM output; include some kind of potential divider to bring the voltage down from a 5V range; and include a coupling capacitor on the output to remove the 2.5V DC bias.

But none of that is necessary if you just want to experiment.  I still haven’t really decided what is best, but I used the Notes and Volts circuit (a 33nF capacitor, 2.2K resistor and in my case a 10uF non-polar capacitor for the output) on a small solderless breadboard for my own experiments right now.

I’ve also used my six-potentiometer board I put together for the Arduino Multi-pot Mozzi FM Synthesis project, just because I happened to have it handy already and it is easy to wire up to an Arduino.

The Code

The Auduino code can be found here: https://code.google.com/archive/p/tinkerit/downloads

You need the auduino_v5.pde file which needs putting in your Arduino src directory.  I created an Auduino folder and renamed the file to auduino.ino, but you could just open the “pde” file directly by the Arduino environment if you wish (Arduino files used to be called .pde files before they were .ino files).

There are three modes in the code, selected by uncommenting one of the “synPhaseInc = ” lines in the main loop() function.  They relate to how the “sync” potentiometer controls the base frequency of the note:

  • “smooth frequency mapping” allows a continuous sweep of frequency in response to the pot.
  • “stepped MIDI mapping” moves between discrete notes in semitone steps.
  • “stepped pentatonic” cycles between D, E, G, A and B over a couple of octaves.

I really like the smooth mapping but you’ll need to experiment more to find some nice pitches.  The pentatonic mapping (the default) will get you up and running and making more harmonious sounds more quickly.

Closing Thoughts

This is all relatively straight forward to get up and running, but I’m not convinced I’ve got a decent output from the thing yet, so I’ll experiment a bit more with some filtering, but it certainly shows some promise.

I’m also not totally understanding the details of how granular synthesis is really working with the pot controls, so that is my next step too to dig into the code a bit more and see if I can work it out.  Looks like the folks at Sparkfun have already taken a look, so I’ll probably start there.

I might also add MIDI at some point (although Notes and Volts and been there and done that already too).

Kevin

2 thoughts on “Auduino Granular Synthesis

  1. This is a great write up! Thanks so much for referencing me, i’m really happy that my project inspired you to make this!!

    I enjoyed reading your little analysis of the code, it’s something I was a bit intimidated by when I wrote mine and didn’t touch on. I’m getting a bit more into the coding side of things now, so i’m also thinking of looking at how the code works. So, thanks for the start 😀

    Keep it up and I will keep an eye out for new stuff from you, great blog 🙂

    Liked by 1 person

  2. Hey no problem! Thanks for stopping by and commenting.

    I’ve just spend the evening deciphering the code as it happens – there seems to be a lot of articles using it, but nothing that I’ve found so far that really says how it works…

    So I’ll do a detailed writeup of how it works at some point. There are some really neat tricks (read “tricky code”) so it will take some explaining, but I think I’m getting there.

    For example, the line “antilogTable[input & 0x3f]) >> (input >> 6)” statement in mapPhaseInc is fascinating for what it does – a really neat trick! But I had to graph out some of the input values in a spreadsheet to see why it worked 🙂 I’ve done something similar for the bit where it generates the triangle wave too (using the C negating operator “~”).

    I just need to chew over how the sample rate (31.25kHz, so basically 32uS per “tick” of the PWM routine) is influencing the frequency changes and I’m probably there – but that is a task for another day now.

    But I really understand in a lot more detail what the pots do now.

    If there is anything on here you’d like a bit more detail on, feel free to ping over a message. Very happy to talk anything through anything I’ve written.

    And I’m looking forward to see where you go with your algorithmic stuff (although I don’t “do” Max).

    Best wishes,
    Kevin

    Like

Leave a comment