Members
csound
Global instance of Csound, shared with Strudel.
- Source:
csoundac
Global instance of CsoundAC.
- Source:
diagnostic_level_
Sets the level of diagnostic messages in this module.
- Source:
parameters
Global reference to the cloud-5 parameters addon.
- Source:
Methods
Chord(name) → {Chord}
Creates and initializes a CsoundAC Chord object. This function should be called from module scope in Strudel code before creating any Patterns. The Chord class is based on Dmitri Tymoczko's model of chord space, and represents an equally tempered chord of the specified number of voices as a single point in chord space, where each dimension of the space corresponds to one voice of the Chord. Chords are equipped with numerous operations from pragmatic music theory, atonal music theory, and neo-Riemannian music theory.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The common musical name of the Chord, e.g. "Cb9." |
- Source:
Returns:
A new CsoundAC Chord object.
- Type
- Chord
Clone(a, b)
A utility for making a value copy of a Chord (or a Scale, which is derived from Chord). Object b is resized to the size of a, and a's pitches are copied to b. Currently, only pitches are copied.
Parameters:
Name | Type | Description |
---|---|---|
a |
Chord | The source Chord (or Scale). |
b |
Chord | The target Chord (or Scale). |
- Source:
Pitv(voices, bass, range) → {PITV}
Creates and initializes a CsoundAC PITV object. This function should be called from module scope in Strudel code before creating any Patterns. The PITV object is a 4 dimensional cyclic group whose dimensions are TI set class (P), chord inversion (I), pitch-class transposition (T), and index of octavewise revoicing within the specified range (V). The elements of the group are chords in 12 tone equal temperament with the specified number of voices. There is a one-to-one mapping between PITV indices and chords, such that each voiced chord corresponds to a PITV index, and each PITV index corresponds to a voiced chord. This enables algorithmically generating harmonies and voicings by independently varying P, I, T, and V.
Parameters:
Name | Type | Description |
---|---|---|
voices |
number | The number of voices in the chord space. |
bass |
number | The lowest pitch (as a MIDI key number) in the chord space. |
range |
number | The range (in MIDI key numbers) of the chord space. |
- Source:
Returns:
A new PITV object.
- Type
- PITV
Scale(name) → {Scale}
Creates and initializes a CsoundAC Scale object. This function can be called from module scope in Strudel code before creating any Patterns. The Scale class is derived from the CsoundAC Chord class, but has been equipped with additional methods based on Dimitri Tymoczko's model of functional harmony. This enables algorithmically generating Chords from scale degrees, transposing Chords by scale degrees, generating all possible modulations given a pivot chord, and implementing secondary dominants and tonicizations based on scale degree.
Parameters:
Name | Type | Description |
---|---|---|
name |
Scale | The common musical name of the Scale, e.g. "C major." |
- Source:
Returns:
A new Scale object.
- Type
- Scale
arrange(score, new_order_)
Replaces the order of instruments in a generated CsoundAC Score with a new
order. Instrument numbers are re-ordered as if they are integers. The
new_order parameter is a map, e.g. {1:5, 3:1, 4:17}
. The map need not
be complete.
Parameters:
Name | Type | Description |
---|---|---|
score |
CsoundAC.Score | A generated CsoundAC Score. |
new_order_ |
Object | A map assigning new Csound instrument numbers (values) to old Csound instrument numbers (keys) |
- Source:
arrange_silencio(score, new_order_)
Replaces the order of instruments in a Silencio Score with a new order.
Instrument numbers are re-ordered as if they are integers. The
new_order parameter is a map, e.g. {1:5, 3:1, 4:17}
. The map need not
be complete.
Parameters:
Name | Type | Description |
---|---|---|
score |
Silencio.Score | A generated CsoundAC Score. |
new_order_ |
Object | A map assigning new Csound instrument numbers (values) to old Csound instrument numbers (keys) |
- Source:
canon(Score, delay, transposition, csoundac_scale) → {Score}
Generates a new copy(s) of the Score in canon to the original, at the specified delay in seconds and transposition in semitones (which may be fractional). If a Scale is supplied, the new Score is conformed to that Scale.
Parameters:
Name | Type | Description |
---|---|---|
Score |
CsoundAC.Score | or fragment of score. |
delay |
number | in seconds. |
transposition |
number | in semitones. |
layers. |
number | |
csoundac_scale |
CsoundAC.Scale | if supplied, the new voice will be conformed to this scale. |
- Source:
Returns:
a modified
- Type
- Score
csoundn(instrument, pat)
A Pattern that sends notes to Csound for rendering with MIDI semantics. Hap values are translated to Csound pfields as follows:
p1 -- Csound instrument either as a number (1-based, can be a fraction), or as a string name. p2 -- time in beats (usually seconds) from start of performance. p3 -- duration in beats (usually seconds). p4 -- MIDI key number from Strudel's Hap value (as a real number, not an integer, in [0, 127]. p5 -- MIDI velocity from Strudel's `gain` control (as a real number, not an integer, in [0, 127]. p6 -- Spatial depth dimension, from a `depth` control, defaulting to 0. p7 -- Spatial pan dimension, from Strudel's `pan` control, in [0, 1], defaulting to 0.5. p8 -- Spatial height dimension, from a `height` control, defaulting to 0.
Parameters:
Name | Type | Description |
---|---|---|
instrument |
number | The Csound instrument number (p1); may be patternified. |
pat |
Pattern | The target of this Pattern. |
- Source:
diagnostic(message, level)
Prints a diagnostic message to both the Strudel logger and the Csound log. Messages are printed only for the specifed diagnostic level or less.
Parameters:
Name | Type | Description |
---|---|---|
message |
string | Text of the message. |
level |
number | Diagnostic level, defaulting to WARNING. |
- Source:
diagnostic_level(new_level) → {number}
Gets and/or sets the level of diagnostic messages.
Parameters:
Name | Type | Description |
---|---|---|
new_level |
number | The new diagnostic level. |
- Source:
Returns:
The previous diagnostic level.
- Type
- number
downsample_lttb(data, buckets) → {Array}
Called by cloud-5 when sampling the WebGL video canvas to reduce the bandwidth of the data, e.g. in preparation for translating it to musical notes.
Adapts https://github.com/pingec/downsample-lttb from time series data to vectors of float HSV pixels. Our data is not [[time, value], [time, value],...], but rather [[column, value, [h,s,v]],...]. The algorithm uses column and value, but [h,s,v] go along for the ride.
Parameters:
Name | Type | Description |
---|---|---|
data |
Array | Data from the canvas, e.g. a row of pixels. |
buckets |
Array | Placeholder data. |
- Source:
Returns:
The downsampled data.
- Type
- Array
frequencyToMidiInteger(frequency) → {number}
A utility that returns the MIDI key number for a frequency in Hz, as the nearest integer.
Parameters:
Name | Type | Description |
---|---|---|
frequency |
number | The frequency in cycles per second. |
- Source:
Returns:
The MIDI key number as an integer.
- Type
- number
frequencyToMidiReal(frequency) → {number}
A utility that returns the MIDI key number for a frequency in Hz, as a real number allowing fractions for microtones.
Parameters:
Name | Type | Description |
---|---|---|
frequency |
number | The frequency in cycles per second. |
- Source:
Returns:
A (possibly fractional) MIDI key number.
- Type
- number
getFrequency(hap) → {number}
Returns the frequency corresponding to any of various ways that pitch is represented in Strudel events.
Parameters:
Name | Type | Description |
---|---|---|
hap |
Hap | A Hap that has some sort of pitch. |
- Source:
Returns:
Its frequency in cycles per second.
- Type
- number
(async) get_csound()
Returns a singleton instance of Csound, if one is available in the JavaScript environment. If Csound has not been loaded, attempts are made to load it from various sources. The csound_message_callback parameter is required, but console.log can be passed.
- Source:
hsvToRgb(h, s, v) → {Array}
Returns the RGB color for an HSV color.
Parameters:
Name | Type | Description |
---|---|---|
h |
number | The hue. |
s |
number | The saturation. |
v |
number | The value. |
- Source:
Returns:
The RGB color.
- Type
- Array
(async) load_csound()
There is an issue on Android in that csound may be undefined when the page is first rendered, and be defined only when the user plays the piece.
- Source:
non_csound()
Tests if Csound is null or undefined.
- Source:
resize()
Called by the browser to resize arrays that are used to sample the WebGL canvas during performance.
- Source:
rgb_to_hsv(rgb) → {Array}
Converts an RGB color value to HSV. The formula is adapted from http://en.wikipedia.org/wiki/HSV_color_space.
Parameters:
Name | Type | Description |
---|---|---|
rgb |
Array | RGB color in [0, 255] |
- Source:
Returns:
An HSV color in [0, 1].
- Type
- Array
setPitch(hap, midi_key) → {Hap}
A utility that assigns a pitch represented as a MIDI key number to the Hap, using the existing pitch property if it exists.
Parameters:
Name | Type | Description |
---|---|---|
hap |
Hap | The Hap. |
midi_key |
number | A MIDI key number. |
- Source:
Returns:
A new Hap.
- Type
- Hap
track(…sections) → {Pattern}
Similar to arrange,
but permits a section to be silenced by setting its
number of cycles to 0; useful for assembling Patterns into longer-form
compositions.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
sections |
any |
<repeatable> |
An array of arrays, in the format
|
- Source:
Returns:
A Pattern.
- Type
- Pattern
(async) url_for_soundfile()
Creates a URL for a soundfile recorded by this piece. All such files exist by default in the Emscripten MEMFS filesystem at '/'.
- Source:
write_file(filepath, data)
May be called to store data to the local filesystem. This is used e.g. to save a copy of the generated Csound .csd file before starting the performance. This can help with debugging. Note that in a browser-based performance, the local filesystem is inside the sandbox.
Parameters:
Name | Type | Description |
---|---|---|
filepath |
string | |
data |
string |
- Source: