Recorder Demo

Recorder Demo

This demo is based off of the work by Laurent Veliscek.

Before reading this, we highly recommend you to read a great tutorial on the Hello World example first. This example is included in AudioKit in the Examples directory with versions for iOS and OSX.

First, set session settings:

    AKSettings.bufferLength = .Medium

    do {
        try AKSettings.setSessionCategory(.PlayAndRecord, withOptions: .DefaultToSpeaker)
    } catch { print("Errored setting category.") }

Then, create an instance of input node, and then 2 mixing nodes (a node that mixes its inputs to a single output).

    let mic = AKMicrophone()
    let micMixer = AKMixer(mic)
    micBooster = AKBooster(micMixer)

And thenm set amplification factor for a mixing node to zero, create an instance of audio recorder class, return the AKAudioFile for reading and set the properties for the playback node. So we're able to create a filter node using the playback one and this gives us an opportunity to playback recorded sounds with the effects like a cutoff frequency and a resonance.

    micBooster!.gain = 0
    recorder = try? AKNodeRecorder(node: micMixer)
    tape = recorder?.audioFile
    player = tape?.player
    player?.looping = true
    player?.completionHandler = playingEnded

    moogLadder = AKMoogLadder(player!)

Finally, create a main mixer node and start the AudioKit engine.

    let mainMixer = AKMixer(moogLadder!, micBooster!)

    AudioKit.output = mainMixer