Skip to content

a TCP-based server/client library for low-latency audio streaming

License

Notifications You must be signed in to change notification settings

sal-ortiz/tcp-audio-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

a TCP-based server/client library for low-latency audio streaming

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages