{
   "name" : "Rate Player",
   "author" : "joehigham",
   "ancestor_list" : [],
   "description" : "This is a player that I use for live work. It takes piano samples (or anything else I guess) and plays them in a rhythmic way that is also based on chord pitches. You'll see the GUI has (for me) chord names to remind me of what harmonic area this plays in. I'm using small sample of Morton Feldman's \"Triadic Memories\", if that's of any interest.",
   "labels" : [
      "sampler",
      "piano player"
   ],
   "is_private" : null,
   "id" : "1-5aA",
   "code" : "s.boot;\r\n\r\n/*============================================\r\nLOAD SOME PIANO SOUNDS HERE\r\n===============================================*/\r\n\r\n(\r\n~chords = Array.new;\r\n~folder = PathName.new(\"\"); // Load your path name here\r\n~folder.entries.do({\r\n\targ path;\r\n\t~chords = ~chords.add(Buffer.read(s,path.fullPath));\r\n});\r\n)\r\n\r\n~chords[rand(7)].play; // test here\r\n\r\n\r\n(\r\nSynthDef(\\pnoRhyth, {\r\n\targ out=0, relTime=1, bufnum=0, rate=1, amp=1;\r\n\tvar env, pno;\r\n\tenv = EnvGen.ar(Env.perc(0.01, relTime),doneAction:2);\r\n\tpno = BufRd.ar(1, bufnum,Phasor.ar(0,BufRateScale.kr(bufnum)*rate,0,BufFrames.kr(bufnum)));\r\n\tpno = pno*env;\r\n\tpno = pno*amp;\r\n\tOut.ar(out, pno);\r\n}).add;\r\n)\r\n\r\nSynth(\\pnoRhyth, [\\bufnum, ~chords[rand(7)], \\relTime, 1.5, \\out, 4, \\amp, 1.5]); // Test again\r\n\r\n/*=====================================================\r\nPIANO PLAYERS - there are pno_1 & pno_2\r\n======================================================*/\r\nt = TempoClock.new(100/60).permanent_(true);\r\n\r\n(\r\nPdefn(\\rate, Pseq([0,3],inf).midiratio);\r\nPdefn(\\amp, 1.5);\r\nPbindef(\\pno_1,\r\n\t\\instrument, \\pnoRhyth,\r\n\t\\dur, Pseq([Pseq([0.5],2), Pseq([0.25],2), Pseq([Rest(0.5)],2)],inf),\r\n\t\\rate, Pdefn(\\rate),\r\n\t\\bufnum, ~chords[0], // Pindex(~chords,Pseq((0..7),inf), inf),\r\n\t\\relTime, 0.3,\r\n\t\\out, 0,\r\n\t\\amp, Pdefn(\\amp),\r\n);\r\n// Player N° 2 //\r\n(\r\nPdefn(\\rate, Pseq([0,3],inf).midiratio);\r\nPdefn(\\amp, 1.5);\r\nPbindef(\\pno_2,\r\n\t\\instrument, \\pnoRhyth,\r\n\t\\dur, Pseq([\r\n\t\tPseq([0.5],2),\r\n\t\tPseq([0.25],4),\r\n\t\tPseq([Rest(0.5)],2)\r\n\t],inf),\r\n\t\\rate, Pdefn(\\rate),\r\n\t\\bufnum, ~chords[3], // Pindex(~chords,Pseq((0..7),inf), inf),\r\n\t\\relTime, 0.2,\r\n\t\\out, 0,\r\n\t\\amp, Pdefn(\\amp),\r\n);\r\n)\r\n)\r\n\r\n/*=====================================================\r\nCONTROLS for PLAYERS\r\n=======================================================*/\r\n\r\nPbindef(\\pno_1).play(t,quant:4);\r\nPbindef(\\pno_2).play(t,quant:4);\r\n\r\nPbindef(\\pno_1).resume(t,quant:1);\r\nPbindef(\\pno_2).resume(t,quant:1);\r\n\r\nPbindef(\\pno_1).pause;\r\nPbindef(\\pno_2).pause;\r\n\r\n\r\nPbindef(\\pno_1).resume;\r\n\r\nPbindef(\\pno_1).stop;Pbindef(\\pno_2).stop;\r\n\r\nPbindef(\\pno_1).clear;Pbindef(\\pno_2).clear;\r\n\r\n/*======================================================\r\nAMP BOOST ---------- if needed\r\n=======================================================*/\r\n\r\nPdefn(\\amp, 1.8);\r\n\r\n/*======================================================\r\nBUTTON FOR CHANGING RATES\r\n\r\n=======================================================*/\r\n\r\n\r\n(\r\nWindow.closeAll;\r\nw=Window(\"rate changer\",Rect(900,200,300,150))\r\n.front\r\n.alwaysOnTop_(true);\r\n\r\nw.view.decorator_(FlowLayout(w.bounds, 20@10,50@10));\r\n\r\n~tex_1 = StaticText(w.view, 80@20)\r\n.string_(\"Button_1\")\r\n.align_(\\center)\r\n.font_(Font(\"Monaco\", 10))\r\n.background_(Color.white);\r\n\r\n~tex_2 = StaticText(w.view, 80@20)\r\n.string_(\"Button_2\")\r\n.align_(\\center)\r\n.font_(Font(\"Monaco\", 10))\r\n.background_(Color.white);\r\n\r\nw.view.decorator.nextLine;\r\n\r\n~button_1 = Button(w.view, 80@80)\r\n.states_([\r\n\t[\"Ebm_1\", Color.black, Color.red],\r\n])\r\n.action_({ |button|\r\n\tswitch (button.value,\r\n\t\t0, { Pdefn(\\rate, Pseq([0,3],inf).midiratio) },\r\n\t)\r\n});\r\n\r\n~button_2 = Button(w.view, 80@80)\r\n.states_([\r\n    [\"Eb_2\", Color.black, Color.green],\r\n\t[\"F7_3\", Color.white, Color.blue]\r\n])\r\n.action_({ |button|\r\n\tswitch (button.value,\r\n\t\t0, { Pdefn(\\rate, Pseq([Pseq([0],3),Pseq([2],1)],inf).midiratio) },\r\n\t\t1, { Pdefn(\\rate, Pseq([Pseq([0],4),Pseq([Prand([2,4],inf)],2)],inf).midiratio) }\r\n\t)\r\n});\r\n);\r\n\r\n\r\n/*=============================================================\r\nPdefn info\r\n================================================================*/\r\nPdefn(\\rate, Pseq([0,3],inf).midiratio);\r\nPdefn(\\rate, Pseq([Pseq([0],3),Pseq([2],1)],inf).midiratio);\r\nPdefn(\\rate, Pseq([0,3],inf).midiratio);\r\nPdefn(\\rate, Pseq([Pseq([0],4),Pseq([Prand([2,4],inf)],2)],inf).midiratio);\r\n/*=================================================================*/\r\n\r\nt.tempo_(90/60); // Tempo change if needed"
}
