audio-slot
Advanced tools
Comparing version 1.1.0 to 1.2.0
18
index.js
@@ -11,2 +11,4 @@ var CustomNode = require('custom-audio-node') | ||
var slot = CustomNode(input, output) | ||
slot._context = audioContext | ||
slot._input = input | ||
@@ -47,3 +49,3 @@ slot._output = output | ||
function triggerOn(at, velocity){ | ||
var sources = this.context.sources || {} | ||
var sources = this._context.sources || {} | ||
var descriptors = this.descriptor.sources || [] | ||
@@ -53,3 +55,3 @@ for (var i=0;i<descriptors.length;i++){ | ||
if (descriptor.node && typeof sources[descriptor.node] === 'function'){ | ||
var source = sources[descriptor.node](this.context) | ||
var source = sources[descriptor.node](this._context) | ||
var event = {from: at, node: source, modulators: [], descriptor: {}, nodeIndex: i} | ||
@@ -59,3 +61,3 @@ | ||
updateParams(this.context, event, descriptor) | ||
updateParams(this._context, event, descriptor) | ||
var offTime = source.start(at) | ||
@@ -116,3 +118,3 @@ | ||
if (!event.choked && (!event.to || at < event.to+0.01) && at > event.from){ | ||
var choker = this.context.createGain() | ||
var choker = this._context.createGain() | ||
event.node.disconnect() | ||
@@ -134,3 +136,3 @@ event.node.connect(choker) | ||
if (~event.nodeIndex){ | ||
updateParams(this.context, event, sourceDescriptors[event.nodeIndex]) | ||
updateParams(this._context, event, sourceDescriptors[event.nodeIndex]) | ||
} | ||
@@ -145,5 +147,5 @@ } | ||
if (desc.node){ | ||
var source = this.context.sources[desc.node] | ||
var source = this._context.sources[desc.node] | ||
if (source && source.prime){ | ||
source.prime(this.context, desc) | ||
source.prime(this._context, desc) | ||
} | ||
@@ -157,3 +159,3 @@ } | ||
updateParams(this.context, this._outputContainer, {gain: descriptor.volume}) | ||
updateParams(this._context, this._outputContainer, {gain: descriptor.volume}) | ||
@@ -160,0 +162,0 @@ this.chokeGroup = descriptor.chokeGroup == null ? null : descriptor.chokeGroup |
var updateParams = require('./update_params') | ||
module.exports = function updateProcessors(slot, processorDescriptors){ | ||
var processors = slot.context.processors || {} | ||
var processors = slot._context.processors || {} | ||
var active = slot._currentProcessors | ||
@@ -20,3 +20,3 @@ | ||
} | ||
update(slot.context, container, descriptor) | ||
update(slot._context, container, descriptor) | ||
} else { | ||
@@ -31,3 +31,3 @@ container.node.disconnect() | ||
var container = { descriptor: {}, node: null, modulators: [] } | ||
update(slot.context, container, descriptor) | ||
update(slot._context, container, descriptor) | ||
active[i] = container | ||
@@ -34,0 +34,0 @@ reconnect.push(i) |
{ | ||
"name": "audio-slot", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Web Audio API triggerable audio slot described with JSON consisting of sources, processors, and modulators.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -57,3 +57,3 @@ audio-slot | ||
var audioContext = new webkitAudioContext() | ||
var audioContext = new AudioContext() | ||
@@ -60,0 +60,0 @@ audioContext.sources = { |
var AudioSlot = require('./index') | ||
var audioContext = new webkitAudioContext() | ||
var audioContext = new AudioContext() | ||
@@ -4,0 +4,0 @@ audioContext.sources = { |
21511
518