# subcollider.jsv0.1.1

## sc

- Range
- use

## Array

- *exprand
- *fib
- *fill
- *fill2D
- *fill3D
- *fillND
- *geom
- *interpolation
- *linrand
- *rand
- *rand2
- *series
- *with
- abs
- absdif
- acos
- add
- addAll
- addFirst
- addIfNotNil
- amclip
- ampdb
- any
- asArray
- asBoolean
- asFloat
- asFloat32Array
- asFloat64Array
- asFunction
- asInt16Array
- asInt32Array
- asInt8Array
- asInteger
- asJSON
- asNumber
- asString
- asUint16Array
- asUint32Array
- asUint8Array
- asin
- at
- atDec
- atInc
- atModify
- atan
- atan2
- biexp
- bilin
- bilinrand
- binaryValue
- bitAnd
- bitNot
- bitOr
- bitTest
- bitXor
- blendAt
- bubble
- ceil
- choose
- clip
- clip2
- clipAt
- clipExtend
- clipPut
- clipSwap
- clump
- clumps
- coin
- collect
- copy
- copyFromStart
- copyRange
- copySeries
- copyToEnd
- cos
- cosh
- count
- cpsmidi
- cpsoct
- cubed
- curdle
- curvelin
- dbamp
- degrad
- degreeToKey
- delimit
- detect
- detectIndex
- difference
- differentiate
- difsqr
- distort
- div
- do
- doAdjacentPairs
- drop
- dup
- equalWithPrecision
- equals
- even
- every
- excess
- exclusivelyBetween
- exp
- expexp
- explin
- exprand
- extend
- factorial
- factors
- fill
- find
- findAll
- first
- flat
- flatIf
- flatSize
- flatten
- floor
- flop
- fold
- fold2
- foldAt
- foldExtend
- foldPut
- foldSwap
- frac
- gauss
- gaussCurve
- gcd
- greater
- greaterThan
- half
- hanWindow
- histo
- hypot
- hypotApx
- includes
- includesAll
- includesAny
- inclusivelyBetween
- indexIn
- indexInBetween
- indexOf
- indexOfEqual
- indexOfGreaterThan
- indexOfPrime
- indicesOf
- indicesOfEqual
- inject
- injectr
- insert
- instill
- invert
- isArray
- isBoolean
- isEmpty
- isFunction
- isNaN
- isNegative
- isNumber
- isPositive
- isPowerOfTwo
- isPrime
- isStrictlyPositive
- isString
- isSubsetOf
- iwrap
- keep
- keyToDegree
- lace
- last
- lastForWhich
- lastIndex
- lastIndexForWhich
- lcm
- lcurve
- leftShift
- less
- lessThan
- lincurve
- linexp
- linlin
- linrand
- log
- log10
- log2
- log2Ceil
- madd
- max
- maxDepth
- maxIndex
- maxSizeAtDepth
- maxValue
- mean
- middle
- middleIndex
- midicps
- midiratio
- min
- minIndex
- minValue
- mirror
- mirror1
- mirror2
- mod
- mode
- nearestInList
- nearestInScale
- neg
- nextPowerOf
- nextPowerOfThree
- nextPowerOfTwo
- nextPrime
- normalize
- normalizeSum
- notEmpty
- notEquals
- nthPrime
- numBits
- obtain
- occurrencesOf
- octcps
- odd
- opAdd
- opDiv
- opMod
- opMul
- opSub
- pairsDo
- performDegreeToKey
- performKeyToDegree
- performNearestInList
- performNearestInScale
- permute
- pop
- postln
- pow
- prevPrime
- previousPowerOf
- product
- put
- putEach
- putFirst
- putLast
- pyramid
- pyramidg
- quantize
- raddeg
- ramp
- rand
- rand2
- ratiomidi
- reciprocal
- rectWindow
- reject
- remove
- removeAll
- removeAllSuchThat
- removeAt
- removeEvery
- removing
- replace
- resamp0
- resamp1
- reverse
- rightShift
- ring1
- ring2
- ring3
- ring4
- rotate
- round
- roundUp
- rrand
- scaleneg
- scramble
- scurve
- sect
- select
- separate
- setBit
- sign
- sin
- sinh
- size
- slide
- softclip
- sputter
- sqrdif
- sqrsum
- sqrt
- squared
- stutter
- sum
- sum3rand
- sumabs
- sumsqr
- swap
- symmetricDifference
- take
- takeAt
- takeThese
- tan
- tanh
- thresh
- transposeKey
- triWindow
- trunc
- twice
- unbubble
- union
- uniq
- unsignedRightShift
- value
- valueArray
- wchoose
- welWindow
- wrap
- wrap2
- wrapAt
- wrapExtend
- wrapPut
- wrapSwap

## Number

- abs
- absdif
- acos
- amclip
- ampdb
- asArray
- asBoolean
- asFloat
- asFunction
- asInteger
- asJSON
- asNumber
- asString
- asin
- atan
- atan2
- biexp
- bilin
- bilinrand
- binaryValue
- bitAnd
- bitNot
- bitOr
- bitTest
- bitXor
- bubble
- ceil
- clip
- clip2
- coin
- collect
- copy
- cos
- cosh
- cpsmidi
- cpsoct
- cubed
- curvelin
- dbamp
- degrad
- degreeToKey
- difsqr
- distort
- div
- do
- dup
- equalWithPrecision
- equals
- even
- excess
- exclusivelyBetween
- exp
- expexp
- explin
- exprand
- factorial
- factors
- fib
- floor
- fold
- fold2
- for
- forBy
- forSeries
- frac
- gauss
- gaussCurve
- gcd
- geom
- greater
- greaterThan
- half
- hanWindow
- hypot
- hypotApx
- inclusivelyBetween
- indexOfPrime
- isArray
- isBoolean
- isFunction
- isNaN
- isNegative
- isNumber
- isPositive
- isPowerOfTwo
- isPrime
- isStrictlyPositive
- isString
- iwrap
- keyToDegree
- lcm
- lcurve
- leftShift
- less
- lessThan
- lincurve
- linexp
- linlin
- linrand
- log
- log10
- log2
- log2Ceil
- madd
- max
- midicps
- midiratio
- min
- mod
- nearestInList
- nearestInScale
- neg
- nextPowerOf
- nextPowerOfThree
- nextPowerOfTwo
- nextPrime
- notEquals
- nthPrime
- numBits
- octcps
- odd
- opAdd
- opDiv
- opMod
- opMul
- opSub
- partition
- postln
- pow
- prevPrime
- previousPowerOf
- quantize
- raddeg
- ramp
- rand
- rand2
- ratiomidi
- reciprocal
- rectWindow
- reverseDo
- rightShift
- ring1
- ring2
- ring3
- ring4
- round
- roundUp
- rrand
- scaleneg
- scurve
- series
- setBit
- sign
- sin
- sinh
- size
- softclip
- sqrdif
- sqrsum
- sqrt
- squared
- sum3rand
- sumsqr
- tan
- tanh
- thresh
- triWindow
- trunc
- twice
- unsignedRightShift
- value
- valueArray
- welWindow
- wrap
- wrap2
- xrand
- xrand2

## Pattern

- *Pgeom
- *Prand
- *Pseq
- *Pser
- *Pseries
- *Pshuf

## RGen

- *RGen
- next

## Scale

- *Scale
- *choose
- at
- cents
- degreeToFreq
- degreeToFreq2
- degreeToRatio
- degreeToRatio2
- degrees
- octaveRatio
- performDegreeToKey
- performKeyToDegree
- performNearestInList
- performNearestInScale
- pitchesPerOctave
- ratios
- semitone
- size
- stepsPerOctave
- tuning
- wrapAt

## Tuning

- *Tuning
- *choose
- at
- cents
- equals
- octaveRatio
- ratios
- semitones
- size
- stepsPerOctave
- tuning
- wrapAt

- Array
- Number

### abs

absolute value

#### Arguments:

none

#### Example:

     (-10).abs(); // => 10
     [ -2, -1, 0, 1, 2 ].abs(); // => [ 2, 1, 0, 1, 2 ]

View Source on GitHub#

- Array
- Number

### absdif

(a - b).abs()

#### Arguments:

(number)

#### Example:

     sc.absdif(10, 15); // => 5

View Source on GitHub#

- Array
- Number

### acos

Arccosine

#### Arguments:

none
View Source on GitHub#

- Array

### add

Adds an item to an Array if there is space. This method may return a new Array.

#### Arguments:

(item)

#### Example:

     [1,2,3].add(4); // => [ 1, 2, 3, 4 ]

View Source on GitHub#

- Array

### addAll

Adds all the elements of items to the contents of the receiver. This method may return a new Array.

#### Arguments:

(items)

#### Aliases:

concat, ++

#### Example:

     [1, 2, 3, 4].addAll([7, 8, 9]); // => [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]

View Source on GitHub#

- Array

### addFirst

Inserts the item before the contents of the receiver, possibly returning a new Array.

#### Arguments:

(item)

#### Example:

     [1, 2, 3, 4].addFirst(999); // [ 999, 2, 3, 4 ]

View Source on GitHub#

- Array

### addIfNotNil

View Source on GitHub#

- Array
- Number

### amclip

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

#### Arguments:

(number)
View Source on GitHub#

- Array
- Number

### ampdb

Convert a linear amplitude to decibels.

#### Arguments:

none

#### Example:

     [0.5, 1, 2].ampdb(); // => [ -6.0205, 0, 6.0205 ]

View Source on GitHub#

- Array

### any

Answer whether function answers True for any item in the receiver. The function is passed two arguments, the item and an integer index.

#### Arguments:

(function)

