This Arduino-powered vocal effects box pitch shifts and distorts incoming audio signals to produce a wide variety of vocal effects. This project is my first experiment with real-time digital signal processing using Arduino. It samples an incoming microphone signal at a rate of about 40kHz, manipulates the audio digitally, and then outputs 8 bit audio at 40kHz. To minimize the amount of computation required by the Arduino, I used a technique called granular synthesis to manipulate the incoming audio signal. Essentially, as audio comes into the Arduino it gets cut up and stored as small (millisecond or microsecond sized) samples called "grains." These grains are then individually manipulated and played back; they may be lengthened or shortened, stretched or compressed, played back in reverse, copied several times, or mixed with other grains. You can hear a (somewhat creepy) audio sample from the effects box below:

Granular synthesis creates a unique type of distortion caused by discontinuities between individual grains in the outgoing signal. Sometimes this distortion creates an effect I can only describe as a "ripping" sound, other times it introduces new frequencies into the audio that were not present before. Here is an example by Aphex Twin, the granular synthesis is especially prominent in the bridge at around 3min in. Another example of granular synthesis, this time applied to vocals for pitch shifting and textural effects, is from Paul Lansky. My favorite thing to do with this effects box is to use subtle pitch shifting to achieve an androgynous vocal sound, I got the idea for the project after listening to copious amounts of Fever Ray this past winter, you can hear how she pitch shifts her voice to sound somewhat masculine at times.


(1x) Arduino Uno REV 3 Radioshack 276-128
(7x) 10K Ohm 1/4-Watt Carbon Film Resistor (2 packages) Radioshack #271-1335
(9x) 20K Ohm 1/4-Watt Carbon Film Resistor (2 packages)
(1x) 1K Ohm 1/4-Watt Carbon Film Resistor Radioshack 271-1321
(1x) 50K-Ohm Linear-Taper Potentiometer Radioshack #271-1716
(1x) 10KOhm Audio Control Potentiometer with SPST Switch Radioshack #271-215 (this will be used to control volume and turn the device on/off)
(5x) 0.25" Knurled Knob Radioshack 274-424
(2x) 9V Alkaline Battery Radioshack #23-866
(2x) Heavy-Duty 9V Snap Connectors Radioshack #270-324
(1x) PC Board with Copper Radioshack #276-147
(1x) SPST PC-Mountable Submini Toggle Switch Radioshack #275-645
(2x) Male Header Pins Jameco 103393
(3x) 8 pin socket Radioshack 276-1995
(1x) TL082 Wide Dual JFET Input Op Amp Radioshack 276-1715
(3x) 100K Ohm 1/4-Watt Carbon Film Resistor (1 package) Radioshack 271-1347
(1x) 10uF electrolytic capacitor
(1x) 47nF capacitor
(3x) 0.1uf capacitor Radioshack 55047557
(2x) 1M-Ohm Linear Taper Potentiometer Radioshack 271-211
(1x) 1MOhm logarithmic potentiometer
(1x) 2kOhm 1/4-Watt Carbon Film Resistor
(1x) male header pins Jameco 103393
(1x) 10K-Ohm Linear-Taper Potentiometer Radioshack 271-1715
(1x) DPDT Flatted Metal Lever Toggle Switch Radioshack 275-636
(2x) 1/4" stereo jack Radioshack 274-141 or Radioshack 274-312
(2x) 5mm High-Brightness White LED (1 package) Radioshack 276-017
(2x) 100 ohm 1/4W 5% Carbon Film Resistor Radioshack 271-1311
(2x) TS922IN Dual Op Amp Digikey 497-3049-5-ND (one TS924 would also work, but they are not available on digikey at the moment)

Additional Materials:
22 Gauge Wire Radioshack #278-1224
Solder Radioshack #64-013
sand paper
wood glue
hot glue

Download Arduino IDE

Step 1: Schematic

I've broken the schematic into three parts so it is easier to understand.

The first schematic shows the audio out circuit. This project outputs audio through an 8 bit R2Rdigital to analog converter through Arduino digital pins 0-7.  This signal is sent through an amplifier, a low pass filter, and a volume control pot before being sent out to speakers.

