This file is indexed.

/usr/share/SuperCollider/HelpSource/Classes/Scale.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
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
CLASS::Scale
summary::represents a musical scale
related::Classes/Tuning
categories::Math, Tuning

DESCRIPTION::
Scale supports arbitrary octave divisions and ratios, and (in conjunction with link::Classes/Tuning::) can generate pitch information in various ways, including as input to Patterns.

code::
s.boot;

a = Scale.major;
a.degrees;		// [ 0, 2, 4, 5, 7, 9, 11 ]
a.semitones;		// [ 0, 2, 4, 5, 7, 9, 11 ]
a.cents;		// [ 0, 200, 300, 500, 700, 900, 1100 ]
a.ratios;		// [ 1, 1.1224620483089, 1.2599210498937, 1.3348398541685, etc. ]

Pbind(\scale, a, \degree, Pseq((0..7) ++ (6..0) ++ [\rest], 1), \dur, 0.25).play;

// use non-standard tuning
a.tuning_(\just);
a.degrees;		// no change; degrees are independent of tuning
a.semitones;		// [ 0, 2.0391000173077, 3.1564128700055, 4.9804499913461, etc. ]
a.ratios.collect(_.round(0.001));	// [ 1, 1.125, 1.2, 1.333, 1.5, 1.667, 1.875 ]

Pbind(\scale, a, \degree, Pseq((0..7) ++ (6..0) ++ [\rest], 1), \dur, 0.25).play;
::

subsection::Creation

strong::*major, *minor, *dorian, *chromatic, *todi, *hijaz, *partch_o1, etc.::

Creates a scale from the library stored in the instance variable "all". Each scale comes with an appropriate default link::Classes/Tuning::, but alternate tunings can be specified at creation time:
code::
Scale.phrygian(\pythagorean)
::
If the tuning size does not match the scale's link::#-pitchesPerOctave::, a warning will be thrown, and the scale will use its default tuning.

For a complete list of available scales, execute
code::
Scale.directory
::

CLASSMETHODS::

method::all
The scale repository, to which new scales can be added.

code::
Scale.all.put(\catastrophic, Scale([0, 0.01, 0.04, 11.2]));
Scale.at(\catastrophic); // access the scale
::

method::at
Access from the scale repository.
code::
Scale.all.put(\catastrophic, Scale([0, 0.01, 0.04, 11.2]));
Scale.at(\ionian);
Scale.newFromKey(\ionian); // access a copy of the scale for modification
::

method::choose
Creates a random scale from the library, constrained by size and pitchsPerOctave if desired.
code::
Scale.choose;		// could be anything
Scale.choose(7);	// will be a seven-note scale in its default tuning (could be any)
Scale.choose(7, 12);	// will be a seven-note scale in a twelve-tone tuning (usually ET!2)

// Random seven-note scale in random twelve-tone tuning
a = Scale.choose(7, 12).tuning_(Tuning.choose(12));
a.tuning.name;
::

