AKMusicTrack

open class AKMusicTrack

Wrapper for internal Apple MusicTrack

  • The representation of Apple’s underlying music track

    Declaration

    Swift

    open var internalMusicTrack: 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>
  • Total duration of the music track

    Declaration

    Swift

    open var length: MusicTimeStamp
  • Initialize with a music track

    Declaration

    Swift

    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

    • paramter numberOfLoops: how many times to loop. 0 is infinte

    Declaration

    Swift

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

    Parameters

    duration

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

  • 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

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

  • Clear all events from the track

    Declaration

    Swift

    open func clear()
  • Undocumented

    Declaration

    Swift

    open class AKMusicTrack
  • Undocumented

    Declaration

    Swift

    open class AKMusicTrack
  • Clear some events from the track

    • Parameters:
      • start: Start of the range to clear, in beats
      • duration: Duration of the range to clear, in beats

    Declaration

    Swift

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

    Parameters

    start

    Start of the range to clear, in beats

    duration

    Duration of the range to clear, in beats

  • Add Note to sequence

    • 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

    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 Controller change to sequence

    • 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

    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

    • 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)

    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)

  • Copy this track to another track

    Declaration

    Swift

    open func copyAndMergeTo(musicTrack: AKMusicTrack)

    Parameters

    musicTrack

    Destination track to copy this track to

  • 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()