outlining the mixer object

This commit is contained in:
alfred 2013-12-30 10:50:54 +00:00
parent 382b9a2625
commit 16b2285694
2 changed files with 40 additions and 0 deletions

1
index.js Normal file
View File

@ -0,0 +1 @@
module.exports = require('./lib/mixer.js');

39
lib/mixer.js Normal file
View File

@ -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;