nxInstrument003

Download all code, records and samples
Download nxInstrument003 2009.15.3 2009.15.6

Instrument Code:

// Supercollider Code:
// nxInstrument003.sc
// Date: 2009.13.03
// Author: Miquel Parera Jaques
// Target: Array
 
(
p = ProxySpace.push(s.boot);
p.makeTempoClock(2.0);
MIDIIn.connect;
History.clear.end;
History.start;
)
 
"aconnect -i".unixCmd;
"aconnect 20:0 129:0".unixCmd;
"aconnect 129:0 130:0".unixCmd;
 
z = Buffer.read(s,"nxInstrument003-01-Sampler.wav",0);
 
s.prepareForRecord("/home/neix/nxInstrument003-01.wav");
s.record;
 
// 1.
 
n = Array.new(12);v = Array.new(12);
 
(
SynthDef(\click_1, {arg freq= 0, freq2= 0, gate= 1, gate2=1;
    var b,c,d, e, f, g;
    b = Blip.ar(freq);
    c = EnvGen.kr(Env.asr(0.001,0.6,0.009), gate, doneAction:2);
    d = c * RLPF.ar(b, 466, 0.01);
    e = Blip.ar(freq2);
    f = EnvGen.kr(Env.asr(0.001,0.3,0.009), gate2, doneAction:2);
    g = f * RLPF.ar(e, 400, 0.01);
    Out.ar(0, Pan2.ar(Mix.new([g,d]), -0.5));
}).load(s);
)
 
MIDIIn.noteOn = {arg src, chan, num, vel; if(n.size != 12, 
    {n.add(num);
        v.add(vel/300);
        h = Pbind(\degree, 4, \dur, Pseq([v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]],inf), \freq, Pseq([n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]],inf).midicps, \instrument, \click_1).play;
        i = Pbind(\degree, 4, \dur, Pseq([v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]],inf), \freq2, Pseq([n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]],inf).midicps, \instrument, \click_1).play;
},
    {n = Array.new(12);
        n.add(num);
        v = Array.new(12);
        v.add(vel/300)
})
};
 
MIDIIn.noteOn = nil;
 
// 2.
 
(
SynthDef(\click_2, {arg freq= 0, freq2= 0, gate= 1, gate2=1;
    var b,c,d, e, f, g;
    b = Blip.ar(freq);
    c = EnvGen.kr(Env.asr(0.001,0.6,0.009), gate, doneAction:2);
    d = c * RLPF.ar(b, 566, 0.01);
    e = Blip.ar(freq2);
    f = EnvGen.kr(Env.asr(0.001,0.3,0.009), gate2, doneAction:2);
    g = f * RLPF.ar(e, 200, 0.01);
    Out.ar(0, Pan2.ar(Mix.new([g,d]), 0.5));
}).load(s);
)
 
n = Array.new(12);v = Array.new(12);
 
MIDIIn.noteOn = {arg src, chan, num, vel; if(n.size != 12, 
    {n.add(num);
        v.add(vel/300);
        j = Pbind(\degree, 4, \dur, Pseq([v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]],inf), \freq, Pseq([n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]],inf).midicps, \instrument, \click_2).play;
        k = Pbind(\degree, 4, \dur, Pseq([v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]],inf), \freq2, Pseq([n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]],inf).midicps, \instrument, \click_2).play;
},
    {n = Array.new(12);
        n.add(num);
        v = Array.new(12);
        v.add(vel/300)
})
};
 
MIDIIn.noteOn = nil;
 
// 3.
 
(
SynthDef(\click_3, {arg freq= 0, freq2= 0, gate= 1, gate2=1;
    var b,c,d, e, f, g;
    b = Blip.ar(freq);
    c = EnvGen.kr(Env.asr(0.001,0.6,0.009), gate, doneAction:2);
    d = c * RLPF.ar(b, 566, 0.01);
    e = Blip.ar(freq2);
    f = EnvGen.kr(Env.asr(0.001,0.3,0.009), gate2, doneAction:2);
    g = f * RHPF.ar(e, 200, 0.01);
    Out.ar(0, Pan2.ar(Mix.new([g,d]), 0));
}).load(s);
)
 
