1.8.2 • Published 1 year ago

audify v1.8.2

Weekly downloads
67
License
MIT
Repository
github
Last release
1 year ago

npm version Master Build Status Prebuilt Build Status

Audify.js

Audify.js - Play/Stream/Record PCM audio data & Encode/Decode Opus to PCM audio data

Features

  • Encode 16-bit integer PCM or floating point PCM to Opus packet using C++ Opus library.
  • Decode Opus packets to 16-bit integer PCM or floating point PCM using C++ Opus library.
  • Complete API for realtime audio input/output across Linux (native ALSA, JACK, PulseAudio and OSS), Macintosh OS X (CoreAudio and JACK), and Windows (DirectSound, ASIO and WASAPI) operating systems using C++ RtAudio library.

Installation

npm install audify

Most regular installs will support prebuilds that are built with each release.

Prebuilds are available for Node versions v12.11.x-v19.x.x and Electron versions v8.x.x-v22.x.x

Requirements for source build

Example

Opus Encode & Decode

const { OpusEncoder, OpusDecoder, OpusApplication } = require("audify");

// Init encoder and decoder
// Sample rate is 48kHz and the amount of channels is 2
// The opus coding mode is optimized for audio
const encoder = new OpusEncoder(48000, 2, OpusApplication.OPUS_APPLICATION_AUDIO);
const decoder = new OpusDecoder(48000, 2);

const frameSize = 1920; // 40ms
const buffer = ...

// Encode and then decode
var encoded = encoder.encode(buffer, frameSize);
var decoded = decoder.decode(encoded, frameSize);

Record audio and play it back realtime

const { RtAudio, RtAudioFormat } = require("audify");

// Init RtAudio instance using default sound API
const rtAudio = new RtAudio(/* Insert here specific API if needed */);

// Open the input/output stream
rtAudio.openStream(
  {
    deviceId: rtAudio.getDefaultOutputDevice(), // Output device id (Get all devices using `getDevices`)
    nChannels: 1, // Number of channels
    firstChannel: 0, // First channel index on device (default = 0).
  },
  {
    deviceId: rtAudio.getDefaultInputDevice(), // Input device id (Get all devices using `getDevices`)
    nChannels: 1, // Number of channels
    firstChannel: 0, // First channel index on device (default = 0).
  },
  RtAudioFormat.RTAUDIO_SINT16, // PCM Format - Signed 16-bit integer
  48000, // Sampling rate is 48kHz
  1920, // Frame size is 1920 (40ms)
  "MyStream", // The name of the stream (used for JACK Api)
  (pcm) => rtAudio.write(pcm) // Input callback function, write every input pcm data to the output buffer
);

// Start the stream
rtAudio.start();

Documentation

Full documentation available here.

Legal

This project is licensed under the MIT license.

1.8.2

1 year ago

1.8.1

1 year ago

1.8.0

1 year ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.3

3 years ago

1.6.2

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.5

3 years ago

1.5.4

3 years ago

1.5.7

3 years ago

1.5.6

3 years ago

1.5.3

3 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.3.0-8

4 years ago

1.3.0-7

4 years ago

1.3.0-6

4 years ago

1.3.0-5

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.3.0-0

4 years ago

1.3.0-4

4 years ago

1.3.0-3

4 years ago

1.3.0-2

4 years ago

1.3.0-1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago