MIKMIDITrack

Objective-C

@interface MIKMIDITrack : NSObject

Swift

class MIKMIDITrack : NSObject

Instances of MIKMIDITrack contain sequences of MIDI events. Commonly, these will be MIDI notes. Multiple MIKMIDITracks can be contained in a MIKMIDISequence, which can be played.

See

MIKMIDISequence
  • Inserts the specified MIDI event into the receiver.

    Declaration

    Objective-C

    - (void)addEvent:(nonnull MIKMIDIEvent *)event;

    Swift

    func addEvent(_ event: MIKMIDIEvent)

    Parameters

    event

    The MIDI event to insert into the track.

  • Inserts the specified MIDI events into the receiver.

    Declaration

    Objective-C

    - (void)addEvents:(nonnull NSArray<MIKMIDIEvent *> *)events;

    Swift

    func addEvents(_ events: [MIKMIDIEvent])

    Parameters

    events

    An NSArray containing the events to be added.

  • Removes the specified MIDI event from the receiver.

    Declaration

    Objective-C

    - (void)removeEvent:(nonnull MIKMIDIEvent *)event;

    Swift

    func removeEvent(_ event: MIKMIDIEvent)

    Parameters

    event

    The MIDI event to remove from the track.

  • Removes the specified MIDI events from the receiver.

    Declaration

    Objective-C

    - (void)removeEvents:(nonnull NSArray<MIKMIDIEvent *> *)events;

    Swift

    func removeEvents(_ events: [MIKMIDIEvent])

    Parameters

    events

    An NSArray containing the events to be removed.

  • Removes all MIDI events from the receiver.

    Declaration

    Objective-C

    - (void)removeAllEvents;

    Swift

    func removeAllEvents()
  • Gets all of the MIDI events in the track starting from startTimeStamp and ending at endTimeStamp inclusively.

    Declaration

    Objective-C

    - (nonnull NSArray<MIKMIDIEvent *> *)
        eventsFromTimeStamp:(MusicTimeStamp)startTimeStamp
                toTimeStamp:(MusicTimeStamp)endTimeStamp;

    Swift

    func events(fromTimeStamp startTimeStamp: MusicTimeStamp, toTimeStamp endTimeStamp: MusicTimeStamp) -> [MIKMIDIEvent]

    Parameters

    startTimeStamp

    The starting time stamp for the range to get MIDI events for.

    endTimeStamp

    The ending time stamp for the range to get MIDI events for. Use kMusicTimeStamp_EndOfTrack to get events up to the end of the track.

    Return Value

    An array of MIKMIDIEvent.

  • Gets all of the MIDI events of a specific class in the track starting from startTimeStamp and ending at endTimeStamp inclusively.

    Declaration

    Objective-C

    - (nonnull NSArray<__kindof MIKMIDIEvent *> *)
        eventsOfClass:(nullable Class)eventClass
        fromTimeStamp:(MusicTimeStamp)startTimeStamp
          toTimeStamp:(MusicTimeStamp)endTimeStamp;

    Swift

    func events(of eventClass: AnyClass?, fromTimeStamp startTimeStamp: MusicTimeStamp, toTimeStamp endTimeStamp: MusicTimeStamp) -> [MIKMIDIEvent]

    Parameters

    eventClass

    The class of MIDI events you would like to retrieve. This class must be the MIKMIDIEvent class or a subclass thereof.

    startTimeStamp

    The staring time stamp for the range to get MIDI events for.

    endTimeStamp

    The ending time stamp for the range to get MIDI events for. Use kMusicTimeStamp_EndOfTrack to get events up to the end of the track.

    Return Value

    An array of specified class of MIDI events.

  • Gets all of the MIDI notes in the track starting from startTimeStamp and ending at endTimeStamp inclusively.

    @discussion Calling this method is equivalent to calling eventsOfClass:fromTimeStamp:toTimeStamp: with [MIKMIDINoteEvent class].

    Declaration

    Objective-C

    - (nonnull NSArray<MIKMIDINoteEvent *> *)
        notesFromTimeStamp:(MusicTimeStamp)startTimeStamp
               toTimeStamp:(MusicTimeStamp)endTimeStamp;

    Swift

    func notes(fromTimeStamp startTimeStamp: MusicTimeStamp, toTimeStamp endTimeStamp: MusicTimeStamp) -> [MIKMIDINoteEvent]

    Parameters

    startTimeStamp

    The starting time stamp for the range to get MIDI events for.

    endTimeStamp

    The ending time stamp for the range to get MIDI notes for. Use kMusicTimeStamp_EndOfTrack to get events up to the end of the track.

    Return Value

    An array of MIKMIDINoteEvent instances.