n = Array.new(12);v = Array.new(12);
 
MIDIIn.noteOn = {arg src, chan, num, vel; if(n.size != 12, 
    {n.add(num);
        v.add(vel/300);
        l = Pbind(\degree, 4, \dur, Pseq([v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]],inf), \freq, Pseq([n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]],inf).midicps, \instrument, \click_3).play;
        m = Pbind(\degree, 4, \dur, Pseq([v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]],inf), \freq2, Pseq([n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]],inf).midicps, \instrument, \click_3).play;
},
    {n = Array.new(12);
        n.add(num);
        v = Array.new(12);
        v.add(vel/300)
})
};
 
MIDIIn.noteOn = nil;
 
// Task for auto off.
 
SynthDef("dragon",{ Out.ar(0, Pan2.ar(PlayBuf.ar(2,0,0.5,0,0,0),0))}).send(s); 
 
 t = Task({x=Synth("dragon");
    16.wait;
    h.stop;
    16.wait;
    i.stop;
    16.wait;
    j.stop;
    16.wait;
    k.stop;
    16.wait;
    l.stop;
    16.wait;
    m.stop;
    16.wait;
    x.free;
    s.stopRecording;
    });
 
t.play;
 
History.end;
History.saveStory("nxInstrument003-01-Story.scd");
 
"killall jackd & killall java".unixCmd; p.pop; s.quit;

Story file:

///////////////////////////////////////////////////
// History, as it was on Sun Mar 15 23:04:27 2009.
///////////////////////////////////////////////////
 
// - 0:0:0 -  
(
p = ProxySpace.push(s.boot);
p.makeTempoClock(2.0);
MIDIIn.connect;
History.clear.end;
History.start;
)
 
// - 0:0:0.15 -  
"aconnect 20:0 129:0".unixCmd;
 
// - 0:0:2.63 -  
z = Buffer.read(s,"nxInstrument003-01-Sampler.wav",0);
 
// - 0:0:5.94 -  
s.prepareForRecord("/home/neix/nxInstrument003-01.wav");
 
// - 0:0:8.57 -  
s.record;
 
// - 0:0:11.12 -  
n = Array.new(12);v = Array.new(12);
 
// - 0:0:16.61 -  
(
SynthDef(\click_1, {arg freq= 0, freq2= 0, gate= 1, gate2=1;
    var b,c,d, e, f, g;
    b = Blip.ar(freq);
    c = EnvGen.kr(Env.asr(0.001,0.6,0.009), gate, doneAction:2);
    d = c * RLPF.ar(b, 466, 0.01);
    e = Blip.ar(freq2);
    f = EnvGen.kr(Env.asr(0.001,0.3,0.009), gate2, doneAction:2);
    g = f * RLPF.ar(e, 400, 0.01);
    Out.ar(0, Pan2.ar(Mix.new([g,d]), -0.5));
}).load(s);
)
 
// - 0:0:23.4 -  
(
MIDIIn.noteOn = {arg src, chan, num, vel; if(n.size != 12, 
    {n.add(num);
        v.add(vel/300);
        h = Pbind(\degree, 4, \dur, Pseq([v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]],inf), \freq, Pseq([n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]],inf).midicps, \instrument, \click_1).play;
        i = Pbind(\degree, 4, \dur, Pseq([v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]],inf), \freq2, Pseq([n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]],inf).midicps, \instrument, \click_1).play;
},
    {n = Array.new(12);
        n.add(num);
        v = Array.new(12);
        v.add(vel/300)
})
};
);
 
// - 0:0:52.28 -  
MIDIIn.noteOn = nil;
 
// - 0:0:58.78 -  
(
SynthDef(\click_2, {arg freq= 0, freq2= 0, gate= 1, gate2=1;
    var b,c,d, e, f, g;
    b = Blip.ar(freq);
    c = EnvGen.kr(Env.asr(0.001,0.6,0.009), gate, doneAction:2);
    d = c * RLPF.ar(b, 566, 0.01);
    e = Blip.ar(freq2);
    f = EnvGen.kr(Env.asr(0.001,0.3,0.009), gate2, doneAction:2);
    g = f * RLPF.ar(e, 200, 0.01);
    Out.ar(0, Pan2.ar(Mix.new([g,d]), 0.5));
}).load(s);
)
 
// - 0:1:1.99 -  
n = Array.new(12);v = Array.new(12);
 
// - 0:1:14.19 -  //MIDI note: After noteOn play midi keys pads from 1 touch to pattern.
          //Select MIDIIn.noteOn = nil and launch another Synth+MIDIIn
(
MIDIIn.noteOn = {arg src, chan, num, vel; if(n.size != 12, 
    {n.add(num);
        v.add(vel/300);
        j = Pbind(\degree, 4, \dur, Pseq([v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]],inf), \freq, Pseq([n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]],inf).midicps, \instrument, \click_2).play;
        k = Pbind(\degree, 4, \dur, Pseq([v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]],inf), \freq2, Pseq([n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]],inf).midicps, \instrument, \click_2).play;
},
    {n = Array.new(12);
        n.add(num);
        v = Array.new(12);
        v.add(vel/300)
})
};
);
 
// - 0:2:0.44 -  
MIDIIn.noteOn = nil;
 
// - 0:2:10.95 -  
(
SynthDef(\click_3, {arg freq= 0, freq2= 0, gate= 1, gate2=1;
    var b,c,d, e, f, g;
    b = Blip.ar(freq);
    c = EnvGen.kr(Env.asr(0.001,0.6,0.009), gate, doneAction:2);
    d = c * RLPF.ar(b, 566, 0.01);
    e = Blip.ar(freq2);
    f = EnvGen.kr(Env.asr(0.001,0.3,0.009), gate2, doneAction:2);
    g = f * RHPF.ar(e, 200, 0.01);
    Out.ar(0, Pan2.ar(Mix.new([g,d]), 0));
}).load(s);
)
 
// - 0:2:12.57 -  
n = Array.new(12);v = Array.new(12);
 
// - 0:2:20.54 -  
(
MIDIIn.noteOn = {arg src, chan, num, vel; if(n.size != 12, 
    {n.add(num);
        v.add(vel/300);
        l = Pbind(\degree, 4, \dur, Pseq([v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]],inf), \freq, Pseq([n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]],inf).midicps, \instrument, \click_3).play;
        m = Pbind(\degree, 4, \dur, Pseq([v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]],inf), \freq2, Pseq([n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]],inf).midicps, \instrument, \click_3).play;
},
    {n = Array.new(12);
        n.add(num);
        v = Array.new(12);
        v.add(vel/300)
})
};
);
 
// - 0:2:45.58 -  
SynthDef("dragon",{ Out.ar(0, Pan2.ar(PlayBuf.ar(2,0,0.5,0,0,0),0))}).send(s); 
 
// - 0:2:54.18 -  
(
 t = Task({x=Synth("dragon");
    16.wait;
    h.stop;
    16.wait;
    i.stop;
    16.wait;
    j.stop;
    16.wait;
    k.stop;
    16.wait;
    l.stop;
    16.wait;
    m.stop;
    16.wait;
    x.free;
    s.stopRecording;
    });
);
 
// - 0:2:57.89 -  
t.play;
 
// - 0:3:27.79 -  
    j.stop;
 
// - 0:3:30.24 -  
    i.stop;
 
// - 0:3:34 -  
    l.stop;
 
// - 0:3:47.26 -  
    m.stop;
 
// - 0:4:15.08 -  
    s.stopRecording;
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License