File: SortBuf.schelp

package info (click to toggle)
supercollider-sc3-plugins 3.7.1~repack-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,332 kB
  • ctags: 11,704
  • sloc: cpp: 140,180; lisp: 14,746; ansic: 2,133; xml: 86; makefile: 82; haskell: 21; sh: 8
file content (70 lines) | stat: -rw-r--r-- 1,832 bytes parent folder | download | duplicates (4)
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
class:: SortBuf			
summary:: Karplus-Strong via a sorting algorithm
categories:: UGens>Buffer
//SLUGens released under the GNU GPL as extensions for SuperCollider 3, by Nick Collins, http://composerprogrammer.com/index.html
keyword:: SLUGens


Description::
In this UGen a target buffer gets sorted into increasing sample values over time- the sorting process causes gradual distortion. The sorting algorithm used is just a naive one of O(N^2) so effects are very dependent on sample length and sorting speed. It works best with small buffers and large sorting speeds will make it very CPU intensive.  

SortBuf assumes that the sample rate of the target buffer is the same as the soundcard output sample rate. 

classmethods::

method::ar

argument::bufnum
target buffer, will be overwritten by the procedure. 
argument::sortrate
number of sorting iterations per play through of the buffer
argument::reset
restart the sorting procedure. 
 
Examples::

code::
b= Buffer.read(s,"sounds/break",20000,10000);

//gradual erosion
(
SynthDef("help-sortbuf",{arg bufnum;
Out.ar(0,
Pan2.ar( 
SortBuf.ar(bufnum,LFNoise0.kr(5,50000,60000),0)
,0.0))
}).play(s,[\bufnum, b.bufnum]);
)

c= Buffer.read(s,"sounds/break",20000,10000);
c.copy(b); //restore buffer


//short 2000 sample buffer sorted over about 10 seconds
b= Buffer.read(s,"sounds/break",20000,2000);
{SortBuf.ar(b.bufnum,10000,1)}.play

(
s = Server.local;
b = Buffer.alloc(s, 512, 1);
c = Buffer.alloc(s, 512, 1);
b.sine1(1.0/[1,2,3,4,5,6], true, true, true);
c.sine1(1.0/[1,2,3,4,5,6], true, true, true);
)

(
SynthDef("help-sortbuf2",{ arg out=0,bufnum=0;

	SortBuf.ar(b.bufnum,1000,1); //attacking b over time

	Out.ar(out,
	//RLPF.ar(
		Osc.ar(b.bufnum, MouseX.kr(20,100), 0, 0.5)
	//	, MouseY.kr(200,4000),0.1)
	)
}).play(s,[\out, 0]);
)

c.copyData(b); //restore buffer
::