<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.3.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AudioToolbox",
  "identifier" : "/documentation/AudioToolbox/MusicSequenceSetUserCallback(_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Audio Toolbox"
    ],
    "preciseIdentifier" : "c:@F@MusicSequenceSetUserCallback"
  },
  "title" : "MusicSequenceSetUserCallback(_:_:_:)"
}
-->

# MusicSequenceSetUserCallback(_:_:_:)

Registers a user callback function with a music sequence.

```
func MusicSequenceSetUserCallback(_ inSequence: MusicSequence, _ inCallback: MusicSequenceUserCallback?, _ inClientData: UnsafeMutableRawPointer?) -> OSStatus
```

## Parameters

`inSequence`

The music sequence that you want to add a user callback function to.

`inCallback`

A reference to your callback function. Use `NULL` to remove a registered callback function.

`inClientData`

Your data that the music sequence provides back to your callback function when it is invoked.

## Return Value

A result code.

## Discussion

The music sequence invokes your callback for each user event added to any music track owned by the sequence. If there is a callback registered, then UserEvents will be chased when MusicPlayerSetTime is called. In that case the inStartSliceBeat and inEndSliceBeat will both be the same value and will be the beat that the player is chasing to.

Usually, where the sequence data is being scheduled for playback, the following applies:

```objc
inStartSliceBeat <= inEventTime < inEndSliceBeat
```

The only exception to this is if the track that owns the MusicEvent is looping. In this case the start beat will still be less than the end beat (so your callback can still determine that it is playing, and what beats are currently being scheduled), however, the inEventTime will be the original time-stamped time of the user event.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)