gpt4 book ai didi

audio - 声音 - 什么是原始声音数据?

转载 作者:行者123 更新时间:2023-12-02 22:57:17 28 4
gpt4 key购买 nike

我有解码 MP3 并用所有“值”填充数组的代码。
我的问题是:这些值(value)观是什么?它们是频率吗?它们是振幅吗?
这是代码:

File file = new File(song.getFilepath());
if (file.exists()) {
AudioInputStream in = AudioSystem.getAudioInputStream(file);
AudioInputStream din = null;
AudioFormat baseFormat = in.getFormat();
AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
baseFormat.getSampleRate(),
16,
baseFormat.getChannels(),
baseFormat.getChannels() * 2,
baseFormat.getSampleRate(),
false);
din = AudioSystem.getAudioInputStream(decodedFormat, in);
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] data = new byte[4096];
SourceDataLine line = getLine(decodedFormat);

int nBytesRead = 0, nBytesWritten = 0;
while (nBytesRead != -1) {
nBytesRead = din.read(data, 0, data.length);
if (nBytesRead != -1) {
nBytesWritten = line.write(data, 0, nBytesRead);
out.write(data, 0, nBytesRead);
}
}
byte[] audio = out.toByteArray();
System.err.println(audio.length);
for (byte b : audio) {
System.err.println(b);
}
}

对于 3 分钟的歌曲,我得到大约 40,000,000 个数字(字节数组的长度),但我不知道它们是什么?

最佳答案

它们是幅度。通常,每个幅度为 16 位(2 个字节,范围从 -32768 到 32767),有两个 channel (左右)。在这种情况下,一个声音样本跨越四个字节。
例子:
100, 0, 2, 1
表示左振幅为 100(32767),右振幅为 258。

关于audio - 声音 - 什么是原始声音数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22409407/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com