method::new
Creates a Scale from scratch. strong::degrees:: should be an array of Integers or scale name. If strong::pitchesPerOctave:: is nil, will guess the most appropriate number based on degrees. strong::tuning:: can be an instance of link::Classes/Tuning:: or a symbol; if nil, will be equal temperament of pitchesPerOctave. Specify strong::descDegrees:: if the Scale should play differently when descending than when ascending; otherwise it should be nil.
code::
Scale.new(#[0, 1, 3, 6, 8, 10, 11], name: "My ET12");		// will be in ET12
Scale.new(#[0, 3, 7, 10, 15, 19, 22], name: "My Quarter-Tone");	// will be in ET24
Scale.new(#[0, 6, 17, 21, 30, 39], 43, \partch, "My Partch");
::

method::chromatic

Returns a chromatic scale for a specific tuning.

INSTANCEMETHODS::

private::storeOn, storedKey, storeArgs, printOn

method::tuning
Sets or gets the tuning of the Scale.
argument::inTuning
can be either an instance of link::Classes/Tuning:: or a symbol matching a library tuning.

method::semitones
Returns a tuned array of semitone values. link::#-as::(Array) is equivalent; link::#-as::(List) returns it as a list, etc.

method::cents
Returns a tuned array of cent values.

method::ratios
Returns a tuned array of ratios.

method::as
Converting. For example code::as(Array)::, code::as(List):: and code::as(LocalBuf):: which is useful for server-side work.
code::
(
r = {
	var scale = Scale.choose.postln;
	SinOsc.ar(
		(
			DegreeToKey.kr(
				scale.as(LocalBuf),
				MouseX.kr(0,15), // mouse indexes into scale
				scale.stepsPerOctave,
				1, // mul = 1
				60 // offset by 72 notes
			)
			+ LFNoise1.kr([3,3], 0.04) // add some low freq stereo detuning
		).midicps, // convert midi notes to hertz
		0,
		0.25
	)
}.play;
)

r.free;
::

method::size
Returns the length of the scale.
code::
Scale.ionian.size; // 7
Scale.minorPentatonic.size; // 5
Scale.ajam.size; // 7
Scale.partch_o1.size; // 6
::

method::pitchesPerOctave
Returns the size of the pitch class set from which the tuning is drawn.
code::
Scale.ionian.pitchesPerOctave; // 12
Scale.minorPentatonic.pitchesPerOctave; // 12
Scale.ajam.pitchesPerOctave; // 24--this is a quarter-tone scale
Scale.partch_o1.pitchesPerOctave; // 43
::

method::stepsPerOctave
Usually 12, but may be different if the current tuning has a stretched or compressed octave. Needed for degreeToKey.
code::
Scale.new((0..14), 15, tuning: \wcAlpha).stepsPerOctave;	// ~ 11.7
Scale.new(#[0, 3, 6, 9, 12], 13, tuning: \bp).stepsPerOctave;	// ~ 19.02
::
but note:
code::
Scale.ajam.stepsPerOctave;	// 12 -- quarter-tone scales have normal octaves
::

method::at, wrapAt
These access the array generated by semitones.
code::
a = Scale.major;
a.wrapAt(4);	// 7
a.wrapAt(5);	// 9
a.wrapAt(6);	// 11
a.wrapAt(7);	// 0
::

method::degreeToFreq
Returns a frequency based on current tuning and rootFreq argument.
code::
Scale.major.degreeToFreq(2, 60.midicps, 1);		// 659.25511...
Scale.major(\just).degreeToFreq(2, 60.midicps, 1);	// 654.06391...
::

method::degreeToRatio
Returns a ratio based on current tuning.
code::
Scale.major.degreeToRatio(2, 1).round(0.001);		// 2.52
Scale.major(\just).degreeToRatio(2, 1).round(0.001);	// 2.5
::

EXAMPLES::

code::
(
s.waitForBoot({
	a = Scale.ionian;

	p = Pbind(
		\degree, Pseq([0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 0, \rest], inf),
		\scale, Pfunc({ a }, inf),
		\dur, 0.25
	);

	q = p.play;
})
)

// change scale
a = Scale.phrygian;

// change tuning
a.tuning_(\just);

// can also set tuning at creation time
a = Scale.ionian(\pythagorean);

// if you use a tuning with the wrong number of pitches per octave,
// you get a warning and the scale reverts to default tuning
a.tuning_(\partch);

// random scale
(
a = Scale.choose(7, 12);
[a.name, a.tuning.name].postln;
)

(
// or make up your own arbitrary scales and tunings
a = Scale.new(
	#[0, 2, 4, 5, 7, 9, 10],
	12,
	Tuning.new([0, 0.8, 2.1, 3, 4.05, 5.2, 6, 6.75, 8.3, 9, 10.08, 11.5]),
	"Custom"
);
)

// tuning has its own class
t = Tuning.werckmeister;

a = Scale.lydian(t);

q.stop;

// getting info
a.name;
a.degrees;
a.semitones;
a.ratios;

a.tuning.name;
a.tuning.semitones;
a.tuning.ratios;
::

code::
// for ascending/descending scales, use Pavaroh
(
Pbind(\note, Pavaroh(
	Pseq([0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 0, \rest], 2),
		Scale.melodicMinor,
		Scale.melodicMinorDesc
	),
	\dur, 0.25
).play;
)
::

code::
// note that the root pitch is not stored in the Scale (which should arguably be called a Mode for that reason)
// instead you supply it at play time:

// key of A
Pbind(
	\degree, Pseq((0..7), inf), // your melody goes here
	\scale, Scale.major, // your scale goes here
	\root, -3 // semitones relative to 60.midicps, so this is A
).play;
::