Reorganize Хэзифу into supercollider-toolset
authorEugene Petkevich <nasedil.genio.code@gmail.com>
Mon, 16 May 2022 17:54:20 +0000 (20:54 +0300)
committerEugene Petkevich <nasedil.genio.code@gmail.com>
Mon, 16 May 2022 17:54:20 +0000 (20:54 +0300)
23 files changed:
33.7.3.2-с-Нэцэ.scd [deleted file]
bcr2000-control.scd [deleted file]
melody.scd [deleted file]
pedal-control.scd [deleted file]
pipelines.scd [deleted file]
push-control.scd [deleted file]
sampler.scd [deleted file]
server.scd [deleted file]
startup.scd [new file with mode: 0644]
test.scd [deleted file]
test2.scd [deleted file]
Хэзифу/33.7.3.2-с-Нэцэ.scd [new file with mode: 0644]
Хэзифу/bcr2000-control.scd [new file with mode: 0644]
Хэзифу/melody.scd [new file with mode: 0644]
Хэзифу/mix101-control.scd [new file with mode: 0644]
Хэзифу/pedal-control.scd [new file with mode: 0644]
Хэзифу/pipelines.scd [new file with mode: 0644]
Хэзифу/push-control.scd [new file with mode: 0644]
Хэзифу/sampler.scd [new file with mode: 0644]
Хэзифу/sl25remote-control.scd [new file with mode: 0644]
Хэзифу/test.scd [new file with mode: 0644]
Хэзифу/test2.scd [new file with mode: 0644]
Хэзифу/Незы.scd [new file with mode: 0644]

diff --git a/33.7.3.2-с-Нэцэ.scd b/33.7.3.2-с-Нэцэ.scd
deleted file mode 100644 (file)
index 27a82ad..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-(
-Pdef(\daki, ~se.makeSynthBind <> Pbind(
-  \dur, Pwrand([
-    Pseq(1!4, 1),
-    Pseq(2!2, 1),
-    Pseq((4/3)!3, 1),
-  ], [5, 2, 1].normalizeSum, inf),
-  \octave, [4, 5],
-  \note, Pxrand([0, 4, 9, 7, 2.5], inf),
-  \db, -5,
-)).quant_(4).stop;
-)
-
-(
-Pdef(\niru, ~se.makeSynthBind <> Pbind(
-  \dur, 1/2 * Pwrand([
-    Pseq(1!4, 1),
-    Pseq(2!2, 1),
-    Pseq((4/3)!3, 1),
-  ], [5, 2, 1].normalizeSum, inf),
-  \octave, [2, 3],
-  \note, Pxrand([0, 4, 9, 7], inf),
-  \db, -10,
-)).quant_(4).stop;
-)
-
-(
-Pdef(\bagi, Pbind(
-  \instrument, \dire,
-  \dur, 1/4 * Pwrand([
-    Pseq(1!4, 1),
-    Pseq(2!2, 1),
-    Pseq((4/3)!3, 1),
-  ], [5, 2, 1].normalizeSum, inf),
-  \octave, [2, 3],
-  \note, Pxrand([0, 4, 9, 7], inf),
-  \db, -20,
-  \legato, 2,
-)).quant_(4).stop;
-)
-
-TempoClock.tempo = 140 / 60;
-
-(
-SynthDef(\dire, { |amp=1, out=0, freq=440, gate=1|
-  var sig, modFreq, env;
-  modFreq = SinOsc.ar(3000, mul: freq/4, add: freq);
-  sig = Pulse.ar(modFreq);
-  env = EnvGen.ar(Env.adsr(), gate, doneAction: 2);
-  sig = sig * env;
-  sig = Pan2.ar(sig, Rand(-0.5, 0.5));
-  Out.ar(out, sig * amp);
-}).add;
-)
\ No newline at end of file
diff --git a/bcr2000-control.scd b/bcr2000-control.scd
deleted file mode 100644 (file)
index 3aee9c4..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-// Ableton push handler
-// by Eugene Zuelum
-//
-// see https://github.com/Ableton/push-interface for info about ABI:
-// https://github.com/Ableton/push-interface/blob/master/doc/AbletonPush2MIDIDisplayInterface.asc
-
-(
-~bcrFactory = {
-  var controler = Environment[
-    \version -> "33.7.3.6",
-
-    \channel -> 0,
-  ];
-
-  controler.know = true;
-
-  MIDIdef.cc(\bcr2000defaultTurn, { |...args|
-    controler.turn(*args);
-  }, (1..110), controler.channel);
-
-  "Ԃиџуту готов к использованию 😊".postln;
-
-  controler;
-};
-)
-
-//============================================================================= Testing
-
-/* Test incoming MIDI messages from push
-(
-MIDIdef.cc(\testcc, {|...args|
-(["cc"] ++ args).postln;
-});
-MIDIdef.noteOn(\testnoteon, {|...args|
-(["note on"] ++ args).postln;
-});
-MIDIdef.noteOff(\testnoteoff, {|...args|
-(["note off"] ++ args).postln;
-});
-MIDIdef.touch(\testtouch, {|...args|
-(["touch"] ++ args).postln;
-});
-MIDIdef.polytouch(\testpolytouch, {|...args|
-(["polytouch"] ++ args).postln;
-});
-MIDIdef.bend(\testbend, {|...args|
-(["bend"] ++ args).postln;
-});
-MIDIdef.sysex(\testsysex, {|...args|
-(["sysex"] ++ args).postln;
-});
-)
-*/
diff --git a/melody.scd b/melody.scd
deleted file mode 100644 (file)
index 293298c..0000000
+++ /dev/null
@@ -1,265 +0,0 @@
-~beri = ~bcrFactory.value;
-
-(
-~melmaker = Environment[
-  \current
-  \makemelody ->
-  {
-
-  }
-];
-~melmaker.know = true;
-
-)
-
-(
-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;
-    sig = Pan2.ar(sig, Rand(-0.6, 0.6));
-    Out.ar(out, sig);
-}).add;
-)
-
-});
-
-}, {});
-
-(
-~curFreq = 110;
-~steps = (0..15);
-~intervalWeights = [1]++(0!15);
-~freqHigh = 1000;
-~freqLow = 200;
-
-~durs = (1..8);
-~durWeights = (0!7) ++ [1];
-
-~legatos = (1..8)/8;
-~legatoWeights = (0!7) ++ [1];
-
-~decibels = (0..7) * -2;
-~decibelWeights = [1] ++ (0!7);
-
-~chorus = (0..15);
-~chorusWeights = [1]++(0!15);
-
-/*~chooseWeighted = {|values, weights|
-  values.
-};*/
-)
-
-(
-~beri.turn = {|zi, val, num|
-  num.postln;
-  if (num <= 16, {
-    ~intervalWeights[num-1] = val;
-    ("interval "++~steps[num-1]++" weight changed to "++val).postln;
-  });
-  if ((num >= 17) && (num <= 32), {
-    ~chorusWeights[num-17] = val;
-    ("chorus "++~chorus[num-17]++" weight changed to "++val).postln;
-  });
-  if ((num >= 81) && (num <= 88), {
-    ~durWeights[num-81] = val;
-    ("duration "++~durs[num-81]++" weight changed to "++val).postln;
-  });
-  if ((num >= 89) && (num <= 96), {
-    ~legatoWeights[num-89] = val;
-    ("legato "++~legatos[num-89]++" weight changed to "++val).postln;
-  });
-  if ((num >= 97) && (num <= 104), {
-    ~decibelWeights[num-97] = val;
-    ("decibel "++~decibels[num-97]++" weight changed to "++val).postln;
-  });
-  ~pnotes = Pfunc({
-    var direction, step, upWeight, downWeight, chorus;
-    upWeight = 1;
-    downWeight = 1;
-    if (~curFreq > ~freqHigh, {downWeight = ~curFreq/~freqHigh;});
-    if (~curFreq < ~freqLow, {upWeight = ~freqLow/~curFreq;});
-    //[downWeight, upWeight].postln;
-    direction = [-1, 1].wchoose([downWeight**3, upWeight**3].normalizeSum);
-    //direction.postln;
-    step = ~steps.wchoose(~intervalWeights.normalizeSum);
-    ~curFreq = ~curFreq * (direction*step).midiratio;
-    chorus = ~chorus.wchoose(~chorusWeights.normalizeSum);
-    //("new chorus: "++chorus).postln;
-    [~curFreq, ~curFreq*chorus.midiratio];
-  });
-
-  ~pdurs = Pfunc({
-    var dur;
-    dur = ~durs.wchoose(~durWeights.normalizeSum);
-    //("new duration: "++dur).postln;
-    dur;
-  });
-
-  ~plegatos = Pfunc({
-    var legato;
-    legato = ~legatos.wchoose(~legatoWeights.normalizeSum);
-    //("new legato: "++legato).postln;
-    legato;
-  });
-
-  ~pdecibel = Pfunc({
-    var decibel;
-    decibel = ~decibels.wchoose(~decibelWeights.normalizeSum);
-    //("new decibel: "++decibel).postln;
-    decibel;
-  });
-
-  ~melody = ~se.makeSynthBind <> Pbind(
-    \instrument, \sinetone,
-    \freq, ~pnotes,
-    \dur, ~pdurs,
-    \legato, ~plegatos,
-    \db, -10+~pdecibel,
-  );
-  Pdef(\melody, ~melody).quant_(1).play;
-};
-)
-
-Pdef(\melody).stop;
-
-~se.shiftPos(0.05);
-~se.playSample
-
-a = ~pnotes.asStream;
-a.next
-
-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
diff --git a/pedal-control.scd b/pedal-control.scd
deleted file mode 100644 (file)
index 1a868f0..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-// MIDI pedals handler
-// by Eugene Zuelum
-
-(
-~pedalFactory = {
-  var pedal = Environment[
-    \version -> "33.7.3.4"
-  ];
-
-  pedal.know = true;
-
-  // Sustain pedal on/off
-  MIDIdef.cc(\midiPedalSustain, { |...args|
-    if (args[0] != 0, {
-      pedal.suDown(*args);
-    }, {
-      pedal.suUp(*args);
-    });
-  },
-  65, 3);
-  // M-Audio Exp-M pedal (values range from 0 to 118 only)
-  MIDIdef.cc(\midiPedalExpression, { |...args|
-    var normed;
-    // m-audio
-    normed = args[0].linlin(0, 118, 0, 1);
-    pedal.xePres(normed, *args);
-  },
-  64, 3);
-
-  pedal.freeDefs = { |zi|
-    MIDIdef(\midiPedalSustain).free;
-    MIDIdef(\midiPedalExpression).free;
-  };
-
-  "Нычосё и Щюҙуԉы готовы к использованию 😊".postln;
-
-  pedal;
-};
-)
-
-//============================================================================= Testing
-
-// Test incoming MIDI messages
-/*
-(
-MIDIdef.cc(\testcc, {|...args|
-(["cc"] ++ args).postln;
-});
-MIDIdef.noteOn(\testnoteon, {|...args|
-(["note on"] ++ args).postln;
-});
-MIDIdef.noteOff(\testnoteoff, {|...args|
-(["note off"] ++ args).postln;
-});
-MIDIdef.touch(\testtouch, {|...args|
-(["touch"] ++ args).postln;
-});
-MIDIdef.polytouch(\testpolytouch, {|...args|
-(["polytouch"] ++ args).postln;
-});
-MIDIdef.bend(\testbend, {|...args|
-(["bend"] ++ args).postln;
-});
-MIDIdef.sysex(\testsysex, {|...args|
-(["sysex"] ++ args).postln;
-});
-)
-*/
-
-// Test library
-/*
-~pe = ~pedalFactory.value;
-~pe.suUp = {"up".postln};
-~pe.suDown = {"down".postln};
-~pe.xePres = {|zi, val| val.postln};
-*/
diff --git a/pipelines.scd b/pipelines.scd
deleted file mode 100644 (file)
index 810ff8e..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-(
-//======== Busses
-// speakers
-~spik = 0;
-
-// headphones
-~phon = 2;
-
-// recording
-~bare = Bus.audio(s, 2);
-
-// effect
-~bafe = Bus.audio(s, 2);
-
-a = { [2r10010, 2r101011, 2r11100].choose.postln };
-b = a >> 2;
-b.value.asBinaryDigits.join;
-
-
-//======== Groups
-// sources
-~guso = Group.new(s);
-
-// recording
-~gu
-
-~gure = Group.new(~guSources, \addAfter);
-
-~tempo
-)
\ No newline at end of file
diff --git a/push-control.scd b/push-control.scd
deleted file mode 100644 (file)
index c5d68a8..0000000
+++ /dev/null
@@ -1,331 +0,0 @@
-// Ableton push handler
-// by Eugene Zuelum
-//
-// see https://github.com/Ableton/push-interface for info about ABI:
-// https://github.com/Ableton/push-interface/blob/master/doc/AbletonPush2MIDIDisplayInterface.asc
-
-(
-~pushFactory = {
-  var dest;
-  var push = Environment[
-    \version -> "33.7.2.5",
-
-    \tempo -> 2,
-
-    \padColor -> IdentityDictionary[
-      \white   ->  0,
-      \red     ->  1,
-      \amber   ->  2,
-      \yellow  ->  3,
-      \lime    ->  4,
-      \green   ->  5,
-      \spring  ->  6,
-      \turquoise -> 7,
-      \cyan    ->  8,
-      \sky     ->  9,
-      \ocean   ->  10,
-      \blue    -> 11,
-      \orchid  -> 12,
-      \magenta -> 13,
-      \pink    -> 14
-    ],
-
-    // preprocess relative controls
-    \ppcr -> { |zi ...args|
-      if (args[0] > 64, {
-        args[0] = args[0] - 128;
-      });
-      args;
-    },
-
-    // preprocess absolute controls and notes
-    \ppca -> { |zi ...args|
-      args[0] = args[0].linlin(0, 127, 0, 1);
-      args;
-    },
-
-    // preprocess bend
-    \ppcb -> { |zi ...args|
-      if (args[0] >= 8192, {
-        args[0] = args[0].linlin(8192, 16383, 0, 1);
-      }, {
-        args[0] = args[0].linlin(0, 8192, -1, 0);
-      });
-      args;
-    },
-
-    // preprocess push color
-    \pppc -> {|zi, c=0,l=3,w=false|
-      var color;
-      c = zi.padColor[c] ? c;
-      if (c == 0, {
-        color = l;
-      },{
-        if (l == 0, {
-          color = 0;
-        }, {
-          if (w, {
-            color = c*4;
-          }, {
-            color = c*4 + 4 - l;
-          });
-        });
-      });
-      color;
-    },
-
-    \hcPushTurnN -> Array.newClear(9),
-    \hcPushTouchN -> Array.newClear(9)
-  ];
-
-  push.know = true;
-
-  push.controllerFuncs = [
-    // Rotators
-    MIDIFunc.cc({ |...args|
-      push.hcPushTurnS(*push.ppcr(*args));
-    }, 14, 0),
-    MIDIFunc.cc({ |...args|
-      push.hcPushTurnL(*push.ppcr(*args));
-    }, 15, 0),
-    MIDIFunc.cc({ |...args|
-      var col = args[1] - 71;
-      push.hcPushTurnN[col].value(*push.ppcr(*args));
-    },
-    (71..79), 0),
-    MIDIFunc.noteOn({ |...args|
-      push.hcPushTouchS(true, *args);
-
-    }, 10, 0),
-    MIDIFunc.noteOn({ |...args|
-      push.hcPushTouchL(true, *args);
-
-    }, 9, 0),
-    MIDIFunc.noteOn({ |...args|
-      //args[1] = args[1] - 71;
-      push.hcPushTouchN[args[1]].value(true, *args);
-    },
-    (0..8), 0),
-    MIDIFunc.noteOff({ |...args|
-      push.hcPushTouchS(false, *args);
-
-    }, 10, 0),
-    MIDIFunc.noteOff({ |...args|
-      push.hcPushTouchL(false, *args);
-
-    }, 9, 0),
-    MIDIFunc.noteOff({ |...args|
-      args[1] = args[1] - 71;
-      push.hcPushTouchN[args[1]].value(false, *args);
-    },
-    (0..8), 0),
-
-    // Left buttons
-    MIDIFunc.cc({ |...args|
-      if (args[0] == 127, {
-        push.playDown(*args);
-      }, {
-        push.playUp(*args);
-      });
-    }, 85, 0),
-    MIDIFunc.cc({ |...args|
-      if (args[0] == 127, {
-        push.recDown(*args);
-      }, {
-        push.recUp(*args);
-      });
-    }, 86, 0),
-
-    // Pads
-    MIDIFunc.noteOn({ |...args|
-      var note, row, col;
-      note = args[1] - 36;
-      col = note % 8;
-      row = (note/ 8).asInteger;
-      push.padDown(row, col, *push.ppca(*args));
-    },
-    (36..99), 0),
-
-    MIDIFunc.noteOff({ |...args|
-      var note, row, col;
-      note = args[1] - 36;
-      col = note % 8;
-      row = (note/ 8).asInteger;
-      push.padUp(row, col, *push.ppca(*args));
-    }, (36..99), 0),
-
-    MIDIFunc.polytouch({ |...args|
-      var note, row, col;
-      note = args[1] - 36;
-      col = note % 8;
-      row = (note/ 8).asInteger;
-      push.padPressure(row, col, *push.ppca(*args));
-    }, (36..99), 0),
-  ];
-
-  //============================== Binding hc to synth parameters
-
-  push.bindMul = { |zi, synth, param, divisor=1|
-    { |d|
-      synth.get(param, { |v|
-        var newVal = v*((d)/divisor).midiratio;
-        "%: % = %\n".postf(synth, param, newVal);
-        synth.set(param, newVal);
-      });
-    }
-  };
-
-  push.bindAdd = { |zi, synth, param, divisor=1|
-    { |d|
-      synth.get(param, { |v|
-        var newVal = v+(d/divisor);
-        "%: % = %\n".postf(synth, param, newVal);
-        synth.set(param, newVal);
-      });
-    }
-  };
-
-  push.bindRange = { |zi, synth, param, start, end|
-    { |v|
-      var newVal = v.linlin(0, 1, start, end);
-      "%: % = %\n".postf(synth, param, newVal);
-      synth.set(param, newVal);
-    }
-  };
-
-  //============================== LED control
-  dest = MIDIClient.destinations.detect({ |item|
-    var res = false;
-    if (item.device == "Ableton Push", {
-      if (item.name == "Ableton Push MIDI 2", {
-        res = true;
-      });
-      if (item.name == "User Port", {
-        res = true;
-      });
-    });
-    res;
-  });
-  push.pushOut = MIDIOut.newByName(dest.device, dest.name);
-  // The following is working by itself,
-  // but factory function assignment to global var
-  // returns nil
-  /*try {
-    // linux
-    push.pushOut = MIDIOut.newByName("Ableton Push", "Ableton Push MIDI 2");
-  }{
-    // mac os
-    push.pushOut = MIDIOut.newByName("Ableton Push", "User Port");
-  };*/
-
-  push.pushOut.latency_(0);
-  if (push.pushOut==nil, {"Cannot control push LEDs!"});
-
-  push.padLight = {|zi, row, col, light=3, color=0, whiten=false, mode=0|
-    if ((col < 0) || (col > 7) || (row < 0) || (row > 7), {}, {
-      zi.pushOut.noteOn(mode, 36+(row*8)+col, zi.pppc(color, light, whiten));
-    });
-  };
-
-  push.hcPushPadLedClear = { |zi|
-    for (0, 7, {|i|
-      for (0, 7, {|j|
-        zi.hcPushPadLed.value(i, j, 0);
-      });
-    });
-  };
-
-  push.freeHC = { |zi|
-    zi.controllerFuncs.do({ |item| item.free; });
-    zi.pushOut.free;
-  };
-
-  // todo — always send clocks, and separate start/stop from setting tempod
-  push.setTempo = { |zi, tempo|
-    {
-      zi.pushOut.start;
-      1.do({
-        24.do({
-          zi.pushOut.midiClock;
-          (1.0/zi.tempo/24).wait;
-        });
-      });
-      zi.pushOut.stop;
-    }.fork();
-  };
-
-  // Starter message and animation
-
-  {
-    (0..127).do({|i|
-      ~push.pushOut.noteOn(0, i, 1);
-      ~push.pushOut.control(0, i, 1);
-    });
-    1.wait;
-    (0..127).do({|i|
-      ~push.pushOut.noteOn(0, i, 0);
-      ~push.pushOut.control(0, i, 0);
-    });
-  }.fork();
-
-  "Џяпюӈи готов к использованию 😊".postln;
-
-  push;
-};
-)
-
-//============================================================================= Testing
-
-/* Test incoming MIDI messages from push
-(
-MIDIdef.cc(\testcc, {|...args|
-(["cc"] ++ args).postln;
-});
-MIDIdef.noteOn(\testnoteon, {|...args|
-(["note on"] ++ args).postln;
-});
-MIDIdef.noteOff(\testnoteoff, {|...args|
-(["note off"] ++ args).postln;
-});
-MIDIdef.touch(\testtouch, {|...args|
-(["touch"] ++ args).postln;
-});
-MIDIdef.polytouch(\testpolytouch, {|...args|
-(["polytouch"] ++ args).postln;
-});
-MIDIdef.bend(\testbend, {|...args|
-(["bend"] ++ args).postln;
-});
-MIDIdef.sysex(\testsysex, {|...args|
-(["sysex"] ++ args).postln;
-});
-)
-*/
-
-/*  Test all LED colors via rotaning left rotary control
-~push = ~pushFactory.value;
-~col = 0;
-
-(
-~push.hcPushTurnS = { |zi, delta|
-~col = (~col + delta).clip(0, 127);
-~col.postln;
-(0..127).do({|i|
-~push.pushOut.noteOn(0, i, ~col);
-~push.pushOut.control(0, i, ~col);
-});
-};
-)
-*/
-
-/* Show first 64 colors
-(
-~color = 1;
-8.do({|i|
-8.do({|j|
-~push.pushOut.noteOn(0, 36+(i*8)+j, ~color);
-~color = ~color + 1;
-});
-});
-)
-*/
diff --git a/sampler.scd b/sampler.scd
deleted file mode 100644 (file)
index ccd5c77..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-(
-// TODO: for whatever reason when called from mac os,
-// every method here is executed 4 times
-
-~samplerFactory = {
-  var maxDur = 10.0;
-  var sampler = Environment[
-    \version -> "33.7.2.3",
-    \maxDur -> maxDur,
-    \synthName -> \samplerPlay,
-    \buf -> Buffer.alloc(s, s.sampleRate * maxDur, 1),
-    \recsynthdef -> SynthDef(\samplerRecord, { |input, buf|
-      var sig;
-      sig = In.ar(input, 1);
-      RecordBuf.ar(sig, buf, doneAction: Done.freeSelf, loop: 0);
-    }).add,
-    \playsynthdef -> SynthDef(\samplerPlay, { |out = 0, buf = 0, startPos = 0, duration = 0.01, freq=220, amp=1, gate=1|
-      var sig, env, rate, susEnv;
-      rate = freq / 220;
-      sig = PlayBuf.ar(1, buf, BufRateScale.ir(buf)*rate, startPos: startPos*BufSampleRate.ir(buf), doneAction: 2);
-      env = Env.new([0, 1, 1, 0], [0.01, duration/rate-0.02, 0.01]);
-      // next env is to to nicely fade out synth on gate close
-      susEnv = Env.asr(0, 1, 0.01);
-      sig = sig * EnvGen.ar(env, doneAction: 2) * EnvGen.ar(susEnv, gate, doneAction: 2);
-      sig = sig * amp.lag(0.03);
-      Out.ar(out, sig!2);
-    }).add,
-    \startRec -> { |zi, pleiPich=false|
-      "startRec called".postln;
-      zi.startPos = 0.0;
-      zi.recSynth = Synth(\samplerRecord, [\input, s.inputBus, \buf, zi.buf], addAction: \addToTail);
-      zi.endPos = s.sampleRate * 10;
-      zi.startTime = thisThread.seconds;
-      zi.pleiPich = pleiPich;
-      if (pleiPich, {
-        zi.pichSint = Synth(\default, [freq: 220]);
-      });
-    },
-    \startPos -> 0,
-    \duration -> 0,
-    \stopRec -> { |zi|
-      "stopRec called".postln;
-      zi.duration = min(thisThread.seconds - zi.startTime, 10);
-      zi.recSynth.free;
-      if (zi.pleiPich, {
-        zi.pichSint.set(\gate, 0);
-      });
-      zi.buf.loadToFloatArray(zi.startPos*zi.buf.sampleRate, zi.duration*zi.buf.sampleRate, action: { |array|
-        { zi.plotter.value = array; }.defer;
-      });
-    },
-    \playSample -> { |zi|
-      "playSample called".postln;
-      zi.playSynth = Synth(\samplerPlay,
-        [\out, 0, \buf, zi.buf, \startPos, zi.startPos, \duration, zi.duration],
-        addAction: \addToHead);
-    },
-    \stopPlay -> { |zi|
-      zi.playSynth.postln;
-      zi.playSynth.set(\gate, 0);
-    },
-    \makeSynthBind -> { |zi|
-      "makeSynthBind called".postln;
-      Pbind(
-        \instrument, \samplerPlay,
-        \buf, zi.buf,
-        \startPos, zi.startPos,
-        \duration, zi.duration,
-      );
-    },
-    \makeSynthArgs -> { |zi|
-      "makeSynthArgs called".postln;
-      [
-        \buf, zi.buf,
-        \startPos, zi.startPos,
-        \duration, zi.duration,
-      ];
-    },
-    \shiftPos -> { |zi, delta|
-      var endPos = zi.startPos + zi.duration;
-      ("shiftPos called"++[delta, endPos, zi.startPos, zi.duration]).postln;
-      zi.startPos = (zi.startPos + delta).clip(0, endPos);
-      zi.duration = endPos - zi.startPos;
-      zi.buf.loadToFloatArray(zi.startPos*zi.buf.sampleRate, zi.duration*zi.buf.sampleRate, action: { |array|
-        if (array.size == 0, {array = [0]});
-        { zi.plotter.value = array; }.defer;
-      });
-    },
-    \window -> Window.new(
-      "Sampler",
-      Rect(Window.screenBounds.width-600,Window.screenBounds.height-180,500,100)
-    )
-  ];
-  sampler.know = true;
-
-  sampler.plotter = Plotter.new("sampler", Rect(0, 0, sampler.window.bounds.width, sampler.window.bounds.height), sampler.window);
-
-  sampler.window.front;
-
-  "Сэмплер готов к использованию 😊".postln;
-
-  sampler;
-};
-)
diff --git a/server.scd b/server.scd
deleted file mode 100644 (file)
index 829242f..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-(
-//s.options.outDevice = "MA WFRIENDZ";
-s.options.maxNodes = 128 * 1024;
-s.options.maxSynthDefs = 32 * 1024;
-s.options.memSize = 1024 * 1024;
-s.options.numBuffers = 32 * 1024;
-s.options.numAudioBusChannels = 32 * 1024;
-s.options.numControlBusChannels = 256 * 1024;
-s.options.numInputBusChannels = 16;
-s.options.numOutputBusChannels = 16;
-s.boot;
-MIDIClient.init;
-MIDIIn.connectAll;
-)
-
diff --git a/startup.scd b/startup.scd
new file mode 100644 (file)
index 0000000..829242f
--- /dev/null
@@ -0,0 +1,15 @@
+(
+//s.options.outDevice = "MA WFRIENDZ";
+s.options.maxNodes = 128 * 1024;
+s.options.maxSynthDefs = 32 * 1024;
+s.options.memSize = 1024 * 1024;
+s.options.numBuffers = 32 * 1024;
+s.options.numAudioBusChannels = 32 * 1024;
+s.options.numControlBusChannels = 256 * 1024;
+s.options.numInputBusChannels = 16;
+s.options.numOutputBusChannels = 16;
+s.boot;
+MIDIClient.init;
+MIDIIn.connectAll;
+)
+
diff --git a/test.scd b/test.scd
deleted file mode 100644 (file)
index e4e0a78..0000000
--- a/test.scd
+++ /dev/null
@@ -1,329 +0,0 @@
-(
-~push = ~pushFactory.value;
-~se = ~samplerFactory.value;
-~pe = ~pedalFactory.value;
-)
-
-(
-~se.buf.loadToFloatArray(action: { |array|
-  {
-    ~data = array;
-    "loading done".postln;
-  }.defer;
-  ~se.window.front;
-});
-)
-
-~se.soundView.setData(~data, 1024, samplerate: ~se.buf.sampleRate);
-
-~se.soundView.data
-
-(\freq: 220).play;
-
-~se.makeSynthEvent
-~se.makeSynthArgs
-(
-~notes = Array.newClear(128);
-~amps = Array.newClear(128);
-~pe.suDown = { |zi|
-  ~se.startRec(true);
-};
-~pe.suUp = { |zi|
-  ~se.stopRec();
-};
-~push.playDown = { |zi|
-  ~se.playSample();
-};
-~push.playUp = { |zi|
-  ~se.stopPlay();
-};
-~push.hcPushTurnL = { |zi, delta|
-  var mul = 0.01;
-  ~se.shiftPos(delta * mul);
-  ~se.startPos.postln;
-  ~se.duration.postln;
-};
-~push.padDown = { |zi, row, col, vel|
-  var freq;
-  ~push.padLight(row, col, 2, 1, false, 0);
-  freq = Scale.major.degreeToFreq(col, 0.midicps, row+1);
-  ~notes[freq.cpsmidi.asInteger] = Synth(~se.synthName, ~se.makeSynthArgs++[\freq, freq, \amp, vel]);
-  ~amps[freq.cpsmidi.asInteger] = vel;
-  ("down "++vel).postln;
-};
-~push.padUp = { |zi, row, col, vel|
-  var freq;
-  ~push.padLight(row, col, 0, 0, false, 1);
-  freq = Scale.major.degreeToFreq(col, 0.midicps, row+1);
-  //~notes[freq.cpsmidi.asInteger].set(\gate, 0);
-  ~amps[freq.cpsmidi.asInteger] = 0;
-};
-~push.padPressure = { |zi, row, col, vel|
-  var freq;
-  //~push.padLight(row, col, 0, 0, false, 1);
-  freq = Scale.major.degreeToFreq(col, 0.midicps, row+1);
-  if (vel > ~amps[freq.cpsmidi.asInteger], {
-    ~notes[freq.cpsmidi.asInteger].get(\amp, { |amp|
-      var maxRatio = 1.5;
-      ("initial "++vel).postln;
-      if ((vel/amp) > maxRatio, { vel = amp * maxRatio; });
-      ~notes[freq.cpsmidi.asInteger].set(\amp, vel);
-      ("new "++vel).postln;
-    });
-  });
-  ("pres "++vel).postln;
-};
-)
-
-//=============================================================================
-
-// sampler test
-
-~se = ~samplerFactory.value;
-
-~se.startRec();
-~se.stopRec();
-
-~se.buf.plot;
-~se.buf.getToFloatArray(wait:0.01, action: {arg array; a = array; { a[0..100].plot }.defer; "done".postln });
-
-~se.playSample();
-~se.duration = 2.5;
-
-(
-SynthDef(\test, { |amp = 1.0|
-  Out.ar(0, SoundIn.ar(1!2, amp.lag(0.01)));
-}).add;
-)
-
-a = Synth(\test);
-a.free;
-
-(
-MIDIdef.cc(\pollcc, { |...args|
-  //"cc".postln;
-  //args.postln;
-});
-
-MIDIdef.noteOn(\pollnoteon, { |...args|
-  "noteon".postln;
-  args.postln;
-});
-)
-
-(
-MIDIdef.cc(\tafe, { |...args|
-  var amp = args[0].linlin(0, 127, 0.1, 20);
-  a.set(\amp, amp);
-  amp.postln;
-}, 1);
-)
-
-/// push test
-
-~push = ~pushFactory.value;
-
-(
-~color = 64;
-8.do({|i|
-  8.do({|j|
-    ~push.pushOut.noteOn(0, 36+(i*8)+j, ~color);
-    ~color = ~color + 1;
-  });
-});
-)
-
-~push.hcPushKeyPressure.valueArray([1, 2, 3, 4]);
-~push.hcPushKeyOn.valueArray([1, 2, 3, 4]);
-
-(
-MIDIdef.cc(\testcc, {|...args|
-  (["cc"] ++ args).postln;
-});
-MIDIdef.noteOn(\testnoteon, {|...args|
-  (["note on"] ++ args).postln;
-});
-MIDIdef.noteOff(\testnoteoff, {|...args|
-  (["note off"] ++ args).postln;
-});
-MIDIdef.touch(\testtouch, {|...args|
-  (["touch"] ++ args).postln;
-});
-MIDIdef.polytouch(\testpolytouch, {|...args|
-  (["polytouch"] ++ args).postln;
-});
-MIDIdef.bend(\testbend, {|...args|
-  (["bend"] ++ args).postln;
-});
-MIDIdef.sysex(\testsysex, {|...args|
-  (["sysex"] ++ args).postln;
-});
-)
-
-MIDIdef.freeAll;
-
-(
-(0..127).do({|i|
-  ~push.pushOut.noteOn(15, i, 4);
-  //~push.pushOut.control(12, i, 3.choose);
-});
-)
-
-(
-~col = 38;
-(0..127).do({|i|
-  ~push.pushOut.noteOn(0, i, ~col);
-  ~push.pushOut.control(0, i, ~col);
-});
-)
-
-~push = ~pushFactory.value;
-~col = 0;
-
-(
-~push.hcPushTurnS = { |zi, delta|
-  ~col = (~col + delta).clip(0, 127);
-  ~col.postln;
-  (0..127).do({|i|
-    ~push.pushOut.noteOn(13, i, ~col);
-    ~push.pushOut.control(0, i, ~col);
-  });
-};
-)
-
-(
-{
-  ~tempo = 40;
-  ~push.pushOut.start;
-  5.do({
-    24.do({
-      ~push.pushOut.midiClock;
-      (60/~tempo/24).wait;
-    });
-  });
-  ~push.pushOut.stop;
-}.fork();
-)
-
-~push.pushOut.sysex(Int8Array[0xF0, 0x00, 0x21, 0x1D, 0x01, 0x01, 0x08, 0x00, 0x00, 0xF7]);
-
-m = MIDIClockOut("Ableton Push", "Ableton Push MIDI 2");
-m.port
-Tempo.bpm = 300;
-
-m.stop
-
-Tempo.default.bpm = 1;
-
-~pushOut = nil;
-
-(
-try {
-  ~pushOut = MIDIOut.newByName("Ableton Push", "Ableton Push MIDI 2").latency_(0);
-} {
-  ~pushOut = MIDIOut.newByName("Ableton Push", "User Port").latency_(0);
-};
-)
-
-// test exception problem
-
-(
-~factory = {
-  var ret;
-try { Exception.new().throw; ret = 1; } { ret = 2 };
-  ret;
-};
-)
-
-~test = ~factory.value;
-
-~push.setTempo(1);
-
-(
-~caller = Environment[
-  \func -> { "test".postln; }
-];
-~caller.know = true;
-)
-
-~caller.func
-
-~se.maxDur
-
-//=========================== scale experiments
-
-(
-//(note: 9, octave: 5).play;
-~se2.startRec;
-)
-~se2.stopRec;
-
-~se2.shiftPos(0.05);
-~se2.duration = ~se.duration - 1;
-~se2.playSample;
-Scale
-Tuning.directory
-(0..12).collect(_ * (3 ** (1/13)))
-~tun = Tuning.new((0..12).collect(_ * (12*(3 ** (1/13)).log2)), 3, "tritave");
-~scale = Scale.chromatic(~tun);
-
-(
-Pdef(\sampe, ~se.makeSynthBind <> Pbind(
-  \scale, ~scale,
-  \octave, 5,
-  \note, Pseq([[0, -7]]++(9!8), inf),
-  \dur, 3,
-  \db, -10,
-)).quant_(9).stop;
-)
-(
-Pdef(\sampo, ~se.makeSynthBind <> Pbind(
-  \scale, ~scale,
-  \octave, 5,
-  \note, Pxrand([2, 5, 8, 11], inf),
-  \dur, 1,
-  \db, -20,
-  \timingOffset, 1/3,
-)).quant_(9).stop;
-)
-(
-Pdef(\sampi, ~se.makeSynthBind <> Pbind(
-  \scale, ~scale,
-  \octave, 7,
-  \note, Pxrand((1,3..12), inf),
-  \dur, 1,
-  \db, -30,
-  \timingOffset, 1/6,
-)).quant_(9).stop;
-)
-
-TempoClock.tempo = 2;
-(
-Pdef(\teste, Pbind(
-  \dur, 1
-)).stop;
-)
-~se2 = ~samplerFactory.value;
-(
-Pdef(\samia, ~se.makeSynthBind <> Pbind(
-  \scale, ~scale,
-  \octave, 5,
-  \note, Pseq((0..12)++(11..1) +.t [0, 7], inf),
-  \dur, 4,
-  \db, -1,
-  \timingOffset, 0,
-)).quant_(4).stop;
-)
-
-(
-Pdef(\samei, ~se2.makeSynthBind <> Pbind(
-  \scale, ~scale,
-  \octave, 5,
-  \note, Pseq((0..12)++(11..1) +.t [0, 3], inf),
-  \dur, 3,
-  \db, -15,
-  \timingOffset, 0,
-)).quant_(4).stop;
-)
-
-{SinOsc.ar(440, mul: 0.2)}.play
\ No newline at end of file
diff --git a/test2.scd b/test2.scd
deleted file mode 100644 (file)
index c1606f8..0000000
--- a/test2.scd
+++ /dev/null
@@ -1,266 +0,0 @@
-// trying varios scales
-
-~tun = Tuning.new((0..12).collect(_ * (12*(3 ** (1/13)).log2)), 3, "tritave");
-~scale = Scale.chromatic(~tun);
-
-(
-SynthDef(\sibino, { |
-  out=0, gate=1, freq=440, modFreq=440, amp=1, release=1.0, maxIndex=1
-  |
-  var sig, modIndex, env;
-  env = EnvGen.ar(Env.asr(releaseTime: release), gate, doneAction: 2);
-  modIndex = (1 - env) * maxIndex;
-  sig = PMOsc.ar(freq, modFreq, modIndex, mul: amp);
-  sig = sig * env;
-  sig = Pan2.ar(sig, Rand(-0.3, 0.3));
-  Out.ar(out, sig * amp);
-}).add;
-)
-
-(
-SynthDef(\sidrub, {
-  | out=0, gate=1, freq=440, amp=1, cut=800, rez=0.8,
-  modFreqMin=7, modFreqMax=12, modAmp=0.01, sustain=1.0 |
-  var sig = 0;
-  var modFreq = SinOsc.kr(Rand(modFreqMin, modFreqMax), 0, modAmp, 1);
-  sig = sig + Pulse.ar(freq * modFreq);
-  sig = RLPF.ar(sig, cut.lag(0.01), rez.lag(0.01));
-  sig = sig * EnvGen.ar(Env.perc(releaseTime: sustain), gate, doneAction: 2);
-  sig = Pan2.ar(sig, Rand(-0.3, 0.3));
-  Out.ar(out, sig * amp);
-}).add;
-)
-
-(
-SynthDef(\siruse, { | gate = 1, freq = 55, amp=1, out=0 |
-  var sig = AnalogBassDrum.ar(
-    gate,
-    infsustain: 1,
-    accent: 0.9,
-    freq: freq,
-    tone: 0.7,
-    decay: 0.15,
-    attackfm: 0.31,
-    selffm: 0.15,
-  );
-  sig = sig * EnvGen.ar(Env.adsr(0.01, 0.2, 0.9, 0.25), gate, doneAction: 2);
-  sig = Pan2.ar(sig, 0);
-  Out.ar(out, sig * amp);
-}).add;
-)
-
-(
-Pdef(\nodi, Pbind(
-  \instrument, \sibino,
-  \scale, ~scale,
-  \octave, 5,
-  \modFreq, Pexprand(1, 1000, inf),
-  \maxIndex, Plprand(1, 20, inf),
-  \note, Pwrand([
-    Pseq([0, 3, 5, 3], 1),
-    Pseq([0, 3, 7, 2], 1),
-    Pseq([3, 7, 5, 2], 1),
-  ],
-  [1, 1, 1].normalizeSum, inf),
-  \db, -4,
-  \dur, 1,
-  \legato, 0.2,
-)).quant_(4).stop;
-)
-
-(
-Pdef(\nosa, Pbind(
-  \instrument, \sibino,
-  \scale, ~scale,
-  \octave, 6,
-  \modFreq, Pexprand(1, 1000, inf),
-  \maxIndex, Plprand(1, 20, inf),
-  \note, Pwrand([
-    Pseq([0, 3, 8, 2], 1),
-    Pseq([0, 3, 7, 2], 1),
-    Pseq([3, 10, 5, 2], 1),
-  ],
-  [1, 1, 1].normalizeSum, inf),
-  \db, -7,
-  \dur, 4 * Pwrand([
-    Pseq([1, 1, 1, 1].normalizeSum, 1),
-    Pseq([3, 3, 2, 3].normalizeSum, 1),
-    Pseq([2, 1, 2, 4].normalizeSum, 1),
-  ],
-  [1, 1, 1].normalizeSum, inf),
-  \legato, 0.6,
-)).quant_(4).stop;
-)
-
-(
-Pdef(\noen, Pbind(
-  \instrument, \sidrub,
-  \scale, ~scale,
-  \octave, 3,
-  \note, Prand([0, 3, 5], inf),
-  \cut, Pwhite(100, 4000, inf),
-  \rez, Pwhite(0.2, 0.8, inf),
-  \db, -5,
-  \dur, Prand([
-    Pseq([1], 1),
-    Pseq([1, 1].normalizeSum, 1),
-    Pseq([1, 1, 1, 1].normalizeSum, 1),
-  ], inf),
-  \legato, 0.7,
-)).quant_(4).stop;
-)
-
-(
-Pdef(\noci, Pbind(
-  \instrument, \sidrub,
-  \scale, ~scale,
-  \octave, 2,
-  \note, Prand([0, 3, 5], inf),
-  \cut, Pwhite(100, 4000, inf),
-  \rez, Pwhite(0.2, 0.8, inf),
-  \db, -10,
-  \dur, Prand([
-    Pseq([1], 1),
-    Pseq([1, 1].normalizeSum, 1),
-    Pseq([1, 1, 1, 1].normalizeSum, 1),
-  ], inf),
-  \legato, 2,
-)).quant_(4).stop;
-)
-
-(
-Pdef(\noni, Pbind(
-  \instrument, \siruse,
-  \scale, ~scale,
-  \octave, [3, 4],
-  \note, Prand([0], inf),
-  \db, -1,
-  \dur, 4,
-  \legato, 0.1,
-)).quant_(4).stop;
-)
-
-(
-// tania vocal
-Pdef(\vocal, ~se2.makeSynthBind <> Pbind(
-  \scale, ~scale,
-  \octave, 5,
-  \note, Pxrand([0, 1, 2, -3, -5], inf),
-  \dur, 16,
-  \db, 3,
-  \timingOffset, -2,
-)).quant_(4).stop;
-)
-
-(
-// tania vocal
-Pdef(\vocal2, ~se3.makeSynthBind <> Pbind(
-  \scale, ~scale,
-  \octave, 5,
-  \note, Pxrand([0, 1, 2, -3, -5], inf),
-  \dur, 1/2 * Prand([1, 3, 2, 4, 3], inf),
-  \db, -18,
-  \timingOffset, 0,
-)).quant_(4).stop;
-)
-
-(
-// axe sound
-Pdef(\vocal3, ~se4.makeSynthBind <> Pbind(
-  \scale, ~scale,
-  \octave, 4,
-  \note, Pxrand([5, 4, 6], inf),
-  \dur, 1 * Prand([4], inf),
-  \db, -15,
-  \timingOffset, -0.2,
-)).quant_(4).stop;
-)
-
-TempoClock.tempo = 160 / 60;
-
-~se3 = ~samplerFactory.value;
-
-(
-//(note: 9, octave: 5).play;
-~se3.startRec;
-)
-~se3.stopRec;
-
-~se3.shiftPos(0.05);
-~se3.duration = ~se.duration - 1;
-~se3.playSample;
-
-
-~se4 = ~samplerFactory.value;
-(
-//(note: 9, octave: 5).play;
-~se4.startRec;
-)
-~se4.stopRec;
-
-~se4.shiftPos(-0.05);
-~se4.duration = ~se4.duration - 1;
-~se4.playSample;
-
-//====
-
-(
-SynthDef(\eoau, { |out=0, amp=1, freq=440, gate=1|
-  var modFreq, sig, env;
-  env = EnvGen.ar(Env.adsr(releaseTime: 0.2), gate, doneAction: 2);
-  modFreq = Pulse.ar((freq**(1/2))*env, mul: env*freq/4, add: freq);
-  sig = Saw.ar(modFreq) * Pulse.ar(modFreq) * SinOsc.ar(freq) * amp;
-  sig = sig * env;
-  sig = Pan2.ar(sig, Rand(-0.5, 0.5));
-  Out.ar(out, sig);
-}).add;
-)
-
-TempoClock.tempo = 90 / 60;
-
-(
-Pdef(\asui, Pbind(
-  \instrument, \eoau,
-  \dur, Pseq([1, 1].normalizeSum / 4, inf),
-  \db, -1,
-  \octave, 2,
-  \note, 0,
-  \legato, Pwhite(0.1, 0.2),
-)).quant_(4).stop;
-)
-
-(
-Pdef(\sodi, Pbind(
-  \instrument, \eoau,
-  \dur, Pseq([1, 1, 1].normalizeSum * 4, inf),
-  \db, -22,
-  \octave, Prand([5, 6], inf),
-  \note, Prand([
-    Pseq([9, 7, 19, 12, 7, 4, 2], 1),
-    Pseq([7, 4, 7, 2], 1),
-  ], inf),
-  \legato, Pwhite(2.8, 4.2),
-)).quant_(4).stop;
-)
-
-(
-Pdef(\osud, Pbind(
-  \instrument, \eoau,
-  \dur, Pseq((1!7).normalizeSum/4, inf),
-  \db, -55,
-  \octave, 7,
-  \note, Prand([9, 7, 16, 12, 7, 4], inf),
-  \legato, 0.5,
-)).quant_(4).stop;
-)
-
-(
-Pdef(\saau, Pbind(
-  \instrument, \eoau,
-  \dur, Pgeom(1, 0.9, 50),
-  \db, -25,
-  \octave, 4,
-  \note, Prand([2, 5, 9, 12], inf),
-  \legato, 1,
-)).quant_(4).stop;
-)
diff --git a/Хэзифу/33.7.3.2-с-Нэцэ.scd b/Хэзифу/33.7.3.2-с-Нэцэ.scd
new file mode 100644 (file)
index 0000000..27a82ad
--- /dev/null
@@ -0,0 +1,54 @@
+(
+Pdef(\daki, ~se.makeSynthBind <> Pbind(
+  \dur, Pwrand([
+    Pseq(1!4, 1),
+    Pseq(2!2, 1),
+    Pseq((4/3)!3, 1),
+  ], [5, 2, 1].normalizeSum, inf),
+  \octave, [4, 5],
+  \note, Pxrand([0, 4, 9, 7, 2.5], inf),
+  \db, -5,
+)).quant_(4).stop;
+)
+
+(
+Pdef(\niru, ~se.makeSynthBind <> Pbind(
+  \dur, 1/2 * Pwrand([
+    Pseq(1!4, 1),
+    Pseq(2!2, 1),
+    Pseq((4/3)!3, 1),
+  ], [5, 2, 1].normalizeSum, inf),
+  \octave, [2, 3],
+  \note, Pxrand([0, 4, 9, 7], inf),
+  \db, -10,
+)).quant_(4).stop;
+)
+
+(
+Pdef(\bagi, Pbind(
+  \instrument, \dire,
+  \dur, 1/4 * Pwrand([
+    Pseq(1!4, 1),
+    Pseq(2!2, 1),
+    Pseq((4/3)!3, 1),
+  ], [5, 2, 1].normalizeSum, inf),
+  \octave, [2, 3],
+  \note, Pxrand([0, 4, 9, 7], inf),
+  \db, -20,
+  \legato, 2,
+)).quant_(4).stop;
+)
+
+TempoClock.tempo = 140 / 60;
+
+(
+SynthDef(\dire, { |amp=1, out=0, freq=440, gate=1|
+  var sig, modFreq, env;
+  modFreq = SinOsc.ar(3000, mul: freq/4, add: freq);
+  sig = Pulse.ar(modFreq);
+  env = EnvGen.ar(Env.adsr(), gate, doneAction: 2);
+  sig = sig * env;
+  sig = Pan2.ar(sig, Rand(-0.5, 0.5));
+  Out.ar(out, sig * amp);
+}).add;
+)
\ No newline at end of file
diff --git a/Хэзифу/bcr2000-control.scd b/Хэзифу/bcr2000-control.scd
new file mode 100644 (file)
index 0000000..3aee9c4
--- /dev/null
@@ -0,0 +1,53 @@
+// Ableton push handler
+// by Eugene Zuelum
+//
+// see https://github.com/Ableton/push-interface for info about ABI:
+// https://github.com/Ableton/push-interface/blob/master/doc/AbletonPush2MIDIDisplayInterface.asc
+
+(
+~bcrFactory = {
+  var controler = Environment[
+    \version -> "33.7.3.6",
+
+    \channel -> 0,
+  ];
+
+  controler.know = true;
+
+  MIDIdef.cc(\bcr2000defaultTurn, { |...args|
+    controler.turn(*args);
+  }, (1..110), controler.channel);
+
+  "Ԃиџуту готов к использованию 😊".postln;
+
+  controler;
+};
+)
+
+//============================================================================= Testing
+
+/* Test incoming MIDI messages from push
+(
+MIDIdef.cc(\testcc, {|...args|
+(["cc"] ++ args).postln;
+});
+MIDIdef.noteOn(\testnoteon, {|...args|
+(["note on"] ++ args).postln;
+});
+MIDIdef.noteOff(\testnoteoff, {|...args|
+(["note off"] ++ args).postln;
+});
+MIDIdef.touch(\testtouch, {|...args|
+(["touch"] ++ args).postln;
+});
+MIDIdef.polytouch(\testpolytouch, {|...args|
+(["polytouch"] ++ args).postln;
+});
+MIDIdef.bend(\testbend, {|...args|
+(["bend"] ++ args).postln;
+});
+MIDIdef.sysex(\testsysex, {|...args|
+(["sysex"] ++ args).postln;
+});
+)
+*/
diff --git a/Хэзифу/melody.scd b/Хэзифу/melody.scd
new file mode 100644 (file)
index 0000000..293298c
--- /dev/null
@@ -0,0 +1,265 @@
+~beri = ~bcrFactory.value;
+
+(
+~melmaker = Environment[
+  \current
+  \makemelody ->
+  {
+
+  }
+];
+~melmaker.know = true;
+
+)
+
+(
+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;
+    sig = Pan2.ar(sig, Rand(-0.6, 0.6));
+    Out.ar(out, sig);
+}).add;
+)
+
+});
+
+}, {});
+
+(
+~curFreq = 110;
+~steps = (0..15);
+~intervalWeights = [1]++(0!15);
+~freqHigh = 1000;
+~freqLow = 200;
+
+~durs = (1..8);
+~durWeights = (0!7) ++ [1];
+
+~legatos = (1..8)/8;
+~legatoWeights = (0!7) ++ [1];
+
+~decibels = (0..7) * -2;
+~decibelWeights = [1] ++ (0!7);
+
+~chorus = (0..15);
+~chorusWeights = [1]++(0!15);
+
+/*~chooseWeighted = {|values, weights|
+  values.
+};*/
+)
+
+(
+~beri.turn = {|zi, val, num|
+  num.postln;
+  if (num <= 16, {
+    ~intervalWeights[num-1] = val;
+    ("interval "++~steps[num-1]++" weight changed to "++val).postln;
+  });
+  if ((num >= 17) && (num <= 32), {
+    ~chorusWeights[num-17] = val;
+    ("chorus "++~chorus[num-17]++" weight changed to "++val).postln;
+  });
+  if ((num >= 81) && (num <= 88), {
+    ~durWeights[num-81] = val;
+    ("duration "++~durs[num-81]++" weight changed to "++val).postln;
+  });
+  if ((num >= 89) && (num <= 96), {
+    ~legatoWeights[num-89] = val;
+    ("legato "++~legatos[num-89]++" weight changed to "++val).postln;
+  });
+  if ((num >= 97) && (num <= 104), {
+    ~decibelWeights[num-97] = val;
+    ("decibel "++~decibels[num-97]++" weight changed to "++val).postln;
+  });
+  ~pnotes = Pfunc({
+    var direction, step, upWeight, downWeight, chorus;
+    upWeight = 1;
+    downWeight = 1;
+    if (~curFreq > ~freqHigh, {downWeight = ~curFreq/~freqHigh;});
+    if (~curFreq < ~freqLow, {upWeight = ~freqLow/~curFreq;});
+    //[downWeight, upWeight].postln;
+    direction = [-1, 1].wchoose([downWeight**3, upWeight**3].normalizeSum);
+    //direction.postln;
+    step = ~steps.wchoose(~intervalWeights.normalizeSum);
+    ~curFreq = ~curFreq * (direction*step).midiratio;
+    chorus = ~chorus.wchoose(~chorusWeights.normalizeSum);
+    //("new chorus: "++chorus).postln;
+    [~curFreq, ~curFreq*chorus.midiratio];
+  });
+
+  ~pdurs = Pfunc({
+    var dur;
+    dur = ~durs.wchoose(~durWeights.normalizeSum);
+    //("new duration: "++dur).postln;
+    dur;
+  });
+
+  ~plegatos = Pfunc({
+    var legato;
+    legato = ~legatos.wchoose(~legatoWeights.normalizeSum);
+    //("new legato: "++legato).postln;
+    legato;
+  });
+
+  ~pdecibel = Pfunc({
+    var decibel;
+    decibel = ~decibels.wchoose(~decibelWeights.normalizeSum);
+    //("new decibel: "++decibel).postln;
+    decibel;
+  });
+
+  ~melody = ~se.makeSynthBind <> Pbind(
+    \instrument, \sinetone,
+    \freq, ~pnotes,
+    \dur, ~pdurs,
+    \legato, ~plegatos,
+    \db, -10+~pdecibel,
+  );
+  Pdef(\melody, ~melody).quant_(1).play;
+};
+)
+
+Pdef(\melody).stop;
+
+~se.shiftPos(0.05);
+~se.playSample
+
+a = ~pnotes.asStream;
+a.next
+
+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
diff --git a/Хэзифу/mix101-control.scd b/Хэзифу/mix101-control.scd
new file mode 100644 (file)
index 0000000..8cc1eb5
--- /dev/null
@@ -0,0 +1,23 @@
+(
+MIDIdef.cc(\testcc, {|...args|
+  (["cc"] ++ args).postln;
+});
+MIDIdef.noteOn(\testnoteon, {|...args|
+  (["note on"] ++ args).postln;
+});
+MIDIdef.noteOff(\testnoteoff, {|...args|
+  (["note off"] ++ args).postln;
+});
+MIDIdef.touch(\testtouch, {|...args|
+  (["touch"] ++ args).postln;
+});
+MIDIdef.polytouch(\testpolytouch, {|...args|
+  (["polytouch"] ++ args).postln;
+});
+MIDIdef.bend(\testbend, {|...args|
+  (["bend"] ++ args).postln;
+});
+MIDIdef.sysex(\testsysex, {|...args|
+  (["sysex"] ++ args).postln;
+});
+)
\ No newline at end of file
diff --git a/Хэзифу/pedal-control.scd b/Хэзифу/pedal-control.scd
new file mode 100644 (file)
index 0000000..1a868f0
--- /dev/null
@@ -0,0 +1,76 @@
+// MIDI pedals handler
+// by Eugene Zuelum
+
+(
+~pedalFactory = {
+  var pedal = Environment[
+    \version -> "33.7.3.4"
+  ];
+
+  pedal.know = true;
+
+  // Sustain pedal on/off
+  MIDIdef.cc(\midiPedalSustain, { |...args|
+    if (args[0] != 0, {
+      pedal.suDown(*args);
+    }, {
+      pedal.suUp(*args);
+    });
+  },
+  65, 3);
+  // M-Audio Exp-M pedal (values range from 0 to 118 only)
+  MIDIdef.cc(\midiPedalExpression, { |...args|
+    var normed;
+    // m-audio
+    normed = args[0].linlin(0, 118, 0, 1);
+    pedal.xePres(normed, *args);
+  },
+  64, 3);
+
+  pedal.freeDefs = { |zi|
+    MIDIdef(\midiPedalSustain).free;
+    MIDIdef(\midiPedalExpression).free;
+  };
+
+  "Нычосё и Щюҙуԉы готовы к использованию 😊".postln;
+
+  pedal;
+};
+)
+
+//============================================================================= Testing
+
+// Test incoming MIDI messages
+/*
+(
+MIDIdef.cc(\testcc, {|...args|
+(["cc"] ++ args).postln;
+});
+MIDIdef.noteOn(\testnoteon, {|...args|
+(["note on"] ++ args).postln;
+});
+MIDIdef.noteOff(\testnoteoff, {|...args|
+(["note off"] ++ args).postln;
+});
+MIDIdef.touch(\testtouch, {|...args|
+(["touch"] ++ args).postln;
+});
+MIDIdef.polytouch(\testpolytouch, {|...args|
+(["polytouch"] ++ args).postln;
+});
+MIDIdef.bend(\testbend, {|...args|
+(["bend"] ++ args).postln;
+});
+MIDIdef.sysex(\testsysex, {|...args|
+(["sysex"] ++ args).postln;
+});
+)
+*/
+
+// Test library
+/*
+~pe = ~pedalFactory.value;
+~pe.suUp = {"up".postln};
+~pe.suDown = {"down".postln};
+~pe.xePres = {|zi, val| val.postln};
+*/
diff --git a/Хэзифу/pipelines.scd b/Хэзифу/pipelines.scd
new file mode 100644 (file)
index 0000000..810ff8e
--- /dev/null
@@ -0,0 +1,30 @@
+(
+//======== Busses
+// speakers
+~spik = 0;
+
+// headphones
+~phon = 2;
+
+// recording
+~bare = Bus.audio(s, 2);
+
+// effect
+~bafe = Bus.audio(s, 2);
+
+a = { [2r10010, 2r101011, 2r11100].choose.postln };
+b = a >> 2;
+b.value.asBinaryDigits.join;
+
+
+//======== Groups
+// sources
+~guso = Group.new(s);
+
+// recording
+~gu
+
+~gure = Group.new(~guSources, \addAfter);
+
+~tempo
+)
\ No newline at end of file
diff --git a/Хэзифу/push-control.scd b/Хэзифу/push-control.scd
new file mode 100644 (file)
index 0000000..c5d68a8
--- /dev/null
@@ -0,0 +1,331 @@
+// Ableton push handler
+// by Eugene Zuelum
+//
+// see https://github.com/Ableton/push-interface for info about ABI:
+// https://github.com/Ableton/push-interface/blob/master/doc/AbletonPush2MIDIDisplayInterface.asc
+
+(
+~pushFactory = {
+  var dest;
+  var push = Environment[
+    \version -> "33.7.2.5",
+
+    \tempo -> 2,
+
+    \padColor -> IdentityDictionary[
+      \white   ->  0,
+      \red     ->  1,
+      \amber   ->  2,
+      \yellow  ->  3,
+      \lime    ->  4,
+      \green   ->  5,
+      \spring  ->  6,
+      \turquoise -> 7,
+      \cyan    ->  8,
+      \sky     ->  9,
+      \ocean   ->  10,
+      \blue    -> 11,
+      \orchid  -> 12,
+      \magenta -> 13,
+      \pink    -> 14
+    ],
+
+    // preprocess relative controls
+    \ppcr -> { |zi ...args|
+      if (args[0] > 64, {
+        args[0] = args[0] - 128;
+      });
+      args;
+    },
+
+    // preprocess absolute controls and notes
+    \ppca -> { |zi ...args|
+      args[0] = args[0].linlin(0, 127, 0, 1);
+      args;
+    },
+
+    // preprocess bend
+    \ppcb -> { |zi ...args|
+      if (args[0] >= 8192, {
+        args[0] = args[0].linlin(8192, 16383, 0, 1);
+      }, {
+        args[0] = args[0].linlin(0, 8192, -1, 0);
+      });
+      args;
+    },
+
+    // preprocess push color
+    \pppc -> {|zi, c=0,l=3,w=false|
+      var color;
+      c = zi.padColor[c] ? c;
+      if (c == 0, {
+        color = l;
+      },{
+        if (l == 0, {
+          color = 0;
+        }, {
+          if (w, {
+            color = c*4;
+          }, {
+            color = c*4 + 4 - l;
+          });
+        });
+      });
+      color;
+    },
+
+    \hcPushTurnN -> Array.newClear(9),
+    \hcPushTouchN -> Array.newClear(9)
+  ];
+
+  push.know = true;
+
+  push.controllerFuncs = [
+    // Rotators
+    MIDIFunc.cc({ |...args|
+      push.hcPushTurnS(*push.ppcr(*args));
+    }, 14, 0),
+    MIDIFunc.cc({ |...args|
+      push.hcPushTurnL(*push.ppcr(*args));
+    }, 15, 0),
+    MIDIFunc.cc({ |...args|
+      var col = args[1] - 71;
+      push.hcPushTurnN[col].value(*push.ppcr(*args));
+    },
+    (71..79), 0),
+    MIDIFunc.noteOn({ |...args|
+      push.hcPushTouchS(true, *args);
+
+    }, 10, 0),
+    MIDIFunc.noteOn({ |...args|
+      push.hcPushTouchL(true, *args);
+
+    }, 9, 0),
+    MIDIFunc.noteOn({ |...args|
+      //args[1] = args[1] - 71;
+      push.hcPushTouchN[args[1]].value(true, *args);
+    },
+    (0..8), 0),
+    MIDIFunc.noteOff({ |...args|
+      push.hcPushTouchS(false, *args);
+
+    }, 10, 0),
+    MIDIFunc.noteOff({ |...args|
+      push.hcPushTouchL(false, *args);
+
+    }, 9, 0),
+    MIDIFunc.noteOff({ |...args|
+      args[1] = args[1] - 71;
+      push.hcPushTouchN[args[1]].value(false, *args);
+    },
+    (0..8), 0),
+
+    // Left buttons
+    MIDIFunc.cc({ |...args|
+      if (args[0] == 127, {
+        push.playDown(*args);
+      }, {
+        push.playUp(*args);
+      });
+    }, 85, 0),
+    MIDIFunc.cc({ |...args|
+      if (args[0] == 127, {
+        push.recDown(*args);
+      }, {
+        push.recUp(*args);
+      });
+    }, 86, 0),
+
+    // Pads
+    MIDIFunc.noteOn({ |...args|
+      var note, row, col;
+      note = args[1] - 36;
+      col = note % 8;
+      row = (note/ 8).asInteger;
+      push.padDown(row, col, *push.ppca(*args));
+    },
+    (36..99), 0),
+
+    MIDIFunc.noteOff({ |...args|
+      var note, row, col;
+      note = args[1] - 36;
+      col = note % 8;
+      row = (note/ 8).asInteger;
+      push.padUp(row, col, *push.ppca(*args));
+    }, (36..99), 0),
+
+    MIDIFunc.polytouch({ |...args|
+      var note, row, col;
+      note = args[1] - 36;
+      col = note % 8;
+      row = (note/ 8).asInteger;
+      push.padPressure(row, col, *push.ppca(*args));
+    }, (36..99), 0),
+  ];
+
+  //============================== Binding hc to synth parameters
+
+  push.bindMul = { |zi, synth, param, divisor=1|
+    { |d|
+      synth.get(param, { |v|
+        var newVal = v*((d)/divisor).midiratio;
+        "%: % = %\n".postf(synth, param, newVal);
+        synth.set(param, newVal);
+      });
+    }
+  };
+
+  push.bindAdd = { |zi, synth, param, divisor=1|
+    { |d|
+      synth.get(param, { |v|
+        var newVal = v+(d/divisor);
+        "%: % = %\n".postf(synth, param, newVal);
+        synth.set(param, newVal);
+      });
+    }
+  };
+
+  push.bindRange = { |zi, synth, param, start, end|
+    { |v|
+      var newVal = v.linlin(0, 1, start, end);
+      "%: % = %\n".postf(synth, param, newVal);
+      synth.set(param, newVal);
+    }
+  };
+
+  //============================== LED control
+  dest = MIDIClient.destinations.detect({ |item|
+    var res = false;
+    if (item.device == "Ableton Push", {
+      if (item.name == "Ableton Push MIDI 2", {
+        res = true;
+      });
+      if (item.name == "User Port", {
+        res = true;
+      });
+    });
+    res;
+  });
+  push.pushOut = MIDIOut.newByName(dest.device, dest.name);
+  // The following is working by itself,
+  // but factory function assignment to global var
+  // returns nil
+  /*try {
+    // linux
+    push.pushOut = MIDIOut.newByName("Ableton Push", "Ableton Push MIDI 2");
+  }{
+    // mac os
+    push.pushOut = MIDIOut.newByName("Ableton Push", "User Port");
+  };*/
+
+  push.pushOut.latency_(0);
+  if (push.pushOut==nil, {"Cannot control push LEDs!"});
+
+  push.padLight = {|zi, row, col, light=3, color=0, whiten=false, mode=0|
+    if ((col < 0) || (col > 7) || (row < 0) || (row > 7), {}, {
+      zi.pushOut.noteOn(mode, 36+(row*8)+col, zi.pppc(color, light, whiten));
+    });
+  };
+
+  push.hcPushPadLedClear = { |zi|
+    for (0, 7, {|i|
+      for (0, 7, {|j|
+        zi.hcPushPadLed.value(i, j, 0);
+      });
+    });
+  };
+
+  push.freeHC = { |zi|
+    zi.controllerFuncs.do({ |item| item.free; });
+    zi.pushOut.free;
+  };
+
+  // todo — always send clocks, and separate start/stop from setting tempod
+  push.setTempo = { |zi, tempo|
+    {
+      zi.pushOut.start;
+      1.do({
+        24.do({
+          zi.pushOut.midiClock;
+          (1.0/zi.tempo/24).wait;
+        });
+      });
+      zi.pushOut.stop;
+    }.fork();
+  };
+
+  // Starter message and animation
+
+  {
+    (0..127).do({|i|
+      ~push.pushOut.noteOn(0, i, 1);
+      ~push.pushOut.control(0, i, 1);
+    });
+    1.wait;
+    (0..127).do({|i|
+      ~push.pushOut.noteOn(0, i, 0);
+      ~push.pushOut.control(0, i, 0);
+    });
+  }.fork();
+
+  "Џяпюӈи готов к использованию 😊".postln;
+
+  push;
+};
+)
+
+//============================================================================= Testing
+
+/* Test incoming MIDI messages from push
+(
+MIDIdef.cc(\testcc, {|...args|
+(["cc"] ++ args).postln;
+});
+MIDIdef.noteOn(\testnoteon, {|...args|
+(["note on"] ++ args).postln;
+});
+MIDIdef.noteOff(\testnoteoff, {|...args|
+(["note off"] ++ args).postln;
+});
+MIDIdef.touch(\testtouch, {|...args|
+(["touch"] ++ args).postln;
+});
+MIDIdef.polytouch(\testpolytouch, {|...args|
+(["polytouch"] ++ args).postln;
+});
+MIDIdef.bend(\testbend, {|...args|
+(["bend"] ++ args).postln;
+});
+MIDIdef.sysex(\testsysex, {|...args|
+(["sysex"] ++ args).postln;
+});
+)
+*/
+
+/*  Test all LED colors via rotaning left rotary control
+~push = ~pushFactory.value;
+~col = 0;
+
+(
+~push.hcPushTurnS = { |zi, delta|
+~col = (~col + delta).clip(0, 127);
+~col.postln;
+(0..127).do({|i|
+~push.pushOut.noteOn(0, i, ~col);
+~push.pushOut.control(0, i, ~col);
+});
+};
+)
+*/
+
+/* Show first 64 colors
+(
+~color = 1;
+8.do({|i|
+8.do({|j|
+~push.pushOut.noteOn(0, 36+(i*8)+j, ~color);
+~color = ~color + 1;
+});
+});
+)
+*/
diff --git a/Хэзифу/sampler.scd b/Хэзифу/sampler.scd
new file mode 100644 (file)
index 0000000..ccd5c77
--- /dev/null
@@ -0,0 +1,104 @@
+(
+// TODO: for whatever reason when called from mac os,
+// every method here is executed 4 times
+
+~samplerFactory = {
+  var maxDur = 10.0;
+  var sampler = Environment[
+    \version -> "33.7.2.3",
+    \maxDur -> maxDur,
+    \synthName -> \samplerPlay,
+    \buf -> Buffer.alloc(s, s.sampleRate * maxDur, 1),
+    \recsynthdef -> SynthDef(\samplerRecord, { |input, buf|
+      var sig;
+      sig = In.ar(input, 1);
+      RecordBuf.ar(sig, buf, doneAction: Done.freeSelf, loop: 0);
+    }).add,
+    \playsynthdef -> SynthDef(\samplerPlay, { |out = 0, buf = 0, startPos = 0, duration = 0.01, freq=220, amp=1, gate=1|
+      var sig, env, rate, susEnv;
+      rate = freq / 220;
+      sig = PlayBuf.ar(1, buf, BufRateScale.ir(buf)*rate, startPos: startPos*BufSampleRate.ir(buf), doneAction: 2);
+      env = Env.new([0, 1, 1, 0], [0.01, duration/rate-0.02, 0.01]);
+      // next env is to to nicely fade out synth on gate close
+      susEnv = Env.asr(0, 1, 0.01);
+      sig = sig * EnvGen.ar(env, doneAction: 2) * EnvGen.ar(susEnv, gate, doneAction: 2);
+      sig = sig * amp.lag(0.03);
+      Out.ar(out, sig!2);
+    }).add,
+    \startRec -> { |zi, pleiPich=false|
+      "startRec called".postln;
+      zi.startPos = 0.0;
+      zi.recSynth = Synth(\samplerRecord, [\input, s.inputBus, \buf, zi.buf], addAction: \addToTail);
+      zi.endPos = s.sampleRate * 10;
+      zi.startTime = thisThread.seconds;
+      zi.pleiPich = pleiPich;
+      if (pleiPich, {
+        zi.pichSint = Synth(\default, [freq: 220]);
+      });
+    },
+    \startPos -> 0,
+    \duration -> 0,
+    \stopRec -> { |zi|
+      "stopRec called".postln;
+      zi.duration = min(thisThread.seconds - zi.startTime, 10);
+      zi.recSynth.free;
+      if (zi.pleiPich, {
+        zi.pichSint.set(\gate, 0);
+      });
+      zi.buf.loadToFloatArray(zi.startPos*zi.buf.sampleRate, zi.duration*zi.buf.sampleRate, action: { |array|
+        { zi.plotter.value = array; }.defer;
+      });
+    },
+    \playSample -> { |zi|
+      "playSample called".postln;
+      zi.playSynth = Synth(\samplerPlay,
+        [\out, 0, \buf, zi.buf, \startPos, zi.startPos, \duration, zi.duration],
+        addAction: \addToHead);
+    },
+    \stopPlay -> { |zi|
+      zi.playSynth.postln;
+      zi.playSynth.set(\gate, 0);
+    },
+    \makeSynthBind -> { |zi|
+      "makeSynthBind called".postln;
+      Pbind(
+        \instrument, \samplerPlay,
+        \buf, zi.buf,
+        \startPos, zi.startPos,
+        \duration, zi.duration,
+      );
+    },
+    \makeSynthArgs -> { |zi|
+      "makeSynthArgs called".postln;
+      [
+        \buf, zi.buf,
+        \startPos, zi.startPos,
+        \duration, zi.duration,
+      ];
+    },
+    \shiftPos -> { |zi, delta|
+      var endPos = zi.startPos + zi.duration;
+      ("shiftPos called"++[delta, endPos, zi.startPos, zi.duration]).postln;
+      zi.startPos = (zi.startPos + delta).clip(0, endPos);
+      zi.duration = endPos - zi.startPos;
+      zi.buf.loadToFloatArray(zi.startPos*zi.buf.sampleRate, zi.duration*zi.buf.sampleRate, action: { |array|
+        if (array.size == 0, {array = [0]});
+        { zi.plotter.value = array; }.defer;
+      });
+    },
+    \window -> Window.new(
+      "Sampler",
+      Rect(Window.screenBounds.width-600,Window.screenBounds.height-180,500,100)
+    )
+  ];
+  sampler.know = true;
+
+  sampler.plotter = Plotter.new("sampler", Rect(0, 0, sampler.window.bounds.width, sampler.window.bounds.height), sampler.window);
+
+  sampler.window.front;
+
+  "Сэмплер готов к использованию 😊".postln;
+
+  sampler;
+};
+)
diff --git a/Хэзифу/sl25remote-control.scd b/Хэзифу/sl25remote-control.scd
new file mode 100644 (file)
index 0000000..000712e
--- /dev/null
@@ -0,0 +1,331 @@
+// Novation SL25 Remote handler
+// by Eugene Zuelum
+//
+// see https://github.com/Ableton/push-interface for info about ABI:
+// https://github.com/Ableton/push-interface/blob/master/doc/AbletonPush2MIDIDisplayInterface.asc
+
+(
+~pushFactory = {
+  var dest;
+  var push = Environment[
+    \version -> "33.7.2.5",
+
+    \tempo -> 2,
+
+    \padColor -> IdentityDictionary[
+      \white   ->  0,
+      \red     ->  1,
+      \amber   ->  2,
+      \yellow  ->  3,
+      \lime    ->  4,
+      \green   ->  5,
+      \spring  ->  6,
+      \turquoise -> 7,
+      \cyan    ->  8,
+      \sky     ->  9,
+      \ocean   ->  10,
+      \blue    -> 11,
+      \orchid  -> 12,
+      \magenta -> 13,
+      \pink    -> 14
+    ],
+
+    // preprocess relative controls
+    \ppcr -> { |zi ...args|
+      if (args[0] > 64, {
+        args[0] = args[0] - 128;
+      });
+      args;
+    },
+
+    // preprocess absolute controls and notes
+    \ppca -> { |zi ...args|
+      args[0] = args[0].linlin(0, 127, 0, 1);
+      args;
+    },
+
+    // preprocess bend
+    \ppcb -> { |zi ...args|
+      if (args[0] >= 8192, {
+        args[0] = args[0].linlin(8192, 16383, 0, 1);
+      }, {
+        args[0] = args[0].linlin(0, 8192, -1, 0);
+      });
+      args;
+    },
+
+    // preprocess push color
+    \pppc -> {|zi, c=0,l=3,w=false|
+      var color;
+      c = zi.padColor[c] ? c;
+      if (c == 0, {
+        color = l;
+      },{
+        if (l == 0, {
+          color = 0;
+        }, {
+          if (w, {
+            color = c*4;
+          }, {
+            color = c*4 + 4 - l;
+          });
+        });
+      });
+      color;
+    },
+
+    \hcPushTurnN -> Array.newClear(9),
+    \hcPushTouchN -> Array.newClear(9)
+  ];
+
+  push.know = true;
+
+  push.controllerFuncs = [
+    // Rotators
+    MIDIFunc.cc({ |...args|
+      push.hcPushTurnS(*push.ppcr(*args));
+    }, 14, 0),
+    MIDIFunc.cc({ |...args|
+      push.hcPushTurnL(*push.ppcr(*args));
+    }, 15, 0),
+    MIDIFunc.cc({ |...args|
+      var col = args[1] - 71;
+      push.hcPushTurnN[col].value(*push.ppcr(*args));
+    },
+    (71..79), 0),
+    MIDIFunc.noteOn({ |...args|
+      push.hcPushTouchS(true, *args);
+
+    }, 10, 0),
+    MIDIFunc.noteOn({ |...args|
+      push.hcPushTouchL(true, *args);
+
+    }, 9, 0),
+    MIDIFunc.noteOn({ |...args|
+      //args[1] = args[1] - 71;
+      push.hcPushTouchN[args[1]].value(true, *args);
+    },
+    (0..8), 0),
+    MIDIFunc.noteOff({ |...args|
+      push.hcPushTouchS(false, *args);
+
+    }, 10, 0),
+    MIDIFunc.noteOff({ |...args|
+      push.hcPushTouchL(false, *args);
+
+    }, 9, 0),
+    MIDIFunc.noteOff({ |...args|
+      args[1] = args[1] - 71;
+      push.hcPushTouchN[args[1]].value(false, *args);
+    },
+    (0..8), 0),
+
+    // Left buttons
+    MIDIFunc.cc({ |...args|
+      if (args[0] == 127, {
+        push.playDown(*args);
+      }, {
+        push.playUp(*args);
+      });
+    }, 85, 0),
+    MIDIFunc.cc({ |...args|
+      if (args[0] == 127, {
+        push.recDown(*args);
+      }, {
+        push.recUp(*args);
+      });
+    }, 86, 0),
+
+    // Pads
+    MIDIFunc.noteOn({ |...args|
+      var note, row, col;
+      note = args[1] - 36;
+      col = note % 8;
+      row = (note/ 8).asInteger;
+      push.padDown(row, col, *push.ppca(*args));
+    },
+    (36..99), 0),
+
+    MIDIFunc.noteOff({ |...args|
+      var note, row, col;
+      note = args[1] - 36;
+      col = note % 8;
+      row = (note/ 8).asInteger;
+      push.padUp(row, col, *push.ppca(*args));
+    }, (36..99), 0),
+
+    MIDIFunc.polytouch({ |...args|
+      var note, row, col;
+      note = args[1] - 36;
+      col = note % 8;
+      row = (note/ 8).asInteger;
+      push.padPressure(row, col, *push.ppca(*args));
+    }, (36..99), 0),
+  ];
+
+  //============================== Binding hc to synth parameters
+
+  push.bindMul = { |zi, synth, param, divisor=1|
+    { |d|
+      synth.get(param, { |v|
+        var newVal = v*((d)/divisor).midiratio;
+        "%: % = %\n".postf(synth, param, newVal);
+        synth.set(param, newVal);
+      });
+    }
+  };
+
+  push.bindAdd = { |zi, synth, param, divisor=1|
+    { |d|
+      synth.get(param, { |v|
+        var newVal = v+(d/divisor);
+        "%: % = %\n".postf(synth, param, newVal);
+        synth.set(param, newVal);
+      });
+    }
+  };
+
+  push.bindRange = { |zi, synth, param, start, end|
+    { |v|
+      var newVal = v.linlin(0, 1, start, end);
+      "%: % = %\n".postf(synth, param, newVal);
+      synth.set(param, newVal);
+    }
+  };
+
+  //============================== LED control
+  dest = MIDIClient.destinations.detect({ |item|
+    var res = false;
+    if (item.device == "Ableton Push", {
+      if (item.name == "Ableton Push MIDI 2", {
+        res = true;
+      });
+      if (item.name == "User Port", {
+        res = true;
+      });
+    });
+    res;
+  });
+  push.pushOut = MIDIOut.newByName(dest.device, dest.name);
+  // The following is working by itself,
+  // but factory function assignment to global var
+  // returns nil
+  /*try {
+    // linux
+    push.pushOut = MIDIOut.newByName("Ableton Push", "Ableton Push MIDI 2");
+  }{
+    // mac os
+    push.pushOut = MIDIOut.newByName("Ableton Push", "User Port");
+  };*/
+
+  push.pushOut.latency_(0);
+  if (push.pushOut==nil, {"Cannot control push LEDs!"});
+
+  push.padLight = {|zi, row, col, light=3, color=0, whiten=false, mode=0|
+    if ((col < 0) || (col > 7) || (row < 0) || (row > 7), {}, {
+      zi.pushOut.noteOn(mode, 36+(row*8)+col, zi.pppc(color, light, whiten));
+    });
+  };
+
+  push.hcPushPadLedClear = { |zi|
+    for (0, 7, {|i|
+      for (0, 7, {|j|
+        zi.hcPushPadLed.value(i, j, 0);
+      });
+    });
+  };
+
+  push.freeHC = { |zi|
+    zi.controllerFuncs.do({ |item| item.free; });
+    zi.pushOut.free;
+  };
+
+  // todo — always send clocks, and separate start/stop from setting tempod
+  push.setTempo = { |zi, tempo|
+    {
+      zi.pushOut.start;
+      1.do({
+        24.do({
+          zi.pushOut.midiClock;
+          (1.0/zi.tempo/24).wait;
+        });
+      });
+      zi.pushOut.stop;
+    }.fork();
+  };
+
+  // Starter message and animation
+
+  {
+    (0..127).do({|i|
+      ~push.pushOut.noteOn(0, i, 1);
+      ~push.pushOut.control(0, i, 1);
+    });
+    1.wait;
+    (0..127).do({|i|
+      ~push.pushOut.noteOn(0, i, 0);
+      ~push.pushOut.control(0, i, 0);
+    });
+  }.fork();
+
+  "Џяпюӈи готов к использованию 😊".postln;
+
+  push;
+};
+)
+
+//============================================================================= Testing
+
+/* Test incoming MIDI messages from push
+(
+MIDIdef.cc(\testcc, {|...args|
+(["cc"] ++ args).postln;
+});
+MIDIdef.noteOn(\testnoteon, {|...args|
+(["note on"] ++ args).postln;
+});
+MIDIdef.noteOff(\testnoteoff, {|...args|
+(["note off"] ++ args).postln;
+});
+MIDIdef.touch(\testtouch, {|...args|
+(["touch"] ++ args).postln;
+});
+MIDIdef.polytouch(\testpolytouch, {|...args|
+(["polytouch"] ++ args).postln;
+});
+MIDIdef.bend(\testbend, {|...args|
+(["bend"] ++ args).postln;
+});
+MIDIdef.sysex(\testsysex, {|...args|
+(["sysex"] ++ args).postln;
+});
+)
+*/
+
+/*  Test all LED colors via rotaning left rotary control
+~push = ~pushFactory.value;
+~col = 0;
+
+(
+~push.hcPushTurnS = { |zi, delta|
+~col = (~col + delta).clip(0, 127);
+~col.postln;
+(0..127).do({|i|
+~push.pushOut.noteOn(0, i, ~col);
+~push.pushOut.control(0, i, ~col);
+});
+};
+)
+*/
+
+/* Show first 64 colors
+(
+~color = 1;
+8.do({|i|
+8.do({|j|
+~push.pushOut.noteOn(0, 36+(i*8)+j, ~color);
+~color = ~color + 1;
+});
+});
+)
+*/
diff --git a/Хэзифу/test.scd b/Хэзифу/test.scd
new file mode 100644 (file)
index 0000000..e4e0a78
--- /dev/null
@@ -0,0 +1,329 @@
+(
+~push = ~pushFactory.value;
+~se = ~samplerFactory.value;
+~pe = ~pedalFactory.value;
+)
+
+(
+~se.buf.loadToFloatArray(action: { |array|
+  {
+    ~data = array;
+    "loading done".postln;
+  }.defer;
+  ~se.window.front;
+});
+)
+
+~se.soundView.setData(~data, 1024, samplerate: ~se.buf.sampleRate);
+
+~se.soundView.data
+
+(\freq: 220).play;
+
+~se.makeSynthEvent
+~se.makeSynthArgs
+(
+~notes = Array.newClear(128);
+~amps = Array.newClear(128);
+~pe.suDown = { |zi|
+  ~se.startRec(true);
+};
+~pe.suUp = { |zi|
+  ~se.stopRec();
+};
+~push.playDown = { |zi|
+  ~se.playSample();
+};
+~push.playUp = { |zi|
+  ~se.stopPlay();
+};
+~push.hcPushTurnL = { |zi, delta|
+  var mul = 0.01;
+  ~se.shiftPos(delta * mul);
+  ~se.startPos.postln;
+  ~se.duration.postln;
+};
+~push.padDown = { |zi, row, col, vel|
+  var freq;
+  ~push.padLight(row, col, 2, 1, false, 0);
+  freq = Scale.major.degreeToFreq(col, 0.midicps, row+1);
+  ~notes[freq.cpsmidi.asInteger] = Synth(~se.synthName, ~se.makeSynthArgs++[\freq, freq, \amp, vel]);
+  ~amps[freq.cpsmidi.asInteger] = vel;
+  ("down "++vel).postln;
+};
+~push.padUp = { |zi, row, col, vel|
+  var freq;
+  ~push.padLight(row, col, 0, 0, false, 1);
+  freq = Scale.major.degreeToFreq(col, 0.midicps, row+1);
+  //~notes[freq.cpsmidi.asInteger].set(\gate, 0);
+  ~amps[freq.cpsmidi.asInteger] = 0;
+};
+~push.padPressure = { |zi, row, col, vel|
+  var freq;
+  //~push.padLight(row, col, 0, 0, false, 1);
+  freq = Scale.major.degreeToFreq(col, 0.midicps, row+1);
+  if (vel > ~amps[freq.cpsmidi.asInteger], {
+    ~notes[freq.cpsmidi.asInteger].get(\amp, { |amp|
+      var maxRatio = 1.5;
+      ("initial "++vel).postln;
+      if ((vel/amp) > maxRatio, { vel = amp * maxRatio; });
+      ~notes[freq.cpsmidi.asInteger].set(\amp, vel);
+      ("new "++vel).postln;
+    });
+  });
+  ("pres "++vel).postln;
+};
+)
+
+//=============================================================================
+
+// sampler test
+
+~se = ~samplerFactory.value;
+
+~se.startRec();
+~se.stopRec();
+
+~se.buf.plot;
+~se.buf.getToFloatArray(wait:0.01, action: {arg array; a = array; { a[0..100].plot }.defer; "done".postln });
+
+~se.playSample();
+~se.duration = 2.5;
+
+(
+SynthDef(\test, { |amp = 1.0|
+  Out.ar(0, SoundIn.ar(1!2, amp.lag(0.01)));
+}).add;
+)
+
+a = Synth(\test);
+a.free;
+
+(
+MIDIdef.cc(\pollcc, { |...args|
+  //"cc".postln;
+  //args.postln;
+});
+
+MIDIdef.noteOn(\pollnoteon, { |...args|
+  "noteon".postln;
+  args.postln;
+});
+)
+
+(
+MIDIdef.cc(\tafe, { |...args|
+  var amp = args[0].linlin(0, 127, 0.1, 20);
+  a.set(\amp, amp);
+  amp.postln;
+}, 1);
+)
+
+/// push test
+
+~push = ~pushFactory.value;
+
+(
+~color = 64;
+8.do({|i|
+  8.do({|j|
+    ~push.pushOut.noteOn(0, 36+(i*8)+j, ~color);
+    ~color = ~color + 1;
+  });
+});
+)
+
+~push.hcPushKeyPressure.valueArray([1, 2, 3, 4]);
+~push.hcPushKeyOn.valueArray([1, 2, 3, 4]);
+
+(
+MIDIdef.cc(\testcc, {|...args|
+  (["cc"] ++ args).postln;
+});
+MIDIdef.noteOn(\testnoteon, {|...args|
+  (["note on"] ++ args).postln;
+});
+MIDIdef.noteOff(\testnoteoff, {|...args|
+  (["note off"] ++ args).postln;
+});
+MIDIdef.touch(\testtouch, {|...args|
+  (["touch"] ++ args).postln;
+});
+MIDIdef.polytouch(\testpolytouch, {|...args|
+  (["polytouch"] ++ args).postln;
+});
+MIDIdef.bend(\testbend, {|...args|
+  (["bend"] ++ args).postln;
+});
+MIDIdef.sysex(\testsysex, {|...args|
+  (["sysex"] ++ args).postln;
+});
+)
+
+MIDIdef.freeAll;
+
+(
+(0..127).do({|i|
+  ~push.pushOut.noteOn(15, i, 4);
+  //~push.pushOut.control(12, i, 3.choose);
+});
+)
+
+(
+~col = 38;
+(0..127).do({|i|
+  ~push.pushOut.noteOn(0, i, ~col);
+  ~push.pushOut.control(0, i, ~col);
+});
+)
+
+~push = ~pushFactory.value;
+~col = 0;
+
+(
+~push.hcPushTurnS = { |zi, delta|
+  ~col = (~col + delta).clip(0, 127);
+  ~col.postln;
+  (0..127).do({|i|
+    ~push.pushOut.noteOn(13, i, ~col);
+    ~push.pushOut.control(0, i, ~col);
+  });
+};
+)
+
+(
+{
+  ~tempo = 40;
+  ~push.pushOut.start;
+  5.do({
+    24.do({
+      ~push.pushOut.midiClock;
+      (60/~tempo/24).wait;
+    });
+  });
+  ~push.pushOut.stop;
+}.fork();
+)
+
+~push.pushOut.sysex(Int8Array[0xF0, 0x00, 0x21, 0x1D, 0x01, 0x01, 0x08, 0x00, 0x00, 0xF7]);
+
+m = MIDIClockOut("Ableton Push", "Ableton Push MIDI 2");
+m.port
+Tempo.bpm = 300;
+
+m.stop
+
+Tempo.default.bpm = 1;
+
+~pushOut = nil;
+
+(
+try {
+  ~pushOut = MIDIOut.newByName("Ableton Push", "Ableton Push MIDI 2").latency_(0);
+} {
+  ~pushOut = MIDIOut.newByName("Ableton Push", "User Port").latency_(0);
+};
+)
+
+// test exception problem
+
+(
+~factory = {
+  var ret;
+try { Exception.new().throw; ret = 1; } { ret = 2 };
+  ret;
+};
+)
+
+~test = ~factory.value;
+
+~push.setTempo(1);
+
+(
+~caller = Environment[
+  \func -> { "test".postln; }
+];
+~caller.know = true;
+)
+
+~caller.func
+
+~se.maxDur
+
+//=========================== scale experiments
+
+(
+//(note: 9, octave: 5).play;
+~se2.startRec;
+)
+~se2.stopRec;
+
+~se2.shiftPos(0.05);
+~se2.duration = ~se.duration - 1;
+~se2.playSample;
+Scale
+Tuning.directory
+(0..12).collect(_ * (3 ** (1/13)))
+~tun = Tuning.new((0..12).collect(_ * (12*(3 ** (1/13)).log2)), 3, "tritave");
+~scale = Scale.chromatic(~tun);
+
+(
+Pdef(\sampe, ~se.makeSynthBind <> Pbind(
+  \scale, ~scale,
+  \octave, 5,
+  \note, Pseq([[0, -7]]++(9!8), inf),
+  \dur, 3,
+  \db, -10,
+)).quant_(9).stop;
+)
+(
+Pdef(\sampo, ~se.makeSynthBind <> Pbind(
+  \scale, ~scale,
+  \octave, 5,
+  \note, Pxrand([2, 5, 8, 11], inf),
+  \dur, 1,
+  \db, -20,
+  \timingOffset, 1/3,
+)).quant_(9).stop;
+)
+(
+Pdef(\sampi, ~se.makeSynthBind <> Pbind(
+  \scale, ~scale,
+  \octave, 7,
+  \note, Pxrand((1,3..12), inf),
+  \dur, 1,
+  \db, -30,
+  \timingOffset, 1/6,
+)).quant_(9).stop;
+)
+
+TempoClock.tempo = 2;
+(
+Pdef(\teste, Pbind(
+  \dur, 1
+)).stop;
+)
+~se2 = ~samplerFactory.value;
+(
+Pdef(\samia, ~se.makeSynthBind <> Pbind(
+  \scale, ~scale,
+  \octave, 5,
+  \note, Pseq((0..12)++(11..1) +.t [0, 7], inf),
+  \dur, 4,
+  \db, -1,
+  \timingOffset, 0,
+)).quant_(4).stop;
+)
+
+(
+Pdef(\samei, ~se2.makeSynthBind <> Pbind(
+  \scale, ~scale,
+  \octave, 5,
+  \note, Pseq((0..12)++(11..1) +.t [0, 3], inf),
+  \dur, 3,
+  \db, -15,
+  \timingOffset, 0,
+)).quant_(4).stop;
+)
+
+{SinOsc.ar(440, mul: 0.2)}.play
\ No newline at end of file
diff --git a/Хэзифу/test2.scd b/Хэзифу/test2.scd
new file mode 100644 (file)
index 0000000..c1606f8
--- /dev/null
@@ -0,0 +1,266 @@
+// trying varios scales
+
+~tun = Tuning.new((0..12).collect(_ * (12*(3 ** (1/13)).log2)), 3, "tritave");
+~scale = Scale.chromatic(~tun);
+
+(
+SynthDef(\sibino, { |
+  out=0, gate=1, freq=440, modFreq=440, amp=1, release=1.0, maxIndex=1
+  |
+  var sig, modIndex, env;
+  env = EnvGen.ar(Env.asr(releaseTime: release), gate, doneAction: 2);
+  modIndex = (1 - env) * maxIndex;
+  sig = PMOsc.ar(freq, modFreq, modIndex, mul: amp);
+  sig = sig * env;
+  sig = Pan2.ar(sig, Rand(-0.3, 0.3));
+  Out.ar(out, sig * amp);
+}).add;
+)
+
+(
+SynthDef(\sidrub, {
+  | out=0, gate=1, freq=440, amp=1, cut=800, rez=0.8,
+  modFreqMin=7, modFreqMax=12, modAmp=0.01, sustain=1.0 |
+  var sig = 0;
+  var modFreq = SinOsc.kr(Rand(modFreqMin, modFreqMax), 0, modAmp, 1);
+  sig = sig + Pulse.ar(freq * modFreq);
+  sig = RLPF.ar(sig, cut.lag(0.01), rez.lag(0.01));
+  sig = sig * EnvGen.ar(Env.perc(releaseTime: sustain), gate, doneAction: 2);
+  sig = Pan2.ar(sig, Rand(-0.3, 0.3));
+  Out.ar(out, sig * amp);
+}).add;
+)
+
+(
+SynthDef(\siruse, { | gate = 1, freq = 55, amp=1, out=0 |
+  var sig = AnalogBassDrum.ar(
+    gate,
+    infsustain: 1,
+    accent: 0.9,
+    freq: freq,
+    tone: 0.7,
+    decay: 0.15,
+    attackfm: 0.31,
+    selffm: 0.15,
+  );
+  sig = sig * EnvGen.ar(Env.adsr(0.01, 0.2, 0.9, 0.25), gate, doneAction: 2);
+  sig = Pan2.ar(sig, 0);
+  Out.ar(out, sig * amp);
+}).add;
+)
+
+(
+Pdef(\nodi, Pbind(
+  \instrument, \sibino,
+  \scale, ~scale,
+  \octave, 5,
+  \modFreq, Pexprand(1, 1000, inf),
+  \maxIndex, Plprand(1, 20, inf),
+  \note, Pwrand([
+    Pseq([0, 3, 5, 3], 1),
+    Pseq([0, 3, 7, 2], 1),
+    Pseq([3, 7, 5, 2], 1),
+  ],
+  [1, 1, 1].normalizeSum, inf),
+  \db, -4,
+  \dur, 1,
+  \legato, 0.2,
+)).quant_(4).stop;
+)
+
+(
+Pdef(\nosa, Pbind(
+  \instrument, \sibino,
+  \scale, ~scale,
+  \octave, 6,
+  \modFreq, Pexprand(1, 1000, inf),
+  \maxIndex, Plprand(1, 20, inf),
+  \note, Pwrand([
+    Pseq([0, 3, 8, 2], 1),
+    Pseq([0, 3, 7, 2], 1),
+    Pseq([3, 10, 5, 2], 1),
+  ],
+  [1, 1, 1].normalizeSum, inf),
+  \db, -7,
+  \dur, 4 * Pwrand([
+    Pseq([1, 1, 1, 1].normalizeSum, 1),
+    Pseq([3, 3, 2, 3].normalizeSum, 1),
+    Pseq([2, 1, 2, 4].normalizeSum, 1),
+  ],
+  [1, 1, 1].normalizeSum, inf),
+  \legato, 0.6,
+)).quant_(4).stop;
+)
+
+(
+Pdef(\noen, Pbind(
+  \instrument, \sidrub,
+  \scale, ~scale,
+  \octave, 3,
+  \note, Prand([0, 3, 5], inf),
+  \cut, Pwhite(100, 4000, inf),
+  \rez, Pwhite(0.2, 0.8, inf),
+  \db, -5,
+  \dur, Prand([
+    Pseq([1], 1),
+    Pseq([1, 1].normalizeSum, 1),
+    Pseq([1, 1, 1, 1].normalizeSum, 1),
+  ], inf),
+  \legato, 0.7,
+)).quant_(4).stop;
+)
+
+(
+Pdef(\noci, Pbind(
+  \instrument, \sidrub,
+  \scale, ~scale,
+  \octave, 2,
+  \note, Prand([0, 3, 5], inf),
+  \cut, Pwhite(100, 4000, inf),
+  \rez, Pwhite(0.2, 0.8, inf),
+  \db, -10,
+  \dur, Prand([
+    Pseq([1], 1),
+    Pseq([1, 1].normalizeSum, 1),
+    Pseq([1, 1, 1, 1].normalizeSum, 1),
+  ], inf),
+  \legato, 2,
+)).quant_(4).stop;
+)
+
+(
+Pdef(\noni, Pbind(
+  \instrument, \siruse,
+  \scale, ~scale,
+  \octave, [3, 4],
+  \note, Prand([0], inf),
+  \db, -1,
+  \dur, 4,
+  \legato, 0.1,
+)).quant_(4).stop;
+)
+
+(
+// tania vocal
+Pdef(\vocal, ~se2.makeSynthBind <> Pbind(
+  \scale, ~scale,
+  \octave, 5,
+  \note, Pxrand([0, 1, 2, -3, -5], inf),
+  \dur, 16,
+  \db, 3,
+  \timingOffset, -2,
+)).quant_(4).stop;
+)
+
+(
+// tania vocal
+Pdef(\vocal2, ~se3.makeSynthBind <> Pbind(
+  \scale, ~scale,
+  \octave, 5,
+  \note, Pxrand([0, 1, 2, -3, -5], inf),
+  \dur, 1/2 * Prand([1, 3, 2, 4, 3], inf),
+  \db, -18,
+  \timingOffset, 0,
+)).quant_(4).stop;
+)
+
+(
+// axe sound
+Pdef(\vocal3, ~se4.makeSynthBind <> Pbind(
+  \scale, ~scale,
+  \octave, 4,
+  \note, Pxrand([5, 4, 6], inf),
+  \dur, 1 * Prand([4], inf),
+  \db, -15,
+  \timingOffset, -0.2,
+)).quant_(4).stop;
+)
+
+TempoClock.tempo = 160 / 60;
+
+~se3 = ~samplerFactory.value;
+
+(
+//(note: 9, octave: 5).play;
+~se3.startRec;
+)
+~se3.stopRec;
+
+~se3.shiftPos(0.05);
+~se3.duration = ~se.duration - 1;
+~se3.playSample;
+
+
+~se4 = ~samplerFactory.value;
+(
+//(note: 9, octave: 5).play;
+~se4.startRec;
+)
+~se4.stopRec;
+
+~se4.shiftPos(-0.05);
+~se4.duration = ~se4.duration - 1;
+~se4.playSample;
+
+//====
+
+(
+SynthDef(\eoau, { |out=0, amp=1, freq=440, gate=1|
+  var modFreq, sig, env;
+  env = EnvGen.ar(Env.adsr(releaseTime: 0.2), gate, doneAction: 2);
+  modFreq = Pulse.ar((freq**(1/2))*env, mul: env*freq/4, add: freq);
+  sig = Saw.ar(modFreq) * Pulse.ar(modFreq) * SinOsc.ar(freq) * amp;
+  sig = sig * env;
+  sig = Pan2.ar(sig, Rand(-0.5, 0.5));
+  Out.ar(out, sig);
+}).add;
+)
+
+TempoClock.tempo = 90 / 60;
+
+(
+Pdef(\asui, Pbind(
+  \instrument, \eoau,
+  \dur, Pseq([1, 1].normalizeSum / 4, inf),
+  \db, -1,
+  \octave, 2,
+  \note, 0,
+  \legato, Pwhite(0.1, 0.2),
+)).quant_(4).stop;
+)
+
+(
+Pdef(\sodi, Pbind(
+  \instrument, \eoau,
+  \dur, Pseq([1, 1, 1].normalizeSum * 4, inf),
+  \db, -22,
+  \octave, Prand([5, 6], inf),
+  \note, Prand([
+    Pseq([9, 7, 19, 12, 7, 4, 2], 1),
+    Pseq([7, 4, 7, 2], 1),
+  ], inf),
+  \legato, Pwhite(2.8, 4.2),
+)).quant_(4).stop;
+)
+
+(
+Pdef(\osud, Pbind(
+  \instrument, \eoau,
+  \dur, Pseq((1!7).normalizeSum/4, inf),
+  \db, -55,
+  \octave, 7,
+  \note, Prand([9, 7, 16, 12, 7, 4], inf),
+  \legato, 0.5,
+)).quant_(4).stop;
+)
+
+(
+Pdef(\saau, Pbind(
+  \instrument, \eoau,
+  \dur, Pgeom(1, 0.9, 50),
+  \db, -25,
+  \octave, 4,
+  \note, Prand([2, 5, 9, 12], inf),
+  \legato, 1,
+)).quant_(4).stop;
+)
diff --git a/Хэзифу/Незы.scd b/Хэзифу/Незы.scd
new file mode 100644 (file)
index 0000000..d456cc9
--- /dev/null
@@ -0,0 +1,39 @@
+~se = ~samplerFactory.value;
+(
+//(note: 9, octave: 5).play;
+~se.startRec;
+)
+~se.stopRec;
+
+~se.shiftPos(0.05);
+~se.duration = ~se.duration + 0.2;
+~se.playSample;
+
+(
+Pdef(\stae, Pbind(
+  \octave, Pxrand([3, 4], inf),
+  \note, Prand([0, 2, 4], inf),
+  \dur, Pwrand([
+    Pseq([1], 1),
+    Pseq(0.5!2, 1),
+    Pseq(0.25!4, 1),
+  ], [1, 1, 1].normalizeSum, inf),
+  \db, -3,
+  \duration, Pwhite(0.1, 0.2),
+) <> ~se.makeSynthBind).quant_(4).stop;
+)
+
+(
+Pdef(\steio, Pbind(
+  \octave, 5,
+  \note, Prand([0, 2, 4, 7, 9], inf),
+  \dur, Pwrand([
+    Pseq([3, 3, 2]/2, 1),
+  ], [1].normalizeSum, inf),
+  \db, -15,
+  \duration, Pwhite(0.5, 2),
+  \startpos, Pwhite(1, 2.0),
+) <> ~se.makeSynthBind).quant_(4).stop;
+)
+
+TempoClock.tempo = 2;
\ No newline at end of file