Playgrounds with live views

audiokit6

You can add an interactive live view to the assistant editor of your playground. Choose:
View > Assistant Editor > Show Assistant Editor
to add the assistant editor to the playground.

AudioKit and playgrounds in Xcode

audiokit4

You can try your Swift program that import AudioKit on a playground to get the immediate result including the sound output.

If you hear no sound, please check your Playground Settings to see if the Platform is correct for your environment by:
View -> Utilities -> Show file inspector

CW Keyer with AudioKit

audiokit3

Modified the sample project, Hello World, to send a fixed message, CQ TEST.

//  ViewController.swift

import Cocoa
import AudioKit

class ViewController: NSViewController {
    
    var oscillator = AKOscillator()
    
    @IBOutlet var plot: AKOutputWaveformPlot!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        AudioKit.output = oscillator
        AudioKit.start()
    }
    
    @IBAction func toggleSound(_ sender: NSButton) {
        oscillator.amplitude = 0.5
        oscillator.frequency = 400
        let message = "cq test"
        let morse: [Character: String] =
            ["c": "1010", "e": "0", "q": "1101", "s": "000",
             "t": "1"   , " ": "0"]
        let weight: [Character: UInt32] = ["1": 150000, "0": 50000]
        let space:       UInt32 =  50000
        let letterSpace: UInt32 = 100000
        let wordSpace:   UInt32 = 300000
        for char in message.characters {
            if char != " " {
                for code in morse[char]!.characters {
                    oscillator.start()
                    usleep(weight!)
                    oscillator.stop()
                    usleep(space)
                }
                usleep(letterSpace)
            } else {
                usleep(wordSpace)
            }
        }
        sender.title = "Send again: " + message
        sender.setNeedsDisplay()
    }
}

I am an absolute beginner in Swift programming, but it is much easier than in FPGA programming.

AudioKit

audiokit

AudioKit is a platform for audio signal processing for iOS, macOS, and tvOS. Note that AudioKit v3.4 requires Xcode 8 to support Swift 3.

audiokit2

Swift 3 and Xcode 8

swift3

They have now five different access levels: open, public, internal, fileprivate, and private.

swift4

% swift
Welcome to Apple Swift version 3.0 (swiftlang-800.0.46.2 clang-800.0.38). Type :help for assistance.
  1> var list = [10, 11, 12]
list: [Int] = 3 values {
  [0] = 10
  [1] = 11
  [2] = 12
}
  2> list.insert(99, at: 1)
  3> print(list)
[10, 99, 11, 12]
  4> public   var r = 1
r: Int = 1
  5> internal let s = 2
s: Int = 2
  6> fileprivate func myfunc() {}
  7> private     func urfunc() {}

You can try Swift 3 without installing if you visit IBM Swift Sandbox.

swift5