基本 wav 数据块
我有一个关于基本 wav 文件数据块的问题。
我知道数据块部分中的每2个字节代表单声道声音并且左右声道交替存储,但我仍然不知道如何理解2个字节的值。
有高有低吗?
- 值 0000 =>最低?
- 值 FFFF =>最高?
- 值 8FFF =>没有声音?
如果是这样,当我想将音量降低 50% 时,我所要做的就是分类低和高 除以 2?
I have a question about the basic wav file data chunk.
I know that each 2 bytes in the data chunk section represent mono sound and left and right channel is alternately stored, but I still have no idea how to understand the 2 byte value.
Is it high and low?
- value 0000 => lowest?
- value FFFF => highest?
- value 8FFF => no sound?
If so, when I want to reduce volume 50%, is all I have to do just classfy low and high
and divive by 2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
WAV 文件可以包含不同位深度和编码的样本,但最常用的之一是 16 位 PCM。对于 WAV 文件中的 16 位 PCM 数据,每两个字节应被解释为短整型(即带符号的两字节数字)。在 WAV 文件中,样本始终是“little-endian”。如果您用语言标记您的问题,有人可能能够提供一些简单的示例代码。在 C/C++ 中,您将从文件中读取的数据数组转换为(短*),以便您轻松访问每个样本。
要回答问题的第二部分,是的,您可以通过将每个样本的值减半来减少体积。
WAV files can contain samples at different bit depths and encodings, but one of the most commonly used is 16 bit PCM. With 16 bit PCM data in a WAV file, each two bytes should be interpreted as a short (i.e. a signed, two-byte number). In WAV files, the samples are always "little-endian". If you tag your question with a language, someone might be able to provide some simple sample code. In C/C++, you would cast your array of data read from the file into a (short *), allowing you to easily access each sample.
To answer the second part of your question, yes you can reduce the volume by halving the value of each sample.
你的理解似乎不错。我唯一能想到的是,一个字节将是最高有效字节,而一个字节将是最低有效字节。除此之外,你看起来很对劲。
你的问题很好(无论如何在我看来!)虽然如果你问一个特定的编程问题可能会得到更有用的答案,但我可以看到这可能是不可能的。
Your understanding seems fine. The only thing I can think to say is one byte will be a most significant byte, and one will be least significant. Other than that, you seem spot on.
And your question is fine (In my opinion anyway!) Although more useful answers might be gotten if you were to ask a specific programming question, but I can see how that might not be possible.