5

实际上我正在使用 LSB 替换算法来实现音频隐写术。我正在使用以下代码将音频转换为字节数组:

    File src = new File("C:\\test.wav");
    AudioInputStream ais = AudioSystem.getAudioInputStream(src);
    byte[] data = new byte[ais.available()];
    int n = ais.read(data);

现在问题是这个音频文件是 16 位样本长度、双通道和 LittleEndian;我使用“isBigEndian()”函数检查了这个。因此,我想知道样本是如何存储在字节数组中的,以便我知道要替换哪些位。

4

1 回答 1

2

你如何将音频转换为字节数组?

实际存储的是样本数组。如果你有一个特定频率的干净单音,你会得到一个遵循正弦曲线的阵列。这是一个完美正弦波的示例:

127,130,133,136,139,142,145,148,151,154,157,160,163,166,169,172,175,178,181,184,186,189,192,194,197,200,202,205,207,209,212,214,216,218,221,223,225,227,229,230,232,234,235,237,239,240,241,243,244,245,246,247,248,249,250,250,251,252,252,253,253,253,253,253,254,253,253,253,253,253,252,252,251,250,250,249,248,247,246,245,244,243,241,240,239,237,235,234,232,230,229,227,225,223,221,218,216,214,212,209,207,205,202,200,197,194,192,189,186,184,181,178,175,172,169,166,163,160,157,154,151,148,145,142,139,136,133,130,127,123,120,117,114,111,108,105,102,99,96,93,90,87,84,81,78,75,72,69,67,64,61,59,56,53, 51,48,46,44,41,39,37,35,32,30,28,26,24,23,21,19,18,16,14,13,12,10,9,8,7, 6,5,4,3,3,2,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,2,3,3,4, 5,6,7,8,9,10,12,13,14,16,18,19,21,23,24,26,28,30,32,35,37,39,41,44,46, 48,51,53,56,59,61,64,67,69,72,75,78,81,84,87,90,93,96,99,102,105,108,111,114,117,120,123

如果您有一个 16 位流,您应该使用 short[] 来存储它,这样您就不必担心大/小端。如果您选择使用 byte[],它将是音频样本数量的两倍,并且需要组合两个连续的字节来表示一个样本。

于 2013-03-12T05:09:49.787 回答