AKSequencer

open class AKSequencer

Basic sequencer

This is currently in transistion from old c core audio apis, to the more modern avaudiosequencer setup. However, the new system is not as advanced as the old, so we will keep both and have them interact. In addition, some of the features of the new AVAudioSequencer don’t even work yet (midi sequencing). Still, both have their strengths and weaknesses so I am keeping them both. As such, there is some code hanging around while we iron it out.

  • Music sequence

    Declaration

    Swift

    open var sequence: MusicSequence?
  • Pointer to Music Sequence

    Declaration

    Swift

    open var sequencePointer: UnsafeMutablePointer<MusicSequence>?
  • AVAudioSequencer - on hold while technology is still unstable

    Declaration

    Swift

    open var avSequencer = AVAudioSequencer()
  • Array of AudioKit Music Tracks

    Declaration

    Swift

    open var tracks = [AKMusicTrack]()
  • Array of AVMusicTracks

    Declaration

    Swift

    open var avTracks: [AVMusicTrack]
  • Loop control

    Declaration

    Swift

    open var loopEnabled: Bool = false
  • Are we using the AVAudioEngineSequencer?

    Declaration

    Swift

    open var isAVSequencer: Bool = false
  • Sequencer Initialization

    Declaration

    Swift

    public init()
  • Initialize the sequence with a MIDI file

    Declaration

    Swift

    public convenience init(filename: String)

    Parameters

    filename

    Location of the MIDI File

  • Initialize the sequence with a midi file and audioengine - on hold while technology is still unstable

    • Parameters:
      • filename: Location of the MIDI File
      • engine: reference to the AV Audio Engine

    Declaration

    Swift

    public convenience init(filename: String, engine: AVAudioEngine)

    Parameters

    filename

    Location of the MIDI File

    engine

    reference to the AV Audio Engine

  • Initialize the sequence with an empty sequence and audioengine (on hold while technology is still unstable)

    Declaration

    Swift

    public convenience init(engine: AVAudioEngine)

    Parameters

    engine

    reference to the AV Audio Engine

  • Load a sequence from data

    Declaration

    Swift

    open func sequenceFromData(_ data: Data)

    Parameters

    data

    data to create sequence from

  • Preroll for the music player

    Declaration

    Swift

    open func preroll()
  • Set loop functionality of entire sequence

    Declaration

    Swift

    open func toggleLoop()
  • Enable looping for all tracks - loops entire sequence

    Declaration

    Swift

    open func enableLooping()
  • Enable looping for all tracks with specified length

    Declaration

    Swift

    open func enableLooping(_ loopLength: AKDuration)

    Parameters

    loopLength

    Loop length in beats

  • Disable looping for all tracks

    Declaration

    Swift

    open func disableLooping()
  • Set looping duration and count for all tracks

    • Parameters:
      • duration: Duration of the loop in beats
      • numberOfLoops: The number of time to repeat

    Declaration

    Swift

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

    Parameters

    duration

    Duration of the loop in beats

    numberOfLoops

    The number of time to repeat

  • Set length of all tracks

    Declaration

    Swift

    open func setLength(_ length: AKDuration)

    Parameters

    length

    Length of tracks in beats

  • Length of longest track in the sequence

    Declaration

    Swift

    open var length: AKDuration
  • Set the rate of the sequencer

    Declaration

    Swift

    open func setRate(_ rate: Double)

    Parameters

    rate

    Set the rate relative to the tempo of the track

  • Rate relative to the default tempo (BPM) of the track

    Declaration

    Swift

    open var rate: Double
  • Set the tempo of the sequencer

    Declaration

    Swift

    open func setTempo(_ bpm: Double)
  • Add a tempo change to the score

    • Parameters:
      • bpm: Tempo in beats per minute
      • position: Point in time in beats

    Declaration

    Swift

    open func addTempoEventAt(tempo bpm: Double, position: AKDuration)

    Parameters

    bpm

    Tempo in beats per minute

    position

    Point in time in beats

  • Tempo retrieved from the sequencer

    Declaration

    Swift

    open var tempo: Double
  • Convert seconds into AKDuration

    Declaration

    Swift

    open func duration(seconds: Double) -> AKDuration

    Parameters

    seconds

    time in seconds

  • Convert beats into seconds

    Declaration

    Swift

    open func seconds(duration: AKDuration) -> Double

    Parameters

    duration

    AKDuration

  • Play the sequence

    Declaration

    Swift

    open func play()
  • Stop the sequence

    Declaration

    Swift

    open func stop()
  • Rewind the sequence

    Declaration

    Swift

    open func rewind()
  • Set the Audio Unit output for all tracks - on hold while technology is still unstable

    Declaration

    Swift

    open func setGlobalAVAudioUnitOutput(_ audioUnit: AVAudioUnit)
  • Wheter or not the sequencer is currently playing

    Declaration

    Swift

    open var isPlaying: Bool
  • Current Time

    Declaration

    Swift

    open var currentPosition: AKDuration
  • Current Time relative to sequencer length

    Declaration

    Swift

    open var currentRelativePosition: AKDuration
  • Track count

    Declaration

    Swift

    open var trackCount: Int
  • Load a MIDI file

    Declaration

    Swift

    open func loadMIDIFile(_ filename: String)
  • Get a new track

    Declaration

    Swift

    open func newTrack(_ name: String = "Unnamed") -> AKMusicTrack?
    • Parameters:
      • start: Starting position of clearing
      • duration: Length of time after the start position to clear

    Declaration

    Swift

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

    Parameters

    start

    Starting position of clearing

    duration

    Length of time after the start position to clear

  • Set the music player time directly

    Declaration

    Swift

    open func setTime(_ time: MusicTimeStamp)

    Parameters

    time

    Music time stamp to set

  • Generate NSData from the sequence

    Declaration

    Swift

    open func genData() -> Data?
  • Print sequence to console

    Declaration

    Swift

    open func debug()
  • Set the midi output for all tracks

    Declaration

    Swift

    open func setGlobalMIDIOutput(_ midiEndpoint: MIDIEndpointRef)
  • Nearest time of quantized beat

    Declaration

    Swift

    open func nearestQuantizedPosition(quantizationInBeats: Double) -> AKDuration
  • The last quantized beat

    Declaration

    Swift

    open func previousQuantizedPosition(quantizationInBeats: Double) -> AKDuration
  • Next quantized beat

    Declaration

    Swift

    open func nextQuantizedPosition(quantizationInBeats: Double) -> AKDuration