Java RIFF-File Surfer


M. Gallant 2/14/97


There are many small sound-player applications which do not correctly read the file "chunk" components of Microsoft RIFF (Resource Interchange File Format) type multimedia files. This is very common for WAVE type RIFF files. Here is a standalone Java application that reads a file and checks the "chunk" structure to verify that it is consistent with the RIFF structure. It is useful for quickly inspecting .wav files on any platform for corruption. The riffread.class file should be launched without any command arguments. The launched program should bring up a local platform (peer) FileDialog where the user is prompted to select a file. The file is parsed and the ID and data size of each chunk are reported to the standard IO stream. The "fmt " chunk is decomposed into its information (sampling rate, bits-per-sample etc.). Also the checksum of all chunk data sizes is tallied and compared with the actual file size for consistency.


riffread.class file.    riffread.java source code.


Typical output screen dumps for two different wave files are shown below. The first example shows the chunks found in a wave file recorded with the standard Win95 sndrec32.exe application. All the details of the sound data (sampling rate, bits/sample etc.) are contained in the fmt chunk. The actual sound samples are in the data chunk. Well behaved RIFF sound file readers/players should test-for and ignore unknown chunks.
 ******  FILE:  /MitchMac HD/Desktop Folder/RIFFread/Eigbst.wav    LENGTH:  42714 bytes ****** 

     RIFF    ----- data size: 42706 bytes
             ----- form type: WAVE


     fmt     ----- data size: 18 bytes
          wFormatTag:  MS PCM format
          nChannels:  2
          nSamplesPerSec:  11025
          nAvgBytesPerSec:  22050
          nBlockAlign:  2
          nBitsPerSample:  8

     fact    ----- data size: 4 bytes

     data    ----- data size: 42656 bytes

     Final RIFF data bytecount: 42706
     File chunk structure consistent with valid RIFF 
 -------------------------------------------------------

The second example shows the chunks found in a wave file recorded with the Win3.1 freeware WHAM1.3 sound application running under Win95. Note the large LIST chunk which can contain extensive useful information (Author, Copyright, Source etc..). Files recorded with this application show up with the "LIST" information in the Win95 control panel for the wave file. The LIST chunk in fact is composed of many subchunks not extracted by this Java application (for simplicity).

 ******  FILE:  /MitchMac HD/Desktop Folder/RIFFread/testall.wav    LENGTH:  98658 bytes ****** 

     RIFF    ----- data size: 98650 bytes
             ----- form type: WAVE


     LIST    ----- data size: 302 bytes

     fmt     ----- data size: 16 bytes
          wFormatTag:  MS PCM format
          nChannels:  1
          nSamplesPerSec:  22050
          nAvgBytesPerSec:  22050
          nBlockAlign:  1
          nBitsPerSample:  8

     data    ----- data size: 98304 bytes

     Final RIFF data bytecount: 98650
     File chunk structure consistent with valid RIFF 
 -------------------------------------------------------

Back to Wave Sound File Information