AbstractFunction:
Filter:
Classes | Core > Kernel

AbstractFunction : Object

An object which responds to a set of messages that represent mathematical functions

Description

An AbstractFunction is an object which responds to a set of messages that represent mathematical functions. Subclasses override a smaller set of messages to respond to the mathematical functions.

The intent is to provide a mechanism for functions that do not calculate values directly but instead compose structures for calculating (lazy evaluation).

Function, Pattern, Stream and UGen are subclasses of AbstractFunction. For example, if you multiply two UGens together the receiver responds by returning a new instance of class BinaryOpUGen which has the two operands as inputs.

For an overview of common operators, see Operators, for specific examples, see also e.g. Function, UGen, Pattern. To see which classes implement a specific method, see that method in the generated Methods overview.

Class Methods

Inherited class methods

Instance Methods

Unary Messages

The following messages return an object which represents a delayed unary operation, i.e. an operation on one object. For example, the reciprocal of a function will result in a new function that, when called, returns the reciprocal of the evaluation of the operand.

All of the following messages send the message composeUnaryOp to the receiver with the unary message selector as an argument. See UnaryOpFunction.

.neg

.reciprocal

.bitNot

Bitwise integer negation.

.abs

Absolute value

.asFloat

.asInt

From extension in /usr/local/share/SuperCollider/SCClassLibrary/deprecated/3.11/deprecated-3.11.sc

Deprecated. Use asInteger instead.

.asInteger

.ceil

.floor

.frac

.sign

Returns a function that returns -1 if receiver returns a negative number, 1 if positive, and 0 if zero.

.squared

.cubed

.sqrt

.exp

Returns e to the power of this.

.midicps

Converts midinote into cycles per seconds (Hz).

.cpsmidi

Converts cycles per seconds (Hz) into midinote.

.midiratio

.ratiomidi

.ampdb

.dbamp

.octcps

.cpsoct

.log

.log2

.log10

.sin

.cos

.tan

.asin

.acos

.atan

.sinh

.cosh

.tanh

.rand

.rand2

.linrand

.bilinrand

.sum3rand

.distort

.softclip

.coin

.even

.odd

.isPositive

.isNegative

.isStrictlyPositive

.rho

.theta

Binary Messages

The following messages return an object which represents a delayed binary operation, i.e. an operation between two objects. For example, adding two functions will result in a new function that, when called, adds the results of the evaluation of the two operands.

All of the following messages send the message composeBinaryOp to the receiver with the binary message selector and the second operand as arguments. See: BinaryOpFunction.

Examples:

// Add two Patterns

// Add two NodeProxies

+(function, adverb)

-(function, adverb)

*(function, adverb)

/(function, adverb)

.div(function, adverb)

%(that)

From superclass: Object

**(that)

From superclass: Object

.min(function, adverb)

.max(function: 0, adverb)

<(function, adverb)

<=(function, adverb)

>(function, adverb)

>=(function, adverb)

&(that)

From superclass: Object

|(that)

From superclass: Object

.lcm(function, adverb)

.gcd(function, adverb)

.round(function: 1, adverb)

.trunc(function: 1, adverb)

.atan2(function, adverb)

.hypot(function, adverb)

.hypotApx(function, adverb)

>>(that)

From superclass: Object

+>>(that)

From superclass: Object

.ring1(function, adverb)

(a * b) + a

.ring2(function, adverb)

((a*b) + a + b)

.ring3(function, adverb)

(a * a * b)

.ring4(function, adverb)

((a*a *b) - (a*b*b))

.difsqr(function, adverb)

(a*a) - (b*b)

.sumsqr(function, adverb)

(a*a) + (b*b)

.sqrdif(function, adverb)

(a - b) ** 2

.sqrsum(function, adverb)

(a + b) ** 2

.absdif(function, adverb)

(a - b).abs

.moddif(function: 0.0, mod: 1.0)

absolute difference in modulo arithmetics.

.amclip(function, adverb)

0 when b <= 0, a*b when b > 0

.scaleneg(function, adverb)

a * b when a < 0, otherwise a.

.clip2(function: 1, adverb)

clips receiver to +/- aNumber

.excess(function: 1, adverb)

Returns the difference of the receiver and its clipped form.

<!(that)

From superclass: Object

.rrand(function, adverb)

.exprand(function, adverb)

.rotate(function)

.dist(function)

.bitAnd(function, adverb)

.bitOr(function, adverb)

.bitXor(function, adverb)

.bitHammingDistance(function, adverb)

@(function, adverb)

Messages with more arguments (n-ary Operators)

The following messages return an object which represents a delayed n-ary operation, i.e. an operation between several objects (often three). For example, rescaling a function with linlin will result in a new function that, when called, scales the results of the evaluation of all operands.

All of the following messages send the message composeNAryOp to the receiver with the binary message selector and the other operands as arguments. See NAryOpFunction.

