WebAudio Csound

CsoundObj()

This ES6 Class provides an interface to the Csound engine running on a node (an AudioWorkletNode where available, ScriptProcessorNode elsewhere) This class is designed to be compatible with the previous ScriptProcessorNode-based CsoundObj

Constructor

new CsoundObj()

Create a CsoundObj
Source:

Methods

(static) createNode(InputChannelCount, OutputChannelCount)

This static method creates a new Csound Engine node unattached to a CsoundObj object. It can be used in scenarios where CsoundObj is not needed (ie. WebAudio API programming)
Parameters:
Name Type Description
InputChannelCount number number of input channels
OutputChannelCount number number of output channels
Source:
Returns:
A new Csound Engine Node (CsoundNode or CsoundScriptProcessorNode)

(static) importScripts(script_base)

This static method is used to asynchronously setup the Csound engine node.
Parameters:
Name Type Default Description
script_base string ./ A string containing the base path to scripts
Source:

compileCSD(csd)

Compiles a CSD, which may be given as a filename in the WASM filesystem or a string containing the code
Parameters:
Name Type Description
csd string A string containing the CSD filename or the CSD code.
Source:

compileOrc(orcString)

Compiles Csound orchestra code.
Parameters:
Name Type Description
orcString string A string containing the orchestra code.
Source:

enableAudioInput(audioInputCallback)

Enables microphone (external audio) input in browser
Parameters:
Name Type Description
audioInputCallback function A callback with a signature function(result), with result set to true in the event of success or false if the microphone cannot be enabled
Source:

evaluateCode(codeString)

Evaluates Csound orchestra code.
Parameters:
Name Type Description
codeString string A string containing the orchestra code.
Source:

getChannel(channelName) → {number|string}

Get the latest requested channel data
Parameters:
Name Type Description
channelName string A string containing the channel name.
Source:
Returns:
The latest channel value requested.
Type
number | string

getNode()

Returns the underlying Csound node running the Csound engine.
Source:

getTable(number) → {Float32Array}

Get the requested table number
Parameters:
Name Type Description
number number The function table number
Source:
Returns:
The table as a typed array.
Type
Float32Array

midiMessage(byte1, byte2, byte1)

Sends a MIDI channel message to Csound
Parameters:
Name Type Description
byte1 number MIDI status byte
byte2 number MIDI data byte 1
byte1 number MIDI data byte 2
Source:

play()

Starts performance, same as start()
Source:

readScore(scoreString)

Reads a numeric score string.
Parameters:
Name Type Description
scoreString string A string containing a numeric score.
Source:

requestControlChannel(channelName, callback)

Request the data from a control channel
Parameters:
Name Type Default Description
channelName string A string containing the channel name.
callback function null An optional callback to be called when the requested data is available. This can be set once for all subsequent requests.
Source:

requestTable(number, callback)

Request the data from a Csound function table
Parameters:
Name Type Default Description
number number The function table number
callback function null An optional callback to be called when the requested data is available. This can be set once for all subsequent requests.
Source:

reset()

Resets the Csound engine.
Source:

setControlChannel(channelName, value)

Sets the value of a control channel in the software bus
Parameters:
Name Type Description
channelName string A string containing the channel name.
value number The value to be set.
Source:

setMessageCallback(msgCallback)

Sets a callback to process Csound console messages.
Parameters:
Name Type Description
msgCallback function A callback to process messages with signature function(message), where message is a string from Csound.
Source:

setOption(option)

Sets a Csound engine option (flag)
Parameters:
Name Type Description
option string The Csound engine option to set. This should not contain any whitespace.
Source:

setStringChannel(channelName, stringValue)

Sets the value of a string channel in the software bus
Parameters:
Name Type Description
channelName string A string containing the channel name.
stringValue string The string to be set.
Source:

setTable(number, table)

Set a table with data from an array
Parameters:
Name Type Description
number number The function table number
table Float32Array The source data for the table
Source:

setTableValue(number, index, value)

Set a specific table position
Parameters:
Name Type Description
number number The function table number
index number The index of the position to be set
value number The value to set
Source:

start()

Starts the node containing the Csound engine.
Source:

stop()

Stops (pauses) performance
Source:

writeToFS(filePath, blobData)

Writes data to a file in the WASM filesystem for use with csound.
Parameters:
Name Type Description
filePath string A string containing the path to write to.
blobData blob The data to write to file.
Source: