npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@qvac/decoder-audio

v0.3.7

Published

This decoder library leverages FFmpeg for efficient audio decoding. It simplifies processing of input audio, particularly as a preprocessing step for other addons.

Downloads

18,714

Readme

qvac-lib-decoder-audio

This decoder library leverages FFmpeg for efficient audio decoding. It simplifies processing of input audio, particularly as a preprocessing step for other addons.

Table of Contents

Supported Platforms

| Platform | Architecture | Min Version | Status | GPU Support | |----------|-------------|-------------|--------|-------------| | macOS | arm64, x64 | 14.0+ | ✅ Tier 1 | N/A (CPU only) | | iOS | arm64 | 17.0+ | ✅ Tier 1 | N/A (CPU only) | | Linux | arm64, x64 | Ubuntu-22+ | ✅ Tier 1 | N/A (CPU only) | | Android | arm64 | 12+ | ✅ Tier 1 | N/A (CPU only) | | Windows | x64 | 10+ | ✅ Tier 1 | N/A (CPU only) |

Dependencies:

  • qvac-lib-inference-addon-cpp: C++ addon framework
  • FFmpeg: Audio decoding engine
  • Bare Runtime (latest): JavaScript runtime

Installation

Prerequisites

Ensure that the Bare Runtime is installed globally on your system. If it's not already installed, you can add it using:

npm install -g bare@latest

Installing the Package

Install the latest version of the decoder addon with the following command:

npm install @qvac/decoder-audio@latest

Usage

This library provides a simple workflow for decoding audio streams.

1. Creating the Decoder Instance

To get started, import the decoder and create an instance:

const { FFmpegDecoder } = require('@qvac/decoder-audio')

const decoder = new FFmpegDecoder({
  config: {
    audioFormat: 's16le', // 's16le' | 'f32le'; default is 's16le'
    sampleRate: 16000 // in Hz; default is 16000
  }
})

The config object accepts the following parameters:

  • audioFormat: Specifies the output format of the decoded audio. Supported values:

    • 's16le': Signed 16-bit little-endian PCM — a widely used raw format.
    • 'f32le': 32-bit floating-point little-endian PCM — ideal for high-precision audio processing.

    Default: 's16le'.

  • sampleRate: Sample rate of the output audio in Hertz (Hz). Default: 16000 (16 kHz), commonly used for speech processing.

2. Loading the Decoder

Initializes and activates the decoder with the provided or default configuration. This method must be called before decoding any audio input.

try {
  await decoder.load()
} catch (err) {
  console.error('Failed to load decoder:', err)
}

3. Decoding Audio

In order to decode audio, we must create an audio stream and pass it to the run() method. This method returns a QVACResponse object.

const fs = require('bare-fs')
const audioFilePath = './sample.ogg'
const audioStream = fs.createReadStream(audioFilePath)

const response = await decoder.run(audioStream)

4. Handling Response Updates

The response supports real-time updates via .onUpdate(). Each update delivers a chunk of decoded audio data, which can be processed or saved as needed:

await response
  .onUpdate(output => {
    // `output.outputArray` is a Uint8Array
    console.log('Decoded chunk:', new Uint8Array(output.outputArray))
  })
  .await() // wait for the stream to finish

You can append or otherwise process these frames as needed.

5. Unloading the decoder

Always unload the decoder when done to free memory:

try {
  await decoder.unload()
} catch (err) {
  console.error('Failed to unload decoder:', err)
}

Quickstart Example

The following example demonstrates how to use the decoder to decode a sample OGG file into a raw audio file. Follow these steps, to run the example:

1. Create a new project:

mkdir decoder-example
cd decoder-example
npm init -y

2. Install the required dependencies:

npm install bare-fs @qvac/decoder-audio

3. Create a file named example.js and paste the following code:

'use strict'

const fs = require('bare-fs')
const { FFmpegDecoder } = require('@qvac/decoder-audio')

const audioFilePath = './path/to/audio/file.ogg'
const outputFilePath = './path/to/output/file.raw'

async function main () {
  const decoder = new FFmpegDecoder({
    config: {
      audioFormat: 's16le',
      sampleRate: 16000
    }
  })

  try {
    await decoder.load()

    const audioStream = fs.createReadStream(audioFilePath)
    const response = await decoder.run(audioStream)

    const decodedFileBuffer = []

    await response
      .onUpdate(output => {
        const bytes = new Uint8Array(output.outputArray)
        decodedFileBuffer.push(bytes)
      })
      .onFinish(() => {
        fs.writeFileSync(outputFilePath, Buffer.concat(decodedFileBuffer))
        console.log('Decoded file saved to', outputFilePath)
      })
      .await()
  } finally {
    await decoder.unload()
  }
}

main().catch(console.error)

4. Run the example:

Make sure to set the correct audioFilePath and outputFilePath before running the example with the following command:

bare example.js

Testing

Running Unit Tests

To run unit tests (using the 'brittle-bare' runner):

npm run test:unit

Test Coverage

To generate a unit test coverage report (using 'brittle' and 'istanbul'):

npm run coverage:unit

Or simply:

npm run coverage

Coverage reports are generated in the 'coverage/unit/' directory. Open the corresponding index.html file in your browser to view the detailed report.

Glossary

  • Bare – A lightweight, modular JavaScript runtime for desktop and mobile.
  • QVACResponse – the response object used by QVAC API
  • QVAC – Our decentralized AI SDK for building runtime-portable inference apps.

Resources

License

This project is licensed under the Apache-2.0 License – see the LICENSE file for details.

For questions or issues, please open an issue on the GitHub repository.