从 MP3 中提取原始音频/波形
这个问题在我心里已经存在了几年,但我从未真正找到答案。
我想做的是提取 MP3 文件的实际波形/PCM,以便我可以使用声卡播放它(当然)。
理想情况下,我会尝试一些 DSP 效果。
我的第一步是研究 LAME,但我没有在程序或类似的东西中找到任何与 MP3 解码相关的内容。
所以我想问在哪里可以找到这样的东西。
我应该使用什么语言? 我正在考虑 C,但也许有一些编程语言可以更有效地完成这项工作。
谢谢!
纪尧姆.
This question has been in my mind for a few years and I never actually found the answer for this.
What I would like to do is extract the actual waveform/PCM of an MP3 file, so that I can play it using the soundcard (of course).
Ideally I would be experimenting some DSP effects.
My first step was to look into LAME, but I didn't find anything relevant about MP3 decoding in a program or stuff like that.
So I'm asking where I could find something like this.
What language should I use? I was thinking C, but maybe there are programming languages out there that would do the job more efficiently.
Thanks!
Guillaume.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
问题归结为:你想实现什么目标?
从你对解码 MP3 并在声卡上播放它的问题的描述来看,听起来好像你正在尝试制作一个媒体播放器。
然而,如果您的目的是玩弄 DSP 效果,那么听起来问题更多是关于处理声音而不是解码 MP3。 如果是这种情况,可能会考虑为现有媒体播放器编写插件(例如 Windows Media Player 和 Winamp) 将是您实现目标的最简单途径试图完成。
坦率地说,学习从头开始编写自己的解码器不仅仅是一个编程问题,而且是一个数学问题,因此使用现有的库是正确的方法。 与操作系统或 DirectSound 等库对话来输出音频似乎是不必要的工作。 我认为为现有播放器开发插件是可行的方法,除非您的目标是制作自己的媒体播放器。
如果您真正想要完成的是播放音频数据,那么可能使用任何 MP3 解码器将 MP3 解码为未压缩的 PCM,然后以您选择的语言对其进行操作将实现处理声音效果的目标。
语言选择将取决于您是否要直接与 MP3 解码库交互,或者是否可以仅使用原始音频输入,这将允许您使用您选择的几乎任何语言。
不久前有一个类似的问题,程序化音频入门,我在其中发布了关于操纵音频的一些基本方法的答案,例如放大、更改播放速度以及使用 FFT 进行一些工作。
The question boils down to: what are you trying to accomplish?
From the description of your question of decoding an MP3 and playing it on the sound card makes it sounds as if you are trying to make a media player.
However, if your intent is to play around with DSP effects, then it sounds like the question is more about processing the sound rather than decoding MP3s. if that's the case, probably looking into writing plug-ins for existing media players (such as Windows Media Player and Winamp) would be easiest path to what you're trying to accomplish.
Frankly, learning to write your own decoder from scratch is not just a programming problem but a mathematical one, so using existing libraries are the way to go. Talking to the operating system or libraries like DirectSound to output audio seems like unnecessary work if anything. I feel that working on plug-ins for existing players would be the way to go, unless your goal is to make your own media player.
If what you really want to accomplish is playing with audio data, then probably decoding an MP3 to uncompressed PCM using any MP3 decoder, then manipulating it in the language of your choice would accomplish your goal of dealing with effects with sound.
The language choice is going to depend on whether you are going to interact directly with MP3 decoding libraries, or whether you can just use raw audio input, which would allow you to use pretty much any language of your choice.
There was a similar question a while back, Getting started with programmatic audio, where I posted an answer on some basic ways to manipulate audio, such as amplification, changing playback speed, and doing some work with FFT.
libmpg123 应该可以解决问题。
libmpg123 should do the trick.
我一直在使用 Windows Media SDK,不是为了这个目的,但我很确定有一些钩子可以让你拦截音频流,或者将 MP4 转换为未压缩的 WAV。 我用的是C++。
I have been using the Windows Media SDK, not for this purpose, but I am pretty sure there are hooks let that let you intercept the audio stream, or convert MP4 to uncompressed WAV. I used C++.
很多:
http://www.mp3-tech.org/programmer/decoding.html< /a>
选择你的毒药...
此外,LAME 确实可以解码 MP3(查看 --decode 选项),因此您可能会在该源中找到一些有趣的东西。
-亚当
Lots:
http://www.mp3-tech.org/programmer/decoding.html
Pick your poison...
Also, LAME does decode MP3s (check out --decode option), so you might find something interesting in that source.
-Adam
这实际上取决于您在什么平台上编程以及您想用代码做什么。 如果您使用的是 Windows,则应查看 Windows 媒体格式 sdk或DirectShow。 它们都应该能够将 mp3 文件解码为原始波形。 在 Mac 上,我希望 Quicktime 也具有同样的功能。 其他人已经建议了 Linux/开源代码的来源。
It really depends what platform you are programming on and what you want to do with the code. If you are on Windows you should look at the windows media format sdk or DirectShow. They should both have the ability to decode mp3 files into the raw waveform. On the Mac, I would expect Quicktime to have this same ability. Others have already suggested source for Linux/open source code.
我建议您查看 Cubase 和 Wavelab,因为它们都可以将 MP3 转换为 WAV 等,并允许您使用波形
I would recommend looking at Cubase and Wavelab as both will convert MP3 to WAV etc and allow you to play around with the waveform