Event Manipulation

  • Moves all of the MIDI events between startTimeStamp and endTimeStamp inclusively by the specified offset.

    Declaration

    Objective-C

    - (BOOL)moveEventsFromStartingTimeStamp:(MusicTimeStamp)startTimeStamp
                          toEndingTimeStamp:(MusicTimeStamp)endTimeStamp
                                   byAmount:(MusicTimeStamp)timestampOffset;

    Swift

    func moveEvents(fromStartingTimeStamp startTimeStamp: MusicTimeStamp, toEndingTimeStamp endTimeStamp: MusicTimeStamp, byAmount timestampOffset: MusicTimeStamp) -> Bool

    Parameters

    startTimeStamp

    The starting time stamp for the range of the events to move.

    endTimeStamp

    The ending time stamp for the range of the events to move.

    timestampOffset

    The amount to move the events

    Return Value

    Whether or not moving the events was succesful.

  • Removes all of the MIDI events between startTimeStamp and endTimeStamp inclusively.

    Declaration

    Objective-C

    - (BOOL)clearEventsFromStartingTimeStamp:(MusicTimeStamp)startTimeStamp
                           toEndingTimeStamp:(MusicTimeStamp)endTimeStamp;

    Swift

    func clearEvents(fromStartingTimeStamp startTimeStamp: MusicTimeStamp, toEndingTimeStamp endTimeStamp: MusicTimeStamp) -> Bool

    Parameters

    startTimeStamp

    The starting time stamp for the range of the events to remove.

    endTimeStamp

    The ending time stamp for the range of the events to move.

    Return Value

    Whether or not moving the MIDI events was succesful.

  • Removes all of the MIDI events between startTimeStamp and endTimeStamp inclusively. Events that fall past the specified range will be moved back by the specified range time.

    Declaration

    Objective-C

    - (BOOL)cutEventsFromStartingTimeStamp:(MusicTimeStamp)startTimeStamp
                         toEndingTimeStamp:(MusicTimeStamp)endTimeStamp;

    Swift

    func cutEvents(fromStartingTimeStamp startTimeStamp: MusicTimeStamp, toEndingTimeStamp endTimeStamp: MusicTimeStamp) -> Bool

    Parameters

    startTimeStamp

    The starting time stamp for the range of the events to cut.

    endTimeStamp

    The ending time stamp for the range of the events to cut.

    Return Value

    Whether or not cutting the MIDI events was succesful.

  • Copies MIDI events from one track and inserts them into the receiver.

    Declaration

    Objective-C

    - (BOOL)copyEventsFromMIDITrack:(nonnull MIKMIDITrack *)origTrack
                      fromTimeStamp:(MusicTimeStamp)startTimeStamp
                        toTimeStamp:(MusicTimeStamp)endTimeStamp
               andInsertAtTimeStamp:(MusicTimeStamp)destTimeStamp;

    Swift

    func copyEvents(from origTrack: MIKMIDITrack, fromTimeStamp startTimeStamp: MusicTimeStamp, toTimeStamp endTimeStamp: MusicTimeStamp, andInsertAtTimeStamp destTimeStamp: MusicTimeStamp) -> Bool

    Parameters

    origTrack

    The track to copy the events from.

    startTimeStamp

    The starting time stamp for the range of the events to copy.

    endTimeStamp

    The ending time stamp for the range of the events to copy.

    destTimeStamp

    The time stamp at which to the copied events will be inserted into the receiver.

    Return Value

    Whether or not copying the MIDI events was succesful.

  • Copies MIDI events from one track and merges them into the receiver.

    Declaration

    Objective-C

    - (BOOL)mergeEventsFromMIDITrack:(nonnull MIKMIDITrack *)origTrack
                       fromTimeStamp:(MusicTimeStamp)startTimeStamp
                         toTimeStamp:(MusicTimeStamp)endTimeStamp
                         atTimeStamp:(MusicTimeStamp)destTimeStamp;

    Swift

    func mergeEvents(from origTrack: MIKMIDITrack, fromTimeStamp startTimeStamp: MusicTimeStamp, toTimeStamp endTimeStamp: MusicTimeStamp, atTimeStamp destTimeStamp: MusicTimeStamp) -> Bool

    Parameters

    origTrack

    The track to copy the events from.

    startTimeStamp

    The starting time stamp for the range of the events to copy.

    endTimeStamp

    The ending time stamp for the range of the events to copy.

    destTimeStamp

    The time stamp at which to the copied events will be merged into the receiver.

    Return Value

    Whether or not merging the MIDI events was succesful.

  • The MIDI sequence the track belongs to.

    Declaration

    Objective-C

    @property (nonatomic, weak, readonly, nullable) MIKMIDISequence *sequence;

    Swift

    weak var sequence: MIKMIDISequence? { get }
  • The underlying MusicTrack that backs the instance of MIKMIDITrack.

    Declaration

    Objective-C

    @property (nonatomic, readonly) MusicTrack _Nonnull musicTrack;

    Swift

    var musicTrack: MusicTrack { get }
  • An array of MIKMIDIEvent containing all of the MIDI events for the track, sorted by timestamp.

    This property can be observed using Key Value Observing.

    Declaration

    Objective-C

    @property (nonatomic, copy) NSArray<MIKMIDIEvent *> *_Nonnull events;

    Swift

    var events: [MIKMIDIEvent] { get set }
  • An array of MIKMIDINoteEvent containing all of the MIDI note events for the track, sorted by timestamp.

    This property can be observed using Key Value Observing.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSArray<MIKMIDINoteEvent *> *_Nonnull notes;

    Swift

    var notes: [MIKMIDINoteEvent] { get }
  • The receiver’s index in its containing sequence, or -1 if the track isn’t in a sequence.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSInteger trackNumber;

    Swift

    var trackNumber: Int { get }
  • A MIDI track’s start time in terms of beat number. By default this value is 0.

    This can be used to offset playback by MIKMIDISequencer of individual tracks in a sequence.

    This property can be observed using Key Value Observing.

    Declaration

    Objective-C

    @property (nonatomic) MusicTimeStamp offset;

    Swift

    var offset: MusicTimeStamp { get set }
  • Whether or not the MIDI track is muted. Muted tracks are not played by MIKMIDISequencer.

    This property can be observed using Key Value Observing.

    Declaration

    Objective-C

    @property (nonatomic, getter=isMuted) BOOL muted;

    Swift

    var isMuted: Bool { get set }
  • Whether or not the MIDI track is soloed.

    If a track is muted, it is not played by MIKMIDISequencer, and its solo status is ignored. If any non-muted tracks in a sequence have this property set to YES, MIKMIDISequencer will only play those, and will not play the non-solo tracks. If this is set to NO for all non-muted tracks, then all non-muted tracks will be played.

    This property can be observed using Key Value Observing.

    Declaration

    Objective-C

    @property (nonatomic, getter=isSolo) BOOL solo;

    Swift

    var isSolo: Bool { get set }
  • The length of the MIDI track.

    This property can be observed using Key Value Observing.

    - - note: This property will automatically get updated whenever the tracks events are changed.
    

    Declaration

    Objective-C

    @property (nonatomic) MusicTimeStamp length;

    Swift

    var length: MusicTimeStamp { get set }
  • The time resolution for a sequence of MIDI events. For example, this value can indicate the time resolution that was specified by the MIDI file used to construct a sequence.

    If you create a MIDI sequence programmatically, the value is set to 480. If you create a MIDI sequence from a MIDI file, the value is set to the time resolution specified in the MIDI file.

    Declaration

    Objective-C

    @property (nonatomic, readonly) SInt16 timeResolution;

    Swift

    var timeResolution: Int16 { get }

Deprecated

  • Deprecated

    @deprecated This method only affects playback using MIKMIDIPlayer. Use -[MIKMIDISequencer isLooping] instead.

    Whether the track is set to loop.

    This property can be observed using Key Value Observing.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL doesLoop;

    Swift

    var doesLoop: Bool { get }
  • Deprecated

    @deprecated This method only affects playback using MIKMIDIPlayer. Use MIKMIDISequencer looping API instead.

    The number of times to play the designated portion of the music track. By default, a music track plays once.
    

    This property can be observed using Key Value Observing.

    Declaration

    Objective-C

    @property (nonatomic) SInt32 numberOfLoops;

    Swift

    var numberOfLoops: Int32 { get set }
  • Deprecated

    @deprecated This method only affects playback using MIKMIDIPlayer. Use -[MIKMIDISequencer setLoopStartTimeStamp:endTimeStamp:], and associated properties instead.

    The point in a MIDI track, measured in beats from the end of the MIDI track, at which to begin playback during looped playback. That is, during looped playback, a MIDI track plays from (length – loopDuration) to length.

    This property can be observed using Key Value Observing.

    Declaration

    Objective-C

    @property (nonatomic) MusicTimeStamp loopDuration;

    Swift

    var loopDuration: MusicTimeStamp { get set }
  • Deprecated

    @deprecated This method only affects playback using MIKMIDIPlayer. Use MIKMIDISequencer looping API instead.

    The loop info for the track.

    This property can be observed using Key Value Observing.

    Declaration

    Objective-C

    @property (nonatomic) MusicTrackLoopInfo loopInfo;

    Swift

    var loopInfo: MusicTrackLoopInfo { get set }
  • Deprecated

    @deprecated This method is deprecated. Use -trackNumber instead.
    

    Gets the track’s track number in it’s owning MIDI sequence.

    Declaration

    Objective-C

    - (BOOL)getTrackNumber:(nonnull UInt32 *)trackNumber;

    Swift

    func getNumber(_ trackNumber: UnsafeMutablePointer<UInt32>) -> Bool

    Parameters

    trackNumber

    On output, the track number of the track.

    Return Value

    Whether or not getting the track number was succesful.

  • Deprecated

    @deprecated This property has been deprecated. Use -[MIKMIDISequencer setDestinationEndpoint:forTrack:] instead.

    The destination endpoint for the MIDI events of the track during playback.

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) MIKMIDIDestinationEndpoint *destinationEndpoint;

    Swift

    var destinationEndpoint: MIKMIDIDestinationEndpoint? { get set }
  • Deprecated

    @deprecated Use -addEvent: instead.

    Inserts the specified MIDI event into the track.

    Declaration

    Objective-C

    - (BOOL)insertMIDIEvent:(nonnull MIKMIDIEvent *)event;

    Swift

    func insert(_ event: MIKMIDIEvent) -> Bool

    Parameters

    event

    The MIDI event to insert into the track.

    Return Value

    Whether or not inserting the MIDI event was succesful.

  • Deprecated

    @deprecated Use -addEvent: instead.

    Inserts MIDI events into the track.

    Declaration

    Objective-C

    - (BOOL)insertMIDIEvents:(nonnull NSSet<MIKMIDIEvent *> *)events;

    Swift

    func insert(_ events: Set<AnyHashable>) -> Bool

    Parameters

    events

    An NSSet of MIKMIDIEvent to insert into the track.

    Return Value

    Whether or not inserting the MIDI events was succesful.

  • Deprecated

    @deprecated Use -removeEvent: instead.

    Removes MIDI events from a track.

    Declaration

    Objective-C

    - (BOOL)removeMIDIEvents:(nonnull NSSet<MIKMIDIEvent *> *)events;

    Swift

    func remove(_ events: Set<AnyHashable>) -> Bool

    Parameters

    events

    An NSSet of MIKMIDIEvent to remove from the track.

    Return Value

    Whether or not removing the MIDI events was succesful.

  • Deprecated

    @deprecated Use -removeAllEvents instead.

    Removes all MIDI events from the track.

    Declaration

    Objective-C

    - (BOOL)clearAllEvents;

    Swift

    func clearAllEvents() -> Bool

    Return Value

    Whether or not removing all of the MIDI events from the track was succesful.