I made an equalizer using eq10q filters. Now I want to use my equalizer for music equalization and make my own music player. So I have some doubts:

  1. If I want to equalize MP3 files, do I have to decode the MP3 file to PCM audio, apply my filters and then play the audio?

  2. What library or codec do you recommend me to this task?

  3. Is possible to apply filters to an MP3 file without convert the data to PCM?

  • $\begingroup$ If you're going to play the audio, you're going to need to undo the MP3 compression anyway, so why not do that first? That's certainly the most straightforward approach. $\endgroup$
    – Jason R
    May 10 '16 at 13:40

The usual approach to achieve your goal would indeed consist in decoding the MP3 file to a series of uncompressed time-domain samples and then filtering this PCM signal. As you are building a player, and as Jason R mentioned in his comment, you will have to decode the MP3 file for being able to play it back via the soundcard anyway.

My answer to your three questions would therefore be

  1. Yes
  2. To perform the actual decoding, I can recommend the libsndfile library. Not only does it provide a high-quality MP3 decoder (and encoder) but it allows you to access a whole bunch of other formats.
  3. I'm not sure, however, I think it should be possible. I'm not aware if anyone has ever tried and, furthermore, I'm not aware if it has any benefit compared to the decode $\rightarrow$ filter $\rightarrow$ encode approach. As the MP3 file contains the audio data in a transform domain you would have to figure out how your filters act in this transform domain. (I reckon this could lead to computationally expensive operations.)

The article All About Audio Equalization: Solutions and Frontiers was just published (May 2016), and should provide you with interesting insights. It comes with some code. One common and older solution is mp3gain (sourceforge), and others are discussed for instance in Ask the Readers: Best method of MP3 volume leveling?.

From what I understand, a little bit of mp3 decoding is necessary since it is a compressed format (you cannot apply filters directly on the binary file). Yet, the format allows access to specific chunks of data converted into frequencies, a domain in which equalization can be applied.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.