.clip(lo, hi)

.wrap(lo, hi)

.fold(lo, hi)

.blend(that, blendFrac: 0.5)

.linlin(inMin, inMax, outMin, outMax, clip: 'minmax')

.linexp(inMin, inMax, outMin, outMax, clip: 'minmax')

.explin(inMin, inMax, outMin, outMax, clip: 'minmax')

.expexp(inMin, inMax, outMin, outMax, clip: 'minmax')

other

.applyTo( ... args)

Interface that allows us to combine selectors (Symbols) and Functions. Sends valueArray(args) to this.

Discussion:

.asUGenInput(for)

Returns:

the result of sending the value(for) message to this.

Discussion:

.sampled(n: 80, from: 0.0, to: 1.0)

Sample a function.

Discussion:

.plotGraph(n: 500, from: 0.0, to: 1.0, name, bounds, discrete: false, numChannels, minval, maxval, separately: true)

From extension in /usr/local/share/SuperCollider/SCClassLibrary/Common/GUI/PlusGUI/Math/PlotView.sc

Sample the function with n points, in the range [from, to], and plot it in a Plotter. Returns a Plotter.

Arguments:

n

Number of values displayed in the plot window (500 by default).

from

Minimum value passed to the function.

to

Maximum value passed to the function.

name

See plot

bounds

See plot

discrete

See plot

numChannels

See plot

minval

See plot

maxval

See plot

separately

See plot

Returns:

Discussion:

Function Composition

When unary, binary or n-ary operators are applied to an abstract function, it returns an object that represents this operation, without evaluating the function: UnaryOpFunction, BinaryOpFunction, NAryOpFunction. Note that different subclasses like Pattern or UGen have their own composition scheme analogous to the one of AbstractFunction itself. For more about functions, see Function.

NOTE: The comparison operators <, <=, > and >= automatically perform function composition, as does * in the example above.

Equality comparisons have two possible meanings: to compare the objects as they exist right now, or a composite operator that will evaluate the operands in the future and check the equality of those results. Both are needed at different times, and are supported by different operators: == for an immediate equality check (which always returns a Boolean result), or |==| for a "lazy" equality operator to be performed later.

Inherited instance methods

Undocumented instance methods

&&(function, adverb)

<>(that)

.asActionFunc(type, extra, startVal)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/wslib/wslib-classes/Extensions/Various/ActionFunc.sc

.asAudioRateInput(for)

.asControlInput

.atan2WT(function: 1)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/wslib/wslib-classes/Extensions/UGens/Atan2Osc.sc

.biexp(inCenter, inMin, inMax, outCenter, outMin, outMax, clip: 'minmax')

.bilin(inCenter, inMin, inMax, outCenter, outMin, outMax, clip: 'minmax')

.composeBinaryOp(aSelector, something, adverb)

.composeNAryOp(aSelector, anArgList)

.composeUnaryOp(aSelector)

.curvelin(inMin: 0, inMax: 1, outMin: 0, outMax: 1, curve: -4, clip: 'minmax')

.degrad

.degreeToKey(scale, stepsPerOctave: 12)

.eq(function, adverb)

From extension in /usr/local/share/SuperCollider/SCClassLibrary/Common/Control/extConvertToOSC.sc

.firstArg(function, adverb)

.fold2(function: 1, adverb)

.hanWindow

.imag

.isValidUGenInput

.leftShift(function, adverb)

.lincurve(inMin: 0, inMax: 1, outMin: 0, outMax: 1, curve: -4, clip: 'minmax')

.mod(function, adverb)

.nand(function, adverb)

.ne(function, adverb)

From extension in /usr/local/share/SuperCollider/SCClassLibrary/Common/Control/extConvertToOSC.sc

.not

.performBinaryOpOnComplex(aSelector, aComplex, adverb)

.performBinaryOpOnSeqColl(aSelector, aSeqColl, adverb)

.performBinaryOpOnSignal(aSelector, aSignal, adverb)

.performBinaryOpOnSimpleNumber(aSelector, aNumber, adverb)

.pow(function, adverb)

.prReverseLazyEquals(that)

.prepareForProxySynthDef

From extension in /usr/local/share/SuperCollider/SCClassLibrary/JITLib/ProxySpace/wrapForNodeProxy.sc

.raddeg

.ramp

.real

.rectWindow

.reduceFuncProxy(args)

From extension in /usr/local/share/SuperCollider/SCClassLibrary/JITLib/Patterns/extFunction.sc

.ref

.reverseComposeBinaryOp(aSelector, something, adverb)

.rightShift(function, adverb)

.roundUp(function: 1, adverb)

.scurve

.thresh(function, adverb)

.triWindow

.unsignedRightShift(function, adverb)

.welWindow

.wrap2(function: 1, adverb)

.xor(function, adverb)

|==|(that)

||(function, adverb)

Examples