Skip to main content

Topic: Add RIFF header to mp3 file progmatically in java (Read 1026 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!

  • saratoga
  • [*][*][*][*][*]
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!

  • [JAZ]
  • [*][*][*][*][*]
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 */

  • saratoga
  • [*][*][*][*][*]
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 :(


  • [JAZ]
  • [*][*][*][*][*]
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.