frondeus / fvtt-syrin-control

Syrinscape Online Control plugin for FoundryVTT
MIT License
13 stars 4 forks source link

Same sound plays when player moves from one ambient sound area to another even though different soundset-mood is configured #115

Closed johnwhobbs closed 7 months ago

johnwhobbs commented 7 months ago

Describe the bug

The same sound plays when a player moves from one ambient sound area to another even though different soundset-mood is confgured for each

To Reproduce

  1. Select Playlist tab in Foundry
  2. Click on previously imported Syrinscape soundset
  3. Drag one Syrinscape sound from soundset onto scene
  4. Click "Create Ambient Sound"
  5. Drag a different Syrinscape sound from soundset onto a different area of the scene
  6. Click "Create Ambient Sound"
  7. Move a player token into the first Ambient Sound area. Correct sound plays
  8. Move player token out of the first Ambient Sound area, but not in the second Ambient Sound area. Sound stops playing
  9. Move player token into the second Ambient Sound area. The sound from the first Ambient Sound area plays instead of the one selected from step 5

Expected behavior

As player token moves into different Ambient Sound areas, the correct sound will play

Screenshots 2024-01-20

Details

Logs

Paste logs here.

Additional context

frondeus commented 7 months ago

I noticed that too recently - even though I haven't change a line of code in months. I will have to properly debug it

frondeus commented 7 months ago

Okay, that has to be a recent change on the Foundry side - now, the foundry made an optimization, where if there are two ambient sounds with the same path to the same file (lets say battle-music.wav), then it will be treated as one ambient sound in two different places.

now, SyrinControl does not depend on the music file, but because I had to put in this field something (otherwise sound is not correct), I put everywhere fake syrinscape.wav.

The problem is, because of this recent change in the Foundry, now there are two ambient sounds pointing to the same fake syrinscape.wav and that messes up with Foundry logic.

Solution: I will replace syrinscape.wav with syrinscape-mood-${moodId}.wav and syrinscape-element-${elementId}.wav.

Ofcourse that means, I have to write a migration for all ambient sounds in all scenes :)

PS. I'm pretty sure it is a recent change so it should work in one of the previous versions - but it is hard for me to pinpoint exactly which one since it requires downloading dosens of FoundryVTT.zip.

johnwhobbs commented 7 months ago

I also noticed that when using syrinscape:mood:id.wav like shown in your ambient sounds screenshot, there is a CORS error when it is trying to access the WAV file.

Access to audio at 'syrinscape:mood:47399.wav' from origin 'local foundry site' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome-untrusted, https, edge.

If it is helpful, I can download versions and pinpoint which one the change happened.

frondeus commented 7 months ago

The screenshot probably need an upgrade. In fact, I already had a migration that was migrating from syrinscape:mood:47399.wav into syrinscape.wav just because some users were confused by it and thought: "oh, I can just modify the number, right?" - and the answer is - not really :)

So maybe instead I should use some kind of quick hashing algorithm that for ambients sound "mood, 47399" would generate a deterministic but non-human-readable syrinscape:cdratu57eh.wav - something that would be still "unique", not that confusing and yet it there are two ambient sounds pointing to the same mood, both of them would have the same syrinscape:cdratu57eh.wav...

If it is helpful, I can download versions and pinpoint which one the change happened.

That in fact could help, at least we could inform users not to upgrade foundry/downgrade it.

frondeus commented 7 months ago

I released a new version of SyrinControl, that at least on my computer resolved the issue :)

johnwhobbs commented 7 months ago

Works perfectly. Thank you!!!!!!