audio-as
v0.0.3
Published
AssemblyScript Audio API for NodeJS and Browser
Downloads
1
Readme
AS-Audio 🔊
AssemblyScript Audio API for NodeJS and Browser
Installation
~ npm install audio-as
Install optional dependencies
~ npm install speaker
Features
- Build for AssemblyScript
- Works with As-Bind
- Isomorphic (Node/Browser)
- ESM/CJS Builds
- Small (~950 bytes)
- Simple API
Setting up
NodeJS
...
const loader = require('@assemblyscript/loader')
+ const AudioImport = require('audio-as/imports')
+ const audio = new AudioImport()
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.esm.js'
+ const audio = new AudioImport()
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