Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

csound-wasm

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csound-wasm

Simplified API for Csound's Webassembly.

  • 6.10.0-5
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

csound-wasm

Simplified API for Csound's Webassembly.

  • Single browser bundle
  • Automatic startup and initialization
  • Easy integration to node.js

Useage

Node.js

Install
npm install csound-wasm --save

Csound-wasm is dependent on the module Speaker. This module is not compatable with all audio modules, and can be buggy on Windows if installed within a unix-shell. MacOsX and Linux should work fine with CoreAudio and Alsa respectively.

Quick start
const csound = require('csound-wasm');

const beeper = `
instr 1
  asig = poscil:a(0.3, 440)
  outc asig, asig
endin`

const makeBeep = `i 1 0 1`

csound.startRealtime()
csound.compileOrc(beeper);
csound.readScore(makeBeep);

setTimeout(() => process.exit(), 5000);

Browser

Download the latest csound-wasm-browser.js under releases and bundle it next to your html file.

<script src="csound-wasm-browser.js"></script>

Or alternatively (preferably for development) refer directly to the gihub releases within the html, like so.

<script src="https://github.com/hlolli/csound-wasm/releases/download/6.10.0-4/csound-wasm-browser.js"></script>

This file is minified via Google Closure Compiler and is intended to be used as is. If you're useing Webpack or Gulp, then add this file as a vendor resource.

Quick start
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
  </head>
  <body>
    <h5>Click Start realtime once, gotta love chrome's new autoplay ban policy</h5>
    <button id="start">Start realtime</button>
    <button onclick="csound.inputMessage('i 1 0 1')">Make beep!</h1>
    <script src="https://github.com/hlolli/csound-wasm/releases/download/6.10.0-4/csound-wasm-browser.js"></script>
  <script>
    const beeper = `
    instr 1
    asig = poscil:a(0.3, 440)
    outc asig, asig
    endin
    `
    document.getElementById('start').onclick = ()=> {
    csound.startRealtime();
    csound.compileOrc(beeper);
    };
  </script>
</body>
</html>

API

Many these functions are a direct implementation of the Csound API. Some are csound-wasm specific.

Public FunctionParametersDescription
csound.startRealtime(config*)config::Object default: {nchnls: 2, zerodbfs: 1, sr: 44100, ksmps: 256}starts/initializes realtime as oppsed to rendering to file
csound.compileOrc(orc)orc::StringCompiles any orchestra code at k-rate without return value.
csound.renderToFile(csd, file)csd::String, file::StringRenders CSD string, filepath for the file output, currently only supported on node
csound.evalCode(orc)orc::Stringlike compileOrc but returns status number on i-rate (0 if successful)
csound.inputMessage(sco)sco::Stringsends (score) event(s) without pre-processing, use \n to seperate multiscore statements
csound.readScore(sco)sco::Stringlike inputMessage but tries to pre-process the before emitting the event
csound.getControlChannel
csound.setControlChannel
csound.setStringChannel
csound.getScoreTime
csound.playCSD
csound.reset
csound.destroy
csound.setOption
csound.compileCSD
csound.setTable
csound.getTable
csound.getTableLength
csound.getKsmps
csound.get0dbfs
csound.enableMidi
csound.pushMidi
csound.compileOrc
csound.evalCode
csound.inputMessage
csound.readScore

Keywords

FAQs

Package last updated on 03 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc