avaudiorecorder

AVAudioRecorder swift 2

做~自己de王妃 提交于 2019-12-03 09:21:30
问题 I had my AVAudioRecorder working, but since upgrading to swift 2, I can't seem to figure out how to configure it correctly. I keep getting an error saying the AVAudioRecorder initializer cannot be invoked, but the parameters I'm providing look correct to me. var recordSettings = [AVSampleRateKey : NSNumber(float: Float(44100.0)), AVFormatIDKey : NSNumber(int: Int32(kAudioFormatMPEG4AAC)), AVNumberOfChannelsKey : NSNumber(int: 1), AVEncoderAudioQualityKey : NSNumber(int: Int32(AVAudioQuality

How can I append to a recorded MPEG4 AAC file?

北战南征 提交于 2019-12-03 07:54:47
问题 I'm recording audio on an iPhone, using an AVAudioRecorder with the following settings: NSMutableDictionary *recordSettings = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt: kAudioFormatMPEG4AAC], AVFormatIDKey, [NSNumber numberWithFloat:44100.0], AVSampleRateKey, [NSNumber numberWithInt:1], AVNumberOfChannelsKey, [NSNumber numberWithInt:12800], AVEncoderBitRateKey, [NSNumber numberWithInt:16], AVLinearPCMBitDepthKey, [NSNumber numberWithInt: AVAudioQualityHigh],

Recording voice in background using AVAudioRecorder

强颜欢笑 提交于 2019-12-03 05:10:54
I'm trying to record user voice in background using AVAudioRecorder but every time i get NO while calling recordForDuration method. I add "audio" to UIBackgroundModes but this don't help. By the way, Everything works perfect in foreground. I'm initializing AVAudioRecorder using this code: NSError* error; if (![[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecord error:&error]) { NSLog(@"Error while setting audio session category. Code - %d, description - \"%@\".", [error code], [error localizedDescription]); return; } NSURL* outputFileURL = [VKMFileSystemHelper

AVAudioRecorder stops working when writing to /dev/null on iPhone 5s with iOS 7

雨燕双飞 提交于 2019-12-03 03:51:00
I have an app that monitors the background audio level without recording to a file. I use the trick of writing to /dev/null to accomplish this. This code has worked on the iPhone 3GS with iOS 6, iPhone 4 with iOS 6 and iOS 7, and in the simulator with iOS 7 and iPhone Retina (4-inch 64-bit). When I try it on a real iPhone 5s, however, the recorder seems to capture audio for a moment, and then silently dies. This is the code: // Inititalize the audio NSURL *url = [NSURL fileURLWithPath:@"/dev/null"]; NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithFloat:

AVAudioRecorder - Proper MPEG4 AAC Recording Settings

江枫思渺然 提交于 2019-12-03 03:15:00
I've got a live app with an estimated 15% of users reporting that the record feature is not working. This isn't happening on our test devices, but the reports show that the problem is that prepareToRecord is returning NO. I've had trouble finding sample settings for AAC format. Are any of my settings off? App requires iOS5 and uses ARC. AVAudioSession *audioSession = [AVAudioSession sharedInstance]; [audioSession setCategory:AVAudioSessionCategoryRecord error:nil]; NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:kAudioFormatMPEG4AAC],

Routing iPhone Audio Sound

放肆的年华 提交于 2019-12-03 00:39:22
I have an app which does listen and play sound at the same time. By default, the sound output goes through the earphone. So I use the following code to route it through the speaker: UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute, sizeof(audioRouteOverride), &audioRouteOverride); This works fine. But now, I'd like to route the sound through the headphones when headphones or external speakers are attached. How would I achieve that? Also ideally all other sound (i.e. music etc.) should mute when the app

How to get the reading of deciBels from iOS AVAudioRecorder in a correct scale?

一世执手 提交于 2019-12-02 19:41:41
I'm trying to obtain a noise level in my iOS app, using AVAudioRecorder. The code I'm using is: [self.recorder updateMeters]; float decibels = [self.recorder averagePowerForChannel:0]; // 160+db here, to scale it from 0 to 160, not -160 to 0. decibels = 160+decibels; NSLog(@"Decibels: %.3f", decibels); The readings I get, when the phone sits on my desk are at about 90-100dB. I checked this this link and the table I saw there shows that: Vacuum Cleaner - 80dB Large Orchestra - 98dB Walkman at Maximum Level - 100dB Front Rows of Rock Concert - 110dB Now, however my office might seem to be a loud

AVAudioRecorder won't record IF movie was previously recorded & played

雨燕双飞 提交于 2019-12-02 19:38:07
My iPhone app uses "AVAudioRecorder" to make voice recordings. It also uses "UIImagePickerController" to record movies and "MPMoviePlayerController" to play movies. Everything works fine until I do all three things in a row: Record a movie using UIImagePickerController Play back the recorded movie using MPMoviePlayerController Try to make a voice recording using AVAudioRecorder When I call AVAudioRecorder's "record" method in step 3, it returns NO indicating failure, but giving no hints as to why (come on Apple!) AVAudioRecorder's audioRecorderEncodeErrorDidOccur delegate method is never

FileManager cannot find audio file

三世轮回 提交于 2019-12-02 05:16:32
Helloo! My ultimate goal is to create a UITableViewController with recordings made in-app, using FileManager to traverse the /Documents/ directory and list all the recordings found there. The recording and playback are functioning just fine with one recording, with the following setup: // In VC#1 func setupRecorder(){ let audioSession:AVAudioSession = AVAudioSession.sharedInstance() do { try audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord) } catch { print("Audio Setup Error: \(error)") } do { try audioSession.setActive(true) } catch { print("Audio Setup Error: \(error)") } let

combine two .caf audio files into a single audio file in iphone

99封情书 提交于 2019-12-02 03:31:45
I am using AVAudioRecorder for recording audio in .caf format. When the user will resume this recording the new recording must append with the old recording. So how can i combine two .caf audio files. You can do it using ExtAudioFileService. In ios developer library they had provided two examples to convert one audio file to another format. In these they are opening one audio file for reading and another file for writing (converted audio). You can change or updated code to read from two files and write them to one out put file in same format(caf) or compressed format. First you have open first