Use EZAudio in Swift,draw Plot for audio from microphone
- Create EZAudioDemo-Bridging-Header.h,import EZAudio.h
- Create PrefixHeader.pch
- Change Project Settings:
- Set Build Settings->Search Paths - Header Search Paths,add EZAudio's header files by drag header files in EZAudio directory to it
- Set Build Settings->Swift Compiler - Code Generation -> Objective-C Bridging Header to EZAudioDemo-Bridging-Header.h
- Set Build Settings->Apple LLVM 6.1 - Language->Prefix Header to PrefixHeader.pch
- Set Build Phases->Compile Sources,add EZAudio source code by drag Souce files in EZAudio directory to it
- Add UIView into Main.storyboard,change it's class to EZAudioPlotGL
- Create microphone function:
func microphone(microphone: EZMicrophone!,
hasAudioReceived buffer: UnsafeMutablePointer<UnsafeMutablePointer<Float>>,
withBufferSize bufferSize: UInt32,
withNumberOfChannels numberOfChannels: UInt32) {
dispatch_async(dispatch_get_main_queue()) {
self.audioPlot.updateBuffer(buffer.memory, withBufferSize: bufferSize)
}
}