-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SoundBank #92
SoundBank #92
Conversation
src/SoundBank.js
Outdated
|
||
stop (target, soundId) { | ||
if (this.playerTargets.get(soundId) === target) { | ||
this.soundPlayers[soundId].stop(); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
src/SoundBank.js
Outdated
getSound (soundId) { | ||
if (!this.soundPlayers[soundId]) { | ||
this.soundPlayers[soundId] = new SoundPlayer(this.audioEngine, { | ||
id: soundId, buffer: this.audioEngine.audioBuffers[soundId] |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
src/SoundBank.js
Outdated
|
||
class SoundBank { | ||
constructor (audioEngine) { | ||
this.audioEngine = audioEngine; |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
src/effects/EffectChain.js
Outdated
addSoundPlayer (soundPlayer) { | ||
if (!this._soundPlayers.has(soundPlayer)) { | ||
this._soundPlayers.add(soundPlayer); | ||
this._effects.forEach(effect => effect.update()); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
src/effects/EffectChain.js
Outdated
@@ -0,0 +1,74 @@ | |||
class EffectChain { | |||
constructor (audioEngine) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
src/effects/EffectChain.js
Outdated
} else if ('soundEffects' in target && effect.name in target.soundEffects) { | ||
effect.set(target.soundEffects[effect.name]); | ||
} else { | ||
effect.set(effect.DEFAULT_VALUE); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
src/effects/EffectChain.js
Outdated
this._effects.reduceRight((nextNode, effect) => { | ||
effect.connect(nextNode); | ||
return effect; | ||
}, this.audioEngine); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
src/SoundBank.js
Outdated
|
||
getSoundEffects (sound) { | ||
if (!this.soundEffects.has(sound)) { | ||
this.soundEffects.set(sound, new EffectsChain(this.audioEngine)); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
66ed7c8
to
f8dc285
Compare
src/SoundBank.js
Outdated
effects.setEffectsFromTarget(target); | ||
effects.addSoundPlayer(player); | ||
|
||
player.connect(effects); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
- EffectChain knows of audioEngine so it can create Effects - EffectChain connects to the target specified by .connect(target) - EffectChain can connect to other Effects or EffectChains - EffectChain can clone itself and connect to the original's target - Add EffectChain.update to mirror Effects API - Use deepest setting first in setEffectsFromTarget
- SoundBank may not create SoundPlayers (but it can call .take if need) - All SoundPlayers SoundBank plays are given to it
24995f4
to
7089b76
Compare
src/effects/EffectChain.js
Outdated
|
||
this.target = target; | ||
|
||
firstEffect.connect(target); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
The first created Effect is closest to the input. The last is closest to the output.
09d0729
to
669ac5f
Compare
(just up for ease of communication, this is purely a first draft right now)