I use EZAudio to record audio and play on iPhone with Xcode 6 Beta 3 and Swift.
At this time, I successfully compiled and deployed the testing application both in the simulator and on my device (until I installed Xcode 6 Beta 3. Now it works only in the simulator).
Xcode 6 identifies 20 warning errors for EZAudio in the classes: EZOutput, EZAudioFile and EZAudio with the following messages:
"'AudioUnitSampleType' is deprecated: The concept of canonical formats is deprecated" "'kAudioFormatFlagsCanonical' is deprecated: The concept of canonical formats is deprecated" "'AudioSessionGetProperty' is deprecated: first deprecated in iOS 7.0" "Apple Mach-O Linker warning: relocatable dylibs (eg embedded frameworks) are only supported on iOS 8.0 and later (@rpath/libswift_stdlib_core.dylib)"
When compiled, the application can record sound and play it. The problem is the live audio recording schedule. I added the EZAudioPilotGL class to the ViewController class:
@IBOutlet var audioPlot: EZAudioPlotGL
Its dimensions: w: 320, h: 62. Viewing mode: scale to fill.
I also included the following lines in the viewDidLoad method.
self.microphone = EZMicrophone(delegate: self) self.audioPlot.backgroundColor = UIColor.clearColor() self.audioPlot.color = UIColor.orangeColor() self.audioPlot.plotType = EZPlotType.Rolling self.audioPlot.opaque = false self.view.opaque = false self.audioPlot.shouldFill = true self.audioPlot.shouldMirror = true
I ported to Swift all the methods implemented in the EZAudioRecordExample project example, including the microphone methods and the audioPlayerDidFinishPlaying method:
func microphone(microphone: EZMicrophone, hasAudioReceived buffer: CMutablePointer<Float>, withBufferSize bufferSize: UInt32, withNumberOfChannels numberOfChannels: UInt32) { dispatch_async(dispatch_get_main_queue(), { println("Updating AudioPlot Buffer") self.audioPlot.updateBuffer(buffer, withBufferSize: bufferSize) println("bufferSize \(bufferSize)") }) } func microphone(microphone: EZMicrophone, hasBufferList bufferList:CMutablePointer<AudioBufferList>, withBufferSize bufferSize:UInt32, withNumberOfChannels numberOfChannels:UInt32){ println(microphone) println(bufferList) if (self.isRecording) { self.recorder!.appendDataFromBufferList(bufferList, withBufferSize:bufferSize) } } func audioPlayerDidFinishPlaying(player: AVAudioPlayer, successfully flag: Bool) { self.isPlaying = false togglePlaying() }
During the recording session, the AudioPilot remains black only without a graph appearing.
It is also verified that portable methods are invoked.
Any help for a solution would be greatly appreciated.