Nxinstrument010

Download all code, records and samples
Download nxInstrument010 2009.05.4 2009.05.7

Launcher:

#!/usr/bin/python
 
# Python Code:
# nxInstrument010-Launcher.py
# Date: 2009.05.03
# Author: Miquel Parera Jaques
# Target: Scripting Supercollider
 
# Launch the SuperCollider Script:
 
import os, sys, subprocess
 
path = os.path.dirname(sys.argv[0])
pathname = os.path.abspath(path)
 
subprocess.Popen("sudo sclang %s/nxInstrument010.sc" %(pathname), shell=True)

SuperCollider Code:

// Supercollider Code:
// nxInstrument010.sc
// Date: 2009.05.03
// Author: Miquel Parera Jaques
// Target: Scripting Supercollider
 
// Init Server:
 
// 1. Launch jackd;
 
"sudo jackd -R -dalsa -dhw:0 -r44100 -p256 -S".unixCmd;
 
// 2. Launch server;
 
(
p = ProxySpace.push(s.boot);
History.clear.end;
History.start;
);
 
// 3. Record the session: (Problems with record) Record with ecasound:
 
//(
//s.recHeaderFormat = "WAV";
//s.prepareForRecord("nxInstrument0010.wav");
//);
 
"sudo ecasound -i jack -o 'nxInstrument0010.wav'".unixCmd;
 
// 4. SynthDefs:
 
(
b = Buffer.alloc(s, 44100, 1);
SynthDef("nx001",
    { arg out=0, freq=440, 
        attack1=0.01, sustain1=0.80, amp1=0.01,
        attack2=0.01, sustain2=0.80, amp2=0.0001; 
    var env1, env2, osc1, osc2, signal;
    env1 = EnvGen.kr(Env.perc(attack1, sustain1), doneAction:2) * amp1;
    osc1 = SinOsc.ar(freq, pi, env1).distort * 8.2;
    env2 = EnvGen.kr(Env.perc(attack2, sustain2), doneAction:2) * amp2;
    osc2 = Saw.ar(freq/2, pi, env2).distort * 0.002;
    signal = osc1 + osc2;
    Out.ar(out, BufDelayN.ar(b, Pan2.ar(signal, -1), 0.5, 1, Pan2.ar(signal, -1)))
}).store;
);
 
(
SynthDef("nx002",
    { arg out=0, freq=440, 
        attack1=0.01, sustain1=0.80, amp1=0.01,
        attack2=0.01, sustain2=0.80, amp2=0.0001; 
    var env1, env2, osc1, osc2, signal;
    env1 = EnvGen.kr(Env.perc(attack1, sustain1), doneAction:2) * amp1;
    osc1 = SinOsc.ar(freq, pi, env1).distort * 8.2;
    env2 = EnvGen.kr(Env.perc(attack2, sustain2), doneAction:2) * amp2;
    osc2 = Saw.ar(freq/2, pi, env2).distort * 0.002;
    signal = osc1 + osc2;
    Out.ar(out, Pan2.ar(signal, 1))
}).store;
);
 
(
SynthDef("nx003",
    { arg out=0, freq=440, 
        attack1=0.01, sustain1=0.80, amp1=0.01,
        attack2=0.01, sustain2=0.80, amp2=0.0001; 
    var env1, env2, osc1, osc2, signal;
    env1 = EnvGen.kr(Env.perc(attack1, sustain1), doneAction:2) * amp1;
    osc1 = SinOsc.ar(freq, pi, env1).distort * 8.2;
    env2 = EnvGen.kr(Env.perc(attack2, sustain2), doneAction:2) * amp2;
    osc2 = Saw.ar(freq/2, pi, env2).distort * 0.002;
    signal = osc1 + osc2;
    Out.ar(out, Pan2.ar(signal, 0))
}).store;
);
 
// 5. Arrays:
 
j = Array.fill(11, {0.6.linrand+0.1}).postln;
k = Array.fill(11, {24.linrand+1}).postln;
l = Array.fill(11, {0.6.linrand+0.1}).postln;
m = Array.fill(11, {24.linrand+1}).postln;
o = Array.fill(11, {0.6.linrand+0.1}).postln;
q = Array.fill(11, {24.linrand+1}).postln;
 
