FileDocCategorySizeDatePackage
WavInfoReader.javaAPI DocJaudiotagger 2.0.42701Wed Mar 30 16:11:54 BST 2011org.jaudiotagger.audio.wav.util

WavInfoReader

public class WavInfoReader extends Object

Fields Summary
Constructors Summary
Methods Summary
public org.jaudiotagger.audio.generic.GenericAudioHeaderread(java.io.RandomAccessFile raf)

        // Reads wav header----------------------------------------
        GenericAudioHeader info = new GenericAudioHeader();

        if (raf.length() < 12)
        {
            throw new CannotReadException("This is not a WAV File (<12 bytes)");
        }
        byte[] b = new byte[12];
        raf.read(b);

        WavRIFFHeader wh = new WavRIFFHeader(b);
        if (wh.isValid())
        {
            b = new byte[24];
            raf.read(b);

            WavFormatHeader wfh = new WavFormatHeader(b);
            if (wfh.isValid())
            {
                // Populates
                // encodingInfo----------------------------------------------------
                info.setPreciseLength(((float) raf.length() - (float) 36) / wfh.getBytesPerSecond());
                info.setChannelNumber(wfh.getChannelNumber());
                info.setSamplingRate(wfh.getSamplingRate());
                info.setEncodingType("WAV-RIFF " + wfh.getBitrate() + " bits");
                info.setExtraEncodingInfos("");
                info.setBitrate(wfh.getBytesPerSecond() * 8 / 1000);
                info.setVariableBitRate(false);
            }
            else
            {
                throw new CannotReadException("Wav Format Header not valid");
            }
        }
        else
        {
            throw new CannotReadException("Wav RIFF Header not valid");
        }

        return info;