Welcome to Project Dalek

You need to be a member in order to access our content.

 

Click Here To Join!

 

For instant access to the plans and all Forum features, choose Active Membership.

andygrove

Arduino Voice Modulator

275 posts in this topic

I've started this thread to document my attempt at building a digital ring modulator using an Arduino. I don't know how well this will work compared to an analog ring modulator but I'm actually going to be trying both. I need something working by Halloween even if it isn't perfect.

I'm pretty new to Arduino and totally new to programming anything related to sound processing. I also only have a basic understanding of electronics, so this has been a very steep learning curve already.

I found this very helpful web page which also has example ring modulator source code.

http://interface.khm...dio-processing/

I was able to modify this example to get an initial version working and I thought it wasn't too bad apart from lots of background noise. This is partly because I'm running with a breadboard and with wires loosely wrapped around audio jacks etc. but also I understand I need something called a low-pass filter to remove noise (I haven't researched that part yet).

The actual code I'm running is available here. It is set up for the Arduino Mega 2560 and a couple of lines of code will need modifying to run on other boards because of differences in timer/pin mappings. I'm going to document this in the code shortly.

https://github.com/a...k_ringmodulator

The input to the board is an electret mic with built in pre-amp that I got from sparkfun for $8. The output is a pair of active PC speakers that obviously have their own amp built in. The Arduino is just reading the input at 15 KHz and combining it with an approximately 30 Hz sine wave before writing the signal to the output.

I'm going to do a bit of soldering as the next step and get some audio connectors and also research low pass filters. If anyone can give me any pointers that would be great!

Here is a photo of the current setup.

post-16139-0-14635100-1348018817_thumb.j

I have an audio recording in m4a format but the forum software won't let me upload it. I will post this separately once I've found out how. I may have to convert it to another format.

0

Share this post


Link to post
Share on other sites

If you zip the audio file it should upload OK. This is fascinating stuff, by the way.

0

Share this post


Link to post
Share on other sites

Ah... Thanks for the tip. I should have thought to try that. Here is the first sample.

DalekArduino1.zip

It's a starting point at least and hopefully I can find a way to filter out the noise. I've started reading about low pass filters and it looks like I just need a few resistors and capacitors to make a circuit to do this.

Andy.

0

Share this post


Link to post
Share on other sites

Ohh, this is very interesting! I have an Arduino somewhere, I'll have to dig it out and give it a go when im next at home! :)

I wonder what kind of other things I could add to it with a little bit of programming! No doubt sound to light can be done fairly easily with a relay board, and maybe even some other more advanced effects (Pitch changing, etc)!

Tom M

0

Share this post


Link to post
Share on other sites

Yup, I wrote code already to drive ultra bright LED dome lights based on the voice input but I haven't tried running this at the same time as the ring modulator code yet. I plan to do that soon. I had to write the code so that it make the LEDs fade away like a traditional light bulb and I was pretty close to how I wanted it.

I've managed to get a considerably better sound now by using a couple electrolytic capacitors on the mic input. There is still a low level background hiss though and I think I know how to solve that but need to order some more capacitors. Once I have it working smoothly I'll post an update with the circuit diagram.

In the meantime, here is the latest audio sample.

DalekArduino2.zip

Andy.

0

Share this post


Link to post
Share on other sites

Here is a short video showing the dome lights working in conjunction with the voice. This is all controlled from a single Arduino board, so it can be a pretty cost effective solution, especially if you build your own arduino board rather than buying a commercial version. I don't have quite that much time on my hands so will be ordering a $20 Arduino Uno that I can use for this project.

0

Share this post


Link to post
Share on other sites

Nice work Andy,

It sounds good too, I'm looking forward to seeing more of this. Although I have an Auduino Uno which is being used for another project, I do have an Auduino Pro Mini than has not seen any use. Would this work with you're project?

Steve

0

Share this post


Link to post
Share on other sites

Pretty sure the Pro Mini would work just fine :) But you need to solder the wires in on that version do you not?

