2012-08-09 8 views

答えて

17

次のコードはApple's Sample AVRecorderから取得されています...このコードは、このクラスのmovieFileOutputの接続メソッドから一連の接続を取得し、各接続のAVCaptureAudioChannelを取得し、それに基づいてデシベル電力を計算します。あなたは出力 "ノイズレベル"を探している場合は、同様の情報をキャプチャすることができると私は推測する。これより低いレベルのものを探しているなら、HAL(Hardware Abstraction Layer)フレームワークを試してみてください。

- (void)updateAudioLevels:(NSTimer *)timer 
{ 
    NSInteger channelCount = 0; 
    float decibels = 0.f; 

    // Sum all of the average power levels and divide by the number of channels 
    for (AVCaptureConnection *connection in [[self movieFileOutput] connections]) { 
     for (AVCaptureAudioChannel *audioChannel in [connection audioChannels]) { 
      decibels += [audioChannel averagePowerLevel]; 
      channelCount += 1; 
     } 
    } 

    decibels /= channelCount; 

    [[self audioLevelMeter] setFloatValue:(pow(10.f, 0.05f * decibels) * 20.0f)]; 
} 
+0

変換はpow(10.f、0.05f * decibels)でなければなりませんか?あなたはその余分な時間20を必要としません。ここをクリックしてください:http://stackoverflow.com/questions/2465328/iphone-sdk-avaudiorecorder-metering-how-to-change-peakpowerforchannel-from-dまたはより良いhttp://travisjeffery.com/b/2013/02/convert-avfoundations-power-levels-to-logarithmic-and-linear-scale/ – ucangetit

+0

@ucangetit、私はコードスニペットに関する細部について知的に話すことができません。 Appleがサンプルコードへのリンクを修正した場合にのみ、私はコードをコピーしました。 –

関連する問題