-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event can't be found, followed by crash when calling create_event_instance(...) #230
Comments
Hello, Now I have to clear up some misconceptions here (probably our fault with the documentation). Now you mentionned that your only Fmod related code is var event: FmodEvent = null
func _ready() -> void:
event = FmodServer.create_event_instance("event:/Spell_Impact") This won't work because you need to load the banks first. "auto initialize" will only start FMOD but won't load the banks for you, even if you have set the bank path. This path is only used by the editor for the Event explorer so far. We should probably add a "Load banks automatically" feature at some point. |
@CedNaru Thanks for that reply, it helps to clarify things a lot. I'm still running into some troubles loading the banks, however. When the first call to var event: FmodEvent = null
func _ready() -> void:
FmodServer.load_bank("bank:/Master.strings", FmodServer.FMOD_STUDIO_LOAD_BANK_NORMAL)
FmodServer.load_bank("bank:/Master", FmodServer.FMOD_STUDIO_LOAD_BANK_NORMAL)
FmodServer.load_bank("bank:/SFX", FmodServer.FMOD_STUDIO_LOAD_BANK_NORMAL)
event = FmodServer.create_event_instance("event:/Spell_Impact") A couple notes additional notes:
WARNING: FMOD Sound System: No listeners are set!void __cdecl godot::FmodServer::_set_listener_attributes(void)src\fmod_serve1
at: push_warning (core/variant/variant_utility.cpp:1112) My personal preference is to use the low-level API as much as possible to avoid scattering nodes around my scene-tree (although if this is the intended way to use the plugin, I'm not averse to using the high-level nodes). Is my updated code above sufficient to load the banks and create an event? I'm essentially just trying to reach a point where I can click a button and have a sound play. "Auto-initialize" is enabled in my FMOD project settings, so I shouldn't need to call those other initializer/setup functions from the sounds of it. I'm not sure if the crash is plugin-related, or if I've just missed another step in my code somewhere. |
You don't need to worry about the listener warning. You should be able to hear sound even without a listener set, it's just that you won't be able to have any "spatialization" of the sounds played because you need some entity with a position registered to FMOD. Regarding the bank loading, it should be enough, but you made an error, you are supposed to provide a path to the bank files in a Godot way, using the regular "res://path/to/your/bank" |
Whoops - not sure how I missed that! I fixed my paths, and now everything seems to be working. Thanks again for the help, much appreciated! I would consider this issue closed/resolved (not an issue). |
I'll keep it open until we clarify the documentation on that matter. |
@CedNaru Speaking of documentation, it may be worthwhile having a section on best practices concerning proper memory management as well. I'm also noticing some questionable signs from Godot's memory profiler when I create new Event instances. Essentially, I have a UI element (a PanelContainer in this case, which is acting as a button) which plays a sound when clicked. The code is roughly as follows: extends PanelContainer
# FMOD banks have already been loaded elsewhere in the project
var audio_event: FmodEvent = null
func _gui_input(event) -> void:
# Handle the click event for this UI control, playing a sound when clicked
if event is InputEventMouseButton and event.pressed:
if event.button_index == MOUSE_BUTTON_LEFT:
audio_event = FmodServer.create_event_instance("event:/Spell_Impact")
audio_event.start()
audio_event.release() When I profile the static memory, the cost of each "click" appears to be roughly 400 bytes. My understanding is that this FMOD Plugin uses RefCounted objects, which should be free'd when the objects go out of scope, however, I'm not familiar enough with Godot's internals to know when this happens or how it occurs. My PanelContainer will probably never be removed from the scene-tree, as it's a static part of the game UI. From what I can tell, calling fmod-gdextension/src/fmod_server.h Lines 275 to 289 in 15908f2
I can see from the template above, that the EventInstance is created, along with a I'm not 100% sure if this is correct, of if I'm misunderstanding how Godot handles the cleaning-up of these |
I have never investigated the memory usage of the plugin to be honest. But when it comes to Godot itself, the simple way to see RefCounted instance is that if you don't have any reference to it in your code, it's going to be automatically freed. Like the name implies, it's using a counter, not some kind of GC, so the memory should be freed immediately. |
You raise a good point about the difference between debug and release builds, and the built-in tracking. I'll probably file this memory issue away for now, and make a mental note to profile the memory once I have a release build candidate so that I don't waste time on early optimization. Thanks again! |
I'm still trying to get the plugin to work on the latest Godot build v4.3.beta2.official, but am running into various issues. I'm not sure if this is a user-error on my part, or an error related to the plugin itself.
For starters, I am able to view my banks in the Fmod Explorer. Note the "Spell_Impact" event under my SFX Bank. I can play this sound successfully with the "Play" button in this screenshot:
When this code runs, I get the following warning:
Immediately following this warning, the game crashes with the following console backtrace:
I'm still a bit unclear about the intended use of high-level nodes, versus low-level API (are they intended to be mix-and-matched?), as well as the seemingly different ways that the low-level API is used in the examples provided (with some of the examples calling
set_software_format
,init
andset_sound_3d_settings
before callingload_bank
, and other examples not doing this). Moreover, some of these examples seem to be outdated in that the expected arguments don't line up with the arguments provided in the example code.Example from the user-guide:
Whereas the latest FMOD GDExtension (4.2.0-4.2.0) release expects
set_software_format()
to be provided settings in the form of anFmodSoftwareFormatSettings
object.Have I failed to set up this plugin correctly? Am I missing something obvious? I've followed the instructions in the user-guide for this plugin, but can't seem to get it working. Any help would be greatly appreciated!
System / Build information:
Windows 11 Pro (x64)
Godot v4.3.beta2.official [b75f0485b]
FMOD GDExtension (4.2.0-4.2.0 [1d3d7f5])
The text was updated successfully, but these errors were encountered: