File: Symbol.sc

package info (click to toggle)
supercollider 1%3A3.10.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 45,496 kB
  • sloc: cpp: 283,513; lisp: 74,040; ansic: 72,252; sh: 23,016; python: 7,175; makefile: 1,087; perl: 766; java: 677; yacc: 314; lex: 175; ruby: 136; objc: 65; xml: 15
file content (259 lines) | stat: -rw-r--r-- 5,015 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
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
Symbol {
	*new { ^this.shouldNotImplement(thisMethod) }

	// conversion
	asSymbol { ^this }
	asInteger {
		_Symbol_AsInteger
		^this.primitiveFailed
	}
	asFloat {
		_Symbol_AsFloat
		^this.primitiveFailed
	}
	ascii { ^this.asString.ascii }

	// the primitive fails to escape '
	asCompileString { ^("'" ++ super.asString.escapeChar($') ++ "'") }
	asClass {
		// if Symbol represents a class name then return the class, else return nil.
		_SymbolClass
		^this.primitiveFailed
	}
	asSetter {
		_SymbolAsSetter
		^this.primitiveFailed
	}
	asGetter {
		_SymbolAsGetter
		^this.primitiveFailed
	}
	asSpec { ^Spec.specs.at(this) }
	asWarp { arg spec; ^Warp.warps.at(this).new(spec) }
	asTuning { ^Tuning.at(this) }
	asScale { ^Scale.at(this) }
	// testing
	isSetter {
		// returns true if last character of symbol is an underscore
		_SymbolIsSetter
		^this.primitiveFailed
	}
	isClassName {
		_SymbolIsClassName
		^this.primitiveFailed;
		// returns true if first character of symbol is a capital letter
	}
	isMetaClassName {
		_SymbolIsMetaClassName
		^this.primitiveFailed;
		// returns true if there is a meta class by this name
	}
	isPrefix { | other |
		_SymbolIsPrefix
		^this.primitiveFailed;
	}
	isPrimitiveName {
		// returns true if symbol is a valid primitive name
		^this.isPrefix(\_)
	}
	isPrimitive {
		// returns true if symbol names a bound primitive
		^this.isPrimitiveName and: { this.primitiveIndex > 0 }
	}
	isMap {
		// returns true if symbol starts with 'a' or 'c' followed by a number
		_Symbol_IsMap
		^this.primitiveFailed
	}
	isRest { ^this.isMap.not }
	isIdentifier {
		_Symbol_IsIdentifier
		^this.primitiveFailed;
	}
	isBinaryOp {
		_Symbol_IsBinaryOp
		^this.primitiveFailed;
	}

	// Environment support
	// The compiler translates use of an Environment variable like ~myvar
	// to a call to one of these methods, for example:
	// 			~myvar = 5;  translates to:  'myvar'.envirPut(5);
	// the implementations have been replaced by primitives
	envirGet {
		_Symbol_envirGet
		^currentEnvironment.at(this)
	}
	envirPut { arg aValue;
		_Symbol_envirPut
		currentEnvironment.put(this, aValue);
		^aValue
	}

	blend { // Envelopes may call this on the curves inst var.
		^this
	}

	++ { arg aString; ^this.asString ++ aString }

	asBinOpString {
		var res;
		res = this.asString;
		^if(res[0].isAlphaNum) { res ++ ":" } { res }
	}

	applyTo { arg firstArg ... args;
		^firstArg.performList(this, args)
	}

	// support for math on symbols

	performBinaryOpOnSomething { ^this }

	// unary ops
	neg { ^this }
	bitNot { ^this }
	abs { ^this }
	ceil { ^this }
	floor { ^this }
	frac { ^this }
	sign { ^this }
	sqrt { ^this }
	exp { ^this }
	midicps { ^this }
	cpsmidi { ^this }
	midiratio { ^this }
	ratiomidi { ^this }
	ampdb { ^this }
	dbamp { ^this }
	octcps { ^this }
	cpsoct { ^this }
	log { ^this }
	log2 { ^this }
	log10 { ^this }
	sin { ^this }
	cos { ^this }
	tan { ^this }
	asin { ^this }
	acos { ^this }
	atan { ^this }
	sinh { ^this }
	cosh { ^this }
	tanh { ^this }
	rand { ^this }
	rand2 { ^this }
	linrand { ^this }
	bilinrand { ^this }
	sum3rand { ^this }

	distort { ^this }
	softclip { ^this }
	coin { ^this }
	even { ^this }
	odd { ^this }

	rectWindow { ^this }
	hanWindow { ^this }
	welWindow { ^this }
	triWindow { ^this }

	scurve { ^this }
	ramp { ^this }

	// binary ops
	+ { ^this }
	- { ^this }
	* { ^this }
	/ { ^this }
	mod { ^this }
	min { ^this }
	max { ^this }
	bitAnd { ^this }
	bitOr { ^this }
	bitXor { ^this }
	bitHammingDistance { ^this }
	hammingDistance { |that| ^this.asString.hammingDistance(that.asString) }
	lcm { ^this }
	gcd { ^this }
	round { ^this }
	roundUp { ^this }
	trunc { ^this }
	atan2 { ^this }
	hypot { ^this }
	hypotApx { ^this }
	pow { ^this }
	leftShift { ^this }
	rightShift { ^this }
	unsignedRightShift { ^this }
	rrand { ^this }
	exprand { ^this }

	< { arg aNumber; _LT; ^this }
	> { arg aNumber; _GT; ^this }
	<= { arg aNumber; _LE; ^this }
	>= { arg aNumber; _GE; ^this }

	degreeToKey { ^this }

	degrad { ^this }
	raddeg { ^this }

	doNumberOp { ^this }
	doComplexOp { ^this }
	doSignalOp { ^this }
	doListOp { arg aSelector, aList;
		aList.collect({ arg item;
			item.perform(aSelector, this)
		})
	}

	primitiveIndex {
		_Symbol_PrimitiveIndex
		^this.primitiveFailed
	}
	specialIndex {
		// used by BasicOpUGens to get an ID number for the operator
		_Symbol_SpecialIndex
		^this.primitiveFailed
	}

	printOn { arg stream;
		stream.putAll(this.asString);
	}
	storeOn { arg stream;
		stream.putAll(this.asCompileString);
	}

	// code gen
	codegen_UGenCtorArg { arg stream;
		this.asString.codegen_UGenCtorArg(stream);
	}

	archiveAsCompileString { ^true }

	kr { | val, lag, fixedLag = false |
		^NamedControl.kr(this, val, lag, fixedLag)
	}

	ir { | val |
		^NamedControl.ir(this, val)
	}

	tr { | val |
		^NamedControl.tr(this, val)
	}

	ar { | val, lag |
		^NamedControl.ar(this, val, lag)
	}

	matchOSCAddressPattern { arg addressPattern;
		_Symbol_matchOSCPattern
		^this.primitiveFailed
	}

	help {
		this.asString.help
	}

}