Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Add RIFF header to mp3 file progmatically in java (Read 7844 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Add RIFF header to mp3 file progmatically in java

Hi All,

I'm using the java-lame project (https://github.com/nwaldispuehl/java-lame) to convert PCM files to mp3.

I need to add RIFF header to the mp3 file to make mp3 files compatible with a legacy application.

I've found this exe (http://www.studiodust.com/riffmp3.html) which does that but I'm looking to do this pragmatically.

Can anyone tell me how can I do that?

My apologies if this is not the right forum to discuss this!

Thanks in advance!

Re: Add RIFF header to mp3 file progmatically in java

Reply #1
You can either use the source code provided for that application in your project or just call that EXE to add the headers.

I am surprised you need to do this however. 

Re: Add RIFF header to mp3 file progmatically in java

Reply #2
You can either use the source code provided for that application in your project or just call that EXE to add the headers.

I am surprised you need to do this however. 

Thanks for reply!

I didn't find any source code for the application.   :(

Calling the exe is last resort because right now everything is done in memory and to use the exe I'll have to save the audio file on disk first. so this will slow down the processing.

If anyone has a suggestion about how to proceed with this, I'll really appreciate it!

Re: Add RIFF header to mp3 file progmatically in java

Reply #3
AFAIK,  a WAV MP3 file is just the MP3 data put inside a WAV container, and indicated by the MP3 codec type. It is very easy to generate a simple WAV header
I am linking here a few pages i found online with a quick search: http://soundfile.sapp.org/doc/WaveFormat/
https://msdn.microsoft.com/en-us/library/windows/desktop/dd317599(v=vs.85).aspx

This is the value for the mp3 tag:
#define  WAVE_FORMAT_MPEGLAYER3                 0x0055 /* ISO/MPEG Layer3 Format Tag */

Re: Add RIFF header to mp3 file progmatically in java

Reply #4
edit misread

Re: Add RIFF header to mp3 file progmatically in java

Reply #5
AFAIK,  a WAV MP3 file is just the MP3 data put inside a WAV container, and indicated by the MP3 codec type. It is very easy to generate a simple WAV header
I am linking here a few pages i found online with a quick search: http://soundfile.sapp.org/doc/WaveFormat/
https://msdn.microsoft.com/en-us/library/windows/desktop/dd317599(v=vs.85).aspx

This is the value for the mp3 tag:
#define  WAVE_FORMAT_MPEGLAYER3                 0x0055 /* ISO/MPEG Layer3 Format Tag */


Thanks for the reply...

This is what I'm trying to do now i.e. create the header and calculate all the meta data. but problem is some of the data is big-endian and some data is little-endian (as per http://soundfile.sapp.org/doc/WaveFormat/)

And I'm struggling to create a file which will have both :(


Re: Add RIFF header to mp3 file progmatically in java

Reply #6
No. the RIFF WAVE format is always little endian.  The original IFF container, and AIFF are big endian.