/** * load a RIFF header * * @param dis * DataInputStream to read from * * @throws IOException * on ill-formatted input */ private void loadHeader(DataInputStream dis) throws IOException { if (!checkChars(dis, "RIFF")) { throw new Error("Invalid wave file format."); } numBytes = General.readInt(dis, false); if (!checkChars(dis, "WAVEfmt ")) { throw new Error("Invalid wave file format."); } headerSize = General.readInt(dis, false); if (General.readShort(dis, false) != RIFF_FORMAT_PCM) { throw new Error("Invalid wave file format."); } if (General.readShort(dis, false) != 1) { throw new Error("Only mono wave files supported."); } sampleRate = General.readInt(dis, false); General.readInt(dis, false); General.readShort(dis, false); General.readShort(dis, false); }