public WavDecoder(InputStream stream) throws Exception {

		// checks if the stream is valid
		if (stream == null)
			throw new IllegalArgumentException("Input stream must not be null");

		inputStream = new EndianDataInputStream(new BufferedInputStream(stream,
				1024 * 1024));

		if (!inputStream.readStringFrom4Byte().equals("RIFF"))
			throw new IllegalArgumentException("It's not a wav");

		inputStream.readIntLittleEndian();

		if (!inputStream.readStringFrom4Byte().equals("WAVE"))
			throw new IllegalArgumentException("expected WAVE tag");

		if (!inputStream.readStringFrom4Byte().equals("fmt "))
			throw new IllegalArgumentException("expected fmt tag");

		// TODO: adicionar suporte para outro bit-rate
		// checks if it's 16-bit
		if (inputStream.readIntLittleEndian() != 16)
			throw new IllegalArgumentException(
					"expected wave chunk size to be 16");

		if (inputStream.readShortLittleEndian() != 1)
			throw new IllegalArgumentException("expected format to be 1");

		channels = inputStream.readShortLittleEndian();
		sampleRate = inputStream.readIntLittleEndian();

		/*
		 * if (sampleRate != 44100) throw new
		 * IllegalArgumentException("Not 44100 sampling rate");
		 */

		inputStream.readIntLittleEndian();
		inputStream.readShortLittleEndian();
		int format = inputStream.readShortLittleEndian();

		if (format != 16)
			throw new IllegalArgumentException(
					"Only 16-bit signed format supported");

		if (!inputStream.readStringFrom4Byte().equals("data"))
			throw new RuntimeException("expected data tag");

		inputStream.readIntLittleEndian();

		/*
		 * it reads until the start of the data tag, the content of this tag
		 * will be read with the function readSample
		 */

	}