Skip to content

Instantly share code, notes, and snippets.

@welbesw
Created March 18, 2016 14:37
Show Gist options
  • Save welbesw/0c5de7793f82d3e14859 to your computer and use it in GitHub Desktop.
Save welbesw/0c5de7793f82d3e14859 to your computer and use it in GitHub Desktop.
Method called by NSTimer to update frequency values from FFT
func timerTick(sender:NSTimer?) {
if audioManager.isPlaying() {
//Get the frequency data from the audio manager and show on horizontal bar graph
var size:UInt32 = 0
let frequencyData = audioManager.guitarFrequencyDataOfLength(&size)
let frequencyValuesArray = Array<Float32>(UnsafeBufferPointer(start: UnsafePointer(frequencyData), count: Int(size)))
//Sanity check for expected 256 length
if frequencyValuesArray.count == 256 {
frequencyView.frequncyValues = frequencyValuesArray
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment