如何在没有音频库的情况下编辑原始 PCM 音频数据

时间:2023-02-07
本文介绍了如何在没有音频库的情况下编辑原始 PCM 音频数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对精确提取 PCM WAV 文件的各个部分感兴趣,直到样本级别.大多数音频模块似乎都依赖于特定于平台的音频库.我想做这个跨平台,速度不是问题,有没有原生的python音频模块可以做到这一点?

I'm interested in precisely extracting portions of a PCM WAV file, down to the sample level. Most audio modules seem to rely on platform-specific audio libraries. I want to make this cross platform and speed is not an issue, are there any native python audio modules that can do this?

如果没有,我将不得不解释 PCM 二进制文件.虽然我确信我可以相当容易地挖掘 PCM 规范,并且原始格式很容易理解,但我以前从未真正用 Python 处理过二进制数据.有没有很好的资源可以解释如何做到这一点?专门与音频相关的只是锦上添花.

If not, I'll have to interpret the PCM binary. While I'm sure I can dig up the PCM specs fairly easily, and raw formats are easy enough to walk, I've never actually dealt with binary data in Python before. Are there any good resources that explain how to do this? Specifically relating to audio would just be icing.

推荐答案

我看了问题和答案,我觉得我一定遗漏了一些非常明显的东西,因为没有人提到以下两个模块:

I read the question and the answers and I feel that I must be missing something completely obvious, because nobody mentioned the following two modules:

  • audioop:操作原始音频数据
  • wave:读写WAV文件
  • audioop: manipulate raw audio data
  • wave: read and write WAV files

也许我来自平行宇宙,Guido 的时间机器实际上是一个时空机器 :)

Perhaps I come from a parallel universe and Guido's time machine is actually a space-time machine :)

如果您需要示例代码,请随时询问.

Should you need example code, feel free to ask.

PS 假设 48kHz 采样率,24/1.001==23.976023976... fps 的视频帧长度为 2002 个音频样本,而 25fps 的视频帧长度为 1920 个音频样本.

PS Assuming 48kHz sampling rate, a video frame at 24/1.001==23.976023976… fps is 2002 audio samples long, and at 25fps it's 1920 audio samples long.

这篇关于如何在没有音频库的情况下编辑原始 PCM 音频数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:在 python 中添加二进制数时需要帮助 下一篇:将二进制整数或字符串写入python中的文件

相关文章

最新文章