I am trying to use vDSP with Swift 3, but I still do not understand how to take care of an UnsafeRawPointer type correctly.
Playgrounds with live views
AudioKit and playgrounds in Xcode
CW Keyer with AudioKit
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 is a platform for audio signal processing for iOS, macOS, and tvOS. Note that AudioKit v3.4 requires Xcode 8 to support Swift 3.
Swift 3 and Xcode 8
They have now five different access levels: open, public, internal, fileprivate, and private.
% 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.