Skip to content

Add getDSPClock() method and ChannelGroup class#435

Open
AleMax wants to merge 2 commits into
utopia-rise:masterfrom
AleMax:dsp-clock
Open

Add getDSPClock() method and ChannelGroup class#435
AleMax wants to merge 2 commits into
utopia-rise:masterfrom
AleMax:dsp-clock

Conversation

@AleMax

@AleMax AleMax commented Mar 31, 2026

Copy link
Copy Markdown

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)

@AleMax AleMax changed the title Added getDSPClock() method and ChannelGroup class Add getDSPClock() method and ChannelGroup class Mar 31, 2026
@CedNaru CedNaru requested review from CedNaru, Copilot and piiertho April 27, 2026 09:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 FmodChannelGroup class with get_dsp_clock() and get_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.

Comment thread src/core/fmod_channel_group.h
Comment thread src/studio/fmod_event.cpp
FMOD::ChannelGroup* channel_group = nullptr;
ERROR_CHECK_WITH_REASON(_wrapped->getChannelGroup(&channel_group), vformat("Cannot get ChannelGroup"));

if (channel_group) {

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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));
}

Copilot uses AI. Check for mistakes.
Comment thread src/core/fmod_channel_group.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants