heraldofgargos / godot-fmod-integration

FMOD Studio middleware integration and scripting API bindings for the Godot game engine.
MIT License
177 stars 13 forks source link

Sound System:`File not found` on export project -MacOS #27

Open diegodelarocha opened 4 years ago

diegodelarocha commented 4 years ago

Describe the bug

After compiling on 3.2 stable Godot with this integration, I'm trying to export a MacOS .dmg of the example project included on the repository, and I get the following message on the terminal:

FMOD Sound System: Live update enabled!
FMOD Sound System: File not found.
FMOD Sound System: File not found.
FMOD Sound System: The requested event, parameter, bus or vca could not be found.
FMOD Sound System: The requested event, parameter, bus or vca could not be found.

The game graphics and logic runs well, but no sound is playing.

To Reproduce Steps to reproduce the behavior:

  1. I'm adding a screenshot of the export settings I'm using

Expected behavior The sound files are likely not getting exported with the app? Hoping Godot exports the FMOD files into the app.

Screenshots

Screen Shot 2020-02-19 at 4 15 49 PM

Configuration

Additional context Maybe I'm just missing to add a specific path somewhere? Or do an extra step for Godot to see the Banks files

diegodelarocha commented 4 years ago

I've checked the package that gets exported to make sure the *.bank files are included, and they are on the file structure, so I'm left thinking that it really is either an option I'm missing or something to do with the code of it?

Screen Shot 2020-02-20 at 9 00 39 AM Screen Shot 2020-02-20 at 9 00 50 AM
heraldofgargos commented 4 years ago

Hey there! Thanks for submitting this issue.

It seems like it wasn't able to find the bank files. Basically, the bank files should not be packed into the .PCK file that Godot generates when building. This is because they are not considered to be "resources". They should be placed in a folder relative to your runnable binary so that the FMOD runtime is able to read them.

Can you try experimenting with the path string that's currently being passed to the load_banks call? (Check FMOD.gd autoload script). Unfortunately, I can't really test it out for myself because at the moment I don't use macOS on a day to day basis.

diegodelarocha commented 4 years ago

Hi there Alex!

Thanks for your answer, that makes sense, I tested breaking the path on the FMOD.gd singleton, and that did spit out the same error on the console inside the editor, so it seems to be definitely on the path of that file.

Unfortunately I've tried placing the Bank files with folders and without (changing the path on the singleton script every time to direct to it) but haven't had any luck.

I'm attaching screenshots of how the folder structure of a Mac .app looks like if that might help you debug, I'd love to help solve this if you can give me more guidance or ideas of how to solve it πŸ€“

I experimented adding the folders/banks inside all the folders Contents, Contents/Frameworks, Contents/MacOs, Contents/Resources`, I even tried making an export template that includes the files on those paths, and also tried putting the application file next to the bank files on the desktop and non of them worked 😭

Do you have another idea of what it might be, or how we can solve it? I feel that you're right on editing that path, but just can't figure out where to place it😬

Also, the path string starts with a dot, what does that mean, is it like force looking for files that aren't Godot files? "."

Let me know if I can help on at all, and thank you for all your work on this so far πŸ™

Screen Shot 2020-03-02 at 10 56 15 AM Screen Shot 2020-03-02 at 10 56 20 AM Screen Shot 2020-03-02 at 10 56 25 AM
heraldofgargos commented 4 years ago

The dot means it is a path relative to the current directory (i.e. project). Can you try using the absolute path to the bank files? You should be able to get the path by right clicking on them in Finder.

You can hard code them into the load_banks call to test if it works. You still need the relative path when shipping your game however. Use the Godot Directory API to get the full path instead.

var dir = Directory.new()
dir.open("./")
var absolute_path = dir.get_current_dir()
diegodelarocha commented 4 years ago

Thanks a lot Alex!

Hard coding the paths into the load_banks call to test worked πŸ’œ!

Then, I tried your approach of using Godot's Directory API, and when using it inside the editor it worked, it found my project (for this case is /Users/[username]/Desktop/demo), and loaded the banks πŸ’œπŸ’œ

However, when testing with an exported binary it didn't work πŸ’”πŸ’”πŸ’”πŸ˜­. When I do a print(absolute_path) it spits out /Users/[username] on the terminal, instead of res:// or /Users/[username]/Desktop/demo Do you have an idea how should we approach this? :open_mouth:

I tried adding some referenced files to the /Users/[username] path, and it did read them from the binary, so your code is working, but it's setting the relative path of./ to /Users/[username] instead of res:// or /Users/[username]/Desktop/demo.

I'm adding the code from the singleton if that helps at all:

func _ready():

    #Get full path from relative path directory using Godot's Directory API
    var dir_bank = Directory.new()
    dir_bank.open("./")
    var absolute_path = dir_bank.get_current_dir()
    print(absolute_path)

    # set up FMOD 
    Fmod.system_set_software_format(0, Fmod.FMOD_SPEAKERMODE_STEREO, 0)
    Fmod.system_init(1024, Fmod.FMOD_STUDIO_INIT_LIVEUPDATE, Fmod.FMOD_INIT_VOL0_BECOMES_VIRTUAL)

    # load banks
    Fmod.bank_load(absolute_path + "/Banks/Desktop/Master.strings.bank", Fmod.FMOD_STUDIO_LOAD_BANK_NORMAL)
    Fmod.bank_load(absolute_path + "/Banks/Desktop/Master.bank", Fmod.FMOD_STUDIO_LOAD_BANK_NORMAL)
yrk06 commented 3 years ago

I found a solution for this issue while working on a project of mine.

It seems that MacOS doesn't have a difference between a relative path or a global path (I have very little experience with MacOS, but from what I tested, this seems to be the case) so each time, FMOD was trying to load my banks from folder at my hard drive root /Sound/<bank names> instead of the /Sound/<bank> inside my game package. After some trial and error, I wrote this code:

if OS.get_name() == "OSX":
    print('MacOS')
    var basePath = OS.get_executable_path().get_base_dir() + "/Sound/"
    Fmod.load_bank(basePath+"Master.strings.bank", Fmod.FMOD_STUDIO_LOAD_BANK_NORMAL)
    Fmod.load_bank(basePath+"Master.bank", Fmod.FMOD_STUDIO_LOAD_BANK_NORMAL)

If the game is running on a MacOS, I can get the executable folder from OS.get_executable_path().get_base_dir(), this folder is: mygame.app/contents/MacOS/ which means that I could place my banks anywhere on the mygame.app/contents and use paths relative from the executable folder. But I decided to make it easier for me and place my banks on mygame.app/contents/MacOS/Sound/<.bank>

This issue seems to be more related to how MacOS file system works rather than the actual FMOD plugin

I would suggest for the GDNative library to automatically add OS.get_executable_path().get_base_dir() to the path when trying to load banks in a MacOS system, this would (just like in windows) make so that the path the user tries to load is relative to the program executable on any OS

edit: Color on the code and better readability

diegodelarocha commented 3 years ago

Ooh thank you so much for this!! <3 I won't have time to test this in months likely, but I'm very excited to test it out whenever I get the time and energy πŸ’œ