Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

opus-decoder

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opus-decoder

Web Assembly streaming Opus decoder

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
305K
decreased by-2.66%
Maintainers
1
Weekly downloads
 
Created
Source

opus-decoder

opus-decoder is a Web Assembly Opus audio decoder.

See the homepage of this repository for more Web Assembly audio decoders like this one.

Installing

Install via NPM.

Usage

  1. Create a new instance and wait for the WASM to finish compiling.

    import {OpusDecoder} from 'opus-decoder';
    
    const decoder = new OpusDecoder();
    
    // wait for the WASM to be compiled
    await decoder.ready;
    
  2. Begin decoding Opus frames.

    // Decode an individual Opus frame
    const {channelData, samplesDecoded, sampleRate} = decoder.decodeFrame(opusFrame);
    
    // Decode an array of individual Opus frames
    const {channelData, samplesDecoded, sampleRate} = decoder.decodeFrames(opusFrameArray);
    
  3. When done decoding, free up the memory being used by the WASM module. You will need to create a new instance to start decoding again.

    decoder.free();
    

API

Getters

  • decoder.ready
    • Returns a promise that is resolved when the WASM is compiled and ready to use.

Methods

Each method returns an object containing the decoded audio, number of samples decoded, and sample rate of the decoded audio.

The channelData contains the raw decoded PCM for each channel (left, and right). Each Float32Array can be used directly in the WebAudio api.

// decoded audio return value
{
    channelData: [leftAudio, rightAudio],
    samplesDecoded: 1234,
    sampleRate: 48000
}
  • decoder.decodeFrame(opusFrame)
    • opusFrame Uint8Array containing a single Opus frame.
  • decoder.decodeFrames(opusFrames)
    • opusFrames Array of Uint8Arrays containing Opus frames.

Keywords

FAQs

Package last updated on 30 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc