Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: 20140103_1504 (pluck piece)
name
code content
/* 140103_1504 (pluck piece) by Nathan Thomas http://www.afternoondust.co.uk This piece uses code from Bruno Ruviaro (pluck pattern), published on SCCode.org: http://sccode.org/1-4Vn Don't forget to update the path to the audio sample on line 26. Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License: http://creativecommons.org/licenses/by-nc-sa/3.0/ */ ( Server.default = s = Server.internal; s.options.memSize = 655360; s.options.sampleRate = 96000.000; s.options.blockSize = 128; ) s.boot; c = Buffer.read(s, "insert/path/to/file/here/leaves_twigs_decode_004_edit.wav"); ( SynthDef("playamp", { arg krBus; var sig, amp, trig, thresh; thresh = MouseX.kr((-15),(-60)); sig = PlayBuf.ar(2,c,0.99,loop:inf); amp = Amplitude.kr(sig).ampdb; trig = amp >= thresh; Out.kr(krBus,trig); }).add; SynthDef("plucking", {arg amp = 1, freq = 440, decay = 5, coef = 0.1, krBus, outBus=0; var env, snd; env = EnvGen.kr(Env.linen(0, decay, 0), doneAction: 2); snd = Pluck.ar( in: Mix.new([WhiteNoise.ar(amp), SinOsc.ar(freq,0,amp)]), trig: Gate.ar(Impulse.ar(1),In.kr(krBus,1)), maxdelaytime: 0.1, delaytime: freq.reciprocal, decaytime: decay, coef: coef, mul: amp); Out.ar(outBus, [snd, snd]); }).add; SynthDef("playbuf", { arg outBus=0; var play; play = PlayBuf.ar(2,c,loop:inf); Out.ar(outBus,play); }).add; SynthDef("bass", {arg amp = 1, freq = 220, decay = 1, outBus=0; var env, snd, pan, env2, splay, phase; env = EnvGen.kr(Env.linen(1, decay, 1,1), doneAction: 2); phase = Array.fill(4, { do({ [0, 0.5, 0.7, 1].choose }) }); snd = SinOsc.ar([freq, freq + phase],[0,phase],amp/4).sum * env; splay = Splay.ar(snd,0.4); Out.ar(outBus, splay); }).add; ) z = Synth(\bass); // Groups ( ~sources = Group.new; ~control = Group.after(~sources); ~bus1 = Bus.control(s,1); ~bus2 = Bus.audio(s,2); ) x = Synth(\playamp,[\krBus,~bus1],~control); y = Synth(\playbuf); // Pluck ( var dur; dur = Prand([0.2, 0.4, 0.8], inf); a = Pbind( \instrument, "plucking", \krBus, ~bus1, \scale, Scale.dorian, \degree, Prand([8, 17, 9, 7, 15, 12, 13, 1, 5, 14], inf), \coef, dur, \dur, dur, \amp, Pwhite(0.3, 0.6), \decay, 3 ).play; ) // bass ( b = Task({ var delta, dur, note; dur = Prand([10, 15], inf).asStream; note = Pwrand([145, 290], [0.8,0.2], inf).asStream; while { delta = dur.next; delta.notNil } { Synth(\bass,[freq: note.next,decay:4]); delta.yield; } }).play(quant:TempoClock.default.beats+1.0); ) a.stop; b.stop; x.free; y.free; ~sources.free;~effects.free;~bus1.free;
code description
New piece arranged and performed in SuperCollider based on code from Bruno Ruviaro, "Pluck (Karpus-Strong) example" (pluck pattern - thanks Bruno) and a recording of dry leaves in a pestle. An archive containing the SuperCollider code and audio sample can be downloaded from http://afternoondust.co.uk/blog/140103_1504-pluck-piece. This code is released under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported license.
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change