Skip to content

Instantly share code, notes, and snippets.


Matej Ukmar matejukmar

View GitHub Profile
matejukmar / gist:7003cc754fb4b358446528cc15e672c7
Last active Oct 8, 2017 — forked from rgcottrell/gist:5b876d9c5eea4c9e411c
An FM Synthesizer in Swift using AVAudioEngine
View gist:7003cc754fb4b358446528cc15e672c7
//Swift 4
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
View shadeColor
extension UIColor {
func shadeColor(factor: CGFloat) -> UIColor {
var r: CGFloat = 0
var g: CGFloat = 0
var b: CGFloat = 0
var a: CGFloat = 0
var t: CGFloat = factor < 0 ? 0 : 1
You can’t perform that action at this time.