Sender Synth

Sequencer Demo

This app uses inter-app audio to create a simple synthesizer to generate audio.

First we'll get our synth set up:

    class ViewController: UIViewController {

    let oscillator = AKOscillatorBank()
        override func viewDidLoad() {
        super.viewDidLoad()

        AudioKit.output = oscillator
        AudioKit.start()
    }

Then we'll set up our UI using some AudioKit UI elements:

       override func viewDidLoad() {
        super.viewDidLoad()

        AudioKit.output = oscillator
        AudioKit.start()

        setupUI()
    }

    func setupUI() {
        let stackView = UIStackView()
        stackView.axis = .vertical
        stackView.distribution = .fillEqually
        stackView.alignment = .fill
        stackView.translatesAutoresizingMaskIntoConstraints = false

        let adsrView = AKADSRView()
        stackView.addArrangedSubview(adsrView)
        let keyboardView = AKKeyboardView()
        stackView.addArrangedSubview(keyboardView)

        view.addSubview(stackView)

        stackView.widthAnchor.constraint(equalToConstant: view.frame.width).isActive = true
        stackView.heightAnchor.constraint(equalToConstant: view.frame.height).isActive = true

        stackView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
        stackView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor).isActive = true
    }

Now we'll link the synth and the UI:

    class ViewController: UIViewController, AKKeyboardDelegate {
    func noteOn(note: MIDINoteNumber) {
        oscillator.play(noteNumber: note, velocity: 80)
    }

    func noteOff(note: MIDINoteNumber) {
        oscillator.stop(noteNumber: note)
    }
    let adsrView = AKADSRView() { att, dec, sus, rel in
            self.oscillator.attackDuration = att
            self.oscillator.decayDuration = dec
            self.oscillator.sustainLevel = sus
            self.oscillator.releaseDuration = rel
        }

After we get our swift code set up we'll need to install Audiobus and add in the corresponding files. For detailed directions please follow allong with our full walk through and build your own Sender Synth app.