# FMOD - Callback on Marker in Xcode

**URL:** <https://qa.fmod.com/t/fmod-callback-on-marker-in-xcode/12601>\
**Category:** FMOD Engine\
**Created:** [July 18, 2016, 5:40am UTC](https://qa.fmod.com/t/fmod-callback-on-marker-in-xcode/12601 "2016-07-18T05:40:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![metaphysician](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@metaphysician](https://qa.fmod.com/u/metaphysician)\
**Post date:** [July 18, 2016, 5:40am UTC](https://qa.fmod.com/t/fmod-callback-on-marker-in-xcode/12601/1 "2016-07-18T05:40:54Z")

</div>

hi folks

i’m currently using FMOD on an iOS project and i want to use a callback to determine if the event playing reaches a certain marker. i’ve looked at the music callback example but it shows every type of callback plus bank creation and event triggering. it’s confusing trying to sort out what’s really needed just for this particular callback. can you give a simple example of how to use the FMOD\_STUDIO\_EVENT\_CALLBACK\_TIMELINE\_MARKER without all the extra code?

basically what i want to do is to wait a couple of seconds until the sound is paused before stopping the event. i figure i can do this by checking if the event has encountered a marker on the Timeline but i’m not certain. any help appreciated!

---

<div class="post-metadata">

**Author:** ![graeme](https://avatars.discourse-cdn.com/v4/letter/g/50afbb/32.png) [@graeme](https://qa.fmod.com/u/graeme)\
**Post date:** [July 21, 2016, 5:13am UTC](https://qa.fmod.com/t/fmod-callback-on-marker-in-xcode/12601/2 "2016-07-21T05:13:50Z")

</div>

All you have to do is register your callback using Studio::EventInstance::setCallback…

```
// After creating the event instance, register the marker callback
instance->setCallback(MarkerCallback, FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_MARKER);

```

Then in your callback, just check for type FMOD\_STUDIO\_EVENT\_CALLBACK\_TIMELINE\_MARKER…

```
FMOD_RESULT F_CALLBACK MarkerCallback(FMOD_STUDIO_EVENT_CALLBACK_TYPE type, FMOD_STUDIO_EVENTINSTANCE* event, void* parameters)
{
    // Cast event instance to C++ type
    FMOD::Studio::EventInstance* instance = (FMOD::Studio::EventInstance*)event;

    if (type == FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_MARKER)
    {
        // Stop this instance when it reaches the timeline marker
        instance->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT);
    }

    return FMOD_OK;
}

```

Your callback also receives some info about the name and position of the timeline marker, via the ‘parameters’ argument. Cast this to a pointer to a FMOD\_STUDIO\_TIMELINE\_MARKER\_PROPERTIES structure. For example, if your event has several markers, you could check the name for the one you’re interested in…

```
FMOD_RESULT F_CALLBACK MarkerCallback(FMOD_STUDIO_EVENT_CALLBACK_TYPE type, FMOD_STUDIO_EVENTINSTANCE* event, void* parameters)
{
    // Cast event instance to C++ type
    FMOD::Studio::EventInstance* instance = (FMOD::Studio::EventInstance*)event;

    if (type == FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_MARKER)
    {
        // Obtain the timeline marker properties
        FMOD_STUDIO_TIMELINE_MARKER_PROPERTIES* props = (FMOD_STUDIO_TIMELINE_MARKER_PROPERTIES*)parameters;

        // Stop this instance when it reaches the specially named marker
        if (strcmp(props->name, "Stopper") == 0)
        {
            instance->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT);
        }
    }

    return FMOD_OK;
}

```

The documentation for FMOD\_STUDIO\_EVENT\_CALLBACK\_TYPE has detailed information about how the ‘parameters’ argument works for each callback type:

[http://www.fmod.org/documentation/#content/generated/FMOD\_STUDIO\_EVENT\_CALLBACK\_TYPE.html](http://www.fmod.org/documentation/#content/generated/FMOD_STUDIO_EVENT_CALLBACK_TYPE.html)

---

<div class="post-metadata">

**Author:** ![wandermyz](https://avatars.discourse-cdn.com/v4/letter/w/e5b9ba/32.png) [@wandermyz](https://qa.fmod.com/u/wandermyz)\
**Post date:** [June 20, 2018, 5:59am UTC](https://qa.fmod.com/t/fmod-callback-on-marker-in-xcode/12601/3 "2018-06-20T05:59:46Z")

</div>

> [@](#):
>
> All you have to do is register your callback using Studio::EventInstance::setCallback…
> 
> ```
> // After creating the event instance, register the marker callback
> instance->setCallback(MarkerCallback, FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_MARKER);
> 
> ```
> 
> Then in your callback, just check for type FMOD\_STUDIO\_EVENT\_CALLBACK\_TIMELINE\_MARKER…
> 
> ```
> FMOD_RESULT F_CALLBACK MarkerCallback(FMOD_STUDIO_EVENT_CALLBACK_TYPE type, FMOD_STUDIO_EVENTINSTANCE* event, void* parameters)
> {
> // Cast event instance to C++ type
> FMOD::Studio::EventInstance* instance = (FMOD::Studio::EventInstance*)event;
> 
> if (type == FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_MARKER)
> {
> // Stop this instance when it reaches the timeline marker
> instance->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT);
> }
> 
> return FMOD_OK;
> }
> 
> ```
> 
> Your callback also receives some info about the name and position of the timeline marker, via the ‘parameters’ argument. Cast this to a pointer to a FMOD\_STUDIO\_TIMELINE\_MARKER\_PROPERTIES structure. For example, if your event has several markers, you could check the name for the one you’re interested in…
> 
> ```
> FMOD_RESULT F_CALLBACK MarkerCallback(FMOD_STUDIO_EVENT_CALLBACK_TYPE type, FMOD_STUDIO_EVENTINSTANCE* event, void* parameters)
> {
> // Cast event instance to C++ type
> FMOD::Studio::EventInstance* instance = (FMOD::Studio::EventInstance*)event;
> 
> if (type == FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_MARKER)
> {
> // Obtain the timeline marker properties
> FMOD_STUDIO_TIMELINE_MARKER_PROPERTIES* props = (FMOD_STUDIO_TIMELINE_MARKER_PROPERTIES*)parameters;
> 
> // Stop this instance when it reaches the specially named marker
> if (strcmp(props->name, "Stopper") == 0)
> {
> instance->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT);
> }
> }
> 
> return FMOD_OK;
> }
> 
> ```
> 
> The documentation for FMOD\_STUDIO\_EVENT\_CALLBACK\_TYPE has detailed information about how the ‘parameters’ argument works for each callback type:
> 
> [http://www.fmod.org/documentation/#content/generated/FMOD\_STUDIO\_EVENT\_CALLBACK\_TYPE.html](http://www.fmod.org/documentation/#content/generated/FMOD_STUDIO_EVENT_CALLBACK_TYPE.html)

Could you explain what is a “named marker” and how can I create one at all?

---

<div class="post-metadata">

**Author:** ![richard\_simms](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/richard_simms/32/261_2.png) [@richard\_simms](https://qa.fmod.com/u/richard_simms)\
**Post date:** [June 21, 2018, 4:44am UTC](https://qa.fmod.com/t/fmod-callback-on-marker-in-xcode/12601/4 "2018-06-21T04:44:14Z")

</div>

Hi Yang,

A named marker is called a destination marker in the FMOD Studio application. Please see our documentation on how these are created and used:

[https://www.fmod.com/resources/documentation-studio?page=authoring-events.html#timeline-logic](https://www.fmod.com/resources/documentation-studio?page=authoring-events.html#timeline-logic)

Thanks,  
Richard