The second schematic shows the mic input circuit.  The line in the from the mic is sent through an amplifier and a DC offset circuit before being sent into the Arduino via analog input pin A0.

The third schematic shows how all the controls of the effects box are connected to the Arduino.  There are two LED indicators in this project: one clipping indicator and one output indicator.  Three pots on the device control grain size, pitch, and wet/dry mix and a switch controls the direction of sample playback (forward or reverse).
<p>Hey, have to say it is very impressive.</p><p>Is it possible to modify the code to get the function of a audio compressor?</p><p><em><strong>[Have you ever needed to talk into a mic for long periods? or headset? in an environment with background sounds? where you appear &quot;less professionally&quot;, when the sound sometimes is too high or too low, or brings that background sounds up so everyone can hear it? where the &quot;buy a professional PA system&quot; is not technically compatible or not economically feasible (charity/hobby)] </strong></em></p><p>The feature I'm looking for is:</p><p><b>- suppress to silence when sound level is below a set level.</b></p><p><strong>- when above, amplifying or suppress sound to att set level.</strong></p><p><strong>- with the aggressiveness as set.</strong></p><p><em>[exactly the same hardware, audio in/out and 3 potentiometer] :D</em></p><p><strong><br></strong></p><p>Best regards, Hans</p><p>(if anyone can help me with code, I will of course also be very happy)</p>
<p>hi amandaghassaei</p><p>am really so impressed by this project , awesome one I did found from long time , just have to ask if you can provide the .fz schema for the wiring and pcb if it's available </p><p>thank u </p>
<p>hi amandaghassaei</p><p>am really so impressed by this project , awesome one I did found from long time , just have to ask if you can provide the .fz schema for the wiring and pcb if it's available </p><p>thank u </p>
<p>I picked up some &quot;compatible&quot; op-amps from Fry's. They had the NTE941M which is supposed to be a replacement for the TS922IN. The problem I'm running into is, the NTE op-amp only has one input, but this circuit is using two inputs. The inverting and non inverting inputs are replaced by &quot;offset null&quot; pins. Is there any way to make it work with the NTE op-amp?</p>
<p>can this be made smaller to install it in a helmet...a Mandalorian Helmet...</p><p>http://imgur.com/dfXBWaU</p>
Great work. :) <br> <br>It'd be very nice if you could also include your input voice for the generated output sound. It'd help us get a much clearer picture.
<p>dear amanda,</p><p>thanks for the grat tutorial, it all works fine and amazing.</p><p>My simple question is:</p><p>I want to be able to select between 4 different input channels. As you use default pin A0 i dont have any idea how to write a funktion for a kind of &quot;switch&quot;,</p><p>Should be like &quot;if blabla0 -&gt; read from pinA0, else if blabla1 -&gt; read from pinA1...&quot;</p><p>Would be a so nice if you can help me out with this, I need a solution until next friday :)</p>
<p>Hello have you ever used DAC0800 or DAC08xx family for converter? </p>
<p>Hi there, I have a quick question. I have built the first part of this circuit, the DAC output, and when I load the code into the arduino looking for the 63 Hz sine wave the output is a square wave instead. Can you think of a reason why this would be?</p><p>Thanks.</p>
<p>Hi!</p><p>The project looks awesome! I've ordered the parts and I am making one on my own. However, how is the Arduino powered? With both batteries going into the microphone circuit, I don't see where Arduino would get its power source.</p><p>Thanks.</p>
<p>Is there a video showing it in action?</p>
<p>Hi!</p><p>This sounds like a great project, however i was wondering if it would work the same if i plugged in a guitar..</p><p>Thx in advance.</p>
<p>Im confused over step 13 where the schematic shows the capacitor with the + end to the op-amp. And then in the pictures/text you say that it should be the - end that connects to the op-amp.<br>Happy for any help!</p>
<p>Hey Amanda...I tried building this but the output isnt coming. I dont know for what reason but the input is being recognised. Can you help me with this?</p>
<p>Hi Amanda, the audio potentiometer with control switch isn't available in radioshack and I can't find anywhere to buy it. May I know the replacement for it, or can I use regular potentiometer as the replacement?</p>
<p>that's a bummer:</p><p><a href="http://www.futurlec.com/Potentiometers/POT10KBSWITCHpr.shtml">http://www.futurlec.com/Potentiometers/POT10KBSWIT...</a></p><p>or you can just use a regular pot and a switch.</p>
<p>thanks for the reply. right now, I have 1M logarithmic potentiometer with switch. will this potentiometer works with this project since the one you used is the regular without switch?</p>
You can use that in place of a 1m log pot without a switch
If I brought a dac device how would it change coding its 2wire serial divice ?
Hi Amanda, <br>do you know would it be ok to plug an external instrument ie. a drum machine or synthesizer into the input of the box? or would that cause some issues with power?
<p>that would work</p>
The capacitor isn't really a DC offset - it's a blocking cap which allows AC to pass and there is a major difference. DC offset is constant while blocking caps must take charge and discharge times into account, and also act as a high pass filter by default. The larger the cap the slower the response of blocking DC will be, while the lower the value the higher the cutoff or corner frequency of the Filter. Trade-offs...
Hey amanda ! <br> <br>What can I do if TS922IN and TS924 have not available in my country? <br> <br>What is the possible trouble if i try to use another kind of Op Amp? <br> <br>Cheers ! <br>
you can use any op amp - 072/82 are fine. the great thing about the TS922 was that it runs off 0-5V, meaning the arduino could send it power.
How about arduino Due ? I'm looking at that. It seem capable enough, am i right?
it's capable enough, but a bunch of the code will need to be modified. The analog input setup code especially.
Sorry, i am having some problem with the CAPTCHA. Hence, i am posting a new comment.. <br> <br>Thanks for the reply amanda! <br>This is an interesting project. Would love to try it out as a toy for my niece! Do you have any idea is there another model of arduino's with higher processing power and with the similar schematic?
there isn't unfortunately, the speed of the mega is the same.
Hey amanda ! <br> <br>May i check where do you store the recorded file being processed ? In the temporary storage in the arduino board itself? <br> <br>Is there any way that i could store the recorded files in a SD/MMC? <br> <br>Cheers !
right now it just get's stored in the arduino's memory, you can theoretically record to an SD card, but I have a feeling you will run into speed problems. The audio in/out is hogging most of the arduino's processing power, so it's difficult to do too many more things in parallel.
For some reason the anti-spam captcha box won't appear when I wish to post a reply. Ill just add my reply as a new post: <br> <br>I see. Yeah I was actually quite surprised at the relatively high samplerate you managed to achieve! I though the atmega328 was way to slow/simple to handle that. Have you considered using a audio codec (external ADC and DAC) (http://uk.rs-online.com/web/c/?sra=oss&amp;r=t&amp;searchTerm=audio+codec&amp;x=-608&amp;y=-21) for both input and output? I don't think there is very much point in increasing the fidelity after the processing when the audio is compressed to 8-bit fidelity when 'entering' the Arduino. <br>This could also be something to look into: http://soniccrayon.blogspot.no/2012/08/anti-nautilus-or-autoglitch.html (the schematic, first image below the youtube video)
Hi Amandaghassaei! First of; Great project! Im gonna have to build one this summer :) Something came to mind though. I saw you mentioned you were looking to increase the fidelity by adding a DAC chip. Have you considered the option of using the output PWM-stream option of the atmega328 chip? That would be a option to building a resistor-ladder as you have done. You would only need one digital output channel and a low-pass filter (preferably a two pole, or steeper, filter).
theoretically this idea is possible, but I think in practice the arduino is just not fast enough to handle audio input and PWM output at 38kHz. The resistor ladder is the most minimally processing intensive way to get the audio out. This project pushed the limits of what the arduino is capable of, I think you would find some very odd behavior if you tried to push it more. great idea though, would totally work in another context! I'm curious about how the fidelity would compare.
An easier alternative to that would be just buying a resistor pack.
Normally, the pitch of a perf board is actually not 2.54 mm but 0.1 inch (although they are almost exactly the same length) - the standard that established that spacing used inches, not mm, so the size should be quoted in inches, not mm.
I might have to try this project...I really want to get my hands dirty with DSP...this looks like the easiest way to learn so far.
I'm working on a similar project, how did you power the arduino, I see no connection to the Vin pin in any of your diagrams.
sorry, I must have forgotten to draw that in the schematic, I'll change it asap.&nbsp; Vin is connected the the +9V supply that is powering the TL082 mic amplifier op amp. It is just a 9V battery supply. be sure to connect the negative terminal of the battery to Arduino's ground. I actually wrote an instructable about it <a href="https://www.instructables.com/id/Powering-Arduino-with-a-Battery/">here</a>.
Also, is it possible to use a ac-dc power supply instead of two batteries? A voltage divider should provide positive and negative current to the op amp but I'm not sure how you'd ground the arduino.
yes it is possible. you should look up dual rail supply circuitls. Here is a good start: <br />https://www.instructables.com/id/Split-rail-power-supply-from-a-single-rail-supply/ <br />you can see in this project how there's a +V, -V, an 0V supply. Connect the 0V supply to Arduino ground.
Got it, thanks a lot. Built a buffered voltage divider using an op-amp to save space. One last question, I want to use a DAC instead of the resistor ladder to save space and improve the sound quality, I have a bunch of DAC0800 ICs and I know the basics of how to work them but my current setup doesn't seem to be getting any sound out of the arduino (I'm using your sine wave generator code) how would you set up the DAC?
funny you ask me that today, I just posted a relevant project here: <br />https://www.instructables.com/id/Stereo-Audio-with-Arduino/ <br />your dac setup should be similar, let me know if you still can't get it up and running, I can take a look at the data sheet.
I got it to run but it turns out the buffer is not doing it's job properly. It works when I invert the voltage inputs but it gives me negative voltage. I tested the divider and I'm getting 4v on one end and 10 on the other I need some kind of buffer that has a small outline (I'm short on space)
I'm thinking either a rail splitter or a BUF634 buffer. <br>
Hey so I am currently putting this project together for a class. I am around step 10 and you say to use a 2kOhm resistor, except in the supplies list there is not one listed, or at least not that I can find. I wanted to make sure this is the resistor I need to get. If you could let me know that'd be great! :)
yes, it's in there. sorry I'll update the parts list!
Hi, there was just a glitch in my connections. Got my sound working all right :) <br>I had this hooked up and was messing around with sound on my PC speakers and was wondering if this voice stream could get sent to my PC via ethernet. Say using the ethernet shield connected to the arduino being used?
I think it could work. The ethernet shield uses pins 10-13 to communicate: <br />http://www.arduino.cc/en/Main/ArduinoEthernetShield <br />so you will need keep those pins free. If you keep the clipping indicator, you will need to move it to another digital pin (like pin 9) <br />Check out this piece of code: <br />https://www.instructables.com/id/Arduino-Audio-Input/step7/Interrupt/ <br />you should try to send your serial data via ethernet inside the interrupt routine. Hopefully the Ethernet Shield is fast enough to send data at 38.5kHz, I'm not sure. <br />code with clipping indicator is at the bottom of this page: <br />https://www.instructables.com/id/Arduino-Audio-Input/step8/Clipping-Indicator/ <br />change all the 13's to 9's
do you have an amplifier connected to the DAC? your headphones may be putting too much of a load on the DAC and causing the signal to sag. do you have an oscilloscope? is there any way for you to measure the amplitude of the incoming/outgoing signals? maybe even a multimeter in ac mode?

About This Instructable




Bio: I'm a grad student at the Center for Bits and Atoms at MIT Media Lab. Before that I worked at Instructables, writing code for ... More »
More by amandaghassaei:OTCA Metapixel - Conway's Game of Life "9 Degrees of Freedom" IMU Twitter Controlled Pet Feeder 
Add instructable to: