# Supercollider 3 Extensions

A collection of classes and methods for Supercollider 3 (download all)

# Classes

## FreqScope

## FormantTable

Formant data of a, e, i, o, u vowels for soprano, alto, counter tenor, tenor and bass.

Randomly returns one of the formant presets.

__*get(preset)__Returns center frequency (f), amplitude (a), and 1/q (rq) values for first five formants of preset in format [[f1,f2,f3,f4,f5],[a1,a2,a3,a4,a5],[rq1,rq2,rq3,rq4,rq5]]. Frequencies are in Hz, amplitudes are a linear 0-1 scale, and 1/q is bandwidth divided by center frequency.__*rand()__Randomly returns one of the formant presets.

## Scale

Returns an array of step ratios. Used in conjuction with SequenceableCollection-tuningScale.

__*new()____nCET(cent)__Returns an n-cent equal temperament scale.__nEDO(divs, octaveRatio, intervals)__Returns an n-equal division octave scale.__et12(intervals)__Returns a 12-tone equal temperament scale.__chromatic(divs, octaveRatio)__Returns an equal temperament chromatic scale.__ionian(), dorian(), phrygian(), lydian(), mixolydian(), aeolian(), locrian()__Return a 12-et mode scale.__ionian5(), dorian5(), phrygian5(), lydian5(), mixolydian5(), aeolian5(), locrian5()__Return a 12-et pentatonic mode scale.__maj(), min(), whole(), etc.__Return a traditional 12-et scale.__alpha(), beta(), gamma()__Return a W. Carlos n-cent equal temperament scale.## SCEnvelopeEdit

## SCFreqScope

A view class for viewing the frequency spectrum of a specified audio bus. Used by FreqScope class above.

# Method Extensions

## Function

__benchmark(num)__Returns time in milliseconds to evaluate function 'num' times.

## Integer

__asPaddedString(size, padChar, padSide)__Returns a padded string of minimum length 'size'.

Examples:

123.asPaddedString(6, $0, \left) -> "00123"

12.asPaddedString(6, $-, \right) -> "12----"

123.asPaddedString(6, $0, \left) -> "00123"

12.asPaddedString(6, $-, \right) -> "12----"

## Probability Distributions (SimpleNumber & SequenceableCollection)

__betarand(val2, prob1, prob2)__Returns a random number from the Eularian Beta distribution within the range of the receiver and 'val2'.

__cauchy(spread)__Returns a random number from the Cauchy distribution with the receiver as the mean.

__gaussian(dev)__Uses a fast Box-Muller algorithm to return a number from the Gaussian distribution with the receiver as the mean.

__linrrand(val2)__Returns a random number from the linear distribution within the range of the receiver and 'val2'.

__logistic(spread)__Returns a random number from the logistic distribution with the receiver as the mean.

__pareto(shape)__Returns a random number from the Pareto distribution within the range of -receiver to receiver.

__poisson()__Returns a random integer from the Poisson distribution with the receiver as the mean and variance.

__weibull(spread, shape)__Returns a random number from the Weibull distribution with the receiver as the mean.

## SequenceableCollection

__*tuningScale(rootFreq, stepRatios, loFreqBound, hiFreqBound)__Returns an array of frequencies (Hz) built from 'rootFreq' frequency using the 'stepRatios' array. 'stepRatios' is generally derived from the Scale class, but can specified directly. Lower and upper limits on the returned frequencies are specified with 'loFreqBound' and 'hiFreqBound', respectively.

Examples: (frequencies rounded for examples)

Array.tuningScale(440, [1.5, 2], 220, 880) -> [220, 330, 440, 660, 880]

Array.tuningScale(440, Scale.new.maj, 440, 880) -> [440, 493.9, 554.4, 587.3, 659.3, 740, 830.6, 880]

Array.tuningScale(440, [1.5, 2], 220, 880) -> [220, 330, 440, 660, 880]

Array.tuningScale(440, Scale.new.maj, 440, 880) -> [440, 493.9, 554.4, 587.3, 659.3, 740, 830.6, 880]

__asAddendsOf(sum)__Returns an array consisting of random elements from the receiver that sum to 'sum'.

Example:

[1,2,3,4].asAddendsOf(10) -> [1,2,3,3,1]

[1,2,3,4].asAddendsOf(10) -> [1,2,3,3,1]

__nearestTo(value)__Returns a number from the receiving array that is the closest in value to 'value'. The receiver must be in ascending order.

Example:

[1,2,6,8].nearestTo(3) -> 2

[1,2,6,8].nearestTo(3) -> 2

__nearestToList(list)__Returns an array of values from the receiving array that are closest matches to the values in 'list'. The receiver must be in ascending order.

Example:

[1,2,6,8].nearestToList([2.2, 1.4, 20, 7.8]) -> [2,1,8,8]

[1,2,6,8].nearestToList([2.2, 1.4, 20, 7.8]) -> [2,1,8,8]

__newFromFile(path, columnSeparator, rowSeparator)__Reads a text file into a 2D array of indexing format [row][col].

Example:

Contents of "file.txt"

1,2,3

4,5,6

7,8,9

Array.newFromFile("file.text", $, ,$\n) -> [[1,2,3],[4,5,6],[7,8,9]]

Contents of "file.txt"

1,2,3

4,5,6

7,8,9

Array.newFromFile("file.text", $, ,$\n) -> [[1,2,3],[4,5,6],[7,8,9]]

__writeFile(path, columnSeparator, rowSeparator)__Inverse of SequenceableCollection-newFromFile.

## SimpleNumber

__asTimeString()__Returns a string "hh:mm:ss:ttt" where t is milliseconds. The receiver is a time in seconds.

Example:

3661.123.asTimeString -> "01:01:01:123"

3661.123.asTimeString -> "01:01:01:123"

__midinote()__Returns a string corresponding to the pitch class letter, accidental, and octave of the receiver number. The key signature is B-major.

Example:

[60, 34, 10, 46, 49].midinote -> ["c 5", "a#2", "a#0", "a#3", "c#4"]

[60, 34, 10, 46, 49].midinote -> ["c 5", "a#2", "a#0", "a#3", "c#4"]

## String

__notemidi()__

Returns a midi note value corresponding to a note string. The note string is a pitch class, accidental (optional), and octave number. Pitch class can be upper or lower case c, d, e, f, g, a, or b. Sharps are designated as #, s, or + and flats are designated as b, f, or -.

Example:

["c5", "A#2", "bf0", "Bb3", "C+4"].notemidi -> [60, 34, 10, 46, 49]

["c5", "A#2", "bf0", "Bb3", "C+4"].notemidi -> [60, 34, 10, 46, 49]

# Plugins (Unit Generators)

**LoopBuf**

Similar to PlayBuf, but allows specification of begin and end loop frames and has selectable interpolation.