getMaxAmplitude() 関数の代わりにオーディオ レコード クラスを使用して、Android アプリ (サウンドメーター) を開発しようとしています。
私はそれを行うためにこのリンクをたどりました:
Androidにサウンドフィルタリングライブラリはありますか
このコードについていくつか質問があります。
- calculatePowerDb()関数で電力を計算するにはどうすればよいですか? なぜサンプルの sqsum を行うのですか? 言い換えれば、この方程式「電力 = (sqsum - sum * sum / samples) / samples」は何を表しているのでしょうか?
- 出力値「return Math.log10(power) * 10f + FUDGE;」です。(power leve/ref_power) の差は?
実際、私はこの機能を理解していません:
public final static double calculatePowerDb(short[] sdata, int off, int samples){
// Calculate the sum of the values, and the sum of the squared values.
// We need longs to avoid running out of bits.
double sum = 0;
double sqsum = 0;
for (int i = 0; i < samples; i++) {
final long v = sdata[off + i];
sum += v; // Ok until here I understand
sqsum += v * v; //why this??
}
double power = (sqsum - sum * sum / samples) / samples;//what's this equation?
// Scale to the range 0 - 1.
power /= MAX_16_BIT * MAX_16_BIT;
// Convert to dB, with 0 being max power. Add a fudge factor to make
// a "real" fully saturated input come to 0 dB.
return Math.log10(power) * 10f + FUDGE; //the value is at decibel?
//if it is, is it a db(a) value,
//a power level value
//or a pressure level value ?
}
このコードは負の値を返し (音響パワーを期待)、デバイスでいくつかのキャリブレーションを行った後 (追加/撤回比率) は正常に動作します。
ここで、このコードの一部を理解したいと思います (上記のコメント)。
あなたの応答と実行できるすべての詳細をありがとう!