#### Example:

     [1, 2, 3, 4].any("even"); // => true
     [1, 2, 3, 4].any(function(x) { return x > 10; }); // => false

View Source on GitHub#

- Function
- String
- Array
- Boolean
- Number

### asArray

Returns a new Array base upon this

#### Arguments:

none

#### Example:

     (1).asArray(); // => [ 1 ]
     [1, 2, 3].asArray(); // => [ 1, 2, 3 ]

View Source on GitHub#

- Function
- String
- Array
- Boolean
- Number

### asBoolean

Returns a new Boolean based upon this

#### Arguments:

none

#### Example:

     (0).asBoolean(); // false
     (1).asBoolean(); // true
     [ ].asBoolean(); // false
     [0].asBoolean(); // true

View Source on GitHub#

- String
- Array
- Number

### asFloat

#### Arguments:

none

#### Example:

     "0.5".asFloat(); // => 0.5
     [1, 2, 3.14].asFloat(); // => [1, 2, 3.14]

View Source on GitHub#

- Array

### asFloat32Array

Returns a new Float32Array based upon this
View Source on GitHub#

- Array

### asFloat64Array

Returns a new Float64Array based upon this
View Source on GitHub#

- Function
- String
- Array
- Number

### asFunction

Returns a new Function based upon this

#### Arguments:

none

#### Example:

     (1).asFunction()(); // => 1

View Source on GitHub#

- Array

### asInt16Array

Returns a new Int16Array based upon this
View Source on GitHub#

- Array

### asInt32Array

Returns a new Int32Array based upon this
View Source on GitHub#

- Array

### asInt8Array

Returns a new Int8Array based upon this
View Source on GitHub#

- String
- Array
- Number

### asInteger

#### Arguments:

none

#### Example:

     "0.5".asInteger(); // => 0
     [1, 2, 3.14].asInteger(); // => [1, 2, 3]

View Source on GitHub#

- String
- Array
- Boolean
- Number

### asJSON

Returns new a JSON string based upon this

#### Arguments:

none
View Source on GitHub#

- Function
- String
- Array
- Boolean
- Number

### asNumber

Returns new a Number based upon this

#### Arguments:

none

#### Example:

     (true).asNumber(); // => 1
     ["a", 10, 3.14].asNumber(); => 10

View Source on GitHub#

- Function
- String
- Array
- Boolean
- Number

### asString

Returns a new String based upon this
View Source on GitHub#

- Array

### asUint16Array

Returns a new Uint16Array based upon this
View Source on GitHub#

- Array

### asUint32Array

Returns a new Uint32Array based upon this
View Source on GitHub#

- Array

### asUint8Array

Returns a new Uint8Array based upon this
View Source on GitHub#

- Array
- Number

### asin

Arcsine

#### Arguments:

none
View Source on GitHub#

- Array

### at

Return the item at index.

#### Arguments:

(index)

#### Aliases:

@

#### Example:

     x = [10,20,30];
     y = [0,0,2,2,1];
     x.at(y); // returns [ 10, 10, 30, 30, 20 ]

View Source on GitHub#

- Array

### atDec

View Source on GitHub#

- Array

### atInc

View Source on GitHub#

- Array

### atModify

View Source on GitHub#

- Array
- Number

### atan

Arctangent

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### atan2

Arctangent of ( this / number )

#### Arguments:

(number)
View Source on GitHub#

- Array
- Number

### biexp

View Source on GitHub#

- Array
- Number

### bilin

View Source on GitHub#

- Array
- Number

### bilinrand

Bilateral linearly distributed random number from -this to +this.

#### Arguments:

none
View Source on GitHub#

- Boolean
- Array
- Number

### binaryValue

View Source on GitHub#

- Array
- Number

### bitAnd

performs a bitwise and with aNumber

#### Arguments:

(number)

#### Aliases:

&
View Source on GitHub#

- Array
- Number

### bitNot

ones complement

#### Arguments:

none

#### Aliases:

~
View Source on GitHub#

- Array
- Number

### bitOr

performs a bitwise or with aNumber

#### Arguments:

(number)

#### Aliases:

|
View Source on GitHub#

- Array
- Number

### bitTest

true if bit at index aNumber is set.

#### Arguments:

(bit)
View Source on GitHub#

- Array
- Number

### bitXor

Bitwise Exclusive Or

#### Arguments:

(number)

#### Aliases:

^
View Source on GitHub#

- Array

### blendAt

Returns a linearly interpolated value between the two closest indices.

#### Arguments:

(index [, method="clipAt"])

#### Example:

      [2, 5, 6].blendAt(0.4); // => 3.2

View Source on GitHub#

- Number
- Array

### bubble

View Source on GitHub#

- Array
- Number

### ceil

next larger integer.

#### Arguments:

none
View Source on GitHub#

- Array

### choose

Choose an element from the collection at random.

#### Arguments:

none

#### Example:

     [1, 2, 3, 4].choose();

View Source on GitHub#

- Array
- Number

### clip

If the receiver is less than minVal then answer minVal, else if the receiver is greater than maxVal then answer maxVal, else answer the receiver.

#### Arguments:

([lo=-1, hi=1])

#### Example:

     [ -0.6, -0.3, 0, 0.3, 0.6 ].clip(-0.5, 0.5); // => [ -0.5, -0.3, 0, 0.3, 0.5 ]

View Source on GitHub#

- Array
- Number

### clip2

clips receiver to +/- aNumber

#### Arguments:

([number=1])

#### Example:

     [ -0.6, -0.3, 0, 0.3, 0.6 ].clip2(0.5); // => [ -0.5, -0.3, 0, 0.3, 0.5 ]

View Source on GitHub#

- Array

### clipAt

Same as `at`, but values for index greater than the size of the Array will be clipped to the last index.

#### Arguments:

(index)

#### Aliases:

|@|

#### Example:

     [ 1, 2, 3 ].clipAt(13); // => 3
     [ 1, 2, 3 ].clipAt([ 0, 1, 2, 3 ]); // => [ 1, 2, 3, 3 ]

View Source on GitHub#

- Array

### clipExtend

Same as `wrapExtend` but the sequences "clip" (return their last element) rather than wrapping.

#### Arguments:

(size)

#### Example:

     [ 1, 2, 3 ].clipExtend(9); // => [ 1, 2, 3, 3, 3, 3, 3, 3, 3 ]

View Source on GitHub#

- Array

### clipPut

Same as `put`, but values for index greater than the size of the Array will be clipped to the last index.

#### Arguments:

(index, item)
View Source on GitHub#

- Array

### clipSwap

Same as `swap`, but values for index greater than the size of the Array will be clipped to the last index.

#### Arguments:

(i, j)
View Source on GitHub#

- Array

### clump

Separates the collection into sub-collections by separating every groupSize elements.

#### Arguments:

(groupSize)

#### Example:

      [1, 2, 3, 4, 5, 6, 7, 8].clump(3); // => [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8 ] ]

View Source on GitHub#

- Array

### clumps

Separates the collection into sub-collections by separating elements into groupings whose size is given by integers in the groupSizeList.

#### Arguments:

(groupSizeList)

#### Example:

      [1, 2, 3, 4, 5, 6, 7, 8].clumps([1, 2]);
      // => [ [ 1 ], [ 2, 3 ], [ 4 ], [ 5, 6 ], [ 7 ], [ 8 ] ]

View Source on GitHub#

- Array
- Number

### coin

Answers a Boolean which is the result of a random test whose probability of success in a range from zero to one is this.

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### collect

Answer a new array which consists of the results of function evaluated for each item in the collection. The function is passed two arguments, the item and an integer index.

#### Arguments:

(function)

#### Example:

     [ 1, 2, 3, 4 ].collect("reciprocal"); // => [ 1, 0.5, 0.3333, 0.25 ]
     (3).collect(function(x) { return x * 100; }); // => [ 0, 100, 200 ]

View Source on GitHub#

- Function
- String
- Array
- Boolean
- Number

### copy

Make a copy of the receiver. (shallow copy)

#### Arguments:

none
View Source on GitHub#

- String
- Array

### copyFromStart

Return a new Array which is a copy of the indexed slots of the receiver from the start of the collection to end.

#### Arguments:

(end)
View Source on GitHub#

- String
- Array

### copyRange

Return a new Array which is a copy of the indexed slots of the receiver from start to end.

#### Arguments:

(start, end)

#### Example:

     [1, 2, 3, 4, 5].copyRange(1, 3); // [ 2, 3, 4 ]

View Source on GitHub#

- Array

### copySeries

Return a new Array consisting of the values starting at first, then every step of the distance between first and second, up until last.

#### Arguments:

(first, second, last)

#### Example:

      [1, 2, 3, 4, 5, 6].copySeries(0, 2, 5); // => [ 1, 3, 5 ]

View Source on GitHub#

- String
- Array

### copyToEnd

Return a new Array which is a copy of the indexed slots of the receiver from start to the end of the collection
View Source on GitHub#

- Array
- Number

### cos

Cosine

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### cosh

Hyperbolic cosine

#### Arguments:

none
View Source on GitHub#

- Array

### count

Answer the number of items for which function answers True. The function is passed two arguments, the item and an integer index.

#### Arguments:

(function)

#### Example:

      [1, 2, 3, 4].count("even"); // => 2
      [1, 2, 3, 4].count(function(x, i) { return x & i; }); // => 1

View Source on GitHub#

- Array
- Number

### cpsmidi

Convert cycles per second to MIDI note.

#### Arguments:

none

#### Returns:

midi note

#### Example:

     (440).cpsmidi(); // => 69
     sc.Range("440, 550..880").cpsmidi(); // => [69, 72.8631, 76.0195, 78.6882, 81 ]

View Source on GitHub#

- Array
- Number

### cpsoct

Convert cycles per second to decimal octaves.

#### Arguments:

none

#### Example:

      (440).cpsoct(); // => 4.75
      sc.Range("440, 550..880").cpsoct(); // => [ 4.75, 5.0719, 5.3349, 5.5573, 5.75 ]

View Source on GitHub#

- Array
- Number

### cubed

the cube of the number

#### Arguments:

none
View Source on GitHub#

- Array

### curdle

Separates the array into sub-array by randomly separating elements according to the given probability.

#### Arguments:

([probability=0.5])
View Source on GitHub#

- Array
- Number

### curvelin

map the receiver from an assumed curve-exponential input range (inMin..inMax) to a linear output range (outMin..outMax). If the input exceeds the assumed input range.

#### Arguments:

([inMin=0, inMax=1, outMin=0, outMax=1, curve=-4, clip="minmax"])

#### Example:

      [0, 2, 4, 6, 8, 10].curvelin(0, 10, -1, 1);
      // => [ -1, 0.2222, 0.2905, 0.3846, 0.5375, 1 ]

View Source on GitHub#

- Array
- Number

### dbamp

Convert a decibels to a linear amplitude.

#### Arguments:

none

#### Example:

      (12).dbamp(); // => 3.981071705534973
      [-6, -3, 0, 3, 6].dbamp(); // => [ 0.5011, 0.7079, 1, 1.412, 1.9952 ]

View Source on GitHub#

- Array
- Number

### degrad

converts degree to radian

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### degreeToKey

#### Arguments:

(scale [, stepsPerOctave=12])
View Source on GitHub#

- Array

### delimit

View Source on GitHub#

- Array

### detect

Answer the first item in the receiver for which function answers True. The function is passed two arguments, the item and an integer index.

#### Arguments:

(function)

#### Example:

     [1, 2, 3, 4].detect("even"); // => 2
     [1, 2, 3, 4].detect(function(x, i) { return x & i; }); // => 3

View Source on GitHub#

- Array

### detectIndex

Similar to `detect` but returns the index instead of the item itself.

#### Arguments:

(function)
View Source on GitHub#

- Array

### difference

Return the set of all items which are elements of this, but not of that.

#### Arguments:

(that)

#### Example:

     [1, 2, 3].difference([2, 3, 4, 5]); // => [ 1 ]

View Source on GitHub#

- Array

### differentiate

Returns an array with the pairwise difference between all elements.

#### Arguments:

none

#### Example:

      [3, 4, 1, 1].differentiate(); // => [ 3, 1, -3, 0 ]

View Source on GitHub#

- Array
- Number

### difsqr

(a * a) - (b * b)

#### Arguments:

(number)
View Source on GitHub#

- Array
- Number

### distort

a nonlinear distortion function.

#### Arguments:

none

#### Example:

      (1).distort(); // => 0.5
      [0, 1, 5, 10].distort(); // => [ 0, 0.5, 0.8333, 0.9090 ]

View Source on GitHub#

- Array
- Number

### div

Integer Division

#### Arguments:

(number)

#### Example:

     (10).div(3);       // => 3
     [10,20,30].div(3); // => [ 3, 6, 10 ]

View Source on GitHub#

- Array
- Number

### do

Iterate over the elements in order, calling the function for each element. The function is passed two arguments, the element and an index.

#### Arguments:

(function)
View Source on GitHub#

- Array

### doAdjacentPairs

Calls function for every adjacent pair of elements in the Array. The function is passed the two adjacent elements and an index.

#### Arguments:

(function)
View Source on GitHub#

- Array

### drop

Drop the first n items of the array. If n is negative, drop the last -n items.

#### Arguments:

(number)

#### Example:

      [1, 2, 3, 4, 5].drop( 3); // [ 4, 5 ]
      [1, 2, 3, 4, 5].drop(-3); // [ 1, 2 ]

View Source on GitHub#

- Function
- String
- Array
- Boolean
- Number

### dup

Duplicates the receiver n times.

#### Arguments:

([n=2])

#### Example:

      (2).dup(5); // => [ 2, 2, 2, 2, 2 ]
      [1, 2, 3].dup(3) // => [ [1, 2, 3], [1, 2, 3], [1, 2, 3] ]

View Source on GitHub#

- Array
- Number

### equalWithPrecision

View Source on GitHub#

- Function
- String
- Array
- Boolean
- Number

### equals

#### Aliases:

==
View Source on GitHub#

- Array
- Number

### even

true if dividable by 2 with no rest

#### Arguments:

none
View Source on GitHub#

- Array

### every

#### Aliases:

sc_every
View Source on GitHub#

- Array
- Number

### excess

Returns the difference of the receiver and its clipped form.

#### Arguments:

(number)
View Source on GitHub#

- Array
- Number

### exclusivelyBetween

whether the receiver is greater than minVal and less than maxVal.

#### Arguments:

(lo, hi)
View Source on GitHub#

- Array
- Number

### exp

e to the power of the receiver.

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### expexp

map the receiver from an assumed exponential input range (inMin..inMax) to an exponential output range (outMin..outMax). If the input exceeds the assumed input range.

#### Arguments:

(inMin, inMax, outMin, outMax [, clip="minmax"])
View Source on GitHub#

- Array
- Number

### explin

map the receiver from an assumed exponential input range (inMin..inMax) to a linear output range (outMin..outMax). If the input exceeds the assumed input range.

#### Arguments:

(inMin, inMax, outMin, outMax [, clip="minmax"])
View Source on GitHub#

- Array

### *exprand

Fill an Array with random values in the range minVal to maxVal with exponential distribution.

#### Arguments:

(size [, minVal=0, maxVal=1])

#### Example:

     Array.exprand(8, 1, 100);

View Source on GitHub#

- Array
- Number

### exprand

an exponentially distributed random number in the interval ]a, b[.

#### Arguments:

(number)
View Source on GitHub#

- Array

### extend

Extends the object to match size by adding a number of items. If size is less than receiver size then truncate. This method may return a new Array.

#### Arguments:

(size, item)

#### Example:

     [1, 2, 3, 4].extend(10, 9); // => [ 1, 2, 3, 4, 9, 9, 9, 9, 9, 9 ]

View Source on GitHub#

- Array
- Number

### factorial

the factorial of this.

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### factors

the prime factors as array.

#### Arguments:

none

#### Example:

     (2000).factors(); // => [ 2, 2, 2, 2, 5, 5, 5 ]

View Source on GitHub#

- Number

### fib

#### Arguments:

([a=0, b=1])

#### Returns:

an array with a fibonacci series of this size beginning with a and b.

#### Example:

     (5).fib(2, 32); // => [ 32, 34, 66, 100, 166 ]

View Source on GitHub#

- Array

### *fib

Fill an Array with a fibonacci series.

#### Arguments:

(size [, a=0, b=1])

#### Example:

     Array.fib(5); // => [ 1, 1, 2, 3, 5 ]

View Source on GitHub#

- Array

### *fill

Creates an Array of the given size, the elements of which are determined by evaluation the given function.

#### Arguments:

(size [, function=nil])

#### Example:

     Array.fill(3, 5); // => [ 5, 5, 5 ]
     Array.fill(3, function(i) { return (i * 2 + 60).midicps(); });
     // => [ 440, 493.8833, 554.3652 ]

View Source on GitHub#

- Array

### fill

Inserts the item into the contents of the receiver.

#### Arguments:

(item)

#### Example:

     [1, 2, 3, 4].fill(4); // [ 4, 4, 4, 4 ]

View Source on GitHub#

- Array

### *fill2D

Creates a 2 dimensional Array of the given sizes. The items are determined by evaluation of the supplied function. The function is passed row and column indexes as arguments.

#### Arguments:

(rows, cols [, function=nil])

#### Example:

     Array.fill2D(3, 3, 1);
     // => [ [ 1, 1, 1 ],
     //      [ 1, 1, 1 ],
     //      [ 1, 1, 1 ] ]

View Source on GitHub#

- Array

### *fill3D

Creates a 3 dimensional Array of the given sizes. The items are determined by evaluation of the supplied function. The function is passed plane, row and column indexes as arguments.

#### Arguments:

(planes, rows, cols [, function=nil])

#### Example:

     Array.fill3D(3, 3, 3, 1);
     // => [ [ [ 1, 1, 1 ],[ 1, 1, 1 ],[ 1, 1, 1 ] ],
     //      [ [ 1, 1, 1 ],[ 1, 1, 1 ],[ 1, 1, 1 ] ],
     //      [ [ 1, 1, 1 ],[ 1, 1, 1 ],[ 1, 1, 1 ] ] ]

View Source on GitHub#

- Array

### *fillND

Creates a N dimensional Array where N is the size of the array dimensions. The items are determined by evaluation of the supplied function. The function is passed N number of indexes as arguments.

#### Arguments:

(dimensions [, function=nil])

#### Example:

      Array.fillND([1, 2, 3, 4], function(a, b, c, d) { return a+b+c+d; }); // => 4D

View Source on GitHub#

- Array

### find

Finds the starting index of a number of elements contained in the array.

#### Arguments:

(sublist [, offset=0])

#### Example:

      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].find([4, 5, 6]); // => 4

View Source on GitHub#

- Array

### findAll

Similar to `find` but returns an array of all the indices at which the sequence is found.

#### Arguments:

(sublist [, offset=0])

#### Example:

      [7, 8, 7, 6, 5, 6, 7, 6, 7, 8, 9].findAll([7, 6]); // => [ 2, 6 ]

View Source on GitHub#

- Array

### first

Return the first element of the collection.

#### Arguments:

none

#### Example:

     [3, 4, 5].first(); // => 3

View Source on GitHub#

- Array

### flat

Returns a collection from which all nesting has been flattened.

#### Arguments:

none

#### Example:

      [[1, 2, 3], [[4, 5], [[6]]]].flat(); // => [ 1, 2, 3, 4, 5, 6 ]

View Source on GitHub#

- Array

### flatIf

View Source on GitHub#

- Array

### flatSize

View Source on GitHub#

- Array

### flatten

Returns an array from which numLevels of nesting has been flattened.

#### Arguments:

([numLevels=1])

#### Example:

     [[1, 2, 3], [[4, 5], [[6]]]].flatten(1); // => [ 1, 2, 3, [ 4, 5 ], [ [ 6 ] ] ]
     [[1, 2, 3], [[4, 5], [[6]]]].flatten(2); // => [ 1, 2, 3, 4, 5, [ 6 ] ]

View Source on GitHub#

- Array
- Number

### floor

next smaller integer

#### Arguments:

none
View Source on GitHub#

- Array

### flop

Invert rows and colums in a two dimensional Array (turn inside out).

#### Arguments:

none

#### Example:

     [[1, 2, 3], [4, 5, 6]].flop(); // => [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]

View Source on GitHub#

- Array
- Number

### fold

the folded value, a bitwise or with aNumber

#### Arguments:

(lo, hi)
View Source on GitHub#

- Array
- Number

### fold2

the folded value, a bitwise or with aNumber

#### Arguments:

(number)
View Source on GitHub#

- Array

### foldAt

Same as `at`, but values for index greater than the size of the Array will be folded back.

#### Arguments:

(index)

#### Aliases:

@|@

#### Example:

     [ 1, 2, 3 ].foldAt(5); // => 2
     [ 1, 2, 3 ].foldAt([ 0, 1, 2, 3 ]); // => [ 1, 2, 3, 2 ]

View Source on GitHub#

- Array

### foldExtend

Same as `wrapExtend` but the sequences fold back on the list elements.

#### Arguments:

(size)

#### Example:

     [ 1, 2, 3 ].foldExtend(9); // => [ 1, 2, 3, 2, 1, 2, 3, 2, 1 ]

View Source on GitHub#

- Array

### foldPut

Same as `put`, but values for index greater than the size of the Array will be folded back.

#### Arguments:

(index, item)
View Source on GitHub#

- Array

### foldSwap

Same as `swap`, but the sequences fold back on the list elements.

#### Arguments:

(i, j)
View Source on GitHub#

- Number

### for

Executes function for all integers from this to endval, inclusive.

#### Arguments:

(endval, function)
View Source on GitHub#

- Number

### forBy

Executes function for all integers from this to endval, inclusive, stepping each time by stepval.

#### Arguments:

(endval, stepval, function)
View Source on GitHub#

- Number

### forSeries

Calls function for numbers from this up to endval stepping each time by a step specified by second.

#### Arguments:

(second, last, function)
View Source on GitHub#

- Array
- Number

### frac

fractional part

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### gauss

a gaussian distributed random number.

#### Arguments:

(upperLimit)
View Source on GitHub#

- Array
- Number

### gaussCurve

map the receiver onto a gauss function.

#### Arguments:

([a=1, b=0, c=1])
View Source on GitHub#

- Array
- Number

### gcd

Greatest common divisor

#### Arguments:

(number)

#### Example:

     [3, 6, 9, 12, 15].gcd(100); // => [ 1, 2, 1, 4, 5 ]

View Source on GitHub#

- Array

### *geom

Fill an Array with a geometric series.

#### Arguments:

(size [, start=1, grow=2])

#### Example:

     Array.geom(5, 1, 3) // => [ 1, 3, 9, 27, 81 ]

View Source on GitHub#

- Number

### geom

#### Arguments:

(start, grow)

#### Returns:

an array with a geometric series of this size from start.

#### Example:

     (5).geom(1, 3) // => [ 1, 3, 9, 27, 81 ]

View Source on GitHub#

- Array
- Number

### greater

greater than

#### Arguments:

(number)

#### Aliases:

>
View Source on GitHub#

- Array
- Number

### greaterThan

greater or equal than

#### Arguments:

(number)

#### Aliases:

>=
View Source on GitHub#

- Array
- Number

### half

View Source on GitHub#

- Array
- Number

### hanWindow

a value for a hanning window function between 0 and 1.

#### Arguments:

none
View Source on GitHub#

- Array

### histo

View Source on GitHub#

- Array
- Number

### hypot

Square root of the sum of the squares.

#### Arguments:

(number)
View Source on GitHub#

- Array
- Number

### hypotApx

View Source on GitHub#

- Array

### includes

Return a boolean indicating whether the collection contains anything matching item.

#### Arguments:

(item)
View Source on GitHub#

- Array

### includesAll

Answer whether all items in list are contained in the receiver.

#### Arguments:

(list)

#### Example:

     [1, 2, 3, 4].includesAll([2, 4]); // => true
     [1, 2, 3, 4].includesAll([4, 5]); // => false

View Source on GitHub#

- Array

### includesAny

Answer whether any item in list is contained in the receiver.

#### Arguments:

(list)

#### Example:

     [1, 2, 3, 4].includesAny([4, 5]); // => true
     [1, 2, 3, 4].includesAny([5, 6]); // => false

View Source on GitHub#

- Array
- Number

### inclusivelyBetween

whether the receiver is greater than or equal to minVal and less than or equal to maxVal.

#### Arguments:

(lo, hi)
View Source on GitHub#

- Array

### indexIn

Returns the closest index of the value in the array (collection must be sorted).

#### Arguments:

(item)

#### Example:

     [2, 3, 5, 6].indexIn(5.2); // => 2

View Source on GitHub#

- Array

### indexInBetween

Returns a linearly interpolated float index for the value (collection must be sorted). Inverse operation is `blendAt`.

#### Arguments:

(item)

#### Example:

     [2, 3, 5, 6].indexInBetween(5.2); // => 2.2

View Source on GitHub#

- Array

### indexOf

Return the index of an item in the collection, or -1 if not found.

#### Arguments:

(item [, offset=0])

#### Aliases:

sc_indexOf
View Source on GitHub#

- Array

### indexOfEqual

Return the index of something in the collection that equals the item, or -1 if not found.

#### Arguments:

(item [, offset=0])

#### Example:

     [[3], [4], [5]].indexOfEqual([5]); // => 2

View Source on GitHub#

- Array

### indexOfGreaterThan

Return the first index containing an item which is greater than item.

#### Arguments:

(item)

#### Example:

     [10, 5, 77, 55, 12, 123].indexOfGreaterThan(70); // => 2

View Source on GitHub#

- Array
- Number

### indexOfPrime

the index of a prime number less than or equal to the receiver up to 65521. If the receiver is not a prime, the answer is -1.

#### Arguments:

none
View Source on GitHub#

- Array

### indicesOf

Return an array of indices of things in the collection that equal the item, or [] if not found.

#### Arguments:

(item [, offset=0])

#### Example:

     [7, 8, 7, 6, 5, 6, 7, 6, 7, 8, 9].indicesOf(7); // => [ 0, 2, 6, 8 ]

View Source on GitHub#

- Array

### indicesOfEqual

Same as `indicesOf`, but use `equals` method.

#### Arguments:

(item [, offset=0])

#### Example:

     [[7], [8], [5], [6], 7, 6, [7], 9].indicesOfEqual([7]); // => [ 0, 6 ]

View Source on GitHub#

- Array

### inject

reduce

#### Arguments:

(thisValue, function)

#### Example:

      [1, 2, 3, 4, 5].inject(0, "+"); // => 15

View Source on GitHub#

- Array

### injectr

reduce right

#### Arguments:

(thisValue, function)

#### Example:

      [1, 2, 3, 4, 5].injectr([], "++"); // => [ 5, 4, 3, 2, 1 ]

View Source on GitHub#

- Array

### insert

Inserts the item into the contents of the receiver. This method may return a new Array.

#### Arguments:

(index, item)

#### Example:

     [1, 2, 3, 4].insert(1, 999); // [ 1, 999, 3, 4 ]

View Source on GitHub#

- Array

### instill

View Source on GitHub#

- Array

### *interpolation

Fill an `Array` with the interpolated values between the start and end values.

#### Arguments:

(size [, start=0, end=1])

#### Example:

     Array.interpolation(5, 3.2, 20.5); // => [3.2, 7.525, 11.850, 16.175, 20.5]

View Source on GitHub#

- Array

### invert

View Source on GitHub#

- Function
- String
- Array
- Boolean
- Number

### isArray

Checks if the receiver is an array.
View Source on GitHub#

- Function
- String
- Array
- Boolean
- Number

### isBoolean

Checks if the receiver is a boolean value.
View Source on GitHub#

- Array

### isEmpty

Checks if the receiver is empty.
View Source on GitHub#

- Function
- String
- Array
- Boolean
- Number

### isFunction

Checks if the receiver is a function.
View Source on GitHub#

- Array
- Number

### isNaN

Checks if the receiver is `NaN`.
View Source on GitHub#

- Array
- Number

### isNegative

Checks if the receiver is < 0.
View Source on GitHub#

- Function
- String
- Array
- Boolean
- Number

### isNumber

Checks if the receiver is a number.
View Source on GitHub#

- Array
- Number

### isPositive

Checks if the receiver is >= 0.
View Source on GitHub#

- Array
- Number

### isPowerOfTwo

the whether the receiver is a power of two.
View Source on GitHub#

- Array
- Number

### isPrime

whether the receiver is prime.

#### Arguments:

none

#### Example:

     (13).isPrime(); // => true

View Source on GitHub#

- Array
- Number

### isStrictlyPositive

Checks if the receiver is > 0.
View Source on GitHub#

- Function
- String
- Array
- Boolean
- Number

### isString

Checks if the receiver is a string.
View Source on GitHub#

- Array

### isSubsetOf

Returns True if all elements of this are also elements of that

#### Arguments:

(that)

#### Example:

     [1, 2].isSubsetOf([ 1, 2, 3, 4]); // => true
     [1, 5].isSubsetOf([ 1, 2, 3, 4]); // => false

View Source on GitHub#

- Array
- Number

### iwrap

View Source on GitHub#

- Array

### keep

Keep the first n items of the array. If n is negative, keep the last -n items.

#### Arguments:

(n)

#### Example:

     [1, 2, 3, 4, 5].keep( 3); // => [ 1, 2, 3 ]
     [1, 2, 3, 4, 5].keep(-3); // => [ 3, 4, 5 ]

View Source on GitHub#

- Array
- Number

### keyToDegree

inverse of degreeToKey.

#### Arguments:

(scale [, stepsPerOctave=12])

#### Example:

     l = [0, 1, 5, 9, 11]; // pentatonic scale
     sc.Range("60..73").collect(function(i) { return i.keyToDegree(l); });
     // => [ 25, 26, 26.25, 26.5, 26.75, 27, 27.25, 27.5, 27.75, 28, 28.5, 29, 30, 31 ]

View Source on GitHub#

- Array

### lace

Returns a new Array whose elements are interlaced sequences of the elements of the receiver's subcollections, up to size length. The receiver is unchanged.

#### Arguments:

(size)

#### Example:

     [[1, 2, 3], [0]].lace(10); // => [ 1, 0, 2, 0, 3, 0, 1, 0, 2, 0 ]

View Source on GitHub#

- Array

### last

Return the last element of the collection.

#### Arguments:

none

#### Example:

     [3, 4, 5].last(); // => 5

View Source on GitHub#

- Array

### lastForWhich

View Source on GitHub#

- Array

### lastIndex

View Source on GitHub#

- Array

### lastIndexForWhich

View Source on GitHub#

- Array
- Number

### lcm

Least common multiple

#### Arguments:

(number)

#### Example:

       [3, 6, 12, 24, 48].lcm(20); // => [ 60, 60, 60, 120, 240 ]

View Source on GitHub#

- Array
- Number

### lcurve

map the receiver onto an L-curve.

#### Arguments:

([a=1, m=0, n=1, tau=1])
View Source on GitHub#

- Array
- Number

### leftShift

performs a binary left shift

#### Arguments:

(number)

#### Aliases:

<<
View Source on GitHub#

- Array
- Number

### less

less than

#### Arguments:

(number)

#### Aliases:

<
View Source on GitHub#

- Array
- Number

### lessThan

smaller or equal than

#### Arguments:

(number)

#### Aliases:

<=
View Source on GitHub#

- Array
- Number

### lincurve

map the receiver from an assumed linear input range (inMin..inMax) to an exponential curve output range (outMin..outMax).

#### Arguments:

([inMin=0, inMax=1, outMin=0, outMax=1, curve=-4, clip="minmax"])
View Source on GitHub#

- Array
- Number

### linexp

map the receiver from an assumed linear input range (inMin..inMax) to an exponential output range (outMin..outMax).

#### Arguments:

([inMin=0, inMax=1, outMin=0, outMax=1, clip="minmax"])
View Source on GitHub#

- Array
- Number

### linlin

map the receiver from an assumed linear input range to a linear output range.

#### Arguments:

([inMin=0, inMax=1, outMin=0, outMax=1, clip="minmax"])
View Source on GitHub#

- Array
- Number

### linrand

#### Arguments:

none

#### Returns:

a linearly distributed random number from zero to this.

#### Example:

     (10).linrand();

View Source on GitHub#

- Array

### *linrand

Fill an Array with random values in the range minVal to maxVal with a linear distribution.

#### Arguments:

(size [, minVal=0, maxVal=1])

#### Example:

     Array.linrand(8, 1, 100);

View Source on GitHub#

- Array
- Number

### log

Base e logarithm.

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### log10

Base 10 logarithm.

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### log2

Base 2 logarithm.

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### log2Ceil

View Source on GitHub#

- Array
- Number

### madd

this * mul + add

#### Arguments:

(mul, add)
View Source on GitHub#

- Array
- Number

### max

Maximum

#### Arguments:

(number)
View Source on GitHub#

- Array

### maxDepth

Returns the maximum depth of all subarrays.

#### Arguments:

none

#### Example:

    [[1, 2, 3], [[41, 52], 5, 6], 1, 2, 3].maxDepth(); // => 3

View Source on GitHub#

- Array

### maxIndex

Answer the index of the maximum of the results of function evaluated for each item in the receiver. The function is passed two arguments, the item and an integer index. If function is nil, then answer the maximum of all items in the receiver.

#### Arguments:

([func=nil])

#### Example:

     [3.2, 12.2, 13, 0.4].maxIndex(); // => 2

View Source on GitHub#

- Array

### maxSizeAtDepth

Returns the maximum size of all subarrays at a certain depth (dimension)

#### Arguments:

(rank)
View Source on GitHub#

- Array

### maxValue

Answer the maximum of the results of function evaluated for each item in the receiver. The function is passed two arguments, the item and an integer index.

#### Arguments:

([function=nil])

#### Aliases:

maxItem

#### Example:

     [ 1, 5, 2, 4, 3 ].maxValue(); // => 5

View Source on GitHub#

- Array

### mean

View Source on GitHub#

- Array

### middle

View Source on GitHub#

- Array

### middleIndex

View Source on GitHub#

- Array
- Number

### midicps

Convert MIDI note to cycles per second

#### Returns:

cycles per second

#### Example:

     (69).midicps(); // => 440
     sc.Range("69..81").midicps(); // => [ 440, 466.1637, ... , 830.6093, 880 ]

View Source on GitHub#

- Array
- Number

### midiratio

Convert an interval in semitones to a ratio.

#### Arguments:

none

#### Returns:

a ratio

#### Example:

     sc.Range("0..12").midiratio(); // => [1, 1.0594, ... , 1.8877, 2]

View Source on GitHub#

- Array
- Number

### min

Minumum

#### Arguments:

(number)
View Source on GitHub#

- Array

### minIndex

Answer the index of the minimum of the results of function evaluated for each item in the receiver. The function is passed two arguments, the item and an integer index. If function is nil, then answer the minimum of all items in the receiver.

#### Arguments:

([function=nil])

#### Example:

     [3.2, 12.2, 13, 0.4].minIndex(); // => 3

View Source on GitHub#

- Array

### minValue

Answer the minimum of the results of function evaluated for each item in the receiver. The function is passed two arguments, the item and an integer index.

#### Arguments:

([function=nil])

#### Aliases:

minItem

#### Example:

     [ -1, -5, -2, -4, -3 ].minValue("abs"); // => -1

View Source on GitHub#

- Array

### mirror

Return a new Array which is the receiver made into a palindrome. The receiver is unchanged.

#### Arguments:

none

#### Example:

     [1, 2, 3, 4].mirror(); // => [1, 2, 3, 4, 3, 2, 1]

View Source on GitHub#

- Array

### mirror1

Return a new Array which is the receiver made into a palindrome with the last element removed. This is useful if the list will be repeated cyclically, the first element will not get played twice. The receiver is unchanged.

#### Arguments:

none

#### Example:

     [1, 2, 3, 4].mirror1(); // => [1, 2, 3, 4, 3, 2]

View Source on GitHub#

- Array

### mirror2

Return a new Array which is the receiver concatenated with a reversal of itself. The center element is duplicated. The receiver is unchanged.

#### Arguments:

none

#### Example:

     [1, 2, 3, 4].mirror2(); // => [1, 2, 3, 4, 4, 3, 2, 1]

View Source on GitHub#

- Array
- Number

### mod

Integer Modulo

#### Arguments:

(number)

#### Example:

     (10).mod(3); // => 1
     [10,20,30].mod(3); // => [ 1, 2, 0 ]

View Source on GitHub#

- Array

### mode

View Source on GitHub#

- Array
- Number

### nearestInList

the value in the list closest to this

#### Arguments:

(list)

#### Example:

     l = [0, 0.5, 0.9, 1];
     sc.Range("0, 0.1..1").collect(function(i) { return i.nearestInList(l); });
     // => [ 0, 0, 0, 0.5, 0.5, 0.5, 0.5, 0.9, 0.9, 0.9, 1 ]

View Source on GitHub#

- Array
- Number

### nearestInScale

the value in the collection closest to this, assuming an octave repeating table of note values.

#### Arguments:

(scale [, stepsPerOctave=12])

#### Example:

     l = [0, 1, 5, 9, 11]; // pentatonic scale
     sc.Range("60, 61..76").collect(function(i) { return i.nearestInScale(l, 12); });
     // => [ 60, 61, 61, 65, 65, 65, 65, 69, 69, 69, 71, 71, 72, 73, 73, 77, 77 ]

View Source on GitHub#

- Array
- Number

### neg

negation

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### nextPowerOf

the next power of aNumber

#### Arguments:

(base)
View Source on GitHub#

- Array
- Number

### nextPowerOfThree

the next power of three

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### nextPowerOfTwo

the number relative to this that is the next power of 2

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### nextPrime

the next prime less than or equal to the receiver up to 65521.

#### Arguments:

none

#### Example:

     (25).nextPrime(); // => 27

