Skip to content

Ambisonic setup skipped when replaying an already-playing sound #70

Description

@ctoth

Summary

Ambisonic/positional-FOA spatialization is set up only inside the if (!sound.isPlaying) branch, so replaying an already-playing key with upmix: "ambisonic" never gets a spatial renderer and stays flat until a follow-up Update.

Details

src/audio/MediaService.ts:332-354 — the whole if (data.upmix === 'ambisonic') block sits inside if (!sound.isPlaying):

if (!sound.isPlaying) {
  const [playback] = sound.play({...});
  ...
  if (data.upmix === 'ambisonic') {
    const inputChannels = this.resolveAmbisonicInputChannels(sound, data);
    const target = await this.resolveAmbisonicTarget(sound, soundKey, data);
    if (inputChannels === 4) { await this.configureAmbisonicPlayback(...); }
    else { await this.configurePositionalFoa(...); }
  }
}

If play() is called for a key whose sound is already playing, the outer guard is false and the ambisonic setup is skipped entirely, so the sound remains non-spatialized. Only a subsequent Update (:384-391) recovers it.

Fix direction

Move the upmix === 'ambisonic' setup out of the !sound.isPlaying guard, or (re)apply the renderer whenever the payload requests ambisonic regardless of current play state.

Verification

Read src/audio/MediaService.ts (play) end to end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions