Skip to content
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

Merged

Conversation

gnarf
Copy link
Contributor

@gnarf gnarf commented Jun 15, 2018

(just up for ease of communication, this is purely a first draft right now)

src/SoundBank.js Outdated

stop (target, soundId) {
if (this.playerTargets.get(soundId) === target) {
this.soundPlayers[soundId].stop();

This comment was marked as abuse.

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.

src/SoundBank.js Outdated

class SoundBank {
constructor (audioEngine) {
this.audioEngine = audioEngine;

This comment was marked as abuse.

This comment was marked as abuse.

addSoundPlayer (soundPlayer) {
if (!this._soundPlayers.has(soundPlayer)) {
this._soundPlayers.add(soundPlayer);
this._effects.forEach(effect => effect.update());

This comment was marked as abuse.

@@ -0,0 +1,74 @@
class EffectChain {
constructor (audioEngine) {

This comment was marked as abuse.

} 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.

this._effects.reduceRight((nextNode, effect) => {
effect.connect(nextNode);
return effect;
}, this.audioEngine);

This comment was marked as abuse.

This comment was marked as abuse.

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.

@thisandagain thisandagain added this to the June 2018 milestone Jun 18, 2018
@gnarf gnarf changed the title [WIP] SoundBank SoundBank Jun 20, 2018
@gnarf gnarf changed the base branch from develop to green-audio-player June 20, 2018 19:17
src/SoundBank.js Outdated
effects.setEffectsFromTarget(target);
effects.addSoundPlayer(player);

player.connect(effects);

This comment was marked as abuse.

@mzgoddard mzgoddard mentioned this pull request Jun 20, 2018
2 tasks
gnarf and others added 8 commits June 21, 2018 14:40
- 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

this.target = target;

firstEffect.connect(target);

This comment was marked as abuse.

The first created Effect is closest to the input. The last is closest
to the output.
@mzgoddard mzgoddard merged commit 98eb914 into scratchfoundation:green-audio-player Jun 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants