[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] Two Ctk related questions



Hi Alessandro. I hope the following answers your questions... let me know if there is anything else.

best,

Josh

(
var orch, score, grainfun, bfbus, options;

// I'm not sure what the synthdef you are using is -
// but here is my version of 'test' with Ambisonics, and a decoder.
orch = CtkProtoNotes(
	SynthDef(\test, {arg outbus, freq, amp, dur, loc;
		var src, bf;
		src = SinOsc.ar(freq, 0,
			EnvGen.kr(
				Env([0, amp, 0], [0.5, 0.5], \sin), timeScale: dur));
		bf = BFEncode1.ar(src, loc, 0, 1);
		Out.ar(outbus, bf);
		}),
	SynthDef(\decode, {arg inbus, outbus;
		var w, x, y, z;
		#w, x, y, z = In.ar(inbus, 4);
		Out.ar(outbus, B2Ster.ar(w, x, y));
		})
	);

// for routing the BF signal
bfbus = CtkAudio.new(numChans: 4);	
score = CtkScore.new;

grainfun = {arg starttime, duration, ampenv, lowfreq, hifreq;
	var now, note, thisgroup;
	now = 0;
ampenv.times = ampenv.times.normalizeSum * duration; // scale the Env's time to the gestures // by default, this will run at the head of 1, so the decoder should have
	// no problem catching all of its output
// This uses addTo to lace the CtkGroup into the Score. This mostly makes it easier to
	// create and add events in a single line of code. Same as:
	// thisgroup = CtkGroup .... blah blah ...
	// score.add(thisgroup)
	thisgroup = CtkGroup.new(starttime, duration + 2).addTo(score);
	while({
		// create a note... add it to the CtkScore
		note = orch[\test].new(starttime + now, 0.1, target: thisgroup)
// the CtkProtoNotes (and the CtkNoteObjects it creates) makes methods to
			// get and set all arguments in the synthdef
			.freq_(lowfreq.rrand(hifreq))
			.amp_(ampenv[now])
			.dur_(0.1)
			.outbus_(bfbus)
			.loc_(0.5pi.rrand(-0.5pi))
			.addTo(score);
		now = now + 0.02;
		now < duration;
		});
	};

// populate the score
grainfun.value(1.0, 12, Env([0, 0.2, 0], [0.1, 0.9], [4, -2]), 1200, 1400);

// you can add notes to a CtkScore through CtkScore.add(anEvent), OR use aCtkObject.addTo(CtkScore)
// use CtkScore.endtime to tell this note how long to play
score.add(orch[\decode].new(0.0, score.endtime, addAction: \after, target: 1).inbus_(bfbus).outbus_(0));

options = ServerOptions.new.numOutputBusChannels_(4);
// write the CtkScore out
score.write("~/test.aif".standardizePath, options: options)
)

On Dec 18, 2007, at 1:00 AM, Alessandro Fogar wrote:

Hi all,

I'm trying to use Ctk classes and I have two questions about these ...

The first: how do you integrate an ambisonic decoder in Ctk ? I mean
in Ctk we use CtkProtoNotes to describe the SynthDef used and then use
them one at a time. Where can you say: at the end of all put the
Ambisonic decoder ?

The second: could you please explain me the kind of syntax shortcuts
used in this code fragment ?
I mean the while condition and the  .addTo and .freq ...

grainfun = {arg starttime, duration, ampenv, lowfreq, hifreq;
	var now, note, thisgroup;
	now = 0;
	ampenv.times = ampenv.times.normalizeSum * duration; // scale the
Env's time to the gestures
	thisgroup = CtkGroup.new(starttime, duration + 2).addTo(score);
	while({
		// create a note... add it to the CtkScore
		note = orch[\test].new(starttime + now, 0.1, target: thisgroup)
			.freq_(lowfreq.rrand(hifreq))
			.amp_(ampenv[now])
			.dur_(0.1).addTo(score);
		now = now + 0.02;
		now < duration;
		});
	};

Many thanks

All the best

--
Alessandro Fogar

http://www.fogar.it
_______________________________________________
sc-users mailing list
sc-users@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-users

******************************************
/* Joshua D. Parmenter
http://www.realizedsound.net/josh/

“Every composer – at all times and in all cases – gives his own interpretation of how modern society is structured: whether actively or passively, consciously or unconsciously, he makes choices in this regard. He may be conservative or he may subject himself to continual renewal; or he may strive for a revolutionary, historical or social palingenesis." - Luigi Nono
*/