简体   繁体   中英

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). 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)? 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. The process is similar to JPEG.

Writing an mp3 decoder and encoder is a project in itself.

Encode

Quantize -> DCT Transform -> Entropy Encode -> Store

Decode

Entropy Decode -> IDCT -> Dequantize -> play

I suggest FMOD its widely accepted and used in the gaming community.

Maybe have a look at mpeglib or SDL_mixer: http://www.libsdl.org/projects/SDL_mixer/ :) Are you under 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). There are plenty of libraries out there, you just have to find one which suits!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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