«Scoring a movie with supercollider» by 56228375

on 12 Aug'17 11:34 in oscsynchronizationmovietimelineblender

This is the supercollider code used in the tutorial about creating a generative movie score with supercollider and blender. The tutorial itself is located here: part I about using markers on blender's timeline to trigger OSC commands at https://technogems.blogspot.be/2017/08/scoring-movie-with-supercollider.html and part II about using blender's keyframes and animation curves to animate parameters in supercollider at https://technogems.blogspot.be/2017/08/scoring-movie-with-supercollider_12.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
(
s.waitForBoot({
	~animFreq = 440;

	SynthDef(\singer, {
		| out=0, freq=440, amp=0.5, vibrato=6|
		var lfo, lfo2, lfo3, sig;
		lfo = SinOsc.kr(1/5, 0).range(250,1000);
		lfo2 = SinOsc.kr(1/5, 0).range(0.1,0.9);
		lfo3 = SinOsc.kr(vibrato).range(0.3, 1);
		sig = lfo3*RLPF.ar(in:VarSaw.ar(freq:Lag.ar(in:K2A.ar(freq), lagTime:0.3), iphase:0, width:lfo2, mul:amp), freq:lfo, rq:200/lfo);
		Out.ar(out, sig!2);
	}).add;

	SynthDef(\percussive, {
		|out=0, freq = 220, rq=0.02|
        Out.ar(out, Pan2.ar(BPF.ar(WhiteNoise.ar * Line.kr(5, 0, 0.02), freq, rq)));
	}).add;

	SynthDef(\explosion, {
		| out = 0 |
		var m = Line.kr(0.01, 0.8, Rand(0.01, 0.04));
		var x = 0.01*SinOsc.ar(LFDNoise3.ar(m.range(18000, 2) ! 2) * (Rand(1, 2) * 600)) * m.exprange(1, 8) * XLine.kr(0.3, 0.0001, 5, doneAction:2);
		Out.ar(out, x);
	}).add;

	SynthDef(\pulsedsine, {
		| out=0, freq=440 |
		var env = EnvGen.kr(Env.perc);
		var sig = Pan2.ar(0.01*SinOsc.ar(freq)*LFPulse.kr(freq/100.0));
		Out.ar(out, sig);
	}).add;

	s.sync;

	n = NetAddr("127.0.0.1"); // local machine; port left unspecified

	OSCdef(\startPattern).free; // free old OSCdefs that may still be around
	OSCdef(\startPattern, {
		| msg, time, addr, port |
		("start pattern " ++ msg[1]).postln;
		Pdef(msg[1].asSymbol).quant_(0);
		Pdef(msg[1].asSymbol).play;
	}, '/stap', n);

	OSCdef(\stopPattern).free; // free old OSCdefs that may still be around
	OSCdef(\stopPattern, {
		| msg, time, addr, port |
		("stop pattern " ++ msg[1]).postln;
		Pdef(msg[1].asSymbol).quant_(0.25);
		Pdef(msg[1].asSymbol).stop;
	}, '/stop', n);

	OSCdef(\synth).free;
	OSCdef(\synth, {
		| msg, time, addr, port |
		("start synth " ++ msg[1]).postln;
		Synth(msg[1].asSymbol);
	}, '/synth', n);

	OSCdef(\init).free;
	OSCdef(\init, {
		| msg, time, addr, port |
		msg.postln;
	}, '/init', n);

	OSCdef(\clean).free;
	OSCdef(\clean, {
		| msg, time, addr, port |
		msg.postln;
	}, '/clean', n);

	OSCdef(\updatefreq).free;
	OSCdef(\updatefreq, {
		| msg, time, addr, port |
		~animFreq = msg[1];
	}, '/animfreq');

	Pdef(\pattern2,
		Pmono(
			\singer,
			\degree, Plag(0.2, Pwhite(0, 5, inf)),
			\dur, Pbrown(0.1, 0.5, 0.1, inf)
	));

	Pdef(\intropattern,
		Pbind(
			\instrument, \percussive,
			\freq, Prand((30..50).midicps, inf),
			\dur, Pbrown(0.03, 0.3, 0.01, inf),
			\rq, Pbrown(0.01, 0.04, 0.001, inf)
	));

	Pdef(\psp, // pulsed sine pattern
		Pmono(
			\pulsedsine,
			\freq, Pfunc({ |ev| ~animFreq; }),
			\dur, Pseq([0.1], inf),
	));


});
)
raw 2593 chars (focus & ctrl+a+c to copy)
reception
comments