This is a very cool project! Im back in cardiff this weekend and plan on picking up all my electronics stuff. May have to give this a test!

Ill fork you on github and let you know if I make any changes :)

Tom M

0

Share this post


Link to post
Share on other sites

Hey Andy,

I was just tidying up some variable names and what not so I have a better idea of whats going on and I have a question :) When the sine wave is generated, it is generated using a 'dc' value of 127, so its basically generated in the range of -1 to 1, multiplied by 127 to give the range -127 to 127 the we add the dc of 127 to make the range 0 254. How ever when the actual modulation is carried out the value of 'mid' is used (Ive looked at the original example you used and they use 127 too) this value is 96. Where did you get this number from? Is there a reason its 96 and not 127?

Tom M

Edit: Also, im sure I remember reading somewhere A long time ago that they also used a low-pass filter on the output side, I believe it was there to remove the sound of the sine wave, because without input you end up being able to hear that wave (assuming there is never total silence on the input) :)

Edit2: Ive put my cleaned up version of your code on GitHub, https://github.com/Milner08/arduino_dalek_ringmodulator, I skipped over the issue above and set it too 127 till I can test it. other than that it should really be identical in functionality to your code :)

0

Share this post


Link to post
Share on other sites

@DrJekyll -

As far as I know the Pro Mini should work fine. I did a quick search and saw that two versions are available - an 8 MHz and a 16 MHz model. If you have the 8 MHz model then you'll need to adjust the code accordingly to get the correct sine wave frequency. @Milner08 - It's great to see you're getting hands-on with this and I appreciate the feedback already. I've now cleaned up my version some more and I have removed the mid variable - that was just some late night hackery before I fully understood the code.

For what it's worth, here is the simplistic setup I have. Both capacitors are 1uF and both resistors are 150 ohm. The output goes to the audio jack shown on the bottom left of the breadboard.

post-16139-0-91925600-1348631544_thumb.j

This works but there is a lot of noise. As Milner08 mentions, the circuit needs a low pass filter to remove this noise. I have attempted this but with no success yet.

Andy.

0

Share this post


Link to post
Share on other sites

Luckily I have the 16 MHz model but this was mistakenly purchased as I was not aware that two versions were available. I needed the 8 MHz model at the time.

Steve

0

Share this post


Link to post
Share on other sites

I contacted the original author of the code to ask about the low-pass filter and he gave me the following link which has schematics for building one with some resistors, capacitors and inductors. I don't have the necessary components to hand but will be placing an order soon. http://interface.khm.de/index.php/lab/experiments/arduino-dds-sinewave-generator/

Andy.

0

Share this post


Link to post
Share on other sites

Am I right in thinking that the low pass filter simply removes (Or at least lowers the volume of) frequencies above a threshold? If so couldn't you just do that in the code? Im not entirely sure how the ADC works in the Arduino, but to remove them entirely wouldn't you just need a simple if statement?

So if the output is above value x, play nothing... I guess theres something there im not understanding (Music theory isn't my strongest point) but would that not at least work as a rudimentary one?

Tom M

0

Share this post


Link to post
Share on other sites

Damn, I just realised that wouldn't work... Ignore me, nothing to see here...

TM

0

Share this post


Link to post
Share on other sites

I made a breakthrough with this last night and now have it working very nicely. It turns out that the main problem the whole time was that the Arduino was being powered by a USB cable connected to my computer. The power signal must be fluctuating due to interference or something. As soon as I powered the board from a regular 9V battery it was 100x better. I have also added a resistor, inductor and capacitor on the output as per the diagram on this page.

I will be soldering the components onto a prototype board this weekend and will then post the final schematics and a new audio sample.

Can anyone recommend good software, preferably free, for Mac or Linux for drawing circuit diagrams?

Thanks,

Andy.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now