Coder Social home page Coder Social logo

tcp-audio-stream's Introduction

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.

tcp-audio-stream's People

Contributors

sal-ortiz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.