How do I play events from Studio banks? #55
|
Hi! I have little experience with FMOD (I only managed to get it working on unity with the official plugin) and I am trying to integrate an adaptive music system (using FMOD Studio) into my pygame project. While testing out the binding, I got the example code that plays an mp3 file working (using I had read that FMOD's engine libraries are split into a core version (that manages low level audio) and a studio version (which includes core functionality as well as support for Studio events and parameters), and since the README mentions setting the path to the studio DLL, I figured pyfmodex could handle events from FMOD Studio .bank files, but I couldn't find any mention of banks in the documentation. I tried looking into the other DLL, but setting the path to the file in my project folder using Is it possible to load banks, play events and modify parameters with this binding? |
Replies: 2 comments
|
That's weird, the path override looks correct, maybe it was done late? And, yes, setting parameters and playing events should work, see the code for what's implemented so far. |
|
After a few hours of hitting my head against a wall I managed to put together a working "bare minimum" script that plays an event. I hope this is useful to someone else. It is purely empirical, though. Project Structure├── fmod.dll main.pyimport os
os.environ["PYFMODEX_STUDIO_DLL_PATH"] = f"{os. getcwd()}/fmodstudio.dll"
# The other dll (fmod.dll) is not required to be on the path. However, and I have no clue why,
# both dll's MUST be on the project folder, otherwise the next line breaks.
import pyfmodex.studio
system = pyfmodex.studio.StudioSystem()
system.initialize()
# Boilerplate
bank = system.load_bank_file("Master.bank")
# Loads the events from the bank file
system.load_bank_file("Master.strings.bank")
# Allows those events to be identified by keys instead of their GUID or something
music_reference = system.get_event("event:/music")
# Creates an event reference by looking up "event:/music" in the Strings bank
music_instance = music_reference.create_instance()
# Creates an instance of the "event:/music" event
music_instance.start()
# You'll never guess what this line does
while True:
system.update()
# This is required to run every tick. Otherwise, the event gets stuck on the STARTING playback state
# This can be verified with print(f"playback state is {music_instance.playback_state}")Thank you for making this! 😁 |
That's weird, the path override looks correct, maybe it was done late? And, yes, setting parameters and playing events should work, see the code for what's implemented so far.