Android 플랫폼에 사운드 미터를 구축하려고합니다. (나는 HTC 산불을 사용하고 있습니다.) 그 목표에 대해 AudioRecord
클래스를 사용하지만, "read"에서 반환되는 값은 합리적이지 않습니다.AudioRecord read가 이상한 값을 반환합니다.
short[] audioData = new short[bufferSize];
int offset =0;
int shortRead = 0;
int sampleToReadPerGet = 1000;//some value in order to avoid momentaraly nosies.
//start tapping into the microphone
audioRecored.startRecording();
//start reading from the microphone to an internal buffer - chuck by chunk
while (offset < sampleToReadPerGet)
{
shortRead = audioRecored.read(audioData, offset ,sampleToReadPerGet - offset);
offset += shortRead;
}
//stop tapping into the microphone
audioRecored.stop();
//average the buffer
int averageSoundLevel = 0;
for (int i = 0 ; i < sampleToReadPerGet ; i++)
{
averageSoundLevel += audioData[i];
}
averageSoundLevel /= sampleToReadPerGet;
그 가치는 무엇입니까 : 내가 그것을에서 데이터를 읽으려고 시도하는 방법이있다
int minBufferSize =
AudioRecord.getMinBufferSize(sampleRateInHz,
android.media.AudioFormat.CHANNEL_IN_MONO,
android.media.AudioFormat.ENCODING_PCM_16BIT);
audioRecored = new AudioRecord(MediaRecorder.AudioSource.MIC,
44100,
android.media.AudioFormat.CHANNEL_IN_MONO,
android.media.AudioFormat.ENCODING_PCM_16BIT,
minBufferSize);
:
이것은 내가 가지 audiorecord 객체를 생성하는 방법이다? 데시벨인가요?
편집 : 값은 -200에서 3000 사이입니다. shortRead의 값은 sampleToReadPerGet (1000)입니다.
을 받고 어떤 값? 물론 16 비트 PCM 샘플을 다시 얻는 것입니다. – Brad
읽기를 호출 한 후 'shortRead'의 값은 무엇입니까? –
질문에 값을 추가했습니다. – talel