README
AS-Audio 🔊
AssemblyScript Audio API for NodeJS and Browser
Installation
~ npm install audio.as
Install optional dependencies
~ npm install speaker
Setting up
NodeJS
...
const loader = require('@assemblyscript/loader')
+ const AudioImport = require('audio.as')
+ const audio = new AudioImport({
+ asBind: false
+ // Can toggle this to true
+ })
const imports = {
+ ...audio.wasmImports
}
const wasmModule = loader.instantiateSync(..., imports);
+ audio.wasmExports = wasmModule.exports
...
Browser
...
import * as loader from '...'
+ import { AudioImport } from 'https://unpkg.com/audio.as@latest/imports.browser.js'
+ const audio = new AudioImport({
+ asBind: false
+ })
const imports = {
+ ...audio.wasmImports
}
loader.instantiate(..., imports).then((wasmModule) => {
+ audio.wasmExports = wasmModule.exports
})
...
Usage
AssemblyScript
import { Audio } from 'audio.as'
const audio = new Audio('https://.../')
audio.play()
// Listen away! 🎧
Notes/To-do
- Pause/Resume does not work yet on NodeJS