Skip to content

Instantly share code, notes, and snippets.

@candyhero
candyhero / ToneOutputUnit.swift
Created July 21, 2017 03:45 — forked from hotpaw2/ToneOutputUnit.swift
Swift 3 Audio class that can play a simple tone on an iOS device
//
// ToneOutputUnit.swift
//
// This is a Swift 3 class (which should be instantiated as a singleton object)
// that can play a single tone of arbitrary tone and frequency on iOS devices
// using run-time sinewave synthesis and the Audio Unit v3 API with RemoteIO.
//
// Created by Ronald Nicholson [email protected] on 2/20/2016.
// revised 2016-Sep-08 for Swift 3
// http://www.nicholson.com/rhn/
@candyhero
candyhero / gist:831abae75495e5e69516ceea893f6449
Created July 21, 2017 03:44 — forked from rgcottrell/gist:5b876d9c5eea4c9e411c
An FM Synthesizer in Swift using AVAudioEngine
import AVFoundation
import Foundation
// The maximum number of audio buffers in flight. Setting to two allows one
// buffer to be played while the next is being written.
private let kInFlightAudioBuffers: Int = 2
// The number of audio samples per buffer. A lower value reduces latency for
// changes but requires more processing but increases the risk of being unable
// to fill the buffers in time. A setting of 1024 represents about 23ms of