Add getDSPClock() method and ChannelGroup class#435
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a minimal ChannelGroup wrapper to expose FMOD ChannelControl::getDSPClock()-related functionality to Godot scripts, primarily to support retrieving DSP clock timing from a Studio::EventInstance via EventInstance.getChannelGroup().
Changes:
- Added new core
FmodChannelGroupclass withget_dsp_clock()andget_parent_dsp_clock()bindings. - Added
FmodEvent.get_channel_group()method and bound it for scripting use. - Registered the new class in module initialization and fixed a docs typo for the git submodule clone flag.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/studio/fmod_event.h | Exposes get_channel_group() on FmodEvent and includes the new core wrapper. |
| src/studio/fmod_event.cpp | Binds and implements get_channel_group() to return a FmodChannelGroup wrapper. |
| src/register_types.cpp | Registers FmodChannelGroup with Godot’s ClassDB. |
| src/core/fmod_channel_group.h | Introduces FmodChannelGroup wrapper and create_ref() helper. |
| src/core/fmod_channel_group.cpp | Implements/binds DSP clock accessors. |
| docs/src/doc/advanced/1-compiling.md | Fixes --recurse-submodules spelling in docs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| FMOD::ChannelGroup* channel_group = nullptr; | ||
| ERROR_CHECK_WITH_REASON(_wrapped->getChannelGroup(&channel_group), vformat("Cannot get ChannelGroup")); | ||
|
|
||
| if (channel_group) { |
There was a problem hiding this comment.
get_channel_group() currently wraps the returned FMOD::ChannelGroup by always calling FmodChannelGroup::create_ref(channel_group), which (as written) creates a new wrapper each call and overwrites the channel group's userData. To avoid repeated allocations and inconsistent wrapper identity, consider reusing an existing wrapper via channel_group->getUserData() when available.
| if (channel_group) { | |
| if (channel_group) { | |
| void* user_data = nullptr; | |
| ERROR_CHECK_WITH_REASON(channel_group->getUserData(&user_data), vformat("Cannot get ChannelGroup userData")); | |
| if (user_data) { | |
| return Ref<FmodChannelGroup>(static_cast<FmodChannelGroup*>(user_data)); | |
| } |
For a personal project of mine I needed the getDSPClock() function on a ChannelControl in FMOD's core API.
In my use case I had to get this from an EventInstance.getChannelGroup(), which returns a ChannelGroup which inherits ChannelControl's methods.
For this I added a ChannelGroup Class in the core/ subdirectory, which implements only the getDSPClock function that I needed. Anyone is welcome to implement more functions.
I added the getChannelGroup to FmodEvent, so I can retreive a ChannelGroup.
I made this for myself, but I made the PR if there is interest in merging this upstream just in case.
(I also fixed a spelling error in the documentation, this is unrelated to the rest of the PR, sorry for adding this here too)