// Music 220a - Final Project - Romain Michon // 12/11/2012 // This is an 'extended' karplus strong algorithm. It is excited by the signal from the audio input. Sorry for the comments in french :). The important one are in English... declare name "ksRom"; import("music.lib"); // defini noise, SR et delay import("instrument.lib"); // GUI freq = hslider("freq", 328, 20, 20000, 1); // Hz gain = hslider("gain", 1, 0, 20, 0.01); // gain compris entre 0 et 1 att = hslider("att",0.1,0,1,0.01); bdwth = hslider("fBandwidth",50,0,10000,0.1); stringFilter(x) = rho * ((b0 * x) + (b1 * x')) with{ B = hslider("brightness", 0.5, 0, 1, 0.01); t60 = hslider("decaytime", 4, 0, 10, 0.01); rho = pow(0.001,1.0/(freq*t60)); b1 = 0.5*B; b0 = 1.0-b1; }; P = SR/freq : smooth(0.999); resonator = (+ : fdelay(4096, P)) ~ (stringFilter); // very simple pitch shifter transpose (w, x, s, sig) = fdelay1s(d,sig)*fmin(d/x,1) + fdelay1s(d+w,sig)*(1-fmin(d/x,1)) with { i = s; d = i : (+ : +(w) : fmod(_,w)) ~ _; }; // shift the pitch of the input signal in function of the desired frequency. 164 is the resonance frequency of the CD shift = (164/(freq)) - 1; // GUI for the pitch shifter pitchshifter = transpose( hslider("window", 1000, 50, 10000, 1), hslider("xfade", 10, 1, 10000, 1), shift ); process = *(gain) : lowpass(2,bdwth) : pitchshifter : resonator;