Skip to content

Latest commit

 

History

History
74 lines (56 loc) · 2.69 KB

README.md

File metadata and controls

74 lines (56 loc) · 2.69 KB

udp-audio-stream

A UDP-based low-latency unicast client/server audio stream library utilizing the native PortAudio library.

This library uses the NodeJS UDP/datagram API and the Naudiodon package's PortAudio bindings.

setup

To install install, run:
       npm install --save-prod udp-audio-stream

Be sure to import the Naudiodon library as well:
       npm install --save-prod naudiodon

components

The library has two main components, a client and a server.

The single udp-audio-stream library contains both components.

const UdpAudioStream = require('udp-audio-stream);

let Server = UdpAudioStream.Server;
let Client = UdpAudioStream.Client;

usage

Import the Naudiodon library from NPM. This dependency was excluded from this package to allow for unique audio configurations. The udp-audio-stream library takes the configured Naudiodon instance as it's input.

a basic implementation for receiving and playing back audio from a client:

const PortAudio = require('naudiodon');
const UdpAudioStream = require('udp-audio-stream);

const outpEngine = new PortAudio.AudioIO({
    outOptions: {
        channelCount: 2,
        sampleFormat: PortAudio.SampleFormat16Bit,
        sampleRate: 22000,
        deviceId: -1,
        closeOnError: false,
        highWaterMark: 1024,
        framesPerBuffer: 16
    }
});

const server = new UdpAudioStream.Server(outpEngine);

server.start(127.0.0.1, 3000);

a basic implementation for sending live audio to a server:

const PortAudio = require('naudiodon');
const UdpAudioStream = require('udp-audio-stream);

const inpEngine = new PortAudio.AudioIO({
    inOptions: {
        channelCount: 2,
        sampleFormat: PortAudio.SampleFormat16Bit,
        sampleRate: 22000,
        deviceId: -1,
        highWaterMark: 1024,
        framesPerBuffer: 16,
    }
});

const client = new UdpAudioStream.Client(inpEngine);

client.connect(127.0.0.1, 3000);

A udp-audio-stream server example can be found here.
A udp-audio-stream client example can be found here.

Further details regarding the use of the Naudiodon package can be found here.