{
   "description" : "A simple synth with some controls and a little musical pattern to test it.\r\n\r\nSorry if my code isn't very good, i'm a newbie. Help will be welcome ...",
   "ancestor_list" : [],
   "name" : "Little FM Synth",
   "author" : "yl0506",
   "is_private" : null,
   "id" : "1-4Tv",
   "code" : "/* I made a simple synth but with some controls, and then I made a little musical pattern.\r\nI'm a newbie, so your help will be welcome if you learn me how improve these codes.\r\n\r\n*/\r\n// Execute this code first\r\n(\r\nSynthDef(\r\n\tname:\"fm3\",\r\n\tugenGraphFunc:{\r\n\t\targ f1 = 220,\r\n\t\t\tfreqmu = 2,\r\n\t\t\tf2,\r\n\t\t\tindex = 8,\r\n\t\t\tdecay = 0.25,\r\n\t\t\tvol = 0.1,\r\n\t\t\tfilterstart = 2000,\r\n\t\t\tfilterend = 10,\r\n\t\t\tphasemod = 10;\r\n\t\t\tf2 = freqmu * f1;\r\n\t\t\tOut.ar(\r\n\t\t\tbus: 0,\r\n\t\t\tchannelsArray: Resonz.ar( \t// A filter with resonance\r\n\t\t\t\tPMOsc.ar(\t\t\t\t// a simple FM oscillator\r\n\t\t\t\t\tcarfreq:[f1,f1+SinOsc.kr(55,0,1,0)*2],\r\n\t\t\t\t\tmodfreq:[f2-SinOsc.kr(27.5,0,1,0)*3,f2+SinOsc.kr(27.5,0,1,0)*3],\r\n\t\t\t\t\tpmindex: index,\r\n\t\t\t\t\tmodphase: phasemod + SinOsc.kr(\r\n\t\t\t\t\t\tfreq:55,\r\n\t\t\t\t\t\tphase:0,\r\n\t\t\t\t\t\tmul:1,\r\n\t\t\t\t\t\tadd:0),\r\n\t\t\t\t\tmul: vol,\r\n\t\t\t\t\tadd: 0) * Line.kr(\r\n\t\t\t\t\t\t\t\tstart: 0.5,\r\n\t\t\t\t\t\t\t\tend: 0,\r\n\t\t\t\t\t\t\t\tdur: decay,\r\n\t\t\t\t\t\t\t\tdoneAction: 2),\r\n\t\t\t\tfreq: XLine.kr(\r\n\t\t\t\t\tstart: filterstart,\r\n\t\t\t\t\tend: filterend,\r\n\t\t\t\t\tdur: decay - 0.09),\r\n\t\t\t\tbwr:1,\r\n\t\t\t    mul: 1)\r\n\t\t);\r\n}).add;\r\n);\r\n\r\n// Rajoutons une reverb, pour cela on crée un synthé qui ne fait que cela\r\n\r\n\r\n// Then execute this code\r\n(\r\nSynthDef(\\FreeVerb2x2, {|outbus, mix = 0.25, room = 0.70, damp = 0.5, amp = 1.0|\r\n    var signal;\r\n\r\n    signal = In.ar(outbus, 2);\r\n\r\n    ReplaceOut.ar(outbus,\r\n        FreeVerb2.ar( // FreeVerb2 - true stereo UGen\r\n            signal[0], // Left channel\r\n            signal[1], // Right Channel\r\n            mix, room, damp, amp)); // same params as FreeVerb 1 chn version\r\n\r\n}).add;\r\n);\r\n\r\n// Finally execute next code\r\n\r\n(\r\n// On va créer deux patterns en parallèle a et b, puis c et d, puis e et f ;\r\nvar a, b, c, d, e, f, n1 = 45, n2, n3, o1, o2, o3, p1, p2, p3, r1 = 1, r2, r3, r4;\r\n// On applique la reverb, ça sonne mieux\r\nz = Synth(\\FreeVerb2x2, [\\outbus, 0], addAction:\\addToTail);\r\n// Permier pattern a\r\nn2 = n1 + 12;\r\nn3 = n2 + 12;\r\no1 = n1 + 2;\r\no2 = o1 + 12;\r\no3 = o2 + 12;\r\np1 = n1 + 4;\r\np2 = p1 + 12;\r\np3 = p2 + 12;\r\nr2 = r1 * 2;\r\nr3 = r1 * 4;\r\nr4 = r1 * 8;\r\na = Pbind(\r\n\t\\instrument, 'fm3',\r\n\t\\dur, Pseq([0.2, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2, 0.2], r1),\r\n\t//\\freqmu, Pshuf([1, 2, 3, 4, 5, 6, 7, 8], 128),\r\n\t\\freqmu, Pshuf([1, 2, 3, 4], r2),\r\n\t\\f1, Pseq([n2,n3,n3,n2], r2).midicps,\r\n//\t\\index, Prand([3,4,5,6],256),\r\n\t\\vol, Prand([0.1,0.05,0.04,0.08],repeats:r4),\r\n);\r\n// Deuxième pattern b\r\nb = Pbind(\r\n\t\\instrument, 'fm3',\r\n\t\\dur, Pseq([0.4, 0.2, 0.2, 0.4, 0.4, 0.4, 0.4, 0.2], r1),\r\n\t//\\freqmu, Pshuf([1, 2, 3, 4, 5, 6, 7, 8], 128),\r\n\t\\freqmu, Pshuf([4, 5, 2, 7], r1),\r\n\t\\f1, Pseq([n1,n2,n2,n1], r1).midicps,\r\n\t\\index, Pseq([3,4,5,6], r1),\r\n\t\\vol, Prand([0.2,0.15,0.1,0.2],repeats:r3),\r\n\t\\filterend, Pseq(list:[10,100,1,500],repeats: r1),\r\n\t\\filterstart, Pseq(list:[1000,2000,500,3000],repeats: r1),\r\n\t\\phasemod, Pseq(list:[100,5,10,15,20],repeats: r1),\r\n\t\\decay, Pseq(list:[0.25,0.40,0.2,0.55,0.15],repeats: r1),\r\n);\r\nc = Pbind(\r\n\t\\instrument, 'fm3',\r\n\t\\dur, Pseq([0.2, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2, 0.2], r1),\r\n\t//\\freqmu, Pshuf([1, 2, 3, 4, 5, 6, 7, 8], 128),\r\n\t\\freqmu, Pshuf([1, 2, 3, 4], r2),\r\n\t\\f1, Pseq([o2,o3,o3,o2], r2).midicps,\r\n//\t\\index, Prand([3,4,5,6],256),\r\n\t\\vol, Prand([0.1,0.05,0.04,0.08],repeats:r4),\r\n);\r\nd = Pbind(\r\n\t\\instrument, 'fm3',\r\n\t\\dur, Pseq([0.4, 0.2, 0.2, 0.4, 0.4, 0.4, 0.4, 0.2], r1),\r\n\t//\\freqmu, Pshuf([1, 2, 3, 4, 5, 6, 7, 8], 128),\r\n\t\\freqmu, Pshuf([4, 5, 2, 7], r1),\r\n\t\\f1, Pseq([o1,o2,o2,o1], r1).midicps,\r\n\t\\index, Pseq([3,4,5,6], r1),\r\n\t\\vol, Prand([0.2,0.15,0.1,0.2],repeats:r3),\r\n\t\\filterend, Pseq(list:[10,100,1,500],repeats: r1),\r\n\t\\filterstart, Pseq(list:[1000,2000,500,3000],repeats: r1),\r\n\t\\phasemod, Pseq(list:[100,5,10,15,20],repeats: r1),\r\n\t\\decay, Pseq(list:[0.25,0.40,0.2,0.55,0.15],repeats: r1),\r\n);\r\ne = Pbind(\r\n\t\\instrument, 'fm3',\r\n\t\\dur, Pseq([0.2, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2, 0.2], r1),\r\n\t//\\freqmu, Pshuf([1, 2, 3, 4, 5, 6, 7, 8], 128),\r\n\t\\freqmu, Pshuf([1, 2, 3, 4], r2),\r\n\t\\f1, Pseq([p2,p3,p3,p2], r2).midicps,\r\n//\t\\index, Prand([3,4,5,6],256),\r\n\t\\vol, Prand([0.1,0.05,0.04,0.08],repeats:r4),\r\n);\r\nf = Pbind(\r\n\t\\instrument, 'fm3',\r\n\t\\dur, Pseq([0.4, 0.2, 0.2, 0.4, 0.4, 0.4, 0.4, 0.2], r1),\r\n\t//\\freqmu, Pshuf([1, 2, 3, 4, 5, 6, 7, 8], 128),\r\n\t\\freqmu, Pshuf([4, 5, 2, 7], r1),\r\n\t\\f1, Pseq([p1,p2,p2,p1], r1).midicps,\r\n\t\\index, Pseq([3,4,5,6], r1),\r\n\t\\vol, Prand([0.2,0.15,0.1,0.2],repeats:r3),\r\n\t\\filterend, Pseq(list:[10,100,1,500],repeats: r1),\r\n\t\\filterstart, Pseq(list:[1000,2000,500,3000],repeats: r1),\r\n\t\\phasemod, Pseq(list:[100,5,10,15,20],repeats: r1),\r\n\t\\decay, Pseq(list:[0.25,0.40,0.2,0.55,0.15],repeats: r1),\r\n);\r\n// On fait jouer les deux patterns en parallèle, les uns à la suite des autres\r\nPseq([Ppar([a, b]),Ppar([c, d]),Ppar([e, f]),Ppar([c, d]),Ppar([a, b])], 3).play;\r\n)\r\n)\r\n‎",
   "labels" : [
      "pattern",
      "educational"
   ]
}
