diff --git a/index.js b/index.js new file mode 100644 index 0000000..c6079b0 --- /dev/null +++ b/index.js @@ -0,0 +1 @@ +module.exports = require('./lib/mixer.js'); diff --git a/lib/mixer.js b/lib/mixer.js new file mode 100644 index 0000000..0547782 --- /dev/null +++ b/lib/mixer.js @@ -0,0 +1,39 @@ +var + Readable = require('stream').Readable, + util = require('util') + ; + +function Mixer(args) { + + if (typeof args === 'undefined') args = {}; + if (args.channels != 1 && args.channels != 2) args.channels = 2; + if (args.bitDepth != 8 && args.bitDepth != 16 && args.bitDepth != 32) args.channels = 2; + if (typeof args.sampleRate === 'number' || args.sampleRate < 1) args.sampleRate = 44100; + + this.channels = args.channels; + this.bitDepth = args.bitDepth; + this.sampleRate = args.sampleRate; + + this.inputs = []; +} + +util.inherits(Mixer, Readable); + +Mixer.prototype._read = function() { + this.push(0); +} + +Mixer.prototype.input = function (args) { + if (typeof args === 'undefined') args = {}; + + var input = new Input({ + channels: args.channels || this.channels, + bitDepth: args.bitDepth || this.bitDepth, + sampleRate: args.sampleRate || this.sampleRate + }); + this.inputs.push(input); + + return input; +} + +module.exports = Mixer;