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

    Declaration

    Swift

    open class AKMusicTrack
  • Nicer function for not empty

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    open var initLength: MusicTimeStamp
  • Undocumented

    Declaration

    Swift

    open class AKMusicTrack
  • 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
  • Clear all events from the track

    Declaration

    Swift

    open func clear()
  • Clear a specific note

    Declaration

    Swift

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

    Declaration

    Swift

    open var isEmpty: Bool
  • 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)

  • Add Pitch Bend change to sequence

    • Parameters:
      • value: The value of pitchbend. The valid range of values is 0 to 16383 (128 ^ 2 values).
      • 8192 is no pitch bend.
      • position: Where in the sequence to insert pitchbend info (expressed in beats)
      • channel: MIDI channel to insert pitch bend on

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

    8192 is no pitch bend

    .

    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

    • Parameters:
      • position: Where in the sequence to insert pitchbend info (expressed in beats)
      • channel: MIDI channel to insert pitch bend reset on

    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

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

    Declaration

    Swift

    open class AKMusicTrack
  • 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()
  • Undocumented

    Declaration

    Swift

    open class AKMusicTrack