I got a mp3 player with FM modulator to play mp3 in my car. The player/modulator is however a crude one. It does not allow seeking in a mp3 file. It remembers the file that it was playing, but not exact last point it was stopped. If I stop the car and the player loses power, next time when it gets power it plays the same mp3 file from the very beginning. This is quite annoying when the audio file is a long one like 40 minutes, because I have to listen from the beginning again. Therefore I need a mp3 splitter to split the 40-min mp3 file into, like 10 4-min files. I don’t mind listening to a 4-min audio again.
Googling mp3 splitter mostly returns some shareware that requires like $19.99. I however have some interest in seeing the internals of an mp3 file, and take this as a chance. It turns out that the MPEG audio file format is quite friendly for splitting. There is not a file header. The audio data is organized in independent (sort of) frames. Each frame has a frame header and real frame audio bits. From the frame header one can know the sample rate, frame byte length and time duration etc. For details, see MPEG Audio Compression Basics.
JavaZoom has created an mp3 decoder/player/converter library in Java, JLayer (JavaLayer). With the help of Java Language Conversion Assistant, Robert Burke was able to create a C# port of JavaLayer, Mp3Sharp. I do not really need to decode an mp3 file, but I take the code to read the frames of an mp3 file. I also use the NConsoler library to support command line options. With these help I created mp3xtool. It is able to read the information of, join, extract a portion of, and slice mp3 files. I’ll upload the Windows binary installer (in msi) of mp3xtool, as well as its source code in a Visual C# 2008 project later.