Sequencing events in supercollider - routine breaks at third or fourth step

Sequencing events in supercollider - routine breaks at third or fourth step

greetings

i am running supercollider 3.10 in ubuntu linux 20.04 lts in an acer predator helios 300 with core i7 8gb ddr4 ram, 500 gb sata disk 250 gb ssd drive with an nvidia gtx 1050. i built a sequenced piece with small samples i grabbed from microsounds music by other people, and i am currently trying to see whether i can get the code fully functional and with nice syntax. i am getting an error on third or fourth step of this routine.

can someone help me to possibly fix this, and improve syntax a little bit?
thank you so much

(
~bufPaths = [
	thisProcess.nowExecutingPath.dirname +/+ "3_1.wav",
	thisProcess.nowExecutingPath.dirname +/+ "3_2.wav",
	thisProcess.nowExecutingPath.dirname +/+ "3_3.wav",
	thisProcess.nowExecutingPath.dirname +/+ "3_4.wav",
	thisProcess.nowExecutingPath.dirname +/+ "3_5.wav",
	thisProcess.nowExecutingPath.dirname +/+ "3_6.wav",
	thisProcess.nowExecutingPath.dirname +/+ "3_7.wav",
	thisProcess.nowExecutingPath.dirname +/+ "3_8.wav",
	thisProcess.nowExecutingPath.dirname +/+ "3_9.wav",
	thisProcess.nowExecutingPath.dirname +/+ "3_10.wav",
	thisProcess.nowExecutingPath.dirname +/+ "4_1.wav",
	thisProcess.nowExecutingPath.dirname +/+ "5.wav",
	thisProcess.nowExecutingPath.dirname +/+ "6.wav",
	thisProcess.nowExecutingPath.dirname +/+ "7.wav",
	thisProcess.nowExecutingPath.dirname +/+ "8.wav",
	thisProcess.nowExecutingPath.dirname +/+ "9.wav",
	thisProcess.nowExecutingPath.dirname +/+ "10.wav",
	thisProcess.nowExecutingPath.dirname +/+ "11.wav"
];
)

~buffers = ~bufPaths.collect(Buffer.read(s,_));

//~buffers = "/media/tmm467/2ED5-246E/electroacousticSampling/*.wav".pathMatch.collect(Buffer.read(_))

(
SynthDef(\playBuf2) { |out=0, buf=0, amp=12, loop=1|
	Out.ar(out, PlayBuf.ar(2, buf, loop:1, doneAction: Done.freeSelf) * amp)
}.add;
)
(
~score = [
	(buf: 0, dur: 30),
	(buf: 1, dur: 30),
	s.freeAll,
	(buf: 1, dur: 30),
	(buf: 2, dur: 30),
	{s.freeAll},
	(buf: 3, dur: 30),
	(buf: 4, dur: 30),
	{s.freeAll; 5.wait},

	(buf: 6, dur: 30),
	(buf: 7, dur: 30),
	{s.freeAll},
	(buf: 7, dur: 30),
	(buf: 8, dur: 30),
	{s.freeAll},
	(buf: 9, dur: 30),
	(buf: 10, dur: 30),
	{s.freeAll; 5.wait},

	(buf: 11, dur: 30),
	(buf: 12, dur: 30),
	{s.freeAll},
	(buf: 13, dur: 30),
	(buf: 14, dur: 30),
	{s.freeAll},
	(buf: 15, dur: 30),
	(buf: 16, dur: 30),
	(buf: 17, dur: 30),
	{s.freeAll; 5.wait},

	(buf: 0, dur: 30),
	(buf: 1, dur: 30),
	{s.freeAll},
];
)


(
r = Routine {
	~score.do {|ev|
		var event = ev.value.postln;
		if(event.respondsTo(\play)) { ((instrument: \playBuf2) ++ event).postln.play };
		(event.dur ? 0).wait;
	}
}
)
r.play;

r.stop; Server.freeAll;

I haven’t tried your code but on the third line,

	s.freeAll,

is not enclosed in a function. It should be { s.freeAll }

1 Like

OK, this is evaluating functions in the event list.

Then…

This means everything in the list needs to respond to .dur.

Events will look up \dur – that’s OK.

Some of your functions return s.freeAll, which will be a Server object. Others of your functions return a number. Let’s check:

Server.findRespondingMethodFor(\dur)
-> nil

SimpleNumber.findRespondingMethodFor(\dur)
-> nil

So these classes of object can’t handle your wait formulation.

Maybe like this? You’ll still have to change { Server.freeAll } to return a wait number, e.g. { Server.freeAll; 5 } (and no need to put wait in these functions).

(
r = Routine {
	~score.do {|ev|
		var event = ev.value.postln;
		if(event.respondsTo(\play)) {
			((instrument: \playBuf2) ++ event).postln.play;
			event = event.dur;
		};
		(event ? 0).wait;
	}
}
)

hjh

thanks james. will give it a try maybe tomorrow, and then eventually coming back to you soon. if we don’t talk to each other, see you in the online notam meeting

can also be without parenthesis as it is not a ugen/synthdef/proxy/etc declaration

If you want s.freeAll to be in the list as an instruction to do later, then it must be in function braces.

Function braces are the only way to defer an action until later.

If you leave them out, then it does the freeAll immediately while building the list, not during the Routine.

hjh