[](https://www.npmjs.com/package/@csound/browser) [](h
npm install @csound/browserScriptProcessorNode support has been removed from the library. ScriptProcessorNode was deprecated in 2014 and provides inferior performance compared to AudioWorklet. All modern browsers (Chrome 64+, Firefox 76+, Safari 14.1+) support AudioWorklet.
Migration: If you were using useSPN: true, simply remove this parameter. The library will automatically use the superior AudioWorklet API.
objectCsoundObj API.
Promise.<(CsoundObj|undefined)>The default entry for @csound/wasm/browser module.
If loaded successfully, it returns CsoundObj,
otherwise undefined.
Promise.<(Float64Array|undefined)>objectKind: global namespace
* CsoundObj : object
* _global_
* getTable(tableNum) ⇒ Promise.<(Float64Array\|undefined)>
* _static_
* .fs : IFs:memfs
* .eventNames() ⇒ Array.<string>
* .listenerCount() ⇒ number
* .listeners(eventName) ⇒ Array.<function()>
* .off(eventName, listener) ⇒ external:EventEmitter
* .on(eventName, listener) ⇒ external:EventEmitter
* .addListener(eventName, listener) ⇒ external:EventEmitter
* .once(eventName, listener) ⇒ external:EventEmitter
* .removeAllListeners(eventName) ⇒ external:EventEmitter
* .removeListener(eventName, listener) ⇒ external:EventEmitter
* .getSr() ⇒ Promise.<number>
* .getKr() ⇒ Promise.<number>
* .getKsmps() ⇒ Promise.<number>
* .getNchnls() ⇒ Promise.<number>
* .getNchnlsInput() ⇒ Promise.<number>
* .get0dBFS() ⇒ Promise.<number>
* .getA4() ⇒ Promise.<number>
* .getCurrentTimeSamples() ⇒ Promise.<number>
* .getSizeOfMYFLT() ⇒ Promise.<number>
* .setOption(option) ⇒ Promise.<number>
* .setParams(csoundParams) ⇒ Promise.<undefined>
* .getParams() ⇒ Promise.<CSOUND\_PARAMS>
* .getDebug() ⇒ Promise.<number>
* .setDebug(debug) ⇒ Promise.<undefined>
* .inputMessage(scoreEvent) ⇒ Promise.<number>
* .inputMessageAsync(scoreEvent) ⇒ Promise.<number>
* .getControlChannel(channelName) ⇒ Promise.<undefined>
* .setControlChannel(channelName, value) ⇒ Promise.<undefined>
* .getStringChannel(channelName) ⇒ Promise.<undefined>
* .setStringChannel(channelName, value) ⇒ Promise.<undefined>
* .getOutputName() ⇒ Promise.<string>
* .getInputName() ⇒ Promise.<string>
* .destroy() ⇒ Promise.<undefined>
* .getAPIVersion() ⇒ Promise.<number>
* .getVersion() ⇒ Promise.<number>
* .initialize() ⇒ Promise.<number>
* .parseOrc(orc) ⇒ Promise.<object>
* .compileTree(tree) ⇒ Promise.<number>
* .compileOrc(orc) ⇒ Promise.<number>
* .evalCode(orc) ⇒ Promise.<number>
* .start() ⇒ Promise.<number>
* .compileCSD(csdOrPath, mode) ⇒ Promise.<number>
* .perform() ⇒ Promise.<number>
* .performKsmps() ⇒ Promise.<number>
* .performBuffer() ⇒ Promise.<number>
* .stop() ⇒ Promise.<undefined>
* .cleanup() ⇒ Promise.<number>
* .reset() ⇒ Promise.<number>
* .getInputBufferSize() ⇒ Promise.<number>
* .getOutputBufferSize() ⇒ Promise.<number>
* .getInputBuffer() ⇒ Promise.<number>
* .getOutputBuffer() ⇒ Promise.<number>
* .getSpin() ⇒ Promise.<number>
* .getSpout() ⇒ Promise.<number>
* .getMIDIDevList(isOutput) ⇒ Promise.<CS\_MIDIDEVICE>
* .getRtMidiName() ⇒ Promise.<string>
* .midiMessage(midi, midi, midi) ⇒ Promise.<void>
* .isScorePending() ⇒ Promise.<number>
* .setScorePending(pending) ⇒ Promise.<undefined>
* .readScore(score) ⇒ Promise.<undefined>
* .getScoreTime() ⇒ Promise.<number>
* .getScoreOffsetSeconds() ⇒ Promise.<number>
* .setScoreOffsetSeconds(time) ⇒ Promise.<number>
* .rewindScore() ⇒ Promise.<number>
* .tableLength(tableNum) ⇒ Promise.<number>
* .tableGet(tableNum, tableIndex) ⇒ Promise.<number>
* .tableSet(tableNum, tableIndex, value) ⇒ Promise.<undefined>
* .tableCopyIn(tableNum, tableIndex, array) ⇒ Promise.<undefined>
* .tableCopyOut(tableNum) ⇒ Promise.<(Float64Array\|undefined)>
* .getTableArgs(tableNum) ⇒ Promise.<(Float64Array\|undefined)>
* .isNamedGEN(tableNum) ⇒ Promise.<number>
* .getNamedGEN(tableNum) ⇒ Promise.<(string\|undefined)>
CsoundObj| Param | Type |
| --- | --- |
| tableNum | string |
Kind: static property of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| eventName | PublicEvents |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| eventName | PublicEvents |
| listener | function |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| eventName | PublicEvents |
| listener | function |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| eventName | PublicEvents |
| listener | function |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| eventName | PublicEvents |
| listener | function |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| eventName | PublicEvents |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| eventName | PublicEvents |
| listener | function |
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| option | string |
Kind: static method of CsoundObj
| Param | Type | Description |
| --- | --- | --- |
| csoundParams | CSOUND\_PARAMS | csoundParams object |
Kind: static method of CsoundObj
Returns: Promise.<CSOUND\_PARAMS> - - CSOUND_PARAMS object
Kind: static method of CsoundObj
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| debug | number |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| scoreEvent | string |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| scoreEvent | string |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| channelName | string |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| channelName | string |
| value | number |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| channelName | string |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| channelName | string |
| value | string |
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Returns: Promise.<number> - - Return value is zero on success,
positive if initialisation was done already, and negative on error.
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| orc | string |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| tree | object |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| orc | string |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| orc | string |
Kind: static method of CsoundObj
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| pathOrText | string |
| mode | number |
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| isOutput | number |
Kind: static method of CsoundObj
Kind: static method of CsoundObj
| Param | Type | Description |
| --- | --- | --- |
| midi | number | status value |
| midi | number | data1 |
| midi | number | data2 |
Kind: static method of CsoundObj
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| pending | number |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| score | string |
Kind: static method of CsoundObj
Kind: static method of CsoundObj
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| time | number |
Kind: static method of CsoundObj
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| tableNum | string |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| tableNum | string |
| tableIndex | string |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| tableNum | string |
| tableIndex | string |
| value | string |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| tableNum | string |
| tableIndex | string |
| array | Array.<number> \| ArrayLike.<number> |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| tableNum | string |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| tableNum | string |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| tableNum | string |
Kind: static method of CsoundObj
| Param | Type |
| --- | --- |
| tableNum | string |
enum| Name | Type | Description |
| --- | --- | --- |
| "play" | string | called anytime performance goes from pause/stop to a running state. |
| "pause" | string | called after any successful csound.pause() calls. |
| "stop" | string | called after end of performance or after a successful csound.stop(). |
| "realtimePerformanceStarted" | string | called at the start of realtime performance but not on resume or render. |
| "realtimePerformancePaused" | string | only called if csound.pause() was successfully called during performance. |
| "realtimePerformanceResumed" | string | only called if csound.resume() was successfully called after a pause. |
| "realtimePerformanceEnded" | string | called after end of performance or after a successful csound.stop(). |
| "renderStarted" | string | called at the start of offline/non-realtime render to disk. |
| "renderEnded" | string | called at the end of offline/non-realtime render to disk. |
| "onAudioNodeCreated" | string | called 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" | string | the 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. |
Promise.<(CsoundObj\|undefined)>Kind: global function
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [params] | Object | | Initialization parameters |
| [params.audioContext] | AudioContext | | Optional AudioContext to use; if none given, an AudioContext will be created. |
| [params.inputChannelCount] | Number | | Optional input channel count for AudioNode used with WebAudio graph. Defaults to the value of nchnls_i in useWorker but 2 otherwise. |
| [params.outputChannelCount] | Number | | Optional output channel count AudioNode used with WebAudio graph. Defaults to the value of nchnls in useWorker but 2 otherwise. |
| [params.autoConnect] | Boolean | true | Set to configure Csound to automatically connect to the audioContext.destination output. |
| [params.withPlugins] | Array.<Object> | | Array of WebAssembly Csound plugin libraries to use with Csound. |
| [params.useWorker] | Boolean | false | Configure to use backend using Web Workers to run Csound in a thread separate from audio callback. |
| [params.useSAB] | Boolean | true | Configure to use SharedArrayBuffers for WebWorker communications if platform supports it. |
| Name | Type |
| --- | --- |
| debug_mode | number |
| buffer_frames | number |
| hardware_buffer_frames | number |
| displays | number |
| ascii_graphs | number |
| postscript_graphs | number |
| message_level | number |
| tempo | number |
| ring_bell | number |
| use_cscore | number |
| terminate_on_midi | number |
| heartbeat | number |
| defer_gen01_load | number |
| midi_key | number |
| midi_key_cps | number |
| midi_key_oct | number |
| midi_key_pch | number |
| midi_velocity | number |
| Name | Type |
| --- | --- |
| device_name | string |
| interface_name | string |
| device_id | string |
| midi_module | string |
| isOutput | number |