{
   "ancestor_list" : [],
   "description" : "A SuperCollider version of Alex McLean's vocable synthesiser. The original is written in haskell and uses hsc3.\r\n\r\n[Source Code](http://yaxu.org/software/vocable/)\r\n\r\n[Background and examples of the original system on Alex's blog](http://yaxu.org/category/vocable/)",
   "name" : "Simple Vocable Synthesiser",
   "author" : "uiae",
   "code" : "// alex mclean's vocable synthesis\r\n\r\n// see:\r\n// http://yaxu.org/software/vocable/\r\n// http://yaxu.org/category/vocable/\r\n\r\n\r\n(\r\nServer.default.waitForBoot({\r\n\tq = ();\r\n\tq.putnam = ( sA:  // soprano\r\n\t\t[ [800, 1150, 2900, 3900, 4950]\r\n\t\t\t, [0, -6,  -32, -20, -50]\r\n\t\t\t, [80, 90,  120, 130, 140] ]\r\n\t\t,sE:\r\n\t\t[ [350, 2000, 2800, 3600, 4950]\r\n\t\t\t, [0, -20, -15, -40, -56]\r\n\t\t\t, [60, 100, 120, 150, 200] ]\r\n\t\t,sI:\r\n\t\t[ [270, 2140, 2950, 3900, 4950]\r\n\t\t\t, [0, -12 , -26 , -26 , -44]\r\n\t\t\t, [60, 90,  100, 120, 120] ]\r\n\t\t,sO:\r\n\t\t[ [450, 800,  2830, 3800, 4950]\r\n\t\t\t, [0, -11 , -22 , -22 , -50]\r\n\t\t\t, [70, 80,  100, 130, 135] ]\r\n\t\t,sU:\r\n\t\t[ [325, 700,  2700, 3800, 4950]\r\n\t\t\t, [0, -16, -35, -40, -60]\r\n\t\t\t, [50, 60,  170, 180, 200] ]\r\n\t\t// alto\r\n\t\t, aA:\r\n\t\t[ [800, 1150, 2800, 3500, 4950]\r\n\t\t\t, [0, -4  , -20, -36 , -60]\r\n\t\t\t, [80, 90,  120, 130, 140] ]\r\n\t\t,aE:\r\n\t\t[ [400, 1600, 2700, 3300, 4950]\r\n\t\t\t, [0, -24 , -30, -35, -60]\r\n\t\t\t, [60, 80,  120, 150, 200] ]\r\n\t\t,aI:\r\n\t\t[ [350, 1700, 2700, 3700, 4950]\r\n\t\t\t, [0, -20, -30, -36 , -60]\r\n\t\t\t, [50, 100, 120, 150, 200] ]\r\n\t\t,aO:\r\n\t\t[ [450, 800,  2830, 3500, 4950]\r\n\t\t\t, [0, -9  , -16 , -28 , -55]\r\n\t\t\t, [70, 80,  100, 130, 135] ]\r\n\t\t,aU:\r\n\t\t[ [325, 700, 2530, 3500, 4950]\r\n\t\t\t, [0, -12 , -30, -40, -64]\r\n\t\t\t, [50, 60,  170, 180, 200] ]\r\n\t\t// counter tenor\r\n\t\t, ctA: [\r\n\t\t\t[660, 1120, 2750, 3000, 3350]\r\n\t\t\t, [0, -6  , -23 , -24 , -38]\r\n\t\t\t, [80, 90,  120, 130, 140] ]\r\n\t\t,ctE: [\r\n\t\t\t[440, 1800, 2700, 3000, 3300]\r\n\t\t\t, [0, -14 , -18 , -20, -20]\r\n\t\t\t, [70, 80,  100, 120, 120] ]\r\n\t\t,ctI: [\r\n\t\t\t[270, 1850, 2900, 3350, 3590]\r\n\t\t\t, [0, -24 , -24 , -36 , -36]\r\n\t\t\t, [40, 90,  100, 120, 120] ]\r\n\t\t,ctO: [\r\n\t\t\t[430, 820,  2700, 3000, 3300]\r\n\t\t\t, [0, -10, -26 , -22 , -34]\r\n\t\t\t, [40, 80,  100, 120, 120] ]\r\n\t\t,ctU: [\r\n\t\t\t[370, 630,  2750, 3000, 3400]\r\n\t\t\t, [0, -20, -23 , -30, -34]\r\n\t\t\t, [40, 60,  100, 120, 120] ]\r\n\t\t// tenor\r\n\t\t,tA:\r\n\t\t[ [650, 1080, 2650, 2900, 3250]\r\n\t\t\t, [0, -6   , -7  , -8 , -22]\r\n\t\t\t, [80, 90,  120, 130, 140] ]\r\n\t\t,tE:\r\n\t\t[ [400, 1700, 2600, 3200, 3580]\r\n\t\t\t, [0, -14 , -12 , -14 , -20]\r\n\t\t\t, [70, 80,  100, 120, 120] ]\r\n\t\t,tI:\r\n\t\t[ [290, 1870, 2800, 3250, 3540]\r\n\t\t\t, [0, -15, -18 , -20, -30]\r\n\t\t\t, [40, 90,  100, 120, 120] ]\r\n\t\t,tO:\r\n\t\t[ [400, 800,  2600, 2800, 3000]\r\n\t\t\t, [0, -10, -12 , -12 , -26]\r\n\t\t\t, [40, 80,  100, 120, 120] ]\r\n\t\t,tU:\r\n\t\t[ [350, 600,  2700, 2900, 3300]\r\n\t\t\t, [0, -20, -17 , -14 , -26]\r\n\t\t\t, [40, 60,  100, 120, 120] ]\r\n\t\t// bass\r\n\t\t,bA:\r\n\t\t[ [600, 1040, 2250, 2450, 2750]\r\n\t\t\t, [0, -7   , -9  , -9 , -20]\r\n\t\t\t, [60, 70,  110, 120, 130] ]\r\n\t\t,bE:\r\n\t\t[ [400, 1620, 2400, 2800, 3100]\r\n\t\t\t, [0, -12  , -9 , -12 , -18]\r\n\t\t\t, [40, 80,  100, 120, 120] ]\r\n\t\t,bI:\r\n\t\t[ [250, 1750, 2600, 3050, 3340]\r\n\t\t\t, [0, -30, -16 , -22 , -28]\r\n\t\t\t, [60, 90,  100, 120, 120] ]\r\n\t\t,bO: [[400, 750,  2400, 2600, 2900],\r\n\t\t\t[0, -11 , -21 , -20, -40],\r\n\t\t\t[40, 80,  100, 120, 120]]\r\n\t\t,bU:\r\n\t\t[ [350, 600,  2400, 2675, 2950]\r\n\t\t\t, [0, -20, -32 , -28 , -36]\r\n\t\t\t, [40, 80,  100, 120, 120] ] );\r\n\r\n\r\n\r\n\tq.consonants = (b: [ 0.00223, 1.00000],\r\n\t\tc: [ 0.00317, 0.86667],\r\n\t\td: [ 0.00596, 0.00571],\r\n\t\tf: [ 0.00105, 0.89714],\r\n\t\tg: [ 0.00340, 0.95330],\r\n\t\th: [ 0.00474, 0.99619],\r\n\t\tj: [ 0.00187, 0.90000],\r\n\t\tk: [ 0.00310, 0.47238],\r\n\t\tl: [ 0.00315, 0.95333],\r\n\t\tm: [ 0.00389, 1.00000],\r\n\t\tn: [ 0.00384, 0.99905],\r\n\t\tp: [ 0.00572, 0.99810],\r\n\t\tq: [ 0.00983, 0.08762],\r\n\t\tr: [ 0.00106, 0.93619],\r\n\t\ts: [ 0.00103, 0.88286],\r\n\t\tt: [ 0.00125, 0.12762],\r\n\t\tv: [ 0.00359, 0.00095],\r\n\t\tw: [ 0.00940, 1.00000],\r\n\t\tx: [ 0.00550, 0.51905],\r\n\t\ty: [ 0.00299, 0.98286],\r\n\t\tz: [ 0.00477, 0.99905] );\r\n\r\n\r\n\r\n\tq.playWord = { |dict,voice=0, word=\"test\"|\r\n\t\t{\r\n\t\t\tq.fd[voice].set(\\gain, 1);\r\n\t\t\tword.toLower.do{\r\n\t\t\t\t|letter|\r\n\t\t\t\tq.playLetter(voice, letter);\r\n\t\t\t\t0.05.wait;\r\n\t\t\t};\r\n\t\t\tq.fd[voice].set(\\gain, 0);\r\n\t\t\tq.playLetter(voice, $a);\r\n\t\t\t//\"done\".postln;\r\n\t\t}.fork;\r\n\t};\r\n\r\n\tq.playLetter = { |dict,voice,letter|\r\n\t\tif(letter.isVowel,\r\n\t\t\t{\r\n\t\t\t\tq.playVowel(voice, letter.asSymbol) },\r\n\t\t\t{\r\n\t\t\t\tif(letter.isAlpha,\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tq.playConsonant(voice, letter.asSymbol, 0.25)\r\n\t\t\t\t\t}, {\r\n\t\t\t\t\t\t//\"non-alphabetic character... ignored\".postln;\r\n\t\t\t\t});\r\n\t}) };\r\n\r\n\tq.playConsonant = { |dict,voice, letter, lagTime|\r\n\t\tq.fd[voice].set(\\lagTime, lagTime,\r\n\t\t\t\\delay, q.consonants[letter][0],\r\n\t\t\t\\blend, q.consonants[letter][1]) };\r\n\r\n\tq.playVowel = { |dict,voice, letter|\r\n\t\tq.sendVowel(voice, 'a' ++ letter.asString.toUpper.asSymbol);\r\n\t};\r\n\r\n\tq.sendVowel = { |dict,voice, letter|\r\n\t\tletter = letter.asSymbol;\r\n\t\tq.fd[voice].set(\r\n\t\t\t\\ffreqs, q.putnam[letter][0],\r\n\t\t\t\\fgains, q.putnam[letter][1],\r\n\t\t\t\\fbws, q.putnam[letter][2]) };\r\n\r\n\tq.initVoices = { |dict,numVoices|\r\n\t\tif(q.fd.isArray,\t{\r\n\t\t\tq.fd.do{ |synth| synth.set(\\gain, 0); synth.free; }});\r\n\t\tq.fd = 0!numVoices;\r\n\t\tnumVoices.do{ |i|\r\n\t\t\tq.fd[i] = Synth(\\ks);\r\n\t}};\r\n\r\n\tSynthDef(\\ks, { |out=0,gain=0,delay=1,blend=440,\r\n\t\tffreqs=#[350, 600,  2400, 2675, 2950],\r\n\t\tfgains=#[0, -20, -32 , -28 , -36],\r\n\t\tfbws=#[40, 80,  100, 120, 120],\r\n\t\tlag = 0.1|\r\n\t\tvar laggedDelay = Lag.kr(delay, lag);\r\n\t\tvar laggedBlend = Lag.kr(blend, lag);\r\n\t\tvar snd0,snd1,snd2,snd3,snd4,snd5,snd6, snd7;\r\n\t\tvar wn = WhiteNoise.ar;\r\n\t\tvar sin = SinOsc.ar(200, 0);\r\n\t\tsnd0 = Decay.ar(Impulse.ar(200, 0), 0.0025) * sin;\r\n\t\tsnd1 = LocalIn.ar(1) + (snd0 * gain.lag(0.01));\r\n\t\tsnd2 = DelayN.ar(snd1, 0.01, laggedDelay);\r\n\t\tsnd3 = Delay1.ar(snd2);\r\n\t\tsnd4 = (snd2 + snd3) / 2;\r\n\t\tsnd5 = ((wn > blend) * snd4) + ((1 - (wn > blend)) * (snd4 * -1));\r\n\t\tsnd6 = Mix(\r\n\t\t\tResonz.ar(snd5,\r\n\t\t\t\tffreqs,\r\n\t\t\t\tfbws/ffreqs)\r\n\t\t\t* fgains.dbamp);\r\n\t\tsnd7 = snd6 * 1.5;\r\n\t\tLocalOut.ar(snd5 * 0.99);\r\n\t\tOut.ar(out, snd7.dup);\r\n\t}).add;\r\n\r\n\tq.initVoices(3);\r\n})\r\n)\r\n\r\nq.playWord(0, \"Hello how are you today\");\r\n\r\nq.playWord(1, \"asdf\");\r\n\r\nq.playWord(1, \"hello\");\r\n\r\nq.playWord(1, \"cmo zeoiza mi xe wvizu\");\r\n\r\n(\r\nTask{\r\n\t[\"hello\", \"how\", \"are\", \"you\", \"today\"].do{\r\n\t\t|word|\r\n\t\tq.playWord(0, word);\r\n\t\t0.5.wait;\r\n\t}\r\n}.play\r\n)\r\n\r\n\r\n(\r\nPdef(\\vocable,\r\n\tPbind(\r\n\t\t\\amp, 0,\r\n\t\t\\word, Pseq([\"soup\", \"tackle\", \"qop\", \"\", \"hello\"],inf),\r\n\t\t\\dur, 0.25,\r\n\t\t\\voice, Pseq([0],inf),\r\n\t\t\\func, Pfunc{|k|\r\n\t\t\t\t\tq.playWord(k.voice,k.word)}))\r\n)\r\n\r\n(\r\nPdef(\\vocable,\r\n\tPbind(\r\n\t\t\\degree, \\rest,\r\n\t\t\\word, Pclump(Pwhite(1,2), Pseq([\"soup\", \"tackle\", \"qop\", \"asdf\", \"ho\", \"hi\"],inf)),\r\n\t\t\\dur, 0.25,\r\n\t\t\\strum, 0.125,\r\n\t\t\\func, Pfunc{|k|\r\n\t\t\tif(k.word.isString,\r\n\t\t\t\t{\r\n\t\t\t\t\tq.playWord(0,k.word);\r\n\t\t\t\t}, {\r\n\t\t\t\t\tk.word[..(q.fd.size-1)].do{\r\n\t\t\t\t\t\t|word,i|\r\n\t\t\t\t\t\tq.playWord(i, word)\r\n\r\n\t\t\t\t}}\r\n\t\t)}\r\n))\r\n)\r\n\r\nPdef(\\vocable).play\r\n\r\n\r\nPdef(\\vocable).stop",
   "id" : "1-4W2",
   "is_private" : null,
   "labels" : [
      "speech",
      "synthesis",
      "vocable",
      "livecoding",
      "yaxu"
   ]
}
