dapetcu21 / defold-fmod

FMOD bindings for Defold
Other
27 stars 7 forks source link

What should load_bank_file path be like for HTML5 builds? #23

Closed subsoap closed 3 years ago

subsoap commented 5 years ago

I have tried a few variations like "./assets/banks/master.bank"

bank1 = "assets/banks/master.bank"
fmod.studio.system:load_bank_file(bank1, fmod.STUDIO_LOAD_BANK_NORMAL)

path

The bank file is there, it can be downloaded.

2019-08-31 04_40_55-Downloads

dapetcu21 commented 5 years ago

For HTML5, you should probably put them in custom_resources and load them with load_bank_memory.

dapetcu21 commented 5 years ago

load_bank_file will load from the emscripten emulated file system. If you place them in bundled_resources, you'll have to download them yourself with JS and then load them with load_bank_memory. I think load_bank_memory takes either dmBuffers or plain Lua strings with data. Or just put them in custom_resources and load them with resource.load()

subsoap commented 5 years ago

I wish Defold made platform specific stuff like this easier to do...

For science I tested making the link absolute and it also didn't work but did give a different error.

2019-08-31 04_45_26-Faerie Solitaire Harvest Free 1 1 19 8 24b

subsoap commented 5 years ago

Or just put them in custom_resources and load them with resource.load()

How should this be done after? With fmod.studio.system:load_bank_memory or?

dapetcu21 commented 5 years ago

Yeah. Look at the example. The banks there are loaded with resource.load()

subsoap commented 5 years ago

Switched over to load_bank_memory + resource.load + custom resources

2019-08-31 05_02_33-Faerie Solitaire Harvest Free 1 1 19 8 24b

ERROR:SCRIPT: A requested output, dsp unit type or codec was not available.

The same setup works on Windows while testing. Any way to get specific info on the error?

dapetcu21 commented 5 years ago

That's all the specific info there is. Check your bank export settings for the HTML5 banks. Maybe Chrome doesn't support the codec you're trying to use.

subsoap commented 5 years ago

Could these be an issue?

2019-08-31 05_16_36-harvest-free fspro - Event Editor 2019-08-31 05_16_20-harvest-free fspro - Event Editor

Do you mean these settings?

2019-08-31 05_18_46-Preferences

dapetcu21 commented 5 years ago

I don't know. We didn't touch the encoding settings in our project and it works. Do you have this in you game.project:?

[fmod]
speaker_mode = stereo
subsoap commented 5 years ago

Yes

2019-08-31 05_26_06-Faerie Solitaire Harvest Free - Defold Editor 2 0

The only other effect is

2019-08-31 05_25_37-harvest-free2 fspro_ - Event Editor

I'm testing removing everything from a copy of the project to see if it works then.

dapetcu21 commented 5 years ago

Our DSP chains are way more complicated than yours, so I don't think that should be the problem. But who knows, maybe HTML doesn't support all DSP types.

subsoap commented 5 years ago

Could you post your encoding settings?

subsoap commented 5 years ago

It works now so it must have been one of those things. Maybe the Multiband EQ?

2019-08-31 05_32_22-Faerie Solitaire Harvest Free 1 1 19 8 24b

subsoap commented 5 years ago

I accidentally deleted my "free" version of fmod project which I wasn't versioning... so I'll have to remake it later but I will try and test this later more too to figure out the exact cause of issue.

subsoap commented 5 years ago

Audio glitches / hangs same as playing audio from the engine whenever doing stuff. Must be because of the way the extension is built with the engine? So whenever the engine is busy doing something it makes the audio stop playing for a moment / repeat frames.

dapetcu21 commented 5 years ago

It’s because there are no threads in JS, so audio processing must be done on the main thread in the update loop along with the rest of the engine’s work. This means that when the game is lagging, fmod doesn’t have the chance to fill up audio buffers and they underrun. There’s no good solution to this. You can try increasing the audio buffer size, though (The extension already makes them larger on HTML5 by default). Don’t know the fmod function by heart, but look through their platform-specific getting started manuals and you’ll find it there. On 1 Sep 2019, 04:15 +0300, Brian notifications@github.com, wrote:

Audio glitches / hangs same as playing audio from the engine whenever doing stuff. Must be because of the way the extension is built with the engine? So whenever the engine is busy doing something it makes the audio stop playing for a moment / repeat frames. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

subsoap commented 5 years ago

This I think?

https://github.com/dapetcu21/defold-fmod/blob/master/bridge/src/fmod_init.c#L92

According to docs it has to be set before init so cannot be changed at runtime.

webasm should have threads on modern browsers but I'd guess that's not enabled / easy to use.

subsoap commented 4 years ago
ERROR:SCRIPT: A requested output, dsp unit type or codec was not available.

Had to visit this again, this error was caused by Multiband EQ and Pitch Shifter I think. To solve it I played the sound in FMOD Studio and recorded it in Audacity, then replaced that setup with the recorded audio.

subsoap commented 4 years ago

Could you help with loading the bank directly and not including it in the game archive?

https://www.solitaire.io/faerie-solitaire-harvest/

When testing FSH from Project -> Build HTML5 audio is pretty good, but the actual bundled version on a server has audio issues. I believe this is because of the bank being in the bundled archive. I've already disabled archive compression and that helps with general loading, but atm it seems clear loading the FMOD bank separately would work better for audio playback.

dapetcu21 commented 4 years ago

I added control over buffer_length and num_buffers (see setDSPBufferSize) from game.project. See if you can mitigate the stutteryness by playing with those numbers. It's set at 2 buffers of 2048 samples each by default on HTML5.

subsoap commented 4 years ago

Cool! Will test soon.