macOS AVAudioRecorder - ignores duration value

Cannot record for duration, regardless of the value of 'dur' it always records for about 7 seconds.


  self.recorder!.prepareToRecord()

  let time = self.recorder!.deviceCurrentTime + 0.01

  let dur: TimeInterval = 1.0

  self.recorder!.record(atTime: time, forDuration: dur)

Any help appreciated, thanks. Paul

Found it, fixed it.

        recorderDefaults = [AVFormatIDKey: Int(kAudioFormatMPEG4AAC),
                           AVEncoderAudioQualityKey: AVAudioQuality.min.rawValue]

Don't use kAudioFormatMPEG4AAC.

macOS AVAudioRecorder - ignores duration value
 
 
Q