outlining the mixer object
This commit is contained in:
parent
382b9a2625
commit
16b2285694
39
lib/mixer.js
Normal file
39
lib/mixer.js
Normal 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;
|
Loading…
Reference in New Issue
Block a user