0.0.2 • Published 3 years ago

tcp-audio-stream v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

tcp-audio-stream

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

This library uses the NodeJS Net API and the Naudiodon package's PortAudio bindings.

setup

To install install, run:        npm install --save-prod tcp-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 tcp-audio-stream library contains both components.

const TcpAudioStream = require('tcp-audio-stream);

let Server = TcpAudioStream.Server;
let Client = TcpAudioStream.Client;

usage

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

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

const PortAudio = require('naudiodon');
const TcpAudioStream = require('tcp-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 TcpAudioStream.Server(outpEngine);

server.start(127.0.0.1, 3000);

a basic implementation for sending live audio to a server:

const PortAudio = require('naudiodon');
const TcpAudioStream = require('tcp-audio-stream);

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

const client = new TcpAudioStream.Client(inpEngine);

client.connect(127.0.0.1, 3000);

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

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

0.0.2

3 years ago

0.0.1

3 years ago