1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916
|
# @csound/browser
[](https://www.npmjs.com/package/@csound/browser)
[](https://github.com/csound/csound/actions?query=workflow%3Acsound_wasm)
[](https://github.com/prettier/prettier)
## Api Documentation
## Objects
<dl>
<dt><a href="#CsoundObj">CsoundObj</a> : <code>object</code></dt>
<dd><p>CsoundObj API.</p>
</dd>
</dl>
## Functions
<dl>
<dt><a href="#Csound">Csound([params])</a> ⇒ <code>Promise.<(CsoundObj|undefined)></code></dt>
<dd><p>The default entry for @csound/wasm/browser module.
If loaded successfully, it returns CsoundObj,
otherwise undefined.</p>
</dd>
<dt><a href="#getTable">getTable(tableNum)</a> ⇒ <code>Promise.<(Float64Array|undefined)></code></dt>
<dd></dd>
</dl>
## Typedefs
<dl>
<dt><a href="#CSOUND_PARAMS">CSOUND_PARAMS</a></dt>
<dd></dd>
<dt><a href="#CS_MIDIDEVICE">CS_MIDIDEVICE</a></dt>
<dd></dd>
</dl>
<a name="CsoundObj"></a>
## CsoundObj : <code>object</code>
CsoundObj API.
**Kind**: global namespace
* [CsoundObj](#CsoundObj) : <code>object</code>
* _global_
* [getTable(tableNum)](#getTable) ⇒ <code>Promise.<(Float64Array\|undefined)></code>
* _static_
* [.fs](#CsoundObj.fs) : <code>IFs:memfs</code>
* [.eventNames()](#CsoundObj.eventNames) ⇒ <code>Array.<string></code>
* [.listenerCount()](#CsoundObj.listenerCount) ⇒ <code>number</code>
* [.listeners(eventName)](#CsoundObj.listeners) ⇒ <code>Array.<function()></code>
* [.off(eventName, listener)](#CsoundObj.off) ⇒ <code>external:EventEmitter</code>
* [.on(eventName, listener)](#CsoundObj.on) ⇒ <code>external:EventEmitter</code>
* [.addListener(eventName, listener)](#CsoundObj.addListener) ⇒ <code>external:EventEmitter</code>
* [.once(eventName, listener)](#CsoundObj.once) ⇒ <code>external:EventEmitter</code>
* [.removeAllListeners(eventName)](#CsoundObj.removeAllListeners) ⇒ <code>external:EventEmitter</code>
* [.removeListener(eventName, listener)](#CsoundObj.removeListener) ⇒ <code>external:EventEmitter</code>
* [.getSr()](#CsoundObj.getSr) ⇒ <code>Promise.<number></code>
* [.getKr()](#CsoundObj.getKr) ⇒ <code>Promise.<number></code>
* [.getKsmps()](#CsoundObj.getKsmps) ⇒ <code>Promise.<number></code>
* [.getNchnls()](#CsoundObj.getNchnls) ⇒ <code>Promise.<number></code>
* [.getNchnlsInput()](#CsoundObj.getNchnlsInput) ⇒ <code>Promise.<number></code>
* [.get0dBFS()](#CsoundObj.get0dBFS) ⇒ <code>Promise.<number></code>
* [.getA4()](#CsoundObj.getA4) ⇒ <code>Promise.<number></code>
* [.getCurrentTimeSamples()](#CsoundObj.getCurrentTimeSamples) ⇒ <code>Promise.<number></code>
* [.getSizeOfMYFLT()](#CsoundObj.getSizeOfMYFLT) ⇒ <code>Promise.<number></code>
* [.setOption(option)](#CsoundObj.setOption) ⇒ <code>Promise.<number></code>
* [.setParams(csoundParams)](#CsoundObj.setParams) ⇒ <code>Promise.<undefined></code>
* [.getParams()](#CsoundObj.getParams) ⇒ [<code>Promise.<CSOUND\_PARAMS></code>](#CSOUND_PARAMS)
* [.getDebug()](#CsoundObj.getDebug) ⇒ <code>Promise.<number></code>
* [.setDebug(debug)](#CsoundObj.setDebug) ⇒ <code>Promise.<undefined></code>
* [.inputMessage(scoreEvent)](#CsoundObj.inputMessage) ⇒ <code>Promise.<number></code>
* [.inputMessageAsync(scoreEvent)](#CsoundObj.inputMessageAsync) ⇒ <code>Promise.<number></code>
* [.getControlChannel(channelName)](#CsoundObj.getControlChannel) ⇒ <code>Promise.<undefined></code>
* [.setControlChannel(channelName, value)](#CsoundObj.setControlChannel) ⇒ <code>Promise.<undefined></code>
* [.getStringChannel(channelName)](#CsoundObj.getStringChannel) ⇒ <code>Promise.<undefined></code>
* [.setStringChannel(channelName, value)](#CsoundObj.setStringChannel) ⇒ <code>Promise.<undefined></code>
* [.getOutputName()](#CsoundObj.getOutputName) ⇒ <code>Promise.<string></code>
* [.getInputName()](#CsoundObj.getInputName) ⇒ <code>Promise.<string></code>
* [.destroy()](#CsoundObj.destroy) ⇒ <code>Promise.<undefined></code>
* [.getAPIVersion()](#CsoundObj.getAPIVersion) ⇒ <code>Promise.<number></code>
* [.getVersion()](#CsoundObj.getVersion) ⇒ <code>Promise.<number></code>
* [.initialize()](#CsoundObj.initialize) ⇒ <code>Promise.<number></code>
* [.parseOrc(orc)](#CsoundObj.parseOrc) ⇒ <code>Promise.<object></code>
* [.compileTree(tree)](#CsoundObj.compileTree) ⇒ <code>Promise.<number></code>
* [.compileOrc(orc)](#CsoundObj.compileOrc) ⇒ <code>Promise.<number></code>
* [.evalCode(orc)](#CsoundObj.evalCode) ⇒ <code>Promise.<number></code>
* [.start()](#CsoundObj.start) ⇒ <code>Promise.<number></code>
* [.compileCsd(path)](#CsoundObj.compileCsd) ⇒ <code>Promise.<number></code>
* [.compileCsdText(orc)](#CsoundObj.compileCsdText) ⇒ <code>Promise.<number></code>
* [.perform()](#CsoundObj.perform) ⇒ <code>Promise.<number></code>
* [.performKsmps()](#CsoundObj.performKsmps) ⇒ <code>Promise.<number></code>
* [.performBuffer()](#CsoundObj.performBuffer) ⇒ <code>Promise.<number></code>
* [.stop()](#CsoundObj.stop) ⇒ <code>Promise.<undefined></code>
* [.cleanup()](#CsoundObj.cleanup) ⇒ <code>Promise.<number></code>
* [.reset()](#CsoundObj.reset) ⇒ <code>Promise.<number></code>
* [.getInputBufferSize()](#CsoundObj.getInputBufferSize) ⇒ <code>Promise.<number></code>
* [.getOutputBufferSize()](#CsoundObj.getOutputBufferSize) ⇒ <code>Promise.<number></code>
* [.getInputBuffer()](#CsoundObj.getInputBuffer) ⇒ <code>Promise.<number></code>
* [.getOutputBuffer()](#CsoundObj.getOutputBuffer) ⇒ <code>Promise.<number></code>
* [.getSpin()](#CsoundObj.getSpin) ⇒ <code>Promise.<number></code>
* [.getSpout()](#CsoundObj.getSpout) ⇒ <code>Promise.<number></code>
* [.getMIDIDevList(isOutput)](#CsoundObj.getMIDIDevList) ⇒ [<code>Promise.<CS\_MIDIDEVICE></code>](#CS_MIDIDEVICE)
* [.getRtMidiName()](#CsoundObj.getRtMidiName) ⇒ <code>Promise.<string></code>
* [.midiMessage(midi, midi, midi)](#CsoundObj.midiMessage) ⇒ <code>Promise.<void></code>
* [.isScorePending()](#CsoundObj.isScorePending) ⇒ <code>Promise.<number></code>
* [.setScorePending(pending)](#CsoundObj.setScorePending) ⇒ <code>Promise.<undefined></code>
* [.readScore(score)](#CsoundObj.readScore) ⇒ <code>Promise.<undefined></code>
* [.getScoreTime()](#CsoundObj.getScoreTime) ⇒ <code>Promise.<number></code>
* [.getScoreOffsetSeconds()](#CsoundObj.getScoreOffsetSeconds) ⇒ <code>Promise.<number></code>
* [.setScoreOffsetSeconds(time)](#CsoundObj.setScoreOffsetSeconds) ⇒ <code>Promise.<number></code>
* [.rewindScore()](#CsoundObj.rewindScore) ⇒ <code>Promise.<number></code>
* [.tableLength(tableNum)](#CsoundObj.tableLength) ⇒ <code>Promise.<number></code>
* [.tableGet(tableNum, tableIndex)](#CsoundObj.tableGet) ⇒ <code>Promise.<number></code>
* [.tableSet(tableNum, tableIndex, value)](#CsoundObj.tableSet) ⇒ <code>Promise.<undefined></code>
* [.tableCopyIn(tableNum, tableIndex, array)](#CsoundObj.tableCopyIn) ⇒ <code>Promise.<undefined></code>
* [.tableCopyOut(tableNum)](#CsoundObj.tableCopyOut) ⇒ <code>Promise.<(Float64Array\|undefined)></code>
* [.getTableArgs(tableNum)](#CsoundObj.getTableArgs) ⇒ <code>Promise.<(Float64Array\|undefined)></code>
* [.isNamedGEN(tableNum)](#CsoundObj.isNamedGEN) ⇒ <code>Promise.<number></code>
* [.getNamedGEN(tableNum)](#CsoundObj.getNamedGEN) ⇒ <code>Promise.<(string\|undefined)></code>
<a name="getTable"></a>
### CsoundObjgetTable(tableNum) ⇒ <code>Promise.<(Float64Array\|undefined)></code>
**Kind**: global method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| tableNum | <code>string</code> |
<a name="CsoundObj.fs"></a>
### CsoundObj.fs : <code>IFs:memfs</code>
The in-browser filesystem based on nodejs's
built-in module "fs"
**Kind**: static property of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.eventNames"></a>
### CsoundObj.eventNames() ⇒ <code>Array.<string></code>
Returns an array listing the events for which the emitter has registered listeners.
The values in the array are strings.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.listenerCount"></a>
### CsoundObj.listenerCount() ⇒ <code>number</code>
Returns the number of listeners listening to the event named eventName.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.listeners"></a>
### CsoundObj.listeners(eventName) ⇒ <code>Array.<function()></code>
Returns a copy of the array of listeners for the event named eventName.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| eventName | [<code>PublicEvents</code>](#PublicEvents) |
<a name="CsoundObj.off"></a>
### CsoundObj.off(eventName, listener) ⇒ <code>external:EventEmitter</code>
Alias for removeListener()
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| eventName | [<code>PublicEvents</code>](#PublicEvents) |
| listener | <code>function</code> |
<a name="CsoundObj.on"></a>
### CsoundObj.on(eventName, listener) ⇒ <code>external:EventEmitter</code>
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 [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| eventName | [<code>PublicEvents</code>](#PublicEvents) |
| listener | <code>function</code> |
<a name="CsoundObj.addListener"></a>
### CsoundObj.addListener(eventName, listener) ⇒ <code>external:EventEmitter</code>
Alias for "on"
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| eventName | [<code>PublicEvents</code>](#PublicEvents) |
| listener | <code>function</code> |
<a name="CsoundObj.once"></a>
### CsoundObj.once(eventName, listener) ⇒ <code>external:EventEmitter</code>
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 [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| eventName | [<code>PublicEvents</code>](#PublicEvents) |
| listener | <code>function</code> |
<a name="CsoundObj.removeAllListeners"></a>
### CsoundObj.removeAllListeners(eventName) ⇒ <code>external:EventEmitter</code>
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 [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| eventName | [<code>PublicEvents</code>](#PublicEvents) |
<a name="CsoundObj.removeListener"></a>
### CsoundObj.removeListener(eventName, listener) ⇒ <code>external:EventEmitter</code>
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 [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| eventName | [<code>PublicEvents</code>](#PublicEvents) |
| listener | <code>function</code> |
<a name="CsoundObj.getSr"></a>
### CsoundObj.getSr() ⇒ <code>Promise.<number></code>
Returns the sample rate from Csound instance
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getKr"></a>
### CsoundObj.getKr() ⇒ <code>Promise.<number></code>
Returns the control rate from Csound instance
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getKsmps"></a>
### CsoundObj.getKsmps() ⇒ <code>Promise.<number></code>
Returns the ksmps value (kr/sr) from Csound instance
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getNchnls"></a>
### CsoundObj.getNchnls() ⇒ <code>Promise.<number></code>
Returns the number of output channels from Csound instance
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getNchnlsInput"></a>
### CsoundObj.getNchnlsInput() ⇒ <code>Promise.<number></code>
Returns the number of input channels from Csound instance
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.get0dBFS"></a>
### CsoundObj.get0dBFS() ⇒ <code>Promise.<number></code>
Returns the value of csoundGet0dBFS
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getA4"></a>
### CsoundObj.getA4() ⇒ <code>Promise.<number></code>
Returns the A4 frequency reference
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getCurrentTimeSamples"></a>
### CsoundObj.getCurrentTimeSamples() ⇒ <code>Promise.<number></code>
Return the current performance time in samples
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getSizeOfMYFLT"></a>
### CsoundObj.getSizeOfMYFLT() ⇒ <code>Promise.<number></code>
Return the size of MYFLT in number of bytes
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.setOption"></a>
### CsoundObj.setOption(option) ⇒ <code>Promise.<number></code>
Set a single csound option (flag),
no spaces are allowed in the string.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| option | <code>string</code> |
<a name="CsoundObj.setParams"></a>
### CsoundObj.setParams(csoundParams) ⇒ <code>Promise.<undefined></code>
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 [<code>CsoundObj</code>](#CsoundObj)
| Param | Type | Description |
| --- | --- | --- |
| csoundParams | [<code>CSOUND\_PARAMS</code>](#CSOUND_PARAMS) | csoundParams object |
<a name="CsoundObj.getParams"></a>
### CsoundObj.getParams() ⇒ [<code>Promise.<CSOUND\_PARAMS></code>](#CSOUND_PARAMS)
Get the current set of parameters
from a Csound instance
in a CSOUND_PARAMS structure.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
**Returns**: [<code>Promise.<CSOUND\_PARAMS></code>](#CSOUND_PARAMS) - - CSOUND_PARAMS object
<a name="CsoundObj.getDebug"></a>
### CsoundObj.getDebug() ⇒ <code>Promise.<number></code>
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 [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.setDebug"></a>
### CsoundObj.setDebug(debug) ⇒ <code>Promise.<undefined></code>
Return the size of MYFLT in number of bytes
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| debug | <code>number</code> |
<a name="CsoundObj.inputMessage"></a>
### CsoundObj.inputMessage(scoreEvent) ⇒ <code>Promise.<number></code>
Inputs an immediate score event
without any pre-process parsing
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| scoreEvent | <code>string</code> |
<a name="CsoundObj.inputMessageAsync"></a>
### CsoundObj.inputMessageAsync(scoreEvent) ⇒ <code>Promise.<number></code>
Inputs an immediate score event
without any pre-process parsing
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| scoreEvent | <code>string</code> |
<a name="CsoundObj.getControlChannel"></a>
### CsoundObj.getControlChannel(channelName) ⇒ <code>Promise.<undefined></code>
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 [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| channelName | <code>string</code> |
<a name="CsoundObj.setControlChannel"></a>
### CsoundObj.setControlChannel(channelName, value) ⇒ <code>Promise.<undefined></code>
Sets the value of control channel identified by channelName
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| channelName | <code>string</code> |
| value | <code>number</code> |
<a name="CsoundObj.getStringChannel"></a>
### CsoundObj.getStringChannel(channelName) ⇒ <code>Promise.<undefined></code>
Retrieves the string channel identified by channelName
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| channelName | <code>string</code> |
<a name="CsoundObj.setStringChannel"></a>
### CsoundObj.setStringChannel(channelName, value) ⇒ <code>Promise.<undefined></code>
Sets the string channel value identified by channelName
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| channelName | <code>string</code> |
| value | <code>string</code> |
<a name="CsoundObj.getOutputName"></a>
### CsoundObj.getOutputName() ⇒ <code>Promise.<string></code>
Returns the audio output name (-o)
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getInputName"></a>
### CsoundObj.getInputName() ⇒ <code>Promise.<string></code>
Returns the audio input name (-i)
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.destroy"></a>
### CsoundObj.destroy() ⇒ <code>Promise.<undefined></code>
Destroys an instance of Csound and frees memory
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getAPIVersion"></a>
### CsoundObj.getAPIVersion() ⇒ <code>Promise.<number></code>
Returns the API version as int
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getVersion"></a>
### CsoundObj.getVersion() ⇒ <code>Promise.<number></code>
Returns the Csound version as int
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.initialize"></a>
### CsoundObj.initialize() ⇒ <code>Promise.<number></code>
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 [<code>CsoundObj</code>](#CsoundObj)
**Returns**: <code>Promise.<number></code> - - Return value is zero on success,
positive if initialisation was done already, and negative on error.
<a name="CsoundObj.parseOrc"></a>
### CsoundObj.parseOrc(orc) ⇒ <code>Promise.<object></code>
Parses a csound orchestra string
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| orc | <code>string</code> |
<a name="CsoundObj.compileTree"></a>
### CsoundObj.compileTree(tree) ⇒ <code>Promise.<number></code>
Compiles AST tree
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| tree | <code>object</code> |
<a name="CsoundObj.compileOrc"></a>
### CsoundObj.compileOrc(orc) ⇒ <code>Promise.<number></code>
Compiles a csound orchestra string
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| orc | <code>string</code> |
<a name="CsoundObj.evalCode"></a>
### CsoundObj.evalCode(orc) ⇒ <code>Promise.<number></code>
Compiles a csound orchestra string
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| orc | <code>string</code> |
<a name="CsoundObj.start"></a>
### CsoundObj.start() ⇒ <code>Promise.<number></code>
Prepares Csound for performance
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.compileCsd"></a>
### CsoundObj.compileCsd(path) ⇒ <code>Promise.<number></code>
Compiles a Csound input file but does not perform it.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| path | <code>string</code> |
<a name="CsoundObj.compileCsdText"></a>
### CsoundObj.compileCsdText(orc) ⇒ <code>Promise.<number></code>
Compiles a CSD string but does not perform it.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| orc | <code>string</code> |
<a name="CsoundObj.perform"></a>
### CsoundObj.perform() ⇒ <code>Promise.<number></code>
Performs(plays) audio until end is reached
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.performKsmps"></a>
### CsoundObj.performKsmps() ⇒ <code>Promise.<number></code>
Performs(plays) 1 ksmps worth of sample(s)
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.performBuffer"></a>
### CsoundObj.performBuffer() ⇒ <code>Promise.<number></code>
Performs(plays) 1 buffer worth of audio
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.stop"></a>
### CsoundObj.stop() ⇒ <code>Promise.<undefined></code>
Stops a csoundPerform
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.cleanup"></a>
### CsoundObj.cleanup() ⇒ <code>Promise.<number></code>
Prints information about the end of a performance,
and closes audio and MIDI devices.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.reset"></a>
### CsoundObj.reset() ⇒ <code>Promise.<number></code>
Prints information about the end of a performance,
and closes audio and MIDI devices.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getInputBufferSize"></a>
### CsoundObj.getInputBufferSize() ⇒ <code>Promise.<number></code>
Returns the number of samples in Csound's input buffer.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getOutputBufferSize"></a>
### CsoundObj.getOutputBufferSize() ⇒ <code>Promise.<number></code>
Returns the number of samples in Csound's output buffer.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getInputBuffer"></a>
### CsoundObj.getInputBuffer() ⇒ <code>Promise.<number></code>
Returns the address of the Csound audio input buffer.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getOutputBuffer"></a>
### CsoundObj.getOutputBuffer() ⇒ <code>Promise.<number></code>
Returns the address of the Csound audio output buffer.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getSpin"></a>
### CsoundObj.getSpin() ⇒ <code>Promise.<number></code>
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 [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getSpout"></a>
### CsoundObj.getSpout() ⇒ <code>Promise.<number></code>
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 [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getMIDIDevList"></a>
### CsoundObj.getMIDIDevList(isOutput) ⇒ [<code>Promise.<CS\_MIDIDEVICE></code>](#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 [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| isOutput | <code>number</code> |
<a name="CsoundObj.getRtMidiName"></a>
### CsoundObj.getRtMidiName() ⇒ <code>Promise.<string></code>
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 [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.midiMessage"></a>
### CsoundObj.midiMessage(midi, midi, midi) ⇒ <code>Promise.<void></code>
Emit a midi message with a given triplet of values
in the range of 0 to 127.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type | Description |
| --- | --- | --- |
| midi | <code>number</code> | status value |
| midi | <code>number</code> | data1 |
| midi | <code>number</code> | data2 |
<a name="CsoundObj.isScorePending"></a>
### CsoundObj.isScorePending() ⇒ <code>Promise.<number></code>
Sees whether Csound score events are performed or not,
independently of real-time MIDI events
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.setScorePending"></a>
### CsoundObj.setScorePending(pending) ⇒ <code>Promise.<undefined></code>
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 [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| pending | <code>number</code> |
<a name="CsoundObj.readScore"></a>
### CsoundObj.readScore(score) ⇒ <code>Promise.<undefined></code>
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 [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| score | <code>string</code> |
<a name="CsoundObj.getScoreTime"></a>
### CsoundObj.getScoreTime() ⇒ <code>Promise.<number></code>
Returns the current score time in seconds since the beginning of performance.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.getScoreOffsetSeconds"></a>
### CsoundObj.getScoreOffsetSeconds() ⇒ <code>Promise.<number></code>
Returns the score time beginning at which score events will actually immediately be performed
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.setScoreOffsetSeconds"></a>
### CsoundObj.setScoreOffsetSeconds(time) ⇒ <code>Promise.<number></code>
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 [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| time | <code>number</code> |
<a name="CsoundObj.rewindScore"></a>
### CsoundObj.rewindScore() ⇒ <code>Promise.<number></code>
Rewinds a compiled Csound score to the time specified with csoundObj.setScoreOffsetSeconds().
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
<a name="CsoundObj.tableLength"></a>
### CsoundObj.tableLength(tableNum) ⇒ <code>Promise.<number></code>
Returns the length of a function table
(not including the guard point),
or -1 if the table does not exist.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| tableNum | <code>string</code> |
<a name="CsoundObj.tableGet"></a>
### CsoundObj.tableGet(tableNum, tableIndex) ⇒ <code>Promise.<number></code>
Returns the value of a slot in a function table.
The table number and index are assumed to be valid.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| tableNum | <code>string</code> |
| tableIndex | <code>string</code> |
<a name="CsoundObj.tableSet"></a>
### CsoundObj.tableSet(tableNum, tableIndex, value) ⇒ <code>Promise.<undefined></code>
Sets the value of a slot in a function table.
The table number and index are assumed to be valid.
**Kind**: static method of [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| tableNum | <code>string</code> |
| tableIndex | <code>string</code> |
| value | <code>string</code> |
<a name="CsoundObj.tableCopyIn"></a>
### CsoundObj.tableCopyIn(tableNum, tableIndex, array) ⇒ <code>Promise.<undefined></code>
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 [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| tableNum | <code>string</code> |
| tableIndex | <code>string</code> |
| array | <code>Array.<number></code> \| <code>ArrayLike.<number></code> |
<a name="CsoundObj.tableCopyOut"></a>
### CsoundObj.tableCopyOut(tableNum) ⇒ <code>Promise.<(Float64Array\|undefined)></code>
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 [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| tableNum | <code>string</code> |
<a name="CsoundObj.getTableArgs"></a>
### CsoundObj.getTableArgs(tableNum) ⇒ <code>Promise.<(Float64Array\|undefined)></code>
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 [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| tableNum | <code>string</code> |
<a name="CsoundObj.isNamedGEN"></a>
### CsoundObj.isNamedGEN(tableNum) ⇒ <code>Promise.<number></code>
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 [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| tableNum | <code>string</code> |
<a name="CsoundObj.getNamedGEN"></a>
### CsoundObj.getNamedGEN(tableNum) ⇒ <code>Promise.<(string\|undefined)></code>
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 [<code>CsoundObj</code>](#CsoundObj)
| Param | Type |
| --- | --- |
| tableNum | <code>string</code> |
<a name="PublicEvents"></a>
## PublicEvents : <code>enum</code>
**Kind**: global enum
**Read only**: true
**Properties**
| Name | Type | Description |
| --- | --- | --- |
| "play" | <code>string</code> | called anytime performance goes from pause/stop to a running state. |
| "pause" | <code>string</code> | called after any successful csound.pause() calls. |
| "stop" | <code>string</code> | called after end of performance or after a successful csound.stop(). |
| "realtimePerformanceStarted" | <code>string</code> | called at the start of realtime performance but not on resume or render. |
| "realtimePerformancePaused" | <code>string</code> | only called if csound.pause() was successfully called during performance. |
| "realtimePerformanceResumed" | <code>string</code> | only called if csound.resume() was successfully called after a pause. |
| "realtimePerformanceEnded" | <code>string</code> | called after end of performance or after a successful csound.stop(). |
| "renderStarted" | <code>string</code> | called at the start of offline/non-realtime render to disk. |
| "renderEnded" | <code>string</code> | called at the end of offline/non-realtime render to disk. |
| "onAudioNodeCreated" | <code>string</code> | 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" | <code>string</code> | 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. |
<a name="Csound"></a>
## Csound([params]) ⇒ <code>Promise.<(CsoundObj\|undefined)></code>
The default entry for @csound/wasm/browser module.
If loaded successfully, it returns CsoundObj,
otherwise undefined.
**Kind**: global function
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [params] | <code>Object</code> | | Initialization parameters |
| [params.audioContext] | <code>AudioContext</code> | | Optional AudioContext to use; if none given, an AudioContext will be created. |
| [params.inputChannelCount] | <code>Number</code> | | Optional input channel count for AudioNode used with WebAudio graph. Defaults to the value of nchnls_i in useWorker but 2 otherwise. |
| [params.outputChannelCount] | <code>Number</code> | | Optional output channel count AudioNode used with WebAudio graph. Defaults to the value of nchnls in useWorker but 2 otherwise. |
| [params.autoConnect] | <code>Boolean</code> | <code>true</code> | Set to configure Csound to automatically connect to the audioContext.destination output. |
| [params.withPlugins] | <code>Array.<Object></code> | | Array of WebAssembly Csound plugin libraries to use with Csound. |
| [params.useWorker] | <code>Boolean</code> | <code>false</code> | Configure to use backend using Web Workers to run Csound in a thread separate from audio callback. |
| [params.useSAB] | <code>Boolean</code> | <code>true</code> | Configure to use SharedArrayBuffers for WebWorker communications if platform supports it. |
| [params.useSPN] | <code>Boolean</code> | <code>false</code> | Configure to use explicitly request ScriptProcessorNode rather than AudioWorklet. Recommended only for debug testing purposes. |
<a name="CSOUND_PARAMS"></a>
## CSOUND\_PARAMS
**Kind**: global typedef
**Properties**
| Name | Type |
| --- | --- |
| debug_mode | <code>number</code> |
| buffer_frames | <code>number</code> |
| hardware_buffer_frames | <code>number</code> |
| displays | <code>number</code> |
| ascii_graphs | <code>number</code> |
| postscript_graphs | <code>number</code> |
| message_level | <code>number</code> |
| tempo | <code>number</code> |
| ring_bell | <code>number</code> |
| use_cscore | <code>number</code> |
| terminate_on_midi | <code>number</code> |
| heartbeat | <code>number</code> |
| defer_gen01_load | <code>number</code> |
| midi_key | <code>number</code> |
| midi_key_cps | <code>number</code> |
| midi_key_oct | <code>number</code> |
| midi_key_pch | <code>number</code> |
| midi_velocity | <code>number</code> |
<a name="CS_MIDIDEVICE"></a>
## CS\_MIDIDEVICE
**Kind**: global typedef
**Properties**
| Name | Type |
| --- | --- |
| device_name | <code>string</code> |
| interface_name | <code>string</code> |
| device_id | <code>string</code> |
| midi_module | <code>string</code> |
| isOutput | <code>number</code> |
|