You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classWaveRecorderView:UIView{fileprivatevarrecordingAudioPlot:EZAudioPlotGL!fileprivatevarmicrophone:EZMicrophone!fileprivatevarrecorder:EZRecorder!privatevarbackgroundImageView:UIImageView!fileprivate(set)varisRecording=falsevarshouldStopAutomatically=truevarmaximumRecordingTime=GlobalConstants.maxClipDuration
init(){
super.init(frame:.zero)setup()}requiredinit?(coder aDecoder:NSCoder){fatalError("init(coder:) has not been implemented")}privatefunc setup(){
backgroundImageView =UIImageView(image: #imageLiteral(resourceName:"StaticWaveBackground"))addSubview(backgroundImageView)
backgroundImageView.autoPinEdgesToSuperviewEdges()startPlot()}privatefunc startPlot(){
recordingAudioPlot =EZAudioPlotGL()
recordingAudioPlot.backgroundColor =UIColor.white
recordingAudioPlot.color =UIColor.customBlue
recordingAudioPlot.gain =5
recordingAudioPlot.plotType =EZPlotType.rolling
recordingAudioPlot.shouldFill =true
recordingAudioPlot.shouldMirror =trueaddSubview(recordingAudioPlot)
recordingAudioPlot.autoPinEdgesToSuperviewEdges()}func startRecording(at fileURL:URL){print(fileURL)
microphone =EZMicrophone(delegate:self, startsImmediately:true)
recorder =EZRecorder(url: fileURL, clientFormat: microphone.audioStreamBasicDescription(), fileType:EZRecorderFileType.M4A, delegate:self)
isRecording =true}func stopRecording(){
isRecording =false
microphone.stopFetchingAudio()
recorder.closeAudioFile()}func removeAudio(){
//There is another class in charge of removing the previously created m4a file and create a
//new URL for the next file
recorder =nil
microphone =nil
recordingAudioPlot.clear()}}
// THE FOLLOWING METHODS ARE CALLED CORRECTLY BUT ONCE I STOP RECORDING
// AND REMOVE THE AUDIO, THESE METHODS ARE NOT CALLED ANY MORE AFTER `STARTRECORDING`
extensionWaveRecorderView:EZMicrophoneDelegate,EZRecorderDelegate{func microphone(_ microphone:EZMicrophone!, hasAudioReceived buffer:UnsafeMutablePointer<UnsafeMutablePointer<Float>?>!, withBufferSize bufferSize:UInt32, withNumberOfChannels numberOfChannels:UInt32){DispatchQueue.main.async{[weak self]inself?.recordingAudioPlot.updateBuffer(buffer[0], withBufferSize: bufferSize)}}func microphone(_ microphone:EZMicrophone!, hasBufferList bufferList:UnsafeMutablePointer<AudioBufferList>!, withBufferSize bufferSize:UInt32, withNumberOfChannels numberOfChannels:UInt32){guard recorder !=nilelse{return}
recorder.appendData(from: bufferList, withBufferSize: bufferSize)}}
The text was updated successfully, but these errors were encountered:
when you remove also the microphone via setting it to = nil you also remove its delegate with it, which leads to no call of the delegate methods of course.
I have a very simple app with 4 buttons (record, stop recording, play and delete) and a plot (EZAudioPlotGL) showing the microphone input realtime.
Everything works very well until I try to delete the file and record again. For some reason, the following delegate methods are not called any more:
This is what my code looks like
The text was updated successfully, but these errors were encountered: