6.18.7 • Published 2 years ago

@csound/browser v6.18.7

Weekly downloads
30
License
LGPL-2.1
Repository
github
Last release
2 years ago

@csound/browser

npm (scoped with tag) GitHub Workflow Status styled with prettier

Api Documentation

Objects

Functions

Typedefs

CsoundObj : object

CsoundObj API.

Kind: global namespace

CsoundObjgetTable(tableNum) ⇒ Promise.<(Float64Array|undefined)>

Kind: global method of CsoundObj

ParamType
tableNumstring

CsoundObj.fs : IFs:memfs

The in-browser filesystem based on nodejs's built-in module "fs"

Kind: static property of CsoundObj

CsoundObj.eventNames() ⇒ Array.<string>

Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings.

Kind: static method of CsoundObj

CsoundObj.listenerCount() ⇒ number

Returns the number of listeners listening to the event named eventName.

Kind: static method of CsoundObj

CsoundObj.listeners(eventName) ⇒ Array.<function()>

Returns a copy of the array of listeners for the event named eventName.

Kind: static method of CsoundObj

ParamType
eventNamePublicEvents

CsoundObj.off(eventName, listener) ⇒ external:EventEmitter

Alias for removeListener()

Kind: static method of CsoundObj

ParamType
eventNamePublicEvents
listenerfunction

CsoundObj.on(eventName, listener) ⇒ external:EventEmitter

Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

Kind: static method of CsoundObj

ParamType
eventNamePublicEvents
listenerfunction

CsoundObj.addListener(eventName, listener) ⇒ external:EventEmitter

Alias for "on"

Kind: static method of CsoundObj

ParamType
eventNamePublicEvents
listenerfunction

CsoundObj.once(eventName, listener) ⇒ external:EventEmitter

Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

Kind: static method of CsoundObj

ParamType
eventNamePublicEvents
listenerfunction

CsoundObj.removeAllListeners(eventName) ⇒ external:EventEmitter

Removes all listeners, or those of the specified eventName. It is bad practice to remove listeners added elsewhere in the code, particularly when the EventEmitter instance was created by some other component or module. Returns a reference to the EventEmitter, so that calls can be chained.

Kind: static method of CsoundObj

ParamType
eventNamePublicEvents

CsoundObj.removeListener(eventName, listener) ⇒ external:EventEmitter

Removes the specified listener from the listener array for the event named eventName. removeListener() will remove, at most, one instance of a listener from the listener array. If any single listener has been added multiple times to the listener array for the specified eventName, then removeListener() must be called multiple times to remove each instance. Removes the specified listener from the listener array for the event named eventName.

Kind: static method of CsoundObj

ParamType
eventNamePublicEvents
listenerfunction

CsoundObj.getSr() ⇒ Promise.<number>

Returns the sample rate from Csound instance

Kind: static method of CsoundObj

CsoundObj.getKr() ⇒ Promise.<number>

Returns the control rate from Csound instance

Kind: static method of CsoundObj

CsoundObj.getKsmps() ⇒ Promise.<number>

Returns the ksmps value (kr/sr) from Csound instance

Kind: static method of CsoundObj

CsoundObj.getNchnls() ⇒ Promise.<number>

Returns the number of output channels from Csound instance

Kind: static method of CsoundObj

CsoundObj.getNchnlsInput() ⇒ Promise.<number>

Returns the number of input channels from Csound instance

Kind: static method of CsoundObj

CsoundObj.get0dBFS() ⇒ Promise.<number>

Returns the value of csoundGet0dBFS

Kind: static method of CsoundObj

CsoundObj.getA4() ⇒ Promise.<number>

Returns the A4 frequency reference

Kind: static method of CsoundObj

CsoundObj.getCurrentTimeSamples() ⇒ Promise.<number>

Return the current performance time in samples

Kind: static method of CsoundObj

CsoundObj.getSizeOfMYFLT() ⇒ Promise.<number>

Return the size of MYFLT in number of bytes

Kind: static method of CsoundObj

CsoundObj.setOption(option) ⇒ Promise.<number>

Set a single csound option (flag), no spaces are allowed in the string.

Kind: static method of CsoundObj

ParamType
optionstring

CsoundObj.setParams(csoundParams) ⇒ Promise.<undefined>

Configure Csound with a given set of parameters defined in the CSOUND_PARAMS structure. These parameters are the part of the OPARMS struct that are configurable through command line flags. The CSOUND_PARAMS structure can be obtained using csoundGetParams(). These options should only be changed before performance has started.

Kind: static method of CsoundObj

ParamTypeDescription
csoundParamsCSOUND_PARAMScsoundParams object

CsoundObj.getParams() ⇒ Promise.<CSOUND_PARAMS>

