Jason (jcreed) wrote,
Jason
jcreed

Thought I wasn't gonna get anything interesting with supercollider tonight, but then I got hooked once I started getting a nice warbly/rotatey organ sound. Secret is: take a square wave, lowpass it until it's nice and mellow and rounded out, and then put it through a bpf with a sine-oscillating center.

Sounds like this. Starting to sound kind of tune-like! The balance of volume gets out of control in the middle, and my improvisation rhythm's shaky as usual.


~out = 2;

(

(
SynthDef('bass', {
arg amp;
var n = BPF.ar(LPF.ar(BrownNoise.ar(1),1000),60);
var e = EnvGen.ar(Env.perc(0.05,0.1), doneAction: 2);
Out.ar(~out, Splay.ar(amp * n * e));
}).memStore;
);

(
SynthDef('snare', {
arg amp;
var n = BPF.ar(WhiteNoise.ar(1),500);
var e = EnvGen.ar(Env.perc(0.01,0.3), doneAction: 2);
Out.ar(~out, Splay.ar(amp * n * e));
}).memStore;
);

(
SynthDef('clo', {
arg amp;
var n = BPF.ar(BrownNoise.ar(1),12000);
var e = EnvGen.ar(Env.perc(0.01,0.05), doneAction: 2);
Out.ar(~out, Splay.ar(amp * n * e));
}).memStore;
);

(
SynthDef('open', {
arg amp;
var n = BPF.ar(BrownNoise.ar(1),12000);
var e = EnvGen.ar(Env.perc(0.01,0.35), doneAction: 2);
Out.ar(~out, Splay.ar(amp * n * e));
}).memStore;
);

(
SynthDef('cymb', {
arg amp;
var n = LPF.ar(BPF.ar(WhiteNoise.ar(1),3000),9000);
var e = EnvGen.ar(Env.perc(0.05,1.5), doneAction: 2);
Out.ar(~out, Splay.ar(0.5 * amp * n * e));
}).memStore;
);

(
SynthDef('porgn', {
arg freq, amp, gate;
var n = BPF.ar(Pulse.ar(freq, 0.25, 0.1 * amp),100);
var e = EnvGen.ar(Env.adsr(0.01,0.35, 0.2, 0.2), doneAction: 2);
Out.ar(~out, Splay.ar( n * e));
}).memStore;
);

(
SynthDef('orgn', {
arg freq, amp, gate = 1;
var n = LPF.ar(Pulse.ar(freq,0.5, amp),800);
var e = EnvGen.ar(Env.adsr(0.01,0.5, 0.5, 0.2), gate, doneAction: 2);
Out.ar(4, Splay.ar( n * e));
}).memStore;
)


)


(
var notes, active, on, off, generic, held;
var sust;

sust = false;
notes = Dictionary.new;
held = Set.new;
active = Set.new;
on = NoteOnResponder({ |src, chan, num, veloc|
// ("on" + num).postln;
(notes[num] != nil).if({ notes[num].set(\gate, 0); notes.removeAt(num); active.remove(num); });
notes.put(num, Synth(\orgn, [\out, ~out, \freq, num.midicps, \amp, veloc / 640]));
active.add(num);
held.add(num);
});
off = NoteOffResponder({ |src, chan, num, veloc|
// ("off" + num).postln;
if (sust.not, { notes[num].set(\gate, 0); notes.removeAt(num); active.remove(num); });
held.remove(num);
});
generic = CCResponder ({ |src, chan, num, value|
var activecopy = active.copy;
sust = value == 127;
// ("sust" + sust).postln;
// ("active size" + active.size).postln;
sust.not.if({ activecopy.do({ |x| // ("active" + x + "held?" + held.includes(x)).postln;
held.includes(x).not.if({ notes[x].set(\gate, 0); notes.removeAt(x); active.remove(x); /* "here?".postln */ }); }); });
}, nil, 0, 64);
q = { on.remove; off.remove; generic.remove; };
)
q.value;

// simpler midi listener
(
var on;
on = NoteOnResponder({ |src, chan, num, veloc| f.value(num, veloc); });
q = { on.remove; };
)

q.value;

(SynthDef(\my_osc, {
|freq = 400|
Out.ar(0, Splay.ar(Saw.ar(Lag.kr(freq, 0.05), 0.2) + Saw.ar(Lag.kr(freq, 1.0), 0.2) + Pulse.ar(Lag.kr(freq, 0.2), 10.0, 0.02)));
}).send(s))

x = Synth(\my_osc);
f = { |z, v| z.midicps.postln; Synth(\orgn, [\freq, z.midicps, \amp, v / 64]); };
f = {};

(
var tick = 0.2;
(
Ppar([
Pbind(
\instrument, \bass,
\amp, Pseq([0.3,0,0,0,0,0,0,0,0,0,0,0.05,0,0.3,0,0], inf),
\dur, tick * 1
),
Pbind(
\instrument, \snare,
\amp, Pseq([0,0,0.1,0,0,0,0.1,0.05], inf),
\dur, tick * 1
),
Pbind(
\instrument, \clo,
\amp, Pseq([0.1,0.05,0.05,0.05], inf),
\dur, tick * 1
),
Pbind(
\instrument, \cymb,
\amp, Pseq([0.1], inf),
\dur, tick * 32
)
]).play;
)
)
Synth(\bass, [\amp, 0.5]);


// start recording
(b= Buffer.alloc(s, 65536, 2);
b.write("/tmp/diskouttest.aiff", "aiff", "int16", 0, 0, true);
d = Synth.tail(nil, "help-Diskout", ["bufnum", b.bufnum]);)

// stop recording
(d.free;
b.close;
b.free;)

(
l = Synth(\lpf_synth, [\param, 0.2]);
b = Synth(\bpf_synth);
)

l.set(\param, 0.2);
b.free;

l.free;

(
SynthDef(\bpf_synth, {
arg param = 0.5;
var i = In.ar(4, 2);
Out.ar(2, BPF.ar(i, SinOsc.kr(MouseX.kr(0.1, 6.0)).range(400, 1000)));
}).store;
)
(
SynthDef(\lpf_synth, {
arg param = 0.5;
var i = In.ar(2, 2);
Out.ar(0, FreeVerb.ar(i,param,param,param));
}).store;
)
Tags: supercollider
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 5 comments