This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // 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/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |