我有一个.au音频文件,我试图将其复制到另一个音频文件,并且我希望复制的音频文件具有一半的音量。我写了下面的代码,并生成以下音频文件:音频文件 - 给定字节帧操纵音量 - Java
for (int i = 24; i < bytes.length; i++) {
// bytes is a byte[] array containing every byte in the .au file
if (i % 2 == 0) {
short byteFrame = (short) (((bytes[i - 0]&0xFF) << 8) | ((bytes[i - 1]&0xFF)));
byteFrame >>= 1;
bytes[i - 0] = (byte) (byteFrame);
bytes[i - 1] = (byte) (byteFrame >>> 8);
}
}
的数据,我从该代码得到的是这样的:
下面的代码是一样的上面,只有“字节[ i - 0]'和'字节[i - 1]'已切换位置。当我这样做时,频道中的信息会被交换到另一个频道。
for (int i = 24; i < bytes.length; i++) {
// bytes is a byte[] array containing every byte in the .au file
if (i % 2 == 0) {
short byteFrame = (short) (((bytes[i - 0]&0xFF) << 8) | ((bytes[i - 1]&0xFF)));
byteFrame *= 0.5;
bytes[i - 1] = (byte) (byteFrame);
bytes[i - 0] = (byte) (byteFrame >>> 8);
}
}
我从代码中得到的数据是这样的(在信道的信息已被交换):
我需要减少一半的两个声道的音量。以下是au文件格式的维基百科页面。有关如何使其在减少音量时能够正常工作的任何想法?这个文件的编码是1(8位G.711 mu-law),2个通道,每帧2个字节,采样率为48000.(它可以在Encoding 3上正常工作,但不能编码为1)。预先感谢任何帮助提供。
http://en.wikipedia.org/wiki/Au_file_format
我想我现在需要它的工作方式。谢谢。 – user1567060