Socket
Socket
Sign inDemoInstall

audio-sink

Package Overview
Dependencies
2
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    audio-sink

Sink or tap audio stream data


Version published
Weekly downloads
184
decreased by-37.41%
Maintainers
3
Install size
22.7 kB
Created
Weekly downloads
 

Readme

Source

audio-sink Build Status stable

Triggers an event for received audio chunk and releases the data. If piped to somewhere, it turns into a pass-throught stream. That way, it is through2-sink and tap-stream in one. Use as a fast replacement for audio-speaker or audio-render.

Can function as a pressure controller. See example.

Usage

npm install audio-sink

Direct
const Sink = require('audio-sink/direct');

let sink = Sink((data, cb) => {
	console.log(data);
	setTimeout(cb, 100);
});

//log data and invoke cb after 100ms
sink(buffer, (err, buffer) => {

});
Pull-stream
const pull = require('pull-stream/pull');
const sink = require('audio-sink/pull');
const generator = require('audio-generator/pull');

//stream generated data to sink with pressure control
pull(
	generator(time => Math.sin(time * Math.PI * 2 * 440)),
	sink((data, cb) => {
		//end stream if needed
		if (tooLate) return cb(true);

		console.log(data);
		setTimeout(cb, 100);
	});
);
Stream
var Gen = require('audio-generator/stream');
var Sink = require('audio-sink/stream');

Gen(function (time) {
	return time ? 0 : 1;
})
.pipe(Sink(function (data, cb) {
	console.log('This sink is a pass-through with 10ms throttling ', data.length);

	setTimeout(cb, 10);
}))
.pipe(Sink(function (data) {
	console.log('This sink gets the data and releases it ', data.length);
}));

stream-sink — universal stream sink.
through2-sink — triggers an event for the data chunk, but does not pass data through.
tap-stream — triggers callback for the passed through data, but does not release data.

Keywords

FAQs

Last updated on 06 Sep 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc