3

For recording sound, I am using the following code:

- (IBAction) recordClicked:(id)sender {
    NSLog(@"play Record");
    if (audioPlayerRecord) {
        if (audioPlayerRecord.isPlaying) [audioPlayerRecord stop];
        else {
            [audioPlayerRecord play];
            [self updateCurrentTimeForPlayer:audioPlayerRecord];
        }
        return;
    } 

    //Initialize playback audio session
    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
    [audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *recDir = [paths objectAtIndex:0];
    NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/recordTest.caf", recDir]];

    NSError *error;
    audioPlayerRecord = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
    [audioPlayerRecord play];
    duration.text = [NSString stringWithFormat:@"%d:%02d", (int)audioPlayerRecord.duration / 60, (int)audioPlayerRecord.duration % 60, nil];
    progressBar.maximumValue = audioPlayerRecord.duration;
    [self updateViewForPlayerState:audioPlayerRecord];
    NSLog(@"Recoder file >");
}

When recording is on going , I want to show the following type of level meter

Level meter

So is there any other simplified way to achieve this problem?

PDP
  • 159
  • 1
  • 12
  • the `SpeakHere` is the perfect example how you can use the `AvFoundation` and `AudioToolBox` frameworks... yes, it takes some extra days to understand it, but I assume you are not lazy to learn new techniques. :) – holex Jan 07 '13 at 14:05
  • Hello PDP have you solved your problem me too facing the same please help ASAP... – BADRI Dec 11 '13 at 19:30

1 Answers1

0

check AQRecorder.mm ...

find: void AQRecorder::StartRecord(CFStringRef inRecordFile)

here you must comment / remove de line

url = CFURLCreateWithString(kCFAllocatorDefault, (CFStringRef)recordFile, NULL);

with

url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)recordFile, kCFURLPOSIXPathStyle, false);
TonyMkenu
  • 7,597
  • 3
  • 27
  • 49