File: Plambda.schelp

package info (click to toggle)
supercollider 1%3A3.11.2%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 71,152 kB
  • sloc: cpp: 387,846; lisp: 80,328; ansic: 76,515; sh: 22,779; python: 7,932; makefile: 2,333; perl: 1,123; javascript: 915; java: 677; xml: 582; yacc: 314; lex: 175; objc: 152; ruby: 136
file content (85 lines) | stat: -rw-r--r-- 2,122 bytes parent folder | download
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
class:: Plambda
summary:: create a scope (namespace) for enclosed streams
related:: Classes/Penvir, Classes/Pkey
categories:: Streams-Patterns-Events>Patterns>Data Sharing

Plambda is used to create a namespace for patterns to share data among each other.

Used in combination with link::Classes/Plet:: and link::Classes/Pget::, it allows you to get the output of a pattern from one stream and use it in another stream and as such create a dataspace for your patterns.

ClassMethods::

method::new

argument::pattern
an event stream.

argument::scope
an event with default bindings (can be nil).

Examples::

code::
/*

A simple example:
Two patterns playing in parallel,
sharing data between eachother

*/
(
	// a melody playing random scale degrees
	a = Pbind(
		\dur, 0.125,
		\octave, 4,
		\degree, Plet(\melody, pattern: Pwhite(0,7))
	);

	// the bass, scale degrees sampled from the \melody variable defined above
	b = Pbind(
		\dur, 0.5,
		\octave, 3,
		\degree, Pget(\melody, default: 1, repeats: inf).trace
	);

	// Play the patterns in parallel
	Plambda(
		Ppar([a, b], inf)
	).play;
)
/*

A more complex example:
Three patterns running in parallel

*/
(
SynthDef(\sine,
	{ arg out=0, freq=440, sustain=0.05, pan=0, amp=0.1;
		var env;
		env = EnvGen.kr(Env.perc(Rand(0.001, 0.02), sustain, AmpCompA.kr(freq)*amp), doneAction: Done.freeSelf);
		Out.ar(out, Pan2.ar(SinOsc.ar(freq), pan, env))
	}).add;
)

(
a = Plambda(
	Pseq([
	Pfindur(5,
		Ppar([
			Pbind(\note, Plet(\x, Prand([1, 5, 1, [10, 14]], inf)), \dur, 8/3, \pan, -1),
			Pbind(\note, Plet(\y, Pseq([5, 3, 2, 0, [0, 5, 6, 9]], inf)), \dur, 0.5, \pan,1),
			Pbind(\note, Pseq([Pget(\x), Pget(\y)], inf) + 12, \pan, 0, \dur, 2/3)
		])
	),
	Pbind(\note, Pget(\x, 0, 6) + [0, 5], \dur, Pstutter(inf, Prand([2/3, 1/6])))
	], inf).trace(\eventScope) // internally, the values are shared via \eventScope
);

b = Pbindf(a, \instrument, \sine, \legato, 0.1);
b.play
)

// Play two copies of the complex pattern above in parallel, one of them transposed and playing with shorter durations
Ppar([b, Pbindf(b, \ctranspose, 24, \dur, Pkey(\dur) * 0.25)]).play;
::