Git Product home page Git Product logo

Comments (7)

yrk06 avatar yrk06 commented on July 21, 2024 1

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

from godot-fmod-integration.

diegodelarocha avatar diegodelarocha commented on July 21, 2024

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

from godot-fmod-integration.

heraldofgargos avatar heraldofgargos commented on July 21, 2024

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.

from godot-fmod-integration.

diegodelarocha avatar diegodelarocha commented on July 21, 2024

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

from godot-fmod-integration.

heraldofgargos avatar heraldofgargos commented on July 21, 2024

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()

from godot-fmod-integration.

diegodelarocha avatar diegodelarocha commented on July 21, 2024

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? ๐Ÿ˜ฎ

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)

from godot-fmod-integration.

diegodelarocha avatar diegodelarocha commented on July 21, 2024

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 ๐Ÿ’œ

from godot-fmod-integration.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.