Git Product home page Git Product logo

node-pcm-cache-stream's Introduction

pcm-cache-stream

Given a live stream of raw PCM data, cache a configurable amount of seconds with valid samples.

The raison d'être for writing this module was to emulate Icecast's "burst-on-connect" setting, which allows live playback to start sooner for the listening client while introducing a small amount of latency.

Use

var PCMCacheStream = require('pcm-cache-stream');
var Speaker = require('speaker')({ 'sampleRate' : 44100, 'bitDepth' : 16, 'channels' : 2, 'cacheSeconds' : 3 });

// Start piping the audio directly to the speaker
process.stdin.pipe(PCMCacheStream).pipe(Speaker);

// During playback, the cache is continually adjusted going back 3 seconds
setTimeout(function () {
    console.log(PCMCacheStream.cache.length);
}, 10 * 1000);

Example

$ ffmpeg -i song.mp3 -f s16le -acodec pcm_s16le -ar 44100 -ac 2 pipe:1 | node example.js

node-pcm-cache-stream's People

Contributors

jproulx avatar

Stargazers

 avatar

Watchers

 avatar  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.