Skip to content
This repository has been archived by the owner on Apr 27, 2019. It is now read-only.

Commit

Permalink
fix meddler
Browse files Browse the repository at this point in the history
  • Loading branch information
mmckegg committed Sep 3, 2014
1 parent 0dbfbdd commit a62e48b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions index.js
Expand Up @@ -18,14 +18,18 @@ var IAC = require('inheritable-audio-context')
module.exports = function(parentAudioContext){

var audioContext = IAC(parentAudioContext, true)
audioContext.inputs = {}

var soundbank = audioContext.createGain()
soundbank._context = audioContext

var output = audioContext.createGain()
var meddler = createMeddler(audioContext)

audioContext.inputs = {
'meddler': meddler
}


meddler.connect(output)
output.connect(soundbank)

Expand All @@ -34,7 +38,7 @@ module.exports = function(parentAudioContext){

var activeGroups = ActiveList()

var slots = {}
var slots = soundbank._slots = {}
var descriptors = {}
var resolvedDescriptors = {}
var slotReferences = SlotReferences()
Expand Down Expand Up @@ -127,13 +131,6 @@ module.exports = function(parentAudioContext){
descriptor = applyProviders(context, descriptor)
slotReferences.update(id, context.slotReferences)

// update meddler
if (oldDescriptor.inputMode === 'meddler' && descriptor.inputMode !== 'meddler'){
meddler.remove(id)
} else if (oldDescriptor.inputMode !== 'meddler' && descriptor.inputMode == 'meddler'){
meddler.add(id, getInput(id))
}

// update existing slot
if (slot){
if (!ctor || !(slot instanceof ctor)){
Expand All @@ -145,6 +142,7 @@ module.exports = function(parentAudioContext){
slot.update({})
slot.disconnect()
slot = slots[id] = null
meddler.remove(id)

} else {

Expand All @@ -166,6 +164,7 @@ module.exports = function(parentAudioContext){
}

updateOutput(slot, descriptor)
meddler.add(id, slot)
}

// emit with providers
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -18,7 +18,7 @@
"license": "MIT",
"dependencies": {
"audio-slot": "^2.0.0",
"audio-meddle": "^0.1.2",
"audio-meddle": "^0.2.0",
"inheritable-audio-context": "^1.0.1"
}
}

0 comments on commit a62e48b

Please sign in to comment.