Multiply audio signals for robot voice C# -


i'm trying wave output of .net speechsynthesizer make voice sound robot-ish.

after research, have found ring modulation might option obtain effect want. have seen formula result(t) = voice(t) * sinewave(t).

although, have no idea of how apply effect wave stream, there library out there :

  • generate sine wave , process wave stream
  • multiply both streams in order result

if not, know other option ? maybe multiply each sample in voice wave stream each sample in sine wave ?

i'm using c# /.net framework.

thank !

edit : okay, after few hours of failed attempts, i've came seems result. problem there's lot of crackling on output, , fix i've found apply low pass filter.

here's i've got far (quick, dirty , uncommented code, should self explanatory):

class mixer {     public static stream ringmodulation(stream voicestream, timespan duration, speechaudioformatinfo format)     {         var sinewave = sineoscillator.generatewave(duration, 80, 1, format);         var numsamples = convert.toint32(duration.totalseconds * format.samplespersecond);         var datastream = new memorystream();          sinewave.position = 0;         voicestream.position = 0;          var buf1 = new byte[2];         var buf2 = new byte[2];         (var = 0; < numsamples; i++)         {             voicestream.read(buf1, 0, 2);             sinewave.read(buf2, 0, 2);              var data = bitconverter.getbytes(convert.toint16(bitconverter.toint16(buf1, 0) * bitconverter.toint16(buf2, 0)));             datastream.write(data, 0, data.length);         }          return datastream;     } }  class sineoscillator {     public static stream generatewave(timespan duration, double frequency, int amplitude, speechaudioformatinfo format)     {         var numsamples = convert.toint32(duration.totalseconds * format.samplespersecond);         var datastream = new memorystream();         var angle = (math.pi * 2 * frequency) / (format.samplespersecond * format.channelcount);          (var = 0; < numsamples; i++)         {             var data = bitconverter.getbytes(convert.toint16(amplitude * math.sin(angle*i)));             // generate sine wave in both channels.             datastream.write(data, 0, data.length);         }          return datastream;     } }  

the low pass filter isn't applied yet, although, questions still open in case has answer provide and/or better way :)

i worked in audio processing time. way have "robot effect" repeat same frequency few milliseconds instead of having smoothed curve.

take frequency values interval
average values
write average output buffer whole interval

there different "robot effects" not sound same, not sound optimus prime unmistakably seem computer generated


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -