# Classes

## FreqScope

A frequency analyzer.

## FormantTable

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

*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

Vector based envelope editor.

## 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

Examples:
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]

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

Example:

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

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]

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]]

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"

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"]

## 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]

# Plugins (Unit Generators)

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