From 00a93afe95d5c17f37d5bbe6baac74b23fad8a8f Mon Sep 17 00:00:00 2001 From: Eugene Petkevich Date: Sun, 15 May 2022 14:31:23 +0300 Subject: [PATCH] Live 2022-05-15 --- melody.scd | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 134 insertions(+), 3 deletions(-) diff --git a/melody.scd b/melody.scd index ed133b3..293298c 100644 --- a/melody.scd +++ b/melody.scd @@ -13,14 +13,15 @@ ) ( -SynthDef(\sinetone, +SynthDef(\pulsetone, { arg out = 0, freq = 440, sustain = 0.05, gate=1, amp=1; var env, sig; sig = Pulse.ar(freq, 0.5, amp); sig = LPF.ar(sig, 4000); env = EnvGen.kr(Env.asr(0.01, 0.8, 0.05), gate, doneAction: Done.freeSelf); sig = sig * env; - Out.ar(out, sig!2) + sig = Pan2.ar(sig, Rand(-0.6, 0.6)); + Out.ar(out, sig); }).add; ) @@ -131,4 +132,134 @@ Pdef(\melody).stop; a = ~pnotes.asStream; a.next -TempoClock.tempo = 8; +TempoClock.tempo = 1; + +// with beat + +( +~curFreq = 220; +~steps = [0, 7, 5, 12]; +~intervalWeights = [1, 5, 2, 1]; +~freqHigh = 800; +~freqLow = 300; + +~durs = [1, 2, 3, 4, 8]; +~durWeights = [1, 2, 0, 1, 0]; + +~legatos = [0.2, 0.3, 0.4, 0.9]; +~legatoWeights = [1, 4, 4, 3]; + +~decibels = [-20, -55, -62]; +~decibelWeights = [0, 43, 28]; + +~chorus = [5, 7, 9, 12]; +~chorusWeights = [1, 2, 1, 5]; + +~pnotes = Pfunc({ + var direction, step, upWeight, downWeight, chorus; + upWeight = 1; + downWeight = 1; + if (~curFreq > ~freqHigh, {downWeight = ~curFreq/~freqHigh;}); + if (~curFreq < ~freqLow, {upWeight = ~freqLow/~curFreq;}); + direction = [-1, 1].wchoose([downWeight**3, upWeight**3].normalizeSum); + step = ~steps.wchoose(~intervalWeights.normalizeSum); + ~curFreq = ~curFreq * (direction*step).midiratio; + chorus = ~chorus.wchoose(~chorusWeights.normalizeSum); + [~curFreq, ~curFreq*chorus.midiratio]; +}); + +~pdurs = Pfunc({ + var dur; + dur = ~durs.wchoose(~durWeights.normalizeSum); + dur; +}); + +~plegatos = Pfunc({ + var legato; + legato = ~legatos.wchoose(~legatoWeights.normalizeSum); + legato; +}); + +~pdecibel = Pfunc({ + var decibel; + decibel = ~decibels.wchoose(~decibelWeights.normalizeSum); + decibel; +}); +) + +( +SynthDef(\beat, + { arg out = 0, amp=1; + var env, sig; + sig = BrownNoise.ar(); + sig = sig + LFPulse.ar(50, width: LFSaw.ar(1, 0.5), mul: 0.4); + sig = LPF.ar(sig, 300); + env = EnvGen.kr(Env.perc(0.001, 0.4), doneAction: Done.freeSelf); + sig = sig * env * amp; + Out.ar(out, sig!2) +}).add; +) + +( +SynthDef(\hat, + { arg out = 0, amp=1; + var env, sig; + sig = PinkNoise.ar(); + sig = sig + LFPulse.ar(200, width: LFSaw.ar(1, 0.5), mul: 0.2); + sig = LPF.ar(sig, 14000); + env = EnvGen.kr(Env.perc(0.001, 0.1), doneAction: Done.freeSelf); + sig = sig * env * amp; + Out.ar(out, sig!2) +}).add; +) + +( +SynthDef(\reverb, { |in, out = 0, mix=0| + var sig, wet; + sig = In.ar(in, 2); + wet = CombC.ar(sig, 5, 3/8, 6/8, mix); + Out.ar(out, sig+wet) +}).add; +) + +( +~melody = Pbind( + \instrument, \pulsetone, + \freq, ~pnotes, + \dur, ~pdurs, + \legato, ~plegatos, + \db, -20+~pdecibel, + \out, ~busOne, +); +Pdef(\melody, ~melody).quant_(8).stop; +) + +( +Pdef(\beat1, Pbind( + \instrument, \beat, + \dur, 8, + \db, -2, + \out, ~busOne, +)).quant_(8).stop; +) + +( +Pdef(\beat2, Pbind( + \instrument, \hat, + \dur, Pwrand([ + Pseq([8], 1), + Pseq(4!2, 1), + Pseq(2!4, 1), + Pseq(1!8, 1), + ], [1, 4, 2, 1].normalizeSum, inf), + \db, -26, + \out, ~busOne, +)).quant_(8).stop; +) + +~busOne = Bus.audio(s, 2); +~groupReverb = Group.new(s, \addToTail); + +~reverbSynth.free; +~reverbSynth = Synth(\reverb, [\in, ~busOne, \out, 0], ~groupReverb); +~reverbSynth.set(\mix, 0.9); \ No newline at end of file -- 2.17.1