Here’s another fun but simple project using the Audio Hacker shield for Arduino. This is a realtime voice changer, which is an improvement upon the original voice changer example I provided with the Audio Hacker library.
This project uses a technique called granular synthesis to change the pitch of the input. Granular synthesis is rather complex, but it involves dividing the sample up into small fragments called “grains”. When playing back a sample, if we want the pitch higher, we play the grain at a higher speed, but we play it over and over again until it takes the same amount of time as the grain played at original speed. Likewise, to lower pitch, we play each grain at a slower speed, but move onto the next grain sooner so that the overall sample has the same duration.
This realtime voice changer only lowers pitch. Raising pitch would require a lag to record something and play snippits of it faster. Lowering the pitch is accomplished by recording the input and then simultaneously playing it slower. That is, the “play head” moves slower than the “record head”. Occasionally, the play head needs to skip ahead over some of the input and catch up to the record head. This way, the playback takes the same amount of time as the recording, making it seem realtime. It is realtime, we are just playing only part of what was input (slowly) and skipping the rest so that the overall time is the same.
The example is in the Audio Hacker Library examples folder so you can load it into the Arduino IDE with
File->Examples->Audio Hacker->RealtimeVoiceChanger
As always, get the Audio Hacker library from GitHub: https://github.com/nootropicdesign/audio-hacker
Would you be able to put this device in a mask?
Hi, how do I buy this exact setup? With the pitch lowering knob and everything.
Follow the link in the article for the product information about Audio Hacker and how to buy it.
https://nootropicdesign.com/audio-hacker/
I own a Dalek ( Dr who sci fi evil thing) has a ring modulator effect been devised for the board?
Hello may I ask if you build this voice changer device and can I buy it from you . kind regards Marcus
Can the modified audio be routed to a PC’s Mic input instead of speakers? Say you want to change your voice and do the recording via the PC so to speak.
The output is headphone level on a 3.5mm jack, so if you can connect it to an input, yes.
What pins are the pitch pot connected to?
It’s connected to A0.
See in the code:
counterMod = map(analogRead(0), 0, 1024, 2, 11);
Do you have a circuit diagram of this
Hi, I would like to convert real-time voice into the wah-wah sound effect from Charlie Brown television series. Is it something that can be done using this set-up?
Is a 250K Ohm Potentiometer fine?
Or do in need necessarily a 500K Ohm?
Any potentiometer between 5K and 100K will be fine. I never said it was 500K.
Hi, How much is the price to build it? I must connect to a pc or it’s like the Batman toy mask of justice league that change the voice in real time?
Hi Mike,
This is so awesome. Thanks for making this.
My son (10) saw it and wants nothing more than this voice changer. We’ve since bought the board and just finished assembling it (fingers crossed we didn’t make any mistakes).
I’m not an expert on coding and Arduino tinkering. I have a fair understanding of programming, but would you be able to give a little bit more details on the project. I desperately trying to find out which pins to connect the potentiometer to.
I did certainly ready that you responded to that:
It’s connected to A0.
See in the code:
counterMod = map(analogRead(0), 0, 1024, 2, 11);
But at my level of knowledge I can’t derive which ports those really are.
Some additional help you be super great.
Thanks!
Are you asking which pin on the Arduino is A0? It’s the pin labeled “A0”. The analog inputs are on the lower right hand part of the Arduino board. The wiper (middle) pin of the pot connects to A0 and the other pins connect to GND and 5V.
https://www.arduino.cc/en/tutorial/potentiometer
Hi Michael. Thanks a lot. I might have figured it out. But when I try to compile the code, I get this:
Hi Michael. Thanks a lot. I might have figured it out. But when I try to compile the code, I get this:
In file included from /Users/xxxxx/git/audio-hacker/examples/VoiceChanger/VoiceChanger.ino:26:0:
/Users/xxxxx/git/audio-hacker/examples/VoiceChanger/AudioHacker.h:32:0: warning: “UINT16_MAX” redefined
#define UINT16_MAX 65535
In file included from /private/var/folders/d9/7gkbjpls0_jdmtf00rn822kh0000gr/T/AppTranslocation/569F7930-1607-44A1-980F-33A8E75A6F59/d/Arduino.app/Contents/Java/hardware/tools/avr/lib/gcc/avr/7.3.0/include/stdint.h:9:0,
from /private/var/folders/d9/7gkbjpls0_jdmtf00rn822kh0000gr/T/AppTranslocation/569F7930-1607-44A1-980F-33A8E75A6F59/d/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/inttypes.h:37,
from /private/var/folders/d9/7gkbjpls0_jdmtf00rn822kh0000gr/T/AppTranslocation/569F7930-1607-44A1-980F-33A8E75A6F59/d/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/avr/pgmspace.h:88,
from /private/var/folders/d9/7gkbjpls0_jdmtf00rn822kh0000gr/T/AppTranslocation/569F7930-1607-44A1-980F-33A8E75A6F59/d/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h:28,
from sketch/VoiceChanger.ino.cpp:1:
/private/var/folders/d9/7gkbjpls0_jdmtf00rn822kh0000gr/T/AppTranslocation/569F7930-1607-44A1-980F-33A8E75A6F59/d/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/stdint.h:346:0: note: this is the location of the previous definition
#define UINT16_MAX (__CONCAT(INT16_MAX, U) * 2U + 1U)
/var/folders/d9/7gkbjpls0_jdmtf00rn822kh0000gr/T//ccdDWeTf.ltrans0.ltrans.o: In function `__vector_13′:
/Users/xxxxxx/git/audio-hacker/examples/VoiceChanger/VoiceChanger.ino:195: undefined reference to `AudioHacker’
/Users/xxxxxx/git/audio-hacker/examples/VoiceChanger/VoiceChanger.ino:195: undefined reference to `AudioHacker’
/Users/xxxxxx/git/audio-hacker/examples/VoiceChanger/VoiceChanger.ino:195: undefined reference to `AudioHackerClass::writeDAC_8bit(unsigned char)’
/Users/xxxxxx/git/audio-hacker/examples/VoiceChanger/VoiceChanger.ino:201: undefined reference to `AudioHacker’
/Users/xxxxxx/git/audio-hacker/examples/VoiceChanger/VoiceChanger.ino:201: undefined reference to `AudioHacker’
/Users/xxxxxx/git/audio-hacker/examples/VoiceChanger/VoiceChanger.ino:201: undefined reference to `AudioHackerClass::readADC_8bit()’
/Users/xxxxxx/git/audio-hacker/examples/VoiceChanger/VoiceChanger.ino:205: undefined reference to `AudioHacker’
/Users/xxxxxx/git/audio-hacker/examples/VoiceChanger/VoiceChanger.ino:205: undefined reference to `AudioHacker’
/Users/xxxxxx/git/audio-hacker/examples/VoiceChanger/VoiceChanger.ino:205: undefined reference to `AudioHackerClass::writeSRAM(unsigned char, long, unsigned char)’
/Users/xxxxxx/git/audio-hacker/examples/VoiceChanger/VoiceChanger.ino:220: undefined reference to `AudioHacker’
/Users/xxxxxx/git/audio-hacker/examples/VoiceChanger/VoiceChanger.ino:220: undefined reference to `AudioHacker’
/Users/xxxxxx/git/audio-hacker/examples/VoiceChanger/VoiceChanger.ino:220: undefined reference to `AudioHackerClass::readSRAM(unsigned char, long)’
/var/folders/d9/7gkbjpls0_jdmtf00rn822kh0000gr/T//ccdDWeTf.ltrans0.ltrans.o: In function `setup’:
/Users/xxxxxx/git/audio-hacker/examples/VoiceChanger/VoiceChanger.ino:77: undefined reference to `AudioHacker’
/Users/xxxxxx/git/audio-hacker/examples/VoiceChanger/VoiceChanger.ino:77: undefined reference to `AudioHacker’
/Users/xxxxxx/git/audio-hacker/examples/VoiceChanger/VoiceChanger.ino:77: undefined reference to `AudioHackerClass::begin()’
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Uno.
What am I doing wrong?
I tried it on my Mac and on a Windows Laptop with the same output.
You didn’t install the library in the correct place. This warning indicates you put the library in the same folder as the VoiceChanger sketch:
/Users/xxxxx/git/audio-hacker/examples/VoiceChanger/AudioHacker.h:32:0: warning: “UINT16_MAX” redefined
That’s not how you install Arduino libraries. See the section about the library on the product page:
https://nootropicdesign.com/audio-hacker/
Right. I didn’t do that right. I’ll look into it. Thanks for your patience. I’ll get it working eventually.
After this embarrassing detour, I now have the code compiled and I uploaded it to the Arduino.
I guess, this is correct. (see below)
I don’t get a single sound out of the “output “jack, where my headphones are connected. Obviously a 3.5mm jack microphone is connected to the input jack.
What’s the minimum viable way to find out if I’ve soldered the board correctly?
+++++++++++++
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file “/var/folders/d9/7gkbjpls0_jdmtf00rn822kh0000gr/T/arduino_build_516711/VoiceChanger.ino.hex”
avrdude: writing flash (4506 bytes):
Writing | ################################################## | 100% 0.76s
avrdude: 4506 bytes of flash written
avrdude: verifying flash memory against /var/folders/d9/7gkbjpls0_jdmtf00rn822kh0000gr/T/arduino_build_516711/VoiceChanger.ino.hex:
avrdude: load data flash data from input file /var/folders/d9/7gkbjpls0_jdmtf00rn822kh0000gr/T/arduino_build_516711/VoiceChanger.ino.hex:
avrdude: input file /var/folders/d9/7gkbjpls0_jdmtf00rn822kh0000gr/T/arduino_build_516711/VoiceChanger.ino.hex contains 4506 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.59s
avrdude: verifying …
avrdude: 4506 bytes of flash verified
avrdude done. Thank you.
Don’t use a microphone unless you are sure how it works and how to power it. Verify the board by using a computer audio ouput connected to the board input with a 3.5mm TRS plug (3 conductors). Turn the volume of the computer output all the way up. You need a strong signal.
We have a support forum for support, not article comments: https://nootropicdesign.com/store/forums/forum/audio-hacker/
Hi, I’m just starting to get into Arduinos and electronics and bought the audio hacker kit. Which base Arduino board would you recommend for a project like this? Thanks for your time!
It’s compatible with Arduino Uno, Duemilanove, Mega, and Leonardo. Arduino Uno is simplest. If you use a Mega or Leonardo, it requires an ICSP header: https://nootropicdesign.com/store/product/icsp-header/
Thanks so much! I’ll give those a look
Hi Michael, I was hoping you could provide insights into how to alter the live pitch shifting Arduino code so that it pitches the audio up instead of down by a desired amount. Thank you!
How would I set the pitch to a defined amount?
This is an important bit of info for this unit if you are new to Arduino. You have to ad the library to the Arduino programming software . this is step by step , you just have it qadd the library from zip
https://www.youtube.com/watch?v=_-aH4BU4sOo&t=337s
There is some example project that correct the Voice pitch in real time, like autotune? O would like to see something like that.
Hey Mike,
How do I toggle between effects with the audio hacker?
I’m not sure I understand the question. Different effects are implemented by different programs you can load. Example projects here: https://nootropicdesign.com/audio-hacker/projects/
Are you able to overlap 2 voices at the same time to create an interesting effect?
For example: the same voice input to be splitted in one that has lower pitch an one that has higher pitch with a slight delay in between so that you create some sort of demon voice?