I have a very simple installTapOnBus
closure that successfully updates the console, but not the UI element. Here's the code:
self.meter.text="..."
let inputNode = audioEngine.inputNode
let bus = 0
inputNode!.installTapOnBus(bus, bufferSize: 2048, format: inputNode!.inputFormatForBus(bus)) {
(buffer: AVAudioPCMBuffer!, time: AVAudioTime!) -> Void in
var someFeature:Float=0.0
for var i=0; i<Int(buffer.frameLength); i += 1{
someFeature += fabs(buffer.floatChannelData.memory[i])
}
someFeature /= Float(buffer.frameLength)
self.meter.text="\(someFeature)" // No effect!
print("\(someFeature)") // This works
}
Perhaps I need to send a weak reference to self
to the closure, but am unsure of the syntax. Any feedback/ideas on how to get the UI element updating would be great! Thanks for reading.