This file is indexed.

/usr/share/SuperCollider/HelpSource/Classes/GrainBuf.schelp is in supercollider-common 1:3.8.0~repack-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
class:: GrainBuf
summary:: Granular synthesis with sound stored in a buffer
categories:: UGens>Buffer, UGens>Generators>Granular
related:: Classes/GrainIn, Classes/GrainFM, Classes/GrainSin

classmethods::
private:: categories

method:: ar

argument:: numChannels
the number of channels to output. If 1, mono is returned and pan is ignored.

argument:: trigger
a kr or ar trigger to start a new grain. If ar, grains after the start of the synth are sample accurate.

argument:: dur
size of the grain (in seconds).

argument:: sndbuf
the buffer holding a mono audio signal. If using multi-channel files, use Buffer.readChannel.

argument:: rate
the playback rate of the sampled sound

argument:: pos
the playback position for the grain to start with (0 is beginning, 1 is end of file)

argument:: interp
the interpolation method used for pitchshifting grains:
list::
## 1 = no interpolation
## 2 = linear
## 4 = cubic interpolation (more computationally intensive)
::

argument:: pan
determines where to pan the output.
list::
## If numChannels = 1, no panning is done.
## If numChannels = 2, panning is similar to Pan2.
## If numChannels > 2, panning is the same as PanAz.
::

argument:: envbufnum
the buffer number containing a signal to use for the grain envelope. -1 uses a built-in Hann envelope.

argument:: maxGrains
the maximum number of overlapping grains that can be used at a given time. This value is set at the UGens init time and can't be modified. Defaults to 512. This can be set lower for more efficient use of memory.

warning:: The above parameter is new (post SC 3.3.1) and has the potential to break code written <= 3.3.1. This parameter is BEFORE the mul slot, and you may need to update code to account for this difference. ::

argument:: mul

argument:: add

discussion:: All args except numChannels and trigger are polled at grain creation time.
instancemethods::
private:: init, argNamesInputsOffset

examples::
code::
s.boot;

(
var winenv;

b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01-44_1.aiff");
// a custom envelope
winenv = Env([0, 1, 0], [0.5, 0.5], [8, -8]);
z = Buffer.sendCollection(s, winenv.discretize, 1);

SynthDef(\buf_grain_test, {arg gate = 1, amp = 1, sndbuf, envbuf;
	var pan, env, freqdev;
	// use mouse x to control panning
	pan = MouseX.kr(-1, 1);
	env = EnvGen.kr(
		Env([0, 1, 0], [1, 1], \sin, 1),
		gate,
		levelScale: amp,
		doneAction: 2);
	Out.ar(0,
		GrainBuf.ar(2, Impulse.kr(10), 0.1, sndbuf, LFNoise1.kr.range(0.5, 2),
			LFNoise2.kr(0.1).range(0, 1), 2, pan, envbuf) * env)
	}).add;

)

// use built-in env
x = Synth(\buf_grain_test, [\sndbuf, b, \envbuf, -1])

// switch to the custom env
x.set(\envbuf, z)
x.set(\envbuf, -1);

x.set(\gate, 0);
::