Skip to content

Latest commit

 

History

History
51 lines (33 loc) · 1.64 KB

README.md

File metadata and controls

51 lines (33 loc) · 1.64 KB

opus

Tags CI Status License

const SAMPLE_RATE = 48000;
const FRAME = 20;
const CHANNELS = 2;

await Opus.load();

// Optimize encoding for audio. Available applications are VOIP, AUDIO, and RESTRICTED_LOWDELAY
let encoder = new Opus(SAMPLE_RATE, CHANNELS, OpusApplication.AUDIO);

let frameSize = SAMPLE_RATE * FRAME / 1000;

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

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

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

Maintainers

Other

Related

  • opusscript - nodejs bindings for libopus 1.3.1, ported with emscripten

Contribution

Pull request, issues and feedback are very welcome. Code style is formatted with deno fmt and commit messages are done following Conventional Commits spec.

Licence

This project is using the MIT license and is a port of abalabahaha/opusscript to deno.

Copyright (c) 2016-2020 abalabahaha Copyright (c) 2020-2021 the denosaurs team