# Adaptive music parameters question

**URL:** <https://qa.fmod.com/t/adaptive-music-parameters-question/19266>\
**Category:** FMOD Studio\
**Created:** [September 12, 2022, 10:40am UTC](https://qa.fmod.com/t/adaptive-music-parameters-question/19266 "2022-09-12T10:40:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![komornik11](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@komornik11](https://qa.fmod.com/u/komornik11)\
**Post date:** [September 12, 2022, 10:40am UTC](https://qa.fmod.com/t/adaptive-music-parameters-question/19266/1 "2022-09-12T10:40:25Z")

</div>

Hey! Is there any way to play music track, after parameter changes, from the specific beat (or time)?

example:

Track no.1 playing. At the 6th beat the parameter (triggered by player hit the collider for example) changing music to track no.2.  
Is it possible, when the parameter goes back to track no.1, to play from the 6th beat instead of begining of the track?

Kindest regards!

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [September 14, 2022, 6:54am UTC](https://qa.fmod.com/t/adaptive-music-parameters-question/19266/2 "2022-09-14T06:54:05Z")

</div>

Hi,

Yes, this can be done using `Channels` and `Channel Groups`. Further explained under [Core API Reference | Channels](https://fmod.com/docs/2.02/api/core-api-channel.html) and [Core API Reference | ChannelGroup](https://fmod.com/docs/2.02/api/core-api-channelgroup.html) respectively.

To retrieve the `channel` and `channelgroup` follow this example.

> **Return channel**
>
> ```auto
> private FMOD.RESULT ReturnEventChannel(FMODUnity.StudioEventEmitter eventEmitter, out FMOD.Channel requestedChannel, out FMOD.ChannelGroup channelsGroup)
> {
> requestedChannel = new FMOD.Channel();
> channelsGroup = new FMOD.ChannelGroup();
> 
> FMOD.RESULT result = eventEmitter.EventInstance.getChannelGroup(out FMOD.ChannelGroup newgroup);
> 
> //Checking at every step if there is an error which will return a invalid result 
> if (result != FMOD.RESULT.OK)
> {
> Debug.Log("Failed to retrieeve parent channel group with error: " + result);
> return result;
> }
> 
> result = newgroup.getGroup(0, out channelsGroup);
> 
> if (result != FMOD.RESULT.OK)
> {
> Debug.Log("Attmpeting with parent group");
> result = newgroup.getChannel(0, out requestedChannel); 
> 
> if (result != FMOD.RESULT.OK)
> {
> Debug.Log("Failed with parent group");
> return result; 
> }
> else
> {
> Debug.Log("Retrieved channel");
> return result; 
> }
> //return result;
> }
> 
> result = channelsGroup.getChannel(0, out requestedChannel);
> 
> if (result == FMOD.RESULT.OK)
> {
> Debug.Log("Retrieved the correct channel");
> return result;
> }
> else
> {
> Debug.Log("Failed to find the right channel with error: " + result);
> return result;
> }
> }
> 
> ```

Now when the player hits the collider, you will want to use [channel.getPosition().](https://fmod.com/docs/2.02/api/core-api-channel.html#channel_getposition) This will allow us to cache the playback position of the current sound. Before we transition to the next sound, we will want to call [FMODUnity.RuntimeManager.StudioSystem.flushCommands()](https://fmod.com/docs/2.02/api/studio-api-system.html#studio_system_flushcommands) and [FMODUnity.RuntimeManager.StudioSystem.flushSampleLoading()](https://fmod.com/docs/2.02/api/studio-api-system.html#studio_system_getadvancedsettings). These will block the calling thread to make sure there isn’t any lag when we to swap to the new sound.  
When the parameter is updated, set the cached playback position of the new sound using [channel.setPosition()](https://fmod.com/docs/2.02/api/core-api-channel.html#channel_setposition).

Hope this helps!
