2

Hey I need to change audio files for my Voice Changer app. I need effects like robot or alien. Therefore, I have to implement a ring modulator http://en.wikipedia.org/wiki/Ring_modulation

Do you have any idea how to implement it? Or do you have a different and easier suggestion? I am able to change pitch, tempo and echo of the file.

Thanks for your help

2 Answers2

2

In principle, the ring modulator simply multiplies an input signal by a carrier, such as a low frequency sine wave:

f - input signal
g - carrier
h - output

h[i] = f[i] * g[i], for all i

As MSalters suggests, h is simply the inner product of f and g, and using a C++ function may be faster than computing it yourself.

However, ring modulators we are used to hearing are analog ring modulators and they introduce much more distortion than a digital ring modulators. If you want to emulate an analog ring modulator in the digital domain, you have to do much more work than is appropriate to describe here. However, there's a great reference here complete with sample code written in javascript and a reference to a nice paper:

http://webaudio.prototyping.bbc.co.uk/ring-modulator/

If you want that evil dalek sound effect that's the way to go. I don't know off the top my head how the simple digital method compares as a voice "robotizer," but I suspect they are both fine if you aren't specifically trying to emulate the dalek.

Of course there are many other methods for "robotizing" a voice, but the ring modulator is pretty classic. The other "classic" one is the channel vocoder, but it's much more complex to implement correctly.

Bjorn Roche
  • 11,279
  • 6
  • 36
  • 58
  • Can I iterate through all values of my wav and simply multiply them with g[i] ? The values of g[i] have to go from -1 to 1 ? How could I implement the sinus function? – Gingerbread123321 Sep 17 '13 at 16:21
  • There are many other questions here about creating a sine wave. Maybe not the best, but the first hit: http://stackoverflow.com/questions/5469030/c-play-back-a-tone-generated-from-a-sinusoidal-wave – Bjorn Roche Sep 17 '13 at 17:30
1

C++ has a standard function for that: std::inner_product. Just feed it the input signal and a sine.

MSalters
  • 173,980
  • 10
  • 155
  • 350