Like I formulated in the topic, my question is, if there is a way to get the time position of the playhead within a programmer instrument (not the Timeline of the Event!)?
It gets even a bit more complicated: The programmer instrument, containing voice lines for dialogs, is running in async mode.
To get the playback position of any underlying sounds, rather than the Timeline position of the Event, you would need to drill down into the EventInstance
’s ChannelGroup
object using Studio.EventInstance.getChannelGroup
, iterate over it’s contained Channel
objects with ChannelGroup.getNumChannels
and ChannelGroup.getChannel, and with each iteration call Channel.getPosition
to get the current playback position of each Channel
.
This should work the same with programmer sounds, but you will need to wait until the sound is started and the Channel
is ready before doing anything.
Cool, that seems to work.
One more challenge: Is there a way to set the playhead within a programmer instrument?
I think the programmers try to construct a workflow for “scrubbing” audio in the Unreal-Engine Sequencer-Tool. (We know, by default scrubbing is not possible!)
Oh and a follow-up question: Does that work with async sounds?
You can also call Channel.setPosition
on a playing channel and that should set the playback position.
And yes it should still work with Async sounds.
We tried that, but it seems the audio file is always playing from the start position.
It seems to be working fine for me. Here is a basic example of how to set the position of a playing programmer sound:
if (programmerSoundInstance->isValid())
{
FMOD::ChannelGroup *cg;
if (programmerSoundInstance->getChannelGroup(&cg) == FMOD_OK)
{
int nGroups;
cg->getNumGroups(&nGroups);
int numChan;
FMOD::ChannelGroup *subGroup;
auto r = cg->getGroup(0, &subGroup);
ERRCHECK(r);
subGroup->getNumChannels(&numChan);
if (numChan > 0)
{
FMOD::Channel *chan;
subGroup->getChannel(0, &chan);
chan->setPosition(1000, FMOD_TIMEUNIT_MS);
}
}
}