Jason (jcreed) wrote,
Jason
jcreed

Hey I am living in Brooklyn so it is legally required for me to make some chiptuney sounding things, isn't it?

New supercollider experiment, recorded some improvisation over "take five". My rhythm is sloppy, but I blame ~40ms synth latency, which is, again, just barely enough to notice, but acceptable.

Code is much the same as before, except I figured out how to get a proper adsr envelope to avoid nasty clicks every note on and note off.


s.boot;
MIDIClient.init(0,0);
MIDIIn.connect(device: 3);

// create midi listener
(
var notes, on, off;
notes = Array.newClear(128);  // array has one slot per possible MIDI note
on = NoteOnResponder({ |src, chan, num, veloc|
// if (notes[num] != nil) {
//  notes[num].set(\gate, 0);
// };
notes[num] = Synth(\my_osc, [\out, 0, \freq, num.midicps,
\amp, veloc * 0.00315]);
});
off = NoteOffResponder({ |src, chan, num, veloc|
	notes[num].set(\gate, 0);
});
q = { on.remove; off.remove; };
)

// destroy midi listener
q.value;

// Square wave organ
(
	SynthDef(\my_osc, {
		arg out = 0, amp = 0.1, gate = 1, freq = 440;		
		// I tried to figure out how to use .do for this but it eluded me this time!
		var x;
		x = EnvGen.kr(Env.adsr(0.01, 0.0, 0.25, 0.05) , gate, doneAction: 2) *
   		    Splay.ar(Pulse.ar(2 * freq * 1.1, 0.3, amp * 0.5));
		Out.ar(out, x);
		
	}).store;
)

// 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;)

Tags: music, 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 

  • 10 comments