【发布时间】:2018-04-29 02:51:43
【问题描述】:
我正在尝试加载一个 .mp3 文件,并区分左右声道。我想从左声道复制数据并创建一个 AudioStream,通过左右声道播放来自左声道的数据。
我一直在尝试使用这段代码来实现它,但它似乎产生了一个难以辨认的字节数组
InputStream inputStream = getApplicationContext().getResources().openRawResource(R.raw.flume);
soundBytes1 = new byte[inputStream.available()];
soundBytes1 = toByteArray(inputStream);
public byte[] toByteArray(InputStream in) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
int read = 0;
byte[] buffer = new byte[1024];
while (read != -1) {
read = in.read(buffer);
if (read != -1)
out.write(buffer,0,read);
}
out.close();
return out.toByteArray();
}
我希望能够使用任何 .mp3 文件执行此过程。是否需要将音频转换为其他格式才能区分通道?
【问题讨论】:
标签: android audio mp3 audio-streaming android-music-player