AudioRecordから振幅を取得するコードがあります。問題は、数学が返すことだけです - 無限。私はいくつかのより多くの目が私と一緒にそれをしてください見てもらうことができます:Amplitude from AudioRecord
private class measureSnoreAudio extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... params) {
Log.d(TAG, "Creating the buffer of size " + BUFFER_SIZE);
byte[] buffer = new byte[BUFFER_SIZE];
Log.d(TAG, "Creating the AudioRecord");
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC,
RECORDING_RATE, CHANNEL, FORMAT, BUFFER_SIZE * 10);
Log.d(TAG, "AudioRecord recording...");
recorder.startRecording();
while (isRecordingSnore) {
// read the data into the buffer
int read = recorder.read(buffer, 0, buffer.length);
int amplitude = (buffer[0] & 0xff) << 8 | buffer[1];
// Determine amplitude
double amplitudeDb = 20 * Math
.log10(Math.abs(amplitude)/32768);
String dbString = String.valueOf(amplitudeDb);
Log.d("Snore DB", "dB " + dbString);
//TextView textAmplitude = (TextView) findViewById(R.id.tvAmplitude);
//textAmplitude.setText(dbString);
}
Log.d(TAG, "AudioRecord finished recording");
return null;
}
}
に変更することができますが、私はあなたがこの行で何をしているか尋ねることができますバッファ[1]; ' また、FFTを使用せずにdb-amplitudeをどのように報告しますか? –