AKMusicTrack

open class AKMusicTrack

Wrapper for internal Apple MusicTrack

  • The representation of Apple’s underlying music track

    Declaration

    Swift

    open var internalMusicTrack: MusicTrack?
  • A copy of the original track at init

    Declaration

    Swift

    open var initMusicTrack: MusicTrack?
  • Sequencer this music track is part of

    Declaration

    Swift

    open var sequencer: AKSequencer
  • Pointer to the Music Track

    Declaration

    Swift

    open var trackPointer: UnsafeMutablePointer<MusicTrack>
  • Declaration

    Swift

    open var initTrackPointer: UnsafeMutablePointer<MusicTrack>
  • Nicer function for not empty

    Declaration

    Swift

    open var isNotEmpty: Bool { get }
  • Total duration of the music track

    Declaration

    Swift

    open var length: MusicTimeStamp { get }
  • Total duration of the music track

    Declaration

    Swift

    open var initLength: MusicTimeStamp { get }
  • Declaration

    Swift

    @objc
    public init(name: String = "Unnamed")
  • Initialize with a music track

    Declaration

    Swift

    @objc
    public init(musicTrack: MusicTrack, name: String = "Unnamed")

    Parameters

    musicTrack

    An Apple Music Track

    name

    Name for the track

  • Initialize with a music track and the AKSequence

    Declaration

    Swift

    public init(musicTrack: MusicTrack, sequencer: AKSequencer)

    Parameters

    musicTrack

    An Apple Music Track

  • Set the Node Output

    Declaration

    Swift

    open func setNodeOutput(_ node: AUNode)

    Parameters

    node

    Apple AUNode for output

  • Set loop info

    Declaration

    Swift

    open func setLoopInfo(_ duration: AKDuration, numberOfLoops: Int)

    Parameters

    duration

    How long the loop will last, from the end of the track backwards

    numberOfLoops

    how many times to loop. 0 is infinte

  • Set length If any of your notes are longer than the new length, this will truncate those notes This will truncate your sequence if you shorten it - so make a copy if you plan on doing that.

    Declaration

    Swift

    open func setLength(_ duration: AKDuration)

    Parameters

    duration

    How long the loop will last, from the end of the track backwards

  • A less destructive and simpler way to set the length

    Declaration

    Swift

    open func setLengthSoft(_ duration: AKDuration)

    Parameters

    duration

  • Clear all events from the track

    Declaration

    Swift

    open func clear()
  • Clear meta events from the track

    Declaration

    Swift

    open func clearMetaEvents()
  • Clear SysEx events from the track

    Declaration

    Swift

    open func clearSysexEvents()
  • Clear a specific note

    Declaration

    Swift

    open func clearNote(_ note: MIDINoteNumber)
  • Determine if the sequence is empty

    Declaration

    Swift

    open var isEmpty: Bool { get }
  • Clear all events from this track within the specified range

    Declaration

    Swift

    open func clearRange(start: AKDuration, duration: AKDuration)

    Parameters

    start

    Start of the range to clear, in beats (inclusive)

    duration

    Length of time after the start position to clear, in beats (exclusive)

  • Add Note to sequence

    Declaration

    Swift

    open func add(noteNumber: MIDINoteNumber,
                  velocity: MIDIVelocity,
                  position: AKDuration,
                  duration: AKDuration,
                  channel: MIDIChannel = 0)

    Parameters

    noteNumber

    The MIDI note number to insert

    velocity

    The velocity to insert note at

    position

    Where in the sequence to start the note (expressed in beats)

    duration

    How long to hold the note (would be better if they let us just use noteOffs…oh well)

    channel

    MIDI channel for this note

  • Add Note to sequence with AKMIDINoteData

    Declaration

    Swift

    open func add(midiNoteData: AKMIDINoteData)

    Parameters

    midiNoteData

    AKMIDINoteData containing relevant note details

  • Erases current note events and recreates track from note data in AKMIDINoteData array Order of structs in array is irrelevant

    Declaration

    Swift

    open func replaceMIDINoteData(with trackMIDINoteData: [AKMIDINoteData])

    Parameters

    midiNoteData

    AKMIDINoteData array containing relevant note details

  • Add Controller change to sequence

    Declaration

    Swift

    open func addController(_ controller: MIDIByte, value: MIDIByte, position: AKDuration, channel: MIDIChannel = 0)

    Parameters

    controller

    The MIDI controller to insert

    value

    The velocity to insert note at

    position

    Where in the sequence to start the note (expressed in beats)

    channel

    MIDI channel for this note

  • Add Sysex message to sequence

    Declaration

    Swift

    open func addSysex(_ data: [MIDIByte], position: AKDuration)

    Parameters

    data

    The MIDI data byte array - standard sysex start and end messages are added automatically

    position

    Where in the sequence to start the note (expressed in beats)

  • Add Pitch Bend change to sequence

    Declaration

    Swift

    open func addPitchBend(_ value: Int = 8_192, position: AKDuration, channel: MIDIChannel = 0)

    Parameters

    value

    The value of pitchbend. The valid range of values is 0 to 16383 (128 ^ 2 values).

    position

    Where in the sequence to insert pitchbend info (expressed in beats)

    channel

    MIDI channel to insert pitch bend on

  • Add Pitch Bend reset to sequence

    Declaration

    Swift

    open func resetPitchBend(position: AKDuration, channel: MIDIChannel = 0)

    Parameters

    position

    Where in the sequence to insert pitchbend info (expressed in beats)

    channel

    MIDI channel to insert pitch bend reset on

  • Get an array of all the MIDI Note data in the internalMusicTrack Modifying this array alone will not change the internalMusicTrack

    NB: The data is generated sequentially, but maintaining the order in not important

    Declaration

    Swift

    open func getMIDINoteData() -> [AKMIDINoteData]
  • Copy this track to another track

    Declaration

    Swift

    open func copyAndMergeTo(musicTrack: AKMusicTrack)

    Parameters

    musicTrack

    Destination track to copy this track to

  • Copy this track to another track

    Declaration

    Swift

    open func copyOf() -> AKMusicTrack
  • Declaration

    Swift

    open func resetToInit()
  • Set the MIDI Ouput

    Declaration

    Swift

    open func setMIDIOutput(_ endpoint: MIDIEndpointRef)

    Parameters

    endpoint

    MIDI Endpoint Port

  • Debug by showing the track pointer.

    Declaration

    Swift

    open func debug()
  • Declaration

    Swift

    open func debugInitTrack()