24 位 wav 文件的数据块是否有符号或无符号字节?
我正在尝试编写一个程序,使用 java 创建 24 位 wav 文件。 java 声音 api 不支持 24 位音频,所以我尝试从头开始编写该文件。这最初只是一种偶然的兴趣,但现在它已经成为对位、字节、符号和块的史诗般的探索。
24 位 wav 文件的数据块有符号字节还是无符号字节?
Java 缺乏无符号字节是令人沮丧的。我读过位掩码整数可用于表示无符号字节,但我想知道如何在文件的最终输出中表示它。
抱歉发散...我的问题是“24 位 wav 文件的数据块是否有签名或无符号字节?”
无论哪种方式,我都必须弄清楚这个签名/未签名的业务,但我在我找到的参考文献中找不到有关数据块的答案。
I am trying to write a program that will create 24 bit wav files using java. The java sound api does not support 24 bit audio so I am trying to write the file from scratch. This started out as a casual interest but it has become an epic quest of bits, bytes, signs and chunks.
Does a 24bit wav file's data chunk have signed or unsigned bytes?
Java's lack of unsigned bytes is frustrating. I have read that bit masked integers can be used to represent unsigned bytes but I wonder how that will be represented in the final output to file.
Sorry to diverge... my question is "Does a 24bit wav file's data chunk have signed or unsigned bytes?"
Either way I am going to have to figure out this signed/unsigned business but I can't find an answer regarding the data chunk in the references I have found.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我还可以确认 WAV 文件中的 24 位数据已签名(当数据以 WAVE_FORMAT_PCM 格式存储时)。更一般地,WAVE_FORMAT_PCM 数据总是带符号的,除非它是每个样本 8 位。
I can also confirm that 24 bit data in WAV files is signed (when the data is stored in the WAVE_FORMAT_PCM format). More generally, WAVE_FORMAT_PCM data is always signed EXCEPT when it is 8-bits per sample.
根据 this (以及我自己的个人经验)Microsoft WAVE 文件使用 2's-对有符号整数求补以表示大于 8 位的 PCM 样本。默认情况下,这些整数的字节顺序是小端字节序。
您可以使用 SoX 包中的
soxi
在您自己的测试文件上验证这一点(你确实有一些,对吧?)。请注意,WAVE 文件还可以保存普通 PCM 以外的音频格式。
According to this (and my own personal experience) Microsoft WAVE files use 2's-complement signed integers to represent PCM samples larger than 8 bits. By default, the byte-order of those integers is little-endian.
You can use
soxi
from the SoX package to verify this on your own test files (you do have some, right?).Please note that WAVE files can also hold audio formats other than plain PCM.