audio-slot
Advanced tools
Comparing version 4.1.0 to 4.2.0
60
index.js
@@ -8,2 +8,3 @@ var Observ = require('observ') | ||
var Property = require('observ-default') | ||
var RoutableSlot = require('./routable') | ||
@@ -31,3 +32,3 @@ module.exports = AudioSlot | ||
var obs = ObservStruct({ | ||
var obs = RoutableSlot(context, { | ||
id: Observ(), | ||
@@ -39,20 +40,8 @@ sources: NodeArray(context), | ||
volume: Property(1) | ||
}) | ||
}, input, output) | ||
obs._type = 'AudioSlot' | ||
obs.context = context | ||
context.noteOffset = obs.noteOffset | ||
context.slot = obs | ||
obs.volume(function (value) { | ||
output.gain.value = value | ||
}) | ||
obs.input = input | ||
// main output | ||
obs.output(queueRefreshConnections) | ||
var removeSlotWatcher = context.slotLookup && context.slotLookup(refreshConnections) | ||
// reconnect sources on add / update | ||
@@ -149,17 +138,2 @@ var connectedSources = [] | ||
obs.connect = function (to) { | ||
extraConnections.push(to) | ||
refreshConnections() | ||
} | ||
obs.disconnect = function () { | ||
extraConnections.length = 0 | ||
refreshConnections() | ||
} | ||
obs.destroy = function () { | ||
removeSlotWatcher && removeSlotWatcher() | ||
removeSlotWatcher = null | ||
} | ||
return obs | ||
@@ -169,30 +143,2 @@ | ||
function queueRefreshConnections () { | ||
if (!refreshingConnections) { | ||
refreshingConnections = true | ||
nextTick(refreshConnections) | ||
} | ||
} | ||
function refreshConnections () { | ||
refreshingConnections = false | ||
output.disconnect() | ||
extraConnections.forEach(function (target) { | ||
output.connect(target) | ||
}) | ||
var outputNames = typeof obs.output() === 'string' ? [obs.output()] : obs.output() | ||
if (Array.isArray(outputNames)) { | ||
outputNames.forEach(function (name) { | ||
var destinationSlot = context.slotLookup.get(name) | ||
if (destinationSlot && destinationSlot.input) { | ||
output.connect(destinationSlot.input) | ||
} | ||
}) | ||
} | ||
} | ||
function updateProcessors () { | ||
@@ -199,0 +145,0 @@ if (checkProcessorsChanged()) { |
{ | ||
"name": "audio-slot", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "Web Audio API FRP wrapper for creating, routing, and triggering AudioNodes.", | ||
@@ -25,3 +25,4 @@ "main": "index.js", | ||
"observ-node-array": "^1.10.0", | ||
"observ-struct": "^6.0.0" | ||
"observ-struct": "^6.0.0", | ||
"xtend": "~4.0.0" | ||
}, | ||
@@ -28,0 +29,0 @@ "keywords": [ |
@@ -62,2 +62,4 @@ var Processor = require('../processor.js') | ||
filter.Q.value = 0 | ||
Apply(context, wet.gain, obs.wet) | ||
@@ -64,0 +66,0 @@ Apply(context, dry.gain, obs.dry) |
68893
31
2179
12
+ Addedxtend@~4.0.0
+ Addedxtend@4.0.2(transitive)