Get the current set of parameters from a Csound instance in a CSOUND_PARAMS structure.

Kind: static method of CsoundObj
Returns: Promise.<CSOUND_PARAMS> - - CSOUND_PARAMS object

CsoundObj.getDebug() ⇒ Promise.<number>

Returns whether Csound is set to print debug messages sent through the DebugMsg() internal API function. Anything different to 0 means true.

Kind: static method of CsoundObj

CsoundObj.setDebug(debug) ⇒ Promise.<undefined>

Return the size of MYFLT in number of bytes

Kind: static method of CsoundObj

ParamType
debugnumber

CsoundObj.inputMessage(scoreEvent) ⇒ Promise.<number>

Inputs an immediate score event without any pre-process parsing

Kind: static method of CsoundObj

ParamType
scoreEventstring

CsoundObj.inputMessageAsync(scoreEvent) ⇒ Promise.<number>

Inputs an immediate score event without any pre-process parsing

Kind: static method of CsoundObj

ParamType
scoreEventstring

CsoundObj.getControlChannel(channelName) ⇒ Promise.<undefined>

Retrieves the value of control channel identified by channelName. If the err argument is not NULL, the error (or success) code finding or accessing the channel is stored in it.

Kind: static method of CsoundObj

ParamType
channelNamestring

CsoundObj.setControlChannel(channelName, value) ⇒ Promise.<undefined>

Sets the value of control channel identified by channelName

Kind: static method of CsoundObj

ParamType
channelNamestring
valuenumber

CsoundObj.getStringChannel(channelName) ⇒ Promise.<undefined>

Retrieves the string channel identified by channelName

Kind: static method of CsoundObj

ParamType
channelNamestring

CsoundObj.setStringChannel(channelName, value) ⇒ Promise.<undefined>

Sets the string channel value identified by channelName

Kind: static method of CsoundObj

ParamType
channelNamestring
valuestring

CsoundObj.getOutputName() ⇒ Promise.<string>

Returns the audio output name (-o)

Kind: static method of CsoundObj

CsoundObj.getInputName() ⇒ Promise.<string>

Returns the audio input name (-i)

Kind: static method of CsoundObj

CsoundObj.destroy() ⇒ Promise.<undefined>

Destroys an instance of Csound and frees memory

Kind: static method of CsoundObj

CsoundObj.getAPIVersion() ⇒ Promise.<number>

Returns the API version as int

Kind: static method of CsoundObj

CsoundObj.getVersion() ⇒ Promise.<number>

Returns the Csound version as int

Kind: static method of CsoundObj

CsoundObj.initialize() ⇒ Promise.<number>

Initialise Csound with specific flags. This function is called internally by csoundCreate(), so there is generally no need to use it explicitly unless you need to avoid default initilization that sets signal handlers and atexit() callbacks.

Kind: static method of CsoundObj
Returns: Promise.<number> - - Return value is zero on success, positive if initialisation was done already, and negative on error.

CsoundObj.parseOrc(orc) ⇒ Promise.<object>

Parses a csound orchestra string

Kind: static method of CsoundObj

ParamType
orcstring

CsoundObj.compileTree(tree) ⇒ Promise.<number>

Compiles AST tree

Kind: static method of CsoundObj

ParamType
treeobject

CsoundObj.compileOrc(orc) ⇒ Promise.<number>

Compiles a csound orchestra string

Kind: static method of CsoundObj

ParamType
orcstring

CsoundObj.evalCode(orc) ⇒ Promise.<number>

Compiles a csound orchestra string

Kind: static method of CsoundObj

ParamType
orcstring

CsoundObj.start() ⇒ Promise.<number>

Prepares Csound for performance

Kind: static method of CsoundObj

CsoundObj.compileCsd(path) ⇒ Promise.<number>

Compiles a Csound input file but does not perform it.

Kind: static method of CsoundObj

ParamType
pathstring

CsoundObj.compileCsdText(orc) ⇒ Promise.<number>

Compiles a CSD string but does not perform it.

Kind: static method of CsoundObj

ParamType
orcstring

CsoundObj.perform() ⇒ Promise.<number>

Performs(plays) audio until end is reached

Kind: static method of CsoundObj

CsoundObj.performKsmps() ⇒ Promise.<number>

Performs(plays) 1 ksmps worth of sample(s)

Kind: static method of CsoundObj

CsoundObj.performBuffer() ⇒ Promise.<number>

Performs(plays) 1 buffer worth of audio

Kind: static method of CsoundObj

CsoundObj.stop() ⇒ Promise.<undefined>

Stops a csoundPerform

Kind: static method of CsoundObj

