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.