简体   繁体   English

读取MP3文件的类

[英]Class for reading MP3 files

I am writing a game that is a bit depending on the soundtrack so I want to read mp3 file and use it's data (like the speed of music, beat and stuff). 我正在写一个有点取决于原声带的游戏,所以我想读取mp3文件并使用它的数据(如音乐,节拍和东西的速度)。 Is there any class (preferably) I could use or article that would cover everything about mp3 reading (from checking if it's an mp3 to actual decoding)? 是否有任何类(最好)我可以使用或文章涵盖有关mp3阅读的所有内容(从检查它是否是mp3到实际解码)? It's OK if I have to do different calculations to find the rhythm and stuff, I just wanna decode file as I don't know the algorithm (and don't know if it's complicated or not). 如果我必须做不同的计算来找到节奏和东西,我只是想解码文件,因为我不知道算法(并且不知道它是否复杂)。

Yes, its complicated. 是的,它很复杂。 MP3s are the typical lossy DCT compression scheme more or less. MP3或多或少是典型的有损DCT压缩方案。 The process is similar to JPEG. 该过程类似于JPEG。

Writing an mp3 decoder and encoder is a project in itself. 编写mp3解码器和编码器本身就是一个项目。

Encode 编码

Quantize -> DCT Transform -> Entropy Encode -> Store 量化 - > DCT变换 - >熵编码 - >存储

Decode 解码

Entropy Decode -> IDCT -> Dequantize -> play 熵解码 - > IDCT - >去量化 - >播放

I suggest FMOD its widely accepted and used in the gaming community. 我建议FMOD被广泛接受并用于游戏社区。

Maybe have a look at mpeglib or SDL_mixer: http://www.libsdl.org/projects/SDL_mixer/ :) Are you under Windows? 也许看看mpeglib或SDL_mixer: http//www.libsdl.org/projects/SDL_mixer/ :)你在Windows下吗?

The mp3 encoding/decoding process is pretty cool but I wouldn't go anywhere near writing your own decoder, the problem space is HUGE (and many mp3 files don't stick to the format). mp3编码/解码过程非常酷,但我不会去编写自己的解码器,问题空间是巨大的(许多MP3文件不坚持格式)。 There are plenty of libraries out there, you just have to find one which suits! 那里有很多图书馆,你只需找到一个适合的图书馆!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM