Thanks for providing your script.
After some testing, potential issues with interval/beat timing calculations aside, it’s likely that setDelay
isn’t being called on the correct Channel
/ChannelGroup
, as I’m able to use it to schedule while also setting the instance’s timeline position without any issues on my end.
I’m not sure on the exact structure of your event, so I’ll go over each possible situation - apologies for the wall of text.
Keeping in mind the following:
- Each audio track in Studio corresponds to a Core API
ChannelGroup
- In an event, (by default) all non-master audio tracks/
ChannelGroup
s route directly into the master audio track/ChannelGroup
- Each instrument playing an asset in Studio is, in the Core API, a
Channel
playing a Sound
If you want to use setDelay
to start/stop an entire event, you can call it directly on the top level ChannelGroup
you retrieve from EventInstance.getChannelGroup()
, which will set the start/stop time for all child Channels
and ChannelGroups
:
instance.getChannelGroup(out FMOD.ChannelGroup channelGroup);
channelGroup.setDelay(nextQuantizedStartTime, nextQuantizedStopTime, true);
If you want to use setDelay
to pause a specific audio track, you’ll need to get its corresponding ChannelGroup
from the Event’s top level ChannelGroup
with ChannelGroup, and call
setDelay` on it:
instance.getChannelGroup(out FMOD.ChannelGroup channelGroup);
// Assuming group 0 is the group we want
channelGroup.getGroup(0, out FMOD.ChannelGroup subChannelGroup);
subChannelGroup.setDelay(nextQuantizedStartTime, nextQuantizedStopTime, true);
If you want to pause a specific instrument, you’ll need to get its specific corresponding Channel
from the audio track’s ChannelGroup
:
```C#
instance.getChannelGroup(out FMOD.ChannelGroup channelGroup);
// Assuming group 0 is the group we want
channelGroup.getGroup(0, out FMOD.ChannelGroup subChannelGroup);
// Assuming channel 0 is the channel we want
subChannelGroup.getChannel(0, out FMOD.Channel channel);
channel.setDelay(nextQuantizedStartTime, nextQuantizedStopTime, true);
As it is right now, your script assumes that the playing instrument is located on the master audio track, and if it isn’t, then the setDelay
call wont work the way you want it to. At minimum, if you want to confirm that your start/stop time calculations are correct and that setDelay
does it fact work, it would be easiest to call setDelay
on the event’s top level ChannelGroup
and see whether the whole instance starts and stops at the quantized times.