Friday, May 21, 2010

Voice Processing I - The Doctor's Voice #4

http://soundcloud.com/credit/docvoice-1

Mixes three signals for final result.  One of which is spectraly morphing  between a clean source and one with fft bin averaging using a parameter derived from the spectral centroid; one is routed through an array of three bandpass filters with the frequency and rq both controlled by respective algorithms derived from the spectral centroid; and one is a clean signal.

(   
var score=CtkScore.new, note, gamp, fftbuf, centbuf;
var doc, crossbuf, warpbuf, chain3buf;

doc = CtkBuffer("/Users/bion/Desktop/Transitions_In-Humanity/Doc1.wav").addTo(score);
fftbuf = CtkBuffer.buffer(2**12).addTo(score);
centbuf = CtkBuffer.buffer(2**12).addTo(score);
crossbuf = CtkBuffer.buffer(2**12).addTo(score);
chain3buf = CtkBuffer.buffer(2**12).addTo(score);

gamp = 6.dbamp;
note = CtkSynthDef(\docvoicing, {
    var chain, env, outS, pdoc, pray, cent, width, yi, er, san, avg, adj, centchain;
    var cross, chain2, waste, res, chain3;
    env = EnvGen.kr(Env([0,1,1,0], [0.01, 1, 0.01].normalizeSum, [-10, 10]), timeScale: doc.duration);
   
    pdoc = PlayBuf.ar(1, doc, BufRateScale.kr(doc));
   
    chain = FFT(fftbuf, pdoc);
    chain3 = PV_Copy(chain, chain3buf);

    centchain = PV_Copy(chain, centbuf);
    centchain = PV_MagAbove(centchain, 100);
    chain2 = PV_Copy(centchain, crossbuf);
    cent = SpecCentroid.kr(centchain);
    er = DelayC.kr(cent, 0.40, 0.40);
    san = DelayC.kr(cent, 0.06, 0.06);
    avg = (cent+er+san)/3;
    avg = avg.min(900);
    avg = avg.max(100);
    adj = LinLin.kr(avg, 100, 900, 0.6, 0);

    chain = PV_MagSmear(chain, 40);
    chain = PV_Morph(chain, chain2, adj);

    chain = IFFT(chain)*8.dbamp;
    chain2 = IFFT(chain2);
    chain3 = IFFT(chain3);
   
    width = (1-(adj+0.01));
    avg = avg*1.3;
    res = Mix.ar(BPF.ar(chain2, avg*[2,3,4], (width*[200, 500, 1000])/avg*[2,3,4]))*3.dbamp;
    outS = res+chain+chain3;
    outS = outS*gamp*env;
    outS = Limiter.ar(outS, 0.dbamp);
    outS = Compander.ar(outS, outS, -4.dbamp, 1, 0.5, clampTime: 0.01, relaxTime: 0.01);
    Out.ar(0, outS);
});

score.add(note.new(0.5, doc.duration/3));
//score.play;
score.write("~/Desktop/docvoice.wav".standardizePath,
    options: ServerOptions.new.numOutputBusChannels_(1))
)

No comments:

Post a Comment