Subscribe ( )

iPhone Programming Tutorials

 

Forum

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

You must be logged in to post Login Register

Search 

Problem with AVAudioRecorder metering

User Post

2:19 am
June 28, 2009


Haibane

Noob

posts 1

1

Hi Everyone,

I am totally desperate now with this new class. I managed to make it work and record audio without problems but for some reason the metering does not work.

Could you please give me some help with this, what am I doing wrong:

In this very simple example I just want to display the current peak or average level, but I always get 0 or -160.

some code:

[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord error: nil];

        NSDictionary *recordSettings =

[[NSDictionary alloc] initWithObjectsAndKeys:

[NSNumber numberWithFloat: 44100.0],                 AVSampleRateKey,

[NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey,

[NSNumber numberWithInt: 1],                         AVNumberOfChannelsKey,

[NSNumber numberWithInt: AVAudioQualityMax],         AVEncoderAudioQualityKey,

nil];

        soundRecorder = [[AVAudioRecorder alloc] initWithURL: recURL

                                                                   settings: recordSettings

                                                                      error: nil];

soundRecorder.meteringEnabled = TRUE;

        soundRecorder.delegate = self;

        [soundRecorder prepareToRecord];

        [soundRecorder record];


and I have a timer for checking:

[soundRecorder updateMeters];

for (int k=0; k < 3; k++) {

float peak = [soundRecorder peakPowerForChannel:k];

float average = [soundRecorder averagePowerForChannel:k];

NSLog(@”Peak power for channel %i: %4.2f”,k,peak);

NSLog(@”Average power for channel %i: %4.2f”,k,average);

}


I am not sure with the channels, 0 and 1 gives always 0, all the other gives -160


About the iCodeBlog forum

Currently Online:

6 Guests

Maximum Online: 44

Forums:

Groups: 2

Forums: 6

Topics: 342

Posts: 789

Members:

There are 766 members

There are 1 guests


Brandon has made 87 posts

Top Posters:

bobcubsfan - 54

crazyiez - 30

VertigoSol - 26

AdeC - 17

Uhu - 17

Administrator: Brandon | Moderators: VertigoSol


© - Version 3.1.4 (Build 357)