BladeEnc Sourcecode

BladeEnc is distributed under the terms of the GNU Lesser General Public License (LGPL), so you are welcome to download and use the sourcecode for anything you want as long as you follow the license agreement.

Please click on "License" in the left frame to view the license agreement before downloading the sourcecode.

Stable and Development versions

The sourcecode for BladeEnc is available in two versions: Stable and Development.

The stable version is the latest released version, which is the recommended sourcecode to download if you want to compile BladeEnc for a platform not supported. As long as you set the right defines in system.h and manage to compile together a binary it should work nicely.

The development version is always the latest thing, provided for people who wants to help developing BladeEnc. It might not work correctly if we are in the middle of some major changes. It also might contain serious bugs or decreased sound quality if we are experimenting with some new algorithms. I don't recommend you to download this for anything except helping out with the development. As soon as we have a development version which we considers to be trustworthy for everyday use, we'll release it as the next stable version.

From time to time there might just be a stable version if I've recently released a new stable version and haven't made any changes since then.

Click here to go to the source archive

Committing back changes

People who have downloaded the sourcecode and made improvements are encouraged to send back their modified sourcecode. This is done by attaching the sourcecode to an e-mail and sending it to Please also write something about what you have changed and why since that will make it easier for me.

WARNING 1 - Audio Quality

People who prefer to compile BladeEnc themselves should be aware that the BladeEnc sourcecode is a very delicate piece of code that needs your compiler to treat it absolutely correctly. Small changes in precision that won't affect other programs can affect BladeEnc's encoding process to such a degree that you get an audible degradation of sound quality!

We have found that some versions of well known compilers such as Visual C++ and GNU C do decrease the output if optimizations are enabled. Visual C++ 5.0 (without service packs) for example generates a mutated BladeEnc that adds a very irritating low-frequency "engine sound" to most music.

If you are serious about sound quality we recommend you to either download binaries from our homepage or check the output of your compiled version with that generated by any of our binaries. Given the same input file they should generate exactly the same output (use md5sum or something similar to compare). If they don't, the quality generated by yours might be lower.

WARNING 2 - MPEG Layer 3 Patents

Although the sourcecode for BladeEnc is distributed under the LGPL, it includes algorithms and solutions that some of the creators of the MPEG Layer 3 standard claims to have patents on.

This makes portions of the BladeEnc sourcecode quite unsuitable for inclusion into other software projects. It might even be a breach of the GPL / LGPL license of another product if you add patent covered parts of BladeEnc to its sourcecode.

Porting BladeEnc

In order to port BladeEnc to a currently unsupported platform, please follow these simple steps:

  1. Download the latest STABLE BladeEnc sourcecode as well as an already available port (which contains all the other files, like the manual, that shall be included with your port).
  2. Make any necessary changes to system.h and bladesys.c. It's very unlikely that you will have to change some other sourcecode and most likely you will only have to add some defines to system.h.
  3. Compile the sourcecode and see if you get a working binary. Play around with the binary to see if it seems to work as it should.
  4. Play around with compiler optimizations to get it as fast as possible.
  5. When you are satisfied with the speed, encode the same input file (a 10 sec sample is enough) using both your own binary and any version downloaded from my homepage. Make sure that the output from both of them are 100% identical. Use a tool that can compare two binary files for this (like md5sum), don't trust your ears. If it fails, try to play around with compiler optimization options or test another compiler. It's most likely just one of the source files that it fails on (codec.c is very error-prone, but luckily not very time critical at all), so hopefully you can compile the others using better optimizations and link together the result to something that works perfectly and still is quite fast.
  6. Make sure to strip your binary from debug information in order to keep down the file size.
  7. Put together a package of the files from the other distribution and your binary. Use the most popular archiving utility on your platform unless there are some clear disadvantages of that (except a few kb in size, which doesn't matter too much).
  8. If you want to you can add a readme file to the package specifying that you did the port and how to contact you along with any platform specific information that isn't covered in my manual.
  9. Attach this package to an e-mail and send it to me, along with any source files you have changed so that I can merge in direct support for your platform in a future version. Please confirm in the letter that you have tested the output and that it has proven to be 100% identical to that generated by one of the official binaries.
  10. Wait for me to put your package on-line (might take a few days). Hopefully you will be the first to submit a binary for your platform, otherwise you will simply have to accept that I took someone else's package instead... :(


Getting Started with the BladeEnc Sourcecode

Here follows some information that might help you to get started with the BladeEnc sourcecode:

A short description of some of the files:
system.h Contains platform specific defines. Change here for switching between platforms.
bladesys.c Contains platform specific code 
samplein.c Mini-library for reading sample files and providing some basic sample conversion (8/16-bit, mono/stereo, big/little-endian etc).
main.c The main code for reading commandlines, handling the batch, producing screen output and handling errors. Doesn't contain any of the MP3 encoding routines.
codec.c The main interface for the MP3-encoding routines. If you just want to look at the MP3 engine you should start here.
bladetab.c Just a damn big table, the inclusion of which was the best optimization so far... :)
tables.c Some tables that were loaded as separate files in the ISO distribution.
formatbitstream2.c Replacement for formatbitstream.c in the ISO distribution which seemed to be copyrighted. Provides the same functionality with about 1/3 of the code. :)