CsoundObj.cleanup() ⇒ Promise.<number>

Prints information about the end of a performance, and closes audio and MIDI devices.

Kind: static method of CsoundObj

CsoundObj.reset() ⇒ Promise.<number>

Prints information about the end of a performance, and closes audio and MIDI devices.

Kind: static method of CsoundObj

CsoundObj.getInputBufferSize() ⇒ Promise.<number>

Returns the number of samples in Csound's input buffer.

Kind: static method of CsoundObj

CsoundObj.getOutputBufferSize() ⇒ Promise.<number>

Returns the number of samples in Csound's output buffer.

Kind: static method of CsoundObj

CsoundObj.getInputBuffer() ⇒ Promise.<number>

Returns the address of the Csound audio input buffer.

Kind: static method of CsoundObj

CsoundObj.getOutputBuffer() ⇒ Promise.<number>

Returns the address of the Csound audio output buffer.

Kind: static method of CsoundObj

CsoundObj.getSpin() ⇒ Promise.<number>

Returns the address of the Csound audio input working buffer (spin). Enables external software to write audio into Csound before calling csoundPerformKsmps.

Kind: static method of CsoundObj

CsoundObj.getSpout() ⇒ Promise.<number>

Returns the address of the Csound audio output working buffer (spout). Enables external software to read audio from Csound after calling csoundPerformKsmps.

Kind: static method of CsoundObj

CsoundObj.getMIDIDevList(isOutput) ⇒ Promise.<CS_MIDIDEVICE>

This function can be called to obtain a list of available input or output midi devices. If list is NULL, the function will only return the number of devices (isOutput=1 for out devices, 0 for in devices).

Kind: static method of CsoundObj

ParamType
isOutputnumber

CsoundObj.getRtMidiName() ⇒ Promise.<string>

This function can be called to obtain a list of available input or output midi devices. If list is NULL, the function will only return the number of devices (isOutput=1 for out devices, 0 for in devices).

Kind: static method of CsoundObj

CsoundObj.midiMessage(midi, midi, midi) ⇒ Promise.<void>

Emit a midi message with a given triplet of values in the range of 0 to 127.

Kind: static method of CsoundObj

ParamTypeDescription
midinumberstatus value
midinumberdata1
midinumberdata2

CsoundObj.isScorePending() ⇒ Promise.<number>

Sees whether Csound score events are performed or not, independently of real-time MIDI events

Kind: static method of CsoundObj

CsoundObj.setScorePending(pending) ⇒ Promise.<undefined>

Sets whether Csound score events are performed or not (real-time events will continue to be performed). Can be used by external software, such as a VST host, to turn off performance of score events (while continuing to perform real-time events), for example to mute a Csound score while working on other tracks of a piece, or to play the Csound instruments live.

Kind: static method of CsoundObj

ParamType
pendingnumber

CsoundObj.readScore(score) ⇒ Promise.<undefined>

Read, preprocess, and load a score from an ASCII string It can be called repeatedly, with the new score events being added to the currently scheduled ones.

Kind: static method of CsoundObj

ParamType
scorestring

CsoundObj.getScoreTime() ⇒ Promise.<number>

Returns the current score time in seconds since the beginning of performance.

Kind: static method of CsoundObj

CsoundObj.getScoreOffsetSeconds() ⇒ Promise.<number>

Returns the score time beginning at which score events will actually immediately be performed

Kind: static method of CsoundObj

CsoundObj.setScoreOffsetSeconds(time) ⇒ Promise.<number>

Csound score events prior to the specified time are not performed, and performance begins immediately at the specified time (real-time events will continue to be performed as they are received). Can be used by external software, such as a VST host, to begin score performance midway through a Csound score, for example to repeat a loop in a sequencer, or to synchronize other events with the Csound score.

Kind: static method of CsoundObj

ParamType
timenumber

CsoundObj.rewindScore() ⇒ Promise.<number>

Rewinds a compiled Csound score to the time specified with csoundObj.setScoreOffsetSeconds().

Kind: static method of CsoundObj

CsoundObj.tableLength(tableNum) ⇒ Promise.<number>

Returns the length of a function table (not including the guard point), or -1 if the table does not exist.

Kind: static method of CsoundObj

ParamType
tableNumstring

CsoundObj.tableGet(tableNum, tableIndex) ⇒ Promise.<number>

Returns the value of a slot in a function table. The table number and index are assumed to be valid.

Kind: static method of CsoundObj

ParamType
tableNumstring
tableIndexstring

CsoundObj.tableSet(tableNum, tableIndex, value) ⇒ Promise.<undefined>

Sets the value of a slot in a function table. The table number and index are assumed to be valid.

Kind: static method of CsoundObj

ParamType
tableNumstring
tableIndexstring
valuestring

CsoundObj.tableCopyIn(tableNum, tableIndex, array) ⇒ Promise.<undefined>

Copy the contents of an Array or TypedArray from javascript into a given csound function table. The table number is assumed to be valid, and the table needs to have sufficient space to receive all the array contents. The table number and index are assumed to be valid.

Kind: static method of CsoundObj

ParamType
tableNumstring
tableIndexstring
arrayArray.<number> | ArrayLike.<number>

CsoundObj.tableCopyOut(tableNum) ⇒ Promise.<(Float64Array|undefined)>

Copies the contents of a function table from csound into Float64Array. The function returns a Float64Array if the table exists, otherwise it returns undefined.

Kind: static method of CsoundObj

ParamType
tableNumstring

CsoundObj.getTableArgs(tableNum) ⇒ Promise.<(Float64Array|undefined)>

Copies the contents of a function table from csound into Float64Array. The function returns a Float64Array if the table exists, otherwise it returns undefined.

Kind: static method of CsoundObj

ParamType
tableNumstring

CsoundObj.isNamedGEN(tableNum) ⇒ Promise.<number>

Checks if a given GEN number num is a named GEN if so, it returns the string length (excluding terminating NULL char). Otherwise it returns 0.

Kind: static method of CsoundObj

ParamType
tableNumstring

CsoundObj.getNamedGEN(tableNum) ⇒ Promise.<(string|undefined)>

Gets the GEN name from a number num, if this is a named GEN. If the table number doesn't represent a named GEN, it will return undefined.

Kind: static method of CsoundObj

ParamType
tableNumstring

PublicEvents : enum

Kind: global enum
Read only: true
Properties

NameTypeDescription
"play"stringcalled anytime performance goes from pause/stop to a running state.
"pause"stringcalled after any successful csound.pause() calls.
"stop"stringcalled after end of performance or after a successful csound.stop().
"realtimePerformanceStarted"stringcalled at the start of realtime performance but not on resume or render.
"realtimePerformancePaused"stringonly called if csound.pause() was successfully called during performance.
"realtimePerformanceResumed"stringonly called if csound.resume() was successfully called after a pause.
"realtimePerformanceEnded"stringcalled after end of performance or after a successful csound.stop().
"renderStarted"stringcalled at the start of offline/non-realtime render to disk.
"renderEnded"stringcalled at the end of offline/non-realtime render to disk.
"onAudioNodeCreated"stringcalled when an audioNode is created from the AudioContext before realtime performance. the event callback will include the audioNode itself, which is needed if autoConnect is set to false.
"message"stringthe main entrypoint to csound's messaging (-m) system, a default event listener will print the message to the browser console, this default listener can be removed by the user.

Csound(params) ⇒ Promise.<(CsoundObj|undefined)>

The default entry for @csound/wasm/browser module. If loaded successfully, it returns CsoundObj, otherwise undefined.

Kind: global function

ParamTypeDefaultDescription
paramsObjectInitialization parameters
params.audioContextAudioContextOptional AudioContext to use; if none given, an AudioContext will be created.
params.inputChannelCountNumberOptional input channel count for AudioNode used with WebAudio graph. Defaults to the value of nchnls_i in useWorker but 2 otherwise.
params.outputChannelCountNumberOptional output channel count AudioNode used with WebAudio graph. Defaults to the value of nchnls in useWorker but 2 otherwise.
params.autoConnectBooleantrueSet to configure Csound to automatically connect to the audioContext.destination output.
params.withPluginsArray.<Object>Array of WebAssembly Csound plugin libraries to use with Csound.
params.useWorkerBooleanfalseConfigure to use backend using Web Workers to run Csound in a thread separate from audio callback.
params.useSABBooleantrueConfigure to use SharedArrayBuffers for WebWorker communications if platform supports it.
params.useSPNBooleanfalseConfigure to use explicitly request ScriptProcessorNode rather than AudioWorklet. Recommended only for debug testing purposes.

CSOUND_PARAMS

Kind: global typedef
Properties

NameType
debug_modenumber
buffer_framesnumber
hardware_buffer_framesnumber
displaysnumber
ascii_graphsnumber
postscript_graphsnumber
message_levelnumber
temponumber
ring_bellnumber
use_cscorenumber
terminate_on_midinumber
heartbeatnumber
defer_gen01_loadnumber
midi_keynumber
midi_key_cpsnumber
midi_key_octnumber
midi_key_pchnumber
midi_velocitynumber

CS_MIDIDEVICE

Kind: global typedef
Properties

NameType
device_namestring
interface_namestring
device_idstring
midi_modulestring
isOutputnumber