0
Mediaplayer를 사용하여 사용자의 음성을 성공적으로 녹음했으며 파일이 SD 카드에 저장되었습니다. 이제 오디오 트랙을 사용하여 해당 음성을 재생하고 싶습니다. 그러나 내가 할 때 그것은 소음을 낸다. Y so.? 여기 AudioTrack에서 소리가 나기 때문에 오디오 파일을 제대로 재생하지 못합니다.
는private void PlayAudioFileViaAudioTrack(String filePath) throws IOException
{
// We keep temporarily filePath globally as we have only two sample sounds now..
if (filePath==null)
return;
int intSize = android.media.AudioTrack.getMinBufferSize(44100, AudioFormat.CHANNEL_CONFIGURATION_STEREO,
AudioFormat.ENCODING_PCM_16BIT);
AudioTrack at = new AudioTrack(AudioManager.STREAM_MUSIC, 44100, AudioFormat.CHANNEL_CONFIGURATION_STEREO,
AudioFormat.ENCODING_PCM_16BIT, intSize, AudioTrack.MODE_STREAM);
if (at==null){
Log.d("TCAudio", "audio track is not initialised ");
return;
}
int count = 512 * 1024; // 512 kb
//Reading the file..
byte[] byteData = null;
File file = null;
file = new File(filePath);
byteData = new byte[(int)count];
FileInputStream in = null;
try {
in = new FileInputStream(file);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int bytesread = 0, ret = 0;
int size = (int) file.length();
at.play();
while (bytesread < size) { ret = in.read(byteData,0, count); if (ret != -1) { // Write the byte array to the track
at.write(byteData,0, ret); bytesread += ret; } else break; } in.close(); at.stop(); at.release(); }
"잡음 만들기 ..." –
잡음은 소리에 큰 왜곡을 만들어내는 것으로 분명하게 음성을 재생하지 못한다고 말할 수 있습니다. – AndroidiVore
@Kenny m waiting – AndroidiVore