JoshuaBThompson/WristBand

Define native iOS classes / methods we need access to

Opened this issue · 0 comments

Below are brief breakdown of steps taken to setup Ableton Link with an audio engine to update tempo

All steps described below are based of the Ableton Link LinkHut example app.

The process of updating the tempo (when another user set's new tempo):

  • First audio engine and Ableton Link objects are setup in ViewController -> viewDidLoad

    • _audioEngine = [[AudioEngine alloc] initWithTempo:_bpm];
    • This is where AVAudioSession shared instance and callbacks get setup
    • ABLLinkSetSessionTempoCallback(...)
      • This is where Ableton Link tempo change gets passed along to user callback to update UI
    • _audioEngine.linkRef, onSessionTempoChanged, (__bridge void *)self);
    • _linkSettings = [ABLLinkSettingsViewController instance:_audioEngine.linkRef];
    • [_audioEngine setQuantum:_quanta];
  • Ableton Link will receive the tempo change from the other user (over the network for ex)

  • Ableton Link will send an event to the AVAudioSession audio engine route

  • User code has a callback that gets called when route event happens

  • See 'AudioEngine.m' in the Ableton LinkHut app example:

    • callback in AudioEngine.m -> audioCallback
    • This is setup in 'setupAudioEngine' method that gets called during init:
    • This is where _linkData object is setup to connect to shared instance of AVAudioSession properties
    • 'AURenderCallbackStruct ioRemoteInput;'
      • gets called to setup i/o callback using 'audioCallback' function
      • audioCallback is defined to checks for a tempo update and saves the timestamp and new tempo
      • See 'static OSStatus audioCallback' method in AudioEngine.m
      • This is where the tempo actually gets updated when we receive an tempo event from Ableton Link
      • If new tempo is valid it passes along the new tempo event to another callback that informs the UI to display the new tempo to the user
      • This happens in 'ABLLinkSetSessionTempoCallback' defined in the ViewController.swift
      • This callback is setup in ViewController.swift -> viewDidLoad -> ABLLinkSetSessionTempoCallback