Skip to content

denosaurs/opus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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