// 7. Task:
 
x = Task({
    20.wait;
    "sudo jack_connect SuperCollider:out_1 ecasound:in_1".unixCmd;
    10.wait;
    "sudo jack_connect SuperCollider:out_2 ecasound:in_2".unixCmd;
    5.wait;
    Pdef(\x).play;
    Pdef(\y).play;
    Pdef(\z).play;
    exprand(5, 12).wait;
    Pdef(\x, Pbind(\dur, Pseq(j, inf), \degree, Pseq(k, inf),\instrument, \nx001));
    Pdef(\y, Pbind(\dur, Pseq(l, inf), \degree, Pseq(m, inf),\instrument, \nx002));
    exprand(12, 30).wait;
    Pdef(\z, Pbind(\dur, Pseq(o, inf), \degree, Pseq(q, inf),\instrument, \nx003));
    exprand(12, 30).wait;
    k = Array.fill(11, {24.linrand+1}).postln;
    Pdef(\x, Pbind(\dur, Pseq(j, inf), \degree, Pseq(k, inf),\instrument, \nx001));
    exprand(12, 30).wait;
    m = Array.fill(11, {24.linrand+1}).postln;
    Pdef(\y, Pbind(\dur, Pseq(l, inf), \degree, Pseq(m, inf),\instrument, \nx002));
    exprand(12, 30).wait;
    q = Array.fill(11, {24.linrand+1}).postln;
    Pdef(\z, Pbind(\dur, Pseq(o, inf), \degree, Pseq(q, inf),\instrument, \nx003));
    exprand(12, 30).wait;
    k = Array.fill(11, {24.linrand+1}).postln;
    Pdef(\x, Pbind(\dur, Pseq(j, inf), \degree, Pseq(k, inf),\instrument, \nx001));
    exprand(12, 30).wait;
    m = Array.fill(11, {24.linrand+1}).postln;
    Pdef(\y, Pbind(\dur, Pseq(l, inf), \degree, Pseq(m, inf),\instrument, \nx002));
    exprand(12, 30).wait;
    q = Array.fill(11, {24.linrand+1}).postln;
    Pdef(\z, Pbind(\dur, Pseq(o, inf), \degree, Pseq(q, inf),\instrument, \nx003));
    exprand(12, 30).wait;
    k = Array.fill(11, {24.linrand+1}).postln;
    Pdef(\x, Pbind(\dur, Pseq(j, inf), \degree, Pseq(k, inf),\instrument, \nx001));
    exprand(12, 30).wait;
    m = Array.fill(11, {24.linrand+1}).postln;
    Pdef(\y, Pbind(\dur, Pseq(l, inf), \degree, Pseq(m, inf),\instrument, \nx002));
    exprand(12, 30).wait;
    q = Array.fill(11, {24.linrand+1}).postln;
    Pdef(\z, Pbind(\dur, Pseq(o, inf), \degree, Pseq(q, inf),\instrument, \nx003));
    exprand(12, 30).wait;
    k = Array.fill(11, {24.linrand+1}).postln;
    Pdef(\x, Pbind(\dur, Pseq(j, inf), \degree, Pseq(k, inf),\instrument, \nx001));
    exprand(12, 30).wait;
    m = Array.fill(11, {24.linrand+1}).postln;
    Pdef(\y, Pbind(\dur, Pseq(l, inf), \degree, Pseq(m, inf),\instrument, \nx002));
    exprand(12, 30).wait;
    q = Array.fill(11, {24.linrand+1}).postln;
    Pdef(\z, Pbind(\dur, Pseq(o, inf), \degree, Pseq(q, inf),\instrument, \nx003));
    exprand(5, 12).wait;
    Pdef(\x).stop;
    Pdef(\x).clear;
    exprand(5, 12).wait;
    Pdef(\y).stop;
    Pdef(\y).clear;
    exprand(5, 12).wait;
    Pdef(\z).stop;
    Pdef(\z).clear;
    exprand(5, 12).wait;
    s.stopRecording;
    History.end;
    History.saveStory("nxInstrument-Story-010");
    "killall jackd & killall ecasound".unixCmd;p.pop; s.quit;
}).play;
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License