diff --git a/ark_d.scd b/ark_d.scd index 3d0d90b..e1de813 100644 --- a/ark_d.scd +++ b/ark_d.scd @@ -13,17 +13,18 @@ Server.default.waitForBoot { "\n--- load samples: ...".postln; ~smpBuffers.do(_.free); //- free all buffers so we don't accumulate? - ~smpBuffers = List(); + //~smpBuffers = List(); + ~smpBuffers = Dictionary(); smpPath.filesDo({ |smpfile,i| // tell me what you are loading: postln(" " + i + smpfile.fileName ); // add a sample into a buffer, store object to List - ~smpBuffers.add(Buffer.readChannel(s, smpfile.fullPath, channels:[0])); + ~smpBuffers.add(smpfile.fileName -> Buffer.readChannel(s, + smpfile.fullPath, channels:[0])); }); - // load libs // "\n--- load libs: ...".postln; @@ -42,30 +43,199 @@ Server.default.waitForBoot { s.meter; s.scope(2); s.plotTree +/////////////////////////////////////////////////////////////////////////////////////// + + +( +// function to partially match filename for buffers +~getSmp = { |regexp| + ~smpBuffers.detect { |buf| + regexp.matchRegexp(buf.path) + } +}; +) + +( +SynthDef(\bufCyc, { + arg bufnum, gate=1, freq=440, chanDetune=1, out=0, amp = 1, attackTime=0.01, releaseTime=1; + + var snd, env; + + env = Linen.kr(gate, attackTime:attackTime, releaseTime:releaseTime, doneAction:2); + + freq = [freq, freq * (1 + (chanDetune * 0.0005))]; + + snd = BufRd.ar( + numChannels: 1, + bufnum: bufnum, + //phase: LFSaw.ar(BufDur.ir(bufnum).reciprocal).range(0, BufFrames.ir(bufnum)), + phase: LFSaw.ar(freq).range(0, BufFrames.ir(bufnum)), + loop: 1, + interpolation: 2); + + snd = snd * amp * env; + Out.ar(out, snd); + +}).add; +) + +Pdef(\x32).play +Pdef(\x32).fadeTime = 0; +( +Pdef(\x32, + Pbind( + \instrument, \bufCyc, + \bufnum, [~getSmp.value("0043"),~getSmp.value("0043")], + \octave, [3,2,4], + \degree, Pseq([2,2,4,1], inf), + \detune, [0.1,0], + \chanDetune, 20, + \dur, Pseq([0.20,0.40,0.60],inf), + \legato, 1, + \amp, [0.3,0.5,0.1], + \releaseTime, 0.01 + )); +) + +Pdef(\x33).play +Pdef(\x33).fadeTime = 0; +( +Pdef(\x33, + Pbind( + \instrument, \bufCyc, + \bufnum, [~getSmp.value("0246"),~getSmp.value("0229")], + \octave, 5, + \degree, Pseq([[4,9],2,8,4,1], inf), + \mtranspose, Pseq([Pn([0],10),Pn([3],10)],inf), + \detune, [0,0.3], + \chanDetune, Pseq([-10,0,5,10,-5],inf), + \dur, Pseq([0.20,0.40,0.60],inf), + \legato, 0.1, + \amp, [0.3,0.5,0.1] * 0.1, + \releaseTime, 1 + )); +) +/////////////////////////////////////////////////////////////////////////////////// + + +x = Synth(\BufCycle, [\bufnum, ~getSmp.value("AKWF_0001"),\freq, 41.midicps, \chanDetune, 100]); +y = Synth(\BufCycle, [\bufnum, ~getSmp.value("AKWF_0001"),\freq, 42.midicps, \chanDetune, 0]); +x = Synth(\BufCycle, [\bufnum, ~getSmp.value("AKWF_0043"),\freq, 75]); +x = Synth(\BufCycle, [\bufnum, ~getSmp.value("AKWF_0001")]); +~getSmp.value("AKWF_0001").plot + + +( +Ppar([ +Pbind( + \instrument, \BufCycle, + \bufnum, ~getSmp.value("AKWF_0043"), + \octave, 4, + \degree, Pseq([2,5,4,1], inf), + \detune, -4, + \dur, 1, + \legato, 0.5, + \amp, 0.5, + \releaseTime, 0.5 +), + +Pbind( + \instrument, \BufCycle, + \bufnum, ~getSmp.value("AKWF_0043"), + \octave, 4, + \degree, Pseq([2,5,4,1], inf), + \detune, 0, + \dur, 1, + \legato, 0.5, + \amp, 0.5, + \releaseTime, 0.5 +)]).play; +) + +s.scope + + + + +{SinOsc.ar(75) * [0,0.5]}.play +x.free + +a = { 10.rand }; b = a.reciprocal; postln("a: " + a.value); postln("1/" + a.value + " = " + b.value); + + 3.reciprocal + + + + + + + + + + + + + + +/////////////////////////////////////////////////////////////////////////////////////////// + + + + + + + + ~smpBuffers.postln; x = Synth(\softSaw); +x.release y = Synth(\granulator, [\bufnum, ~smpBuffers.at(0)]) -y.set(\amp,4) +y.set(\amp,0.4) y.set(\spread,1) y.set(\pan, 0) y.set(\gate, 0) -z = Synth(\bufPlayer, [\bufnum, ~smpBuffers.at(0)]) +( +// function to partially match filename for buffers +~getSample = { |regexp| + ~smpBuffers.detect { |buf| + regexp.matchRegexp(buf.path) + } +}; +) + +// how to match filename to bufnum +z = Synth(\bufPlayer, [\bufnum, ~smpBuffers.at("Ljuben Dimkaroski plays the Divje Babe Bone Flute-AZCWFcyxUhQ.wav")]) +z = Synth(\bufPlayer, [\bufnum, ~smpBuffers.detect { |buf| buf.path == "/home/random/Cloud/cloud.tmp.si/Projects/ark'd betwix/scd/smp/Ljuben Dimkaroski plays the Divje Babe Bone Flute-AZCWFcyxUhQ.wav" }]) +z = Synth(\bufPlayer, [\bufnum, ~smpBuffers.detect { |buf| "Divje Babe Bone Flute".matchRegexp(buf.path) }]) +z = Synth(\bufPlayer, [\bufnum, ~getSample.value("Divje Babe Bone Flute")]) + +~smpBuffers.detect { |buf| buf.path == .... } + +z.free + + + +~smpBuffers.dump + + + + /////////////////////////////////////////////////////////////////////////////////////////// ~smpBuffers[1].plot - +// buffer oscilator ( Ndef(\bosc, { - var buffer = ~smpBuffers[2], freq = 30, oscDetune = 1.01, amp = 0.2; + var buffer = ~getSample.value("AKWF_0001"), freq = 30, oscDetune = 1.01, amp = 0.2; BufRd.ar(1, bufnum:buffer, phase: LFSaw.ar([freq,freq*oscDetune]) * BufFrames.ir(buffer)) * amp //+ SinOsc.ar(60.2) * 0.5; } ); @@ -76,7 +246,7 @@ Ndef(\bosc).fadeTime=2; Ndef(\bosc).clear /////////////////////////////////////////////////////////////////////////////////////////////// -// creating buffers and filling them with weird waveforms +// creating buffers and filling them with waveforms a = Harmonics.new(16); // just returns an instance of Harmonics with size b = Buffer.alloc(s, 512, 1); @@ -84,12 +254,12 @@ b = Buffer.alloc(s, 512, 1); z = SynthDef("help-Osc",{ arg out=0,bufnum=0; Out.ar(out, LeakDC.ar( - Osc.ar(bufnum, [50,50.22], 0, 0.5) + Osc.ar(bufnum, [50,50.2], 0, 0.5) + + Osc.ar(bufnum, [50.01,50.21], 0, 0.5) ) ) }); ) - a.ramp(1.0, 2.0); a.ramp(0.5, -0.025) @@ -107,7 +277,7 @@ a.formant(6, 4); ( b.sine2( freqs: a.ramp(0,0.1).postln, - amps: a.ramp(1,0), + amps: a.ramp(1,3), normalize:true, asWavetable:true, clearFirst:true).plot; ) b.sine2(a.ramp(1.0,0.1).postln, a.geom(1.2), true, true, true); @@ -118,19 +288,68 @@ y.free; {SinOsc.ar()}.play +( +z = SynthDef("help-Osc",{ arg out=0,bufnum=0; + Out.ar(out, + Osc.ar(bufnum, 200, 0, 0.5) + ) +}); +) +//////////////////// +a.ramp(1.0, 1.0); // returns a harmonic series + +b = Buffer.alloc(s, 512, 1); +// harmonic series for freqs, ramp down for amps +b.sine2(a.ramp(1.0, 1.0).postln, a.ramp(0.5, -0.025).postln, true, true, true); +( +z = SynthDef("help-Osc",{ arg out=0,bufnum=0; + Out.ar(out, + Osc.ar(bufnum, 200, 0, 0.5) + ) +}); +) +y = z.play(s,[\out, 0, \bufnum, b]); +y.free; + +a.decay(1.0); + +b.sine2(a.rand(0.1, 0.9).postln, a.rand(0,1).postln, true, true, true); +b.plot +y = z.play(s,[\out, 0, \bufnum, b]); +y.free; + + + +a.teeth(6, 4); + +b.sine2(a.teeth(6, 4).postln, a.teett(2.2).postln, true, true, true); +y = z.play(s,[\out, 0, \bufnum, b]); +b.sine2(a.teeth(9, 1).postln, a.geom(1.2), true, true, true); +b.sine2(a.teeth(1, 3).postln, a.geom(1.2), true, true, true); +b.sine2(a.teeth(2, 3).postln, a.geom(1.2), true, true, true); +y.free; + /////////////////////////////////////////////////////////////////////////////////////////// +// create a stere bus of verbDelayFX ~reverBus = Bus.audio(s,2); + Ndef(\ba).play(~reverBus, addAction: \addToHead) +// reverb delay ~reverbDelay = Synth(\verbDelayFX, [\inBus, ~reverBus, \outBus, 0], addAction: \addAfter); -~reverbDelay.set(\revWet, 0); -~reverbDelay.set(\dlyWet, 1); +~reverbDelay = Synth(\verbDelayFX, [\inBus, ~reverBus, \outBus, 0], addAction: \addToTail); +~reverbDelay = Synth(\verbDelayFX, [\inBus, ~reverBus, \outBus, 0]); + +~reverbDelay.set(\revWet, 1); +~reverbDelay.set(\dlyWet, 0.5); + ~reverbDelay.free + Ndef(\ba).fadeTime=0.01; // for Patterns we don't want crossfade, but quantization // set default quant @@ -144,12 +363,13 @@ Ndef(\ba, \octave, [4,5,7], \amp, [0.1,0.2,0.005], \degree, Pseq([0,3,4,2,6,Prand([3,4,2,6])], inf), - \dur, Prand([1,0.5,2], 50), + \dur, Prand([1,0.5,2], 250), ), Pbind( \octave, [3,6], \degree, Pseq([[0,-3],4,6,3,2], inf), - \dur, Pseq([3.5,5], 10), + \dur, Pseq([Rest(30),Pseq([3.5,5], 30)]), + //\dur, Pseq([3.5,5], 30), \amp, 0.05, \legato, 0.6, \attackTime, 2, @@ -158,12 +378,14 @@ Ndef(\ba, // common parameters \instrument, \sinPulz, \oscDetune, Prand([1,3,5,7]*0.01, inf), - \scale, Scale.minor.tuning_(\just), + \scale, Pseq([Scale.minor.tuning_(\et12),Scale.minor.tuning_(\et12),Scale.minor.tuning_(\just)],inf), \cutoff, Prand([0.5,1,1.5], inf), + \mtranspose, Pseq([Pn([1],30),Pn([2],10),Pn([1],20),Pn([0],5)],inf), \out, ~reverBus )) ) +Tuning.directory Ndef(\ba).stop(1); Ndef(\ba).clear; diff --git a/work/bufCyc.scd b/work/bufCyc.scd new file mode 100644 index 0000000..09ac2b8 --- /dev/null +++ b/work/bufCyc.scd @@ -0,0 +1,74 @@ + +( +// function to partially match filename for buffers +~getSmp = { |regexp| + ~smpBuffers.detect { |buf| + regexp.matchRegexp(buf.path) + } +}; +) + +( +SynthDef(\bufCyc, { + arg bufnum, gate=1, freq=440, chanDetune=1, out=0, amp = 1, attackTime=0.01, releaseTime=1; + + var snd, env; + + env = Linen.kr(gate, attackTime:attackTime, releaseTime:releaseTime, doneAction:2); + + freq = [freq, freq * (1 + (chanDetune * 0.0005))]; + + snd = BufRd.ar( + numChannels: 1, + bufnum: bufnum, + //phase: LFSaw.ar(BufDur.ir(bufnum).reciprocal).range(0, BufFrames.ir(bufnum)), + phase: LFSaw.ar(freq).range(0, BufFrames.ir(bufnum)), + loop: 1, + interpolation: 2); + + snd = snd * amp * env; + Out.ar(out, snd); + +}).add; +) + +Pdef(\x32).play +Pdef(\x32).fadeTime = 0; +( +Pdef(\x32, + Pbind( + \instrument, \bufCyc, + \bufnum, [~getSmp.value("0043"),~getSmp.value("0043")], + \octave, [3,2,4], + \degree, Pseq([2,2,4,1], inf), + \mtranspose, Pseq([Pn([0],10),Pn([1],5),Pn([0],10),Pn([3],4)],inf), + \ctranspose, Pseq([Pn([0],50), Pn([5],5)],inf), + \detune, [0.1,0], + \chanDetune, 20, + //\dur, Pseq([0.20,0.40,0.60],inf), + \dur, Pseq([0.20,0.40,Prand([0.60,0.20])],inf), + \legato, 0.8, + \amp, [0.3,0.5,0.1], + \releaseTime, 0.06 + )); +) + +Pdef(\x33).play +Pdef(\x33).fadeTime = 0; +( +Pdef(\x33, + Pbind( + \instrument, \bufCyc, + \bufnum, [~getSmp.value("0246"),~getSmp.value("0229")], + \octave, [4,5,6], + \degree, Pseq([[4,9],2,8,4,1], inf), + \mtranspose, Pseq([Pn([0],10),Pn([3],10),Pn([0],10),Pn([5],5)],inf), + \ctranspose, Pseq([Pn([0],50), Pn([5],10)],inf), + \detune, [0,0.3,-0.3], + \chanDetune, Pseq([-10,0,5,10,-5],inf), + \dur, Pseq([0.20,0.40,Prand([0.60,0.20])],inf), + \legato, 0.1, + \amp, [0.7,0.5,0.1] * 0.1, + \releaseTime, 1 + )); +)