3

I am trying to record an wav file with AVAudiorecorder using the following settings. The file created plays fine on my mac and iPhone but when i mail it to a blackberry device and try to play it from there it says the format is not supported.. what am i possibly doing wrong?? i believe i am missing something when initializing the settings for the audiorecorder so i am posting only the settings dictionary

NSDictionary *settings = [[NSDictionary alloc] initWithObjectsAndKeys:
                                 [NSNumber numberWithFloat: 44100.0],AVSampleRateKey,
                                 [NSNumber numberWithInt: kAudioFormatLinearPCM],AVFormatIDKey,// kAudioFormatLinearPCM
                                 [NSNumber numberWithInt:16],AVLinearPCMBitDepthKey,
                                 [NSNumber numberWithInt: 2], AVNumberOfChannelsKey,
                                 [NSNumber numberWithBool:NO],AVLinearPCMIsBigEndianKey,
                                 [NSNumber numberWithBool:NO],AVLinearPCMIsFloatKey,  
                                 [NSNumber numberWithInt: AVAudioQualityMedium],AVEncoderAudioQualityKey,nil];
hemant
  • 1,771
  • 4
  • 31
  • 43
  • The link can be helpful to you http://stackoverflow.com/questions/570430/recording-sound-as-wav-on-iphone – Maulik Jun 06 '12 at 13:26

1 Answers1

2

mush easier to achieve this, in 2021 with swift 5,

      let fileURL: URL = {
            let src = "abc.wav"
            return FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent(src)
       }()


       let recordSettings: [String : Any] = [AVFormatIDKey: Int(kAudioFormatLinearPCM),
                                      AVSampleRateKey: 44100.0,
                                      AVNumberOfChannelsKey: 1,
                                      AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue ]
        
        do {
            audioRecorder = try AVAudioRecorder(url: fileURL, settings: recordSettings)
            audioRecorder?.prepareToRecord()
        } catch {
            print("Error creating audio Recorder. \(error)")
        }
    
black_pearl
  • 2,549
  • 1
  • 23
  • 36