Skip to content
JS bindings for libopus 1.3.1, ported with emscripten
JavaScript C++ Makefile
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build libopus 1.3.1, WASM support Aug 8, 2019
opus-native @ e85ed77 libopus 1.3.1, WASM support Aug 8, 2019
src libopus 1.3.1, WASM support Aug 8, 2019
.gitignore Initial commit Aug 28, 2016
.gitmodules
.npmignore libopus 1.3.1, WASM support Aug 8, 2019
LICENSE Update LICENSE year Oct 3, 2017
Makefile libopus 1.3.1, WASM support Aug 8, 2019
README.md libopus 1.3.1, WASM support Aug 8, 2019
index.d.ts Add constructor options typings Nov 20, 2019
index.js libopus 1.3.1, WASM support Aug 8, 2019
package.json Add constructor options typings Nov 20, 2019

README.md

opusscript

JS bindings for libopus 1.3.1, ported with emscripten

var opusscript = require("opusscript");

// 48kHz sampling rate, 20ms frame duration, stereo audio (2 channels)
var samplingRate = 48000;
var frameDuration = 20;
var channels = 2;

// Optimize encoding for audio. Available applications are VOIP, AUDIO, and RESTRICTED_LOWDELAY
var encoder = new opusscript(samplingRate, channels, opusscript.Application.AUDIO);

var frameSize = samplingRate * frameDuration / 1000;

// Get PCM data from somewhere and encode it into opus
var pcmData = new Buffer(pcmSource);
var encodedPacket = encoder.encode(pcmData, frameSize);

// Decode the opus packet back into PCM
var decodedPacket = encoder.decode(encodedPacket);

// Delete the encoder when finished with it (Emscripten does not automatically call C++ object destructors)
encoder.delete();

TypeScript

Since this module wasn't written for TypeScript, you need to use import = require syntax.

// Import using:
import OpusScript = require('opusscript');

// and NOT:
import OpusScript from 'opusscript';
You can’t perform that action at this time.