View Source on GitHub#

- Array

### normalize

Returns a new Array with the receiver items normalized between min and max.

#### Arguments:

([min=0, max=1])

#### Example:

     [1, 2, 3].normalize(-20, 10); // => [ -20, -5, 10 ]

View Source on GitHub#

- Array

### normalizeSum

Returns the Array resulting from `this[i] / this.sum()`, so that the array will sum to 1.0.

#### Arguments:

none

#### Example:

     [1, 2, 3].normalizeSum(); // => [ 0.1666, 0.3333, 0.5 ]

View Source on GitHub#

- Array

### notEmpty

Checks is the receiver is not empty.
View Source on GitHub#

- Function
- String
- Array
- Number

### notEquals

#### Aliases:

!=
View Source on GitHub#

- Array
- Number

### nthPrime

the nth prime number. The receiver must be from 0 to 6541.

#### Arguments:

none

#### Example:

    [0, 1, 2, 3, 4, 5].nthPrime(); // => [ 2, 3, 5, 7, 11, 13 ]

View Source on GitHub#

- Array
- Number

### numBits

number of required bits

#### Arguments:

none
View Source on GitHub#

- Array

### obtain

View Source on GitHub#

- Array

### occurrencesOf

Answer the number of items in the receiver which are equal to anObject.

#### Arguments:

(item)

#### Example:

     [1, 2, 3, 3, 4, 3, 4, 3].occurrencesOf(3); // => 4

View Source on GitHub#

- Array
- Number

### octcps

Convert decimal octaves to cycles per second.

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### odd

true if not dividable by 2 with no rest

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### opAdd

Addition

#### Aliases:

+

#### Example:

     (10).opAdd(2); // => 12
     [10,20,30].sc("+")(10); // => [ 20, 30, 40 ]

View Source on GitHub#

- Array
- Number

### opDiv

Division

#### Aliases:

/

#### Example:

     (10).opDiv(2); // => 5
     [10,20,30].sc("/")(10); // => [ 1, 2, 3 ]

View Source on GitHub#

- Array
- Number

### opMod

Modulo

#### Aliases:

%

#### Example:

     (10).opMod(3); // => 1
     [10,20,30].sc("%")(3); // => [ 1, 2, 0 ]

View Source on GitHub#

- Array
- Number

### opMul

Multiplication

#### Aliases:

*

#### Example:

     (10).opMul(2); // => 20
     [10,20,30].sc("*")(10); // => [ 100, 200, 300 ]

View Source on GitHub#

- Array
- Number

### opSub

Subtraction

#### Aliases:

-

#### Example:

     (10).opSub(2); // => 8
     [10,20,30].sc("-")(10); // => [ 0, 10, 20 ]

View Source on GitHub#

- Array

### pairsDo

Calls function for each subsequent pair of elements in the Array. The function is passed the two elements and an index.

#### Arguments:

(function)

#### Aliases:

keyValuesDo
View Source on GitHub#

- Number

### partition

randomly partition a number into parts of at least min size.

#### Arguments:

([parts=2, min=1])

#### Example:

     (75).partition(8, 3);

View Source on GitHub#

- Array

### performDegreeToKey

View Source on GitHub#

- Array

### performKeyToDegree

View Source on GitHub#

- Array

### performNearestInList

View Source on GitHub#

- Array

### performNearestInScale

View Source on GitHub#

- Array

### permute

Returns a new Array whose elements are the nthPermutation of the elements of the receiver.

#### Arguments:

(nthPermutation)
View Source on GitHub#

- Array

### pop

Remove and return the last element of the Array.

#### Arguments:

none

#### Example:

     [1, 2, 3].pop(); // 3

View Source on GitHub#

- Function
- String
- Array
- Boolean
- Number

### postln

View Source on GitHub#

- Array
- Number

### pow

this to the power of aNumber

#### Arguments:

(number)

#### Aliases:

**
View Source on GitHub#

- Array
- Number

### prevPrime

the next prime less than or equal to the receiver up to 65521.

#### Arguments:

none

#### Example:

     (25).prevPrime(); // => 23

View Source on GitHub#

- Array
- Number

### previousPowerOf

the number relative to this that is the previous power of aNumber
View Source on GitHub#

- Array

### product

View Source on GitHub#

- Array

### put

Put item at index, replacing what is there.

#### Arguments:

(index, item)
View Source on GitHub#

- Array

### putEach

Put the values in the corresponding indices given by keys. If one of the two argument arrays is longer then it will wrap.

#### Arguments:

(keys, values)
View Source on GitHub#

- Array

### putFirst

Place item at the first index in the collection. Note that if the collection is empty (and therefore has no indexed slots) the item will not be added.

#### Arguments:

(item)

#### Example:

     [3, 4, 5].putFirst(100); // => [ 100, 4, 5 ]
     [].putFirst(100); // => []

View Source on GitHub#

- Array

### putLast

Place item at the last index in the collection. Note that if the collection is empty (and therefore has no indexed slots) the item will not be added.

#### Arguments:

(item)

#### Example:

     [3, 4, 5].putLast(100); // => [ 3, 4, 100 ]
     [].putLast(100); // => []

View Source on GitHub#

- Array

### pyramid

Return a new Array whose elements have been reordered via one of 10 "counting" algorithms.

#### Arguments:

(patternType)

#### Example:

     [1, 2, 3, 4].pyramid(0);
     // => [ 1, 1, 2, 1, 2, 3, 1, 2, 3, 4 ]

View Source on GitHub#

- Array

### pyramidg

Like `pyramid`, but keep the resulting values grouped in subarrays.

#### Arguments:

(patternType)

#### Example:

     [1, 2, 3, 4].pyramidg(0);
     => [ [ 1 ], [ 1, 2 ], [ 1, 2, 3 ], [ 1, 2, 3, 4 ] ]

View Source on GitHub#

- Array
- Number

### quantize

round the receiver to the quantum.

#### Arguments:

([quantum=1, tolerance=0.05, strength=1])

#### Example:

     sc.Range("0,0.1..1").quantize(1, 0.3, 0.5)
     // => [ 0, 0.05, 0.1, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9, 0.95, 1 ]

View Source on GitHub#

- Array
- Number

### raddeg

converts radian to degree

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### ramp

Map receiver onto a ramp starting at 0.

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### rand

Random number from zero up to the receiver, exclusive.

#### Arguments:

none
View Source on GitHub#

- Array

### *rand

Fill a Array with random values in the range minVal to maxVal.

#### Arguments:

(size [, minVal=0, maxVal=1])

#### Example:

     Array.rand(8, 1, 100);

View Source on GitHub#

- Array

### *rand2

Fill an Array with random values in the range -val to +val.

#### Arguments:

(size [, val=1])

#### Example:

     Array.rand2(8, 100);

View Source on GitHub#

- Array
- Number

### rand2

#### Returns:

a random number from -this to +this.
View Source on GitHub#

- Array
- Number

### ratiomidi

Convert a ratio to an interval in semitones.

#### Arguments:

none

#### Returns:

an interval in semitones

#### Example:

     sc.Range("1, 1.2..2").ratiomidi();
     // => [ 0, 3.1564, 5.8251, 8.1368, 10.1759, 11.9999 ]

View Source on GitHub#

- Array
- Number

### reciprocal

1 / this

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### rectWindow

a value for a rectangular window function between 0 and 1.

#### Arguments:

none
View Source on GitHub#

- Array

### reject

Answer a new collection which consists of all items in the receiver for which function answers False. The function is passed two arguments, the item and an integer index.

#### Arguments:

(function)
View Source on GitHub#

- Array

### remove

Remove item from the receiver.

#### Arguments:

(item)
View Source on GitHub#

- Array

### removeAll

Remove all items in array from the receiver.

#### Arguments:

(list)
View Source on GitHub#

- Array

### removeAllSuchThat

Remove all items in the receiver for which function answers True. The function is passed two arguments, the item and an integer index.

#### Arguments:

(function)
View Source on GitHub#

- Array

### removeAt

Remove and return the element at index, shrinking the size of the Array.

#### Arguments:

(index)
View Source on GitHub#

- Array

### removeEvery

Remove all occurrences of the items in array from the receiver.

#### Arguments:

(list)
View Source on GitHub#

- Array

### removing

View Source on GitHub#

- Array

### replace

Return a new array in which a number of elements have been replaced by another.

#### Arguments:

(find, replace)
View Source on GitHub#

- Array

### resamp0

Returns a new Array of the desired length, with values resampled evenly-spaced from the receiver without interpolation.

#### Arguments:

(newSize)

#### Example:

     [1, 2, 3, 4].resamp0(12); // => [ 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4 ]
     [1, 2, 3, 4].resamp0( 2); // => [ 1, 4 ]

View Source on GitHub#

- Array

### resamp1

Returns a new Array of the desired length, with values resampled evenly-spaced from the receiver with linear interpolation.

#### Arguments:

(newSize)

#### Example:

     [1, 2, 3, 4].resamp1(12); // => [ 1, 1.2727, 1.5454, ... , 3.7272, 4 ]
     [1, 2, 3, 4].resamp1( 3); // => [ 1, 2.5, 4 ]

View Source on GitHub#

- Array

### reverse

Return a new Array whose elements are reversed.

#### Arguments:

none

#### Aliases:

sc_reverse
View Source on GitHub#

- Number

### reverseDo

Iterate over the elements in reverse order, calling the function for each element. The function is passed two arguments, the element and an index.

#### Arguments:

(function)
View Source on GitHub#

- Array
- Number

### rightShift

performs a binary right shift

#### Arguments:

(number)

#### Aliases:

>>
View Source on GitHub#

- Array
- Number

### ring1

(a * b) + a

#### Arguments:

(number)
View Source on GitHub#

- Array
- Number

### ring2

((a*b) + a + b)

#### Arguments:

(number)
View Source on GitHub#

- Array
- Number

### ring3

(a * a *b)

#### Arguments:

(number)
View Source on GitHub#

- Array
- Number

### ring4

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

#### Arguments:

(number)
View Source on GitHub#

- Array

### rotate

Return a new Array whose elements are in rotated order. The receiver is unchanged.

#### Arguments:

(n)

#### Example:

     [1, 2, 3, 4].rotate( 1); // => [ 4, 1, 2, 3 ]
     [1, 2, 3, 4].rotate(-1); // => [ 2, 3, 4, 1 ]

View Source on GitHub#

- Array
- Number

### round

Round to multiple of aNumber

#### Arguments:

(number)
View Source on GitHub#

- Array
- Number

### roundUp

round up to a multiply of aNumber

#### Arguments:

(number)
View Source on GitHub#

- Array
- Number

### rrand

a random number in the interval ]a, b[.

#### Arguments:

(number)
View Source on GitHub#

- Array
- Number

### scaleneg

a * b when a < 0, otherwise a.

#### Arguments:

(number)
View Source on GitHub#

- Array

### scramble

Returns a new Array whose elements have been scrambled. The receiver is unchanged.

#### Arguments:

none

#### Aliases:

shuffle
View Source on GitHub#

- Array
- Number

### scurve

Map receiver in the onto an S-curve.

#### Arguments:

none
View Source on GitHub#

- Array

### sect

Return the set theoretical intersection of this and that.

#### Arguments:

(that)

#### Example:

     [1, 2, 3].sect([2, 3, 4, 5]); // => [ 2, 3 ]

View Source on GitHub#

- Array

### select

Answer a new collection which consists of all items in the receiver for which function answers True. The function is passed two arguments, the item and an integer index.

#### Arguments:

(function)
View Source on GitHub#

- Array

### separate

Separates the collection into sub-collections by calling the function for each adjacent pair of elements. If the function returns true, then a separation is made between the elements.

#### Arguments:

(function)

#### Example:

     sc.Range("0..10").separate("isPrime");
     // => [ [0,1,2] , [3], [4,5], [6,7], [8,9,10] ]

View Source on GitHub#

- Array

### *series

Fill an Array with an arithmetic series.

#### Arguments:

(size [, start=0, step=1])

#### Example:

     Array.series(5, 10, 2); // => [ 10, 12, 14, 16, 18 ]

View Source on GitHub#

- Number

### series

return an artithmetic series from this over second to last.

#### Arguments:

(second, last)

#### Example:

     (5).series(7, 10); // => [ 5, 7, 9 ]

View Source on GitHub#

- Array
- Number

### setBit

set nth bit to zero (bool = false) or one (bool = true)

#### Arguments:

(number, bool)
View Source on GitHub#

- Array
- Number

### sign

Answer -1 if negative, +1 if positive or 0 if zero.

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### sin

Sine

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### sinh

Hyperbolic sine

#### Arguments:

none
View Source on GitHub#

- Function
- String
- Array
- Boolean
- Number

### size

Return the number of elements the receiver.

#### Arguments:

none
View Source on GitHub#

- Array

### slide

Return a new Array whose elements are repeated subsequences from the receiver. Easier to demonstrate than explain.

#### Arguments:

([windowLength=3, stepSize=1])

#### Example:

     [1, 2, 3, 4, 5, 6].slide(3, 1); // => [ 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6 ]

View Source on GitHub#

- Array
- Number

### softclip

Distortion with a perfectly linear region from -0.5 to +0.5

#### Arguments:

none
View Source on GitHub#

- Array

### sputter

Return a new Array of length maxlen with the items partly repeated (random choice of given probability).

#### Arguments:

([probability=0.25, maxlen=100])
View Source on GitHub#

- Array
- Number

### sqrdif

(a - b) ** 2

#### Arguments:

(number)
View Source on GitHub#

- Array
- Number

### sqrsum

(a + b) ** 2

#### Arguments:

(number)
View Source on GitHub#

- Array
- Number

### sqrt

the square root of the number.

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### squared

the square of the number

#### Arguments:

none
View Source on GitHub#

- Array

### stutter

Return a new Array whose elements are repeated n times.

#### Arguments:

(n)

#### Example:

     [1, 2, 3].stutter(2); // => [ 1, 1, 2, 2, 3, 3 ]

View Source on GitHub#

- Array

### sum

Answer the sum of the results of function evaluated for each item in the receiver. The function is passed two arguments, the item and an integer index.

#### Arguments:

(function)

#### Example:

     sc.Range("0..10").sum(); // => 55

View Source on GitHub#

- Array
- Number

### sum3rand

This was suggested by Larry Polansky as a poor man's gaussian.

#### Arguments:

none
View Source on GitHub#

- Array

### sumabs

View Source on GitHub#

- Array
- Number

### sumsqr

(a * a) + (b * b)

#### Arguments:

(number)
View Source on GitHub#

- Array

### swap

Swap two elements in the collection at indices i and j.

#### Arguments:

(i, j)

#### Example:

     [0,1,2,3,4,5].swap(2, 3); // => [0, 1, 3, 2, 4, 5]

View Source on GitHub#

- Array

### symmetricDifference

Return the set of all items which are not elements of both this and that. this -- that

#### Arguments:

(that)

#### Example:

     [1, 2, 3].symmetricDifference([2, 3, 4, 5]); // => [ 1, 4, 5 ]

View Source on GitHub#

- Array

### take

Remove and return item from collection. The last item in the collection will move to occupy the vacated slot (and the collection size decreases by one).

#### Arguments:

(item)

#### Example:

     a =  [11, 12, 13, 14, 15];
     a.take(12); // => 12
     a; => [ 11, 15, 13, 14 ]

View Source on GitHub#

- Array

### takeAt

Similar to `removeAt`, but does not maintain the order of the items following the one that was removed. Instead, the last item is placed into the position of the removed item and the array's size decreases by one.

#### Arguments:

(index)

#### Example:

     y = [ 1, 2, 3, 4, 5 ];
     y.takeAt(1); // => 2
     y; // => [ 1, 5, 3, 4 ]

View Source on GitHub#

- Array

### takeThese

Removes all items in the receiver for which the function answers true. The function is passed two arguments, the item and an integer index.

#### Arguments:

(function)

#### Example:

     y = [1, 2, 3, 4];
     y.takeThese("odd"); // => [ 4, 2 ]
     y; // => [ 4, 2 ]

View Source on GitHub#

- Array
- Number

### tan

Tangent

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### tanh

Hyperbolic tangent

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### thresh

View Source on GitHub#

- Array

### transposeKey

View Source on GitHub#

- Array
- Number

### triWindow

a value for a triangle window function between 0 and 1.

#### Arguments:

none
View Source on GitHub#

- Array
- Number

### trunc

Truncate to multiple of aNumber

#### Arguments:

(number)
View Source on GitHub#

- Array
- Number

### twice

View Source on GitHub#

- Array

### unbubble

View Source on GitHub#

- Array

### union

Return the set theoretical union of this and that.

#### Arguments:

(that)

#### Example:

     [1, 2, 3].union([2, 3, 4, 5]); // => [ 1, 2, 3, 4, 5 ]

View Source on GitHub#

- Array

### uniq

View Source on GitHub#

- Array
- Number

### unsignedRightShift

performs an unsigned right shift

#### Arguments:

(number)

#### Aliases:

>>>
View Source on GitHub#

- Function
- String
- Array
- Boolean
- Number

### value

View Source on GitHub#

- Function
- String
- Array
- Boolean
- Number

### valueArray

View Source on GitHub#

- Array

### wchoose

Choose an element from the collection at random using a list of probabilities or weights. The weights must sum to 1.0.

#### Arguments:

(weights)

#### Example:

     [1, 2, 3, 4].wchoose([0.1, 0.2, 0.3, 0.4]);

View Source on GitHub#

- Array
- Number

### welWindow

a value for a welsh window function between 0 and 1.

#### Arguments:

none
View Source on GitHub#

- Array

### *with

Create a new Array whose slots are filled with the given arguments.

#### Arguments:

(... args)
View Source on GitHub#

- Array
- Number

### wrap

Wrapping at lo and hi.

#### Arguments:

(lo, hi)
View Source on GitHub#

- Array
- Number

### wrap2

View Source on GitHub#

- Array

### wrapAt

Same as `at`, but values for index greater than the size of the Array will be wrapped around to 0.

#### Aliases:

@@

#### Example:

     [ 1, 2, 3 ].wrapAt(13); // => 2
     [ 1, 2, 3 ].wrapAt([ 0, 1, 2, 3 ]); // => [ 1, 2, 3, 1 ]

View Source on GitHub#

- Array

### wrapExtend

Returns a new Array whose elements are repeated sequences of the receiver, up to size length.

#### Arguments:

(size)

#### Example:

     [ 1, 2, 3 ].wrapExtend(9); // => [ 1, 2, 3, 1, 2, 3, 1, 2, 3 ]

View Source on GitHub#

- Array

### wrapPut

Same as `put`, but values for index greater than the size of the Array will be wrapped around to 0.

#### Arguments:

(index, item)
View Source on GitHub#

- Array

### wrapSwap

Same as `swap`, but values for index greater than the size of the Array will be wrapped around to 0.

#### Arguments:

(i, j)
View Source on GitHub#

- Number

### xrand

a random value from zero to this, excluding the value exclude.

#### Arguments:

(exclude)
View Source on GitHub#

- Number

### xrand2

a random value from this.neg to this, excluding the value exclude.

#### Arguments:

(exclude)
View Source on GitHub#

- Pattern

### *Pgeom

Returns a stream that behaves like a geometric series.

#### Arguments:

([start=0, grow=1, length=inf])

#### Example:

     p = sc.Pgeom(1, 2, 5);
     p.next(); // => 1
     p.next(); // => 2
     p.next(); // => 4
     p.next(); // => 8
     p.next(); // => 16
     p.next(); // => null

View Source on GitHub#

- Pattern

### *Prand

Embed one item from the list at random for each repeat.

#### Arguments:

(list [, repeats=1, seed=nil])

#### Example:

     p = sc.Prand([1,2,3], 5, 12345);
     p.next(); // => 3
     p.next(); // => 1
     p.next(); // => 2
     p.next(); // => 1
     p.next(); // => 3
     p.next(); // => null

View Source on GitHub#

- Pattern

### *Pseq

Cycles over a list of values. The repeats variable gives the number of times to repeat the entire list.

#### Arguments:

(list [, repeat=1, offset=0])

#### Example:

     p = sc.Pseq([1,2,3], 2);
     p.next(); // => 1
     p.next(); // => 2
     p.next(); // => 3
     p.next(); // => 1
     p.next(); // => 2
     p.next(); // => 3
     p.next(); // => null

View Source on GitHub#

- Pattern

### *Pser

is like `Pseq`, however the repeats variable gives the number of items returned instead of the number of complete cycles

#### Arguments:

(list [, repeat=1, offset=0])

#### Example:

     p = sc.Pser([1,2,3], 4);
     p.next(); // => 1
     p.next(); // => 2
     p.next(); // => 3
     p.next(); // => 1
     p.next(); // => null

View Source on GitHub#

- Pattern

### *Pseries

Returns a stream that behaves like an arithmetric series.

#### Arguments:

([start=0, step=1, length=inf])

#### Example:

     p = sc.Pseries(0, 2, 5);
     p.next(); // => 0
     p.next(); // => 2
     p.next(); // => 4
     p.next(); // => 6
     p.next(); // => 8
     p.next(); // => null

View Source on GitHub#

- Pattern

### *Pshuf

Returns a shuffled version of the list item by item, with n repeats.

#### Arguments:

(list [, repeats=1, seed=nil])

#### Example:

     p = sc.Pshuf([1,2,3], 5, 12345);
     p.next(); // => 2
     p.next(); // => 1
     p.next(); // => 3
     p.next(); // => 2
     p.next(); // => 1
     p.next(); // => null

View Source on GitHub#

- Rgen

### *RGen

Random Generator

#### Arguments:

([seed])

#### Example:

     r = sc.RGen();
     r.next();

View Source on GitHub#

- Rgen

### next

return a number from 0.0 to 0.999...

#### Arguments:

none

#### Example:

     r = sc.RGen(100);
     r.next(); // => 0.6258506774902344
     r.next(); // => 0.4134453535079956
     r.next(); // => 0.13581514358520508

View Source on GitHub#

- sc

### Range

Creates an array of numbers (positive and/or negative) progressing from first up to last.

#### Arguments:

("[first[,second]]...?last")

#### Aliases:

R

#### Example:

     sc.Range(5); // => [ 0, 1, 2, 3, 4, 5 ]
     sc.Range("1..5"); // => [ 1, 2, 3, 4, 5 ]
     sc.Range("5..1"); // => [ 5, 4, 3, 2, 1 ]
     sc.Range("0, 2.5..10"); // => [ 0, 2.5, 5, 7.5, 10 ]
     sc.Range("0...10") // => [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]

View Source on GitHub#

- sc

### use

#### Arguments:

(type)

#### Example:

     sc.use("global"); // install sc.functions to global namespace
     midicps(69); // => 40

View Source on GitHub#

- Scale

### *Scale

Scale supports arbitrary octave divisions and ratios, and (in conjunction with Tuning) can generate pitch information in various ways.

#### Example:

     sc.Scale.major(); // => Major Scale
     sc.Scale.dorian("Pythagorean"); // => Dorian Scale with Pythagorean Tuning
     sc.ScaleInfo.names(); // list of scale name
     sc.ScaleInfo.at("minor"); // => Minor Scale

View Source on GitHub#

- Scale

### *choose

Creates a random scale from the library, constrained by size and pitchesPerOctave if desired

#### Arguments:

([size=7, pitchesPerOctave=12])

#### Example:

     sc.Scale.choose(7);

View Source on GitHub#

- Scale

### at

#### Arguments:

(index)
View Source on GitHub#

- Scale

### cents

Returns a turned array of cent values

#### Arguments:

none
View Source on GitHub#

- Scale

### degreeToFreq

Returns a frequency based on current tuning and rootFreq argument.

#### Example:

     sc.Scale.major().degreeToFreq(2, (60).midicps(), 1); // => 659.25511...
     sc.Scale.major("just").degreeToFreq(2, (60).midicps(), 1); // => 654.06391...

View Source on GitHub#

- Scale

### degreeToFreq2

Same `degreeToFreq`, but use `blendAt`.

#### Example:

     sc.Scale.major().degreeToFreq2(2.5, (60).midicps(), 1); // => 678.8557...
     sc.Scale.major("just").degreeToFreq2(2.5, (60).midicps(), 1); // => 675.8660...

View Source on GitHub#

- Scale

### degreeToRatio

Returns a ratio based on current tuning.

#### Arguments:

(degree [, octave=0])

#### Example:

     sc.Scale.major().degreeToRatio(2, 1).round(0.001); // => 2.52
     sc.Scale.major("just").degreeToRatio(2, 1).round(0.001); // => 2.5

View Source on GitHub#

- Scale

### degreeToRatio2

Same as `degreeToRatio`, but use `blendAt`.

#### Arguments:

(degree [, octave=0])

#### Example:

     sc.Scale.major().degreeToRatio2(2.5, 1).round(0.001); // => 2.595
     sc.Scale.major("just").degreeToRatio2(2.5, 1).round(0.001); // => 2.583

View Source on GitHub#

- Scale

### degrees

#### Arguments:

none
View Source on GitHub#

- Scale

### octaveRatio

#### Arguments:

none
View Source on GitHub#

- Scale

### performDegreeToKey

#### Arguments:

(scaleDegree, stepsPerOctave [, accidental=0])
View Source on GitHub#

- Scale

### performKeyToDegree

#### Arguments:

(degree [, stepsPerOctave=12])
View Source on GitHub#

- Scale

### performNearestInList

#### Arguments:

(degree)
View Source on GitHub#

- Scale

### performNearestInScale

#### Arguments:

(degree [, stepsPerOctave=12])
View Source on GitHub#

- Scale

### pitchesPerOctave

Returns the size of the pitch class set from which the tuning is drawn

#### Arguments:

none

#### Example:

     sc.Scale.aeolian().pitchesPerOctave(); // 12
     sc.Scale.ajam().pitchesPerOctave(); // 24 (this is a quarter-tone scale)

View Source on GitHub#

- Scale

### ratios

Return a turned array of ratios

#### Arguments:

none
View Source on GitHub#

- Scale

### semitone

Returns a tuned array of semitone values

#### Arguments:

none
View Source on GitHub#

- Scale

### size

Returns the length of the scale.

#### Arguments:

none

#### Example:

     sc.Scale.ionian().size(); // 7
     sc.Scale.minorPentatonic().size(); // 5

View Source on GitHub#

- Scale

### stepsPerOctave

Usually 12, but may be different if the current tuning has a stretched or compressed octave. Needed for degreeToKey

#### Arguments:

none
View Source on GitHub#

- Scale

### tuning

Sets or gets the tuning of the Scale.

#### Arguments:

([inTuning])

#### Example:

     sc.Scale.major().tuning("just"); // set tuning
     sc.Scale.major().tuning(); // get tuning

View Source on GitHub#

- Scale

### wrapAt

These access the array generated by semitones.

#### Arguments:

(index)

#### Example:

     a = sc.Scale.major();
     a.wrapAt(4); // =>  7
     a.wrapAt([5, 6, 7]); // => [ 9, 11, 0 ]

View Source on GitHub#

- Tuning

### *Tuning

Represents a musical tuning (e.g. equal temperament, just intonation, etc.). Used in conjunction with `Scale` to generate pitch information.

#### Example:

     sc.Tuning.et12(); // => equal temperament
     sc.TuningInfo.names(); // => list of tuning name
     sc.TuningInfo.at("just"); // => Limit Just Intonation

View Source on GitHub#

- Tuning

### *choose

Creates a random tuning from the library, constrained by size (which defaults to 12)

#### Arguments:

([size=12])
View Source on GitHub#

- Tuning

### at

#### Arguments:

(index)
View Source on GitHub#

- Tuning

### cents

Returns a array of cent values for the pitch set

#### Arguments:

none
View Source on GitHub#

- Tuning

### equals

#### Arguments:

(that)
View Source on GitHub#

- Tuning

### octaveRatio

#### Arguments:

none
View Source on GitHub#

- Tuning

### ratios

Returns a tuned array of ratios for the pitch set

#### Arguments:

none
View Source on GitHub#

- Tuning

### semitones

Returns an array of semitone values for the pitch set

#### Arguments:

none
View Source on GitHub#

- Tuning

### size

#### Arguments:

none
View Source on GitHub#

- Tuning

### stepsPerOctave

#### Arguments:

none
View Source on GitHub#

- Tuning

### tuning

#### Arguments:

none
View Source on GitHub#

- Tuning

### wrapAt

#### Arguments:

(index)
View Source on GitHub#