wav 录音流提取卷号

发布于 2024-12-22 04:17:27 字数 165 浏览 5 评论 0原文

我有一个来自麦克风的音频数据Stream,我想显示其当前录音音量级别。根据我收集的信息,我需要在数组中存储 X 个字节,然后我可以使用该数据来处理记录中的一个样本。如何确定 X 是什么?我需要做什么才能从该数据中获取音量级别?

我正在使用 C#,但即使是伪代码也会非常有帮助

I have a Stream of audio data coming from my mic for which I would like to display the current recording volume level. From what I've gathered, I need to store X number of bytes in an array and then I can use that data to process that one sample from the recording. How do I determine what X is, and what do I need to do to get the volume level from that data?

I'm working in C# but even pseudo code would be very helpful

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

oО清风挽发oО 2024-12-29 04:17:27

WAV 文件是调幅的,因此每个样本值都是相对音量。对时间进行平均,您将得到平均音量。

注意事项:

  • 以上仅适用于未压缩的 LPCM 数据。 WAV 文件可以被压缩,在这种情况下,您需要实现所需的任何解码器才能使用未压缩的数据。
  • WAV 文件可以是 8 位或 16 位
  • WAV 文件确实有一些要跳过的标头信息,文件格式有详细记录 (https://ccrma.stanford.edu/courses/422/projects/WaveFormat/)
  • 读取标头时请注意字节顺序

以下是一些用于读取 WAV 文件的 .NET 示例代码:
http://www.codeproject.com/KB/audio-video/WaveEdit.aspx

WAV files are amplitude-modulated, so each sample value is the relative volume. Average across time and you get an average volume.

Things to watch out for:

  • The above only applies to uncompressed LPCM data. WAV files can be compressed, in which case you'd need to implement whatever decoder is needed to get uncompressed data to work with.
  • WAV files can be both 8-bit or 16-bit
  • WAV files do have some header info to skip past, the file format is well-documented (https://ccrma.stanford.edu/courses/422/projects/WaveFormat/)
  • Watch your endians when reading the header

Here's some sample .NET code for reading WAV files:
http://www.codeproject.com/KB/audio-video/WaveEdit.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文