1.1.6 • Published 8 years ago

audio-sink v1.1.6

Weekly downloads
198
License
MIT
Repository
github
Last release
8 years ago

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);
}));

Related

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.

1.1.6

8 years ago

1.1.5

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago