// Path: src/exception/IncorrectFormatException.java
// public class IncorrectFormatException extends Exception
// {
// 	public static final int NOT_A_RIFF = 0;
// 	public static final int INCORRECT_FILESIZE = 1;
// 	public static final int NOT_A_WAVE = 2;
// 	public static final int DOES_NOT_HAVE_FMT = 3;
// 	public static final int SUBCHUNK_SIZE_INCORRECT = 4;
// 	public static final int COMPRESSION_DETECTED = 5;
// 	public static final int DATA_NOT_FOUND = 6;
// 	public static final int UNSUPPORTED_SAMPLE_SIZE = 7;
// 	public static final int UNSUPPORTED_CHANNEL_NUMBER = 8;
// 	
// 	public IncorrectFormatException(int type)
// 	{
// 		switch(type)
// 		{
// 			case 0: System.err.println("The .wav files header is not RIFF."); break;
// 			case 1: System.err.println("The .wav files size is reported incorrectly."); break;
// 			case 2: System.err.println("The format of the .wav file is not WAVE"); break;
// 			case 3: System.err.println("The .wav header does not have fmt "); break;
// 			case 4: System.err.println("Subchunk size indicates it is not PCM"); break;
// 			case 5: System.err.println("Compressed .wav files are not supported."); break;
// 			case 6: System.err.println("The value 'data' has not been found in the .wav header"); break;
// 			case 7: System.err.println("Currently only supports 8 and 16 bit sample sizes."); break;
// 			case 8: System.err.println("Currently only support 1 or 2 channels."); break;
// 		}
// 	}
// }


import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
import org.lwjgl.openal.AL10;
import exception.IncorrectFormatException;
		}
		catch (FileNotFoundException e)
		{
			e.printStackTrace();
			return;
		}

		try
		{	

			//Read in the first 4 bytes. These bytes should spell RIFF.
			byte[] buffer = new byte[4];
			dir.read(buffer);

			//Unsign the bytes and put it into a IntBuffer for comparison to the IntBuffer RIFF
			IntBuffer is_riff = IntBuffer.wrap(this.unsign_byte(buffer));

			if(RIFF.compareTo(is_riff) != 0)
			{
				new IncorrectFormatException(IncorrectFormatException.NOT_A_RIFF);
				return;
			}
			
			//The next 4 bytes describe the total filesize minus 8.
			dir.read(buffer);
			
			int length = turn_byte_buffer_into_int(buffer);
			
			if(length+8 != potential_wav.length())
			{
// Path: src/exception/IncorrectFormatException.java
// public class IncorrectFormatException extends Exception
// {
// 	public static final int NOT_A_RIFF = 0;
// 	public static final int INCORRECT_FILESIZE = 1;
// 	public static final int NOT_A_WAVE = 2;
// 	public static final int DOES_NOT_HAVE_FMT = 3;
// 	public static final int SUBCHUNK_SIZE_INCORRECT = 4;
// 	public static final int COMPRESSION_DETECTED = 5;
// 	public static final int DATA_NOT_FOUND = 6;
// 	public static final int UNSUPPORTED_SAMPLE_SIZE = 7;
// 	public static final int UNSUPPORTED_CHANNEL_NUMBER = 8;
// 	
// 	public IncorrectFormatException(int type)
// 	{
// 		switch(type)
// 		{
// 			case 0: System.err.println("The .wav files header is not RIFF."); break;
// 			case 1: System.err.println("The .wav files size is reported incorrectly."); break;
// 			case 2: System.err.println("The format of the .wav file is not WAVE"); break;
// 			case 3: System.err.println("The .wav header does not have fmt "); break;
// 			case 4: System.err.println("Subchunk size indicates it is not PCM"); break;
// 			case 5: System.err.println("Compressed .wav files are not supported."); break;
// 			case 6: System.err.println("The value 'data' has not been found in the .wav header"); break;
// 			case 7: System.err.println("Currently only supports 8 and 16 bit sample sizes."); break;
// 			case 8: System.err.println("Currently only support 1 or 2 channels."); break;
// 		}
// 	}
// }


// Path: src/sound/WaveLoader.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
import org.lwjgl.openal.AL10;
import exception.IncorrectFormatException;

		}
		catch (FileNotFoundException e)
		{
			e.printStackTrace();
			return;
		}

		try
		{	

			//Read in the first 4 bytes. These bytes should spell RIFF.
			byte[] buffer = new byte[4];
			dir.read(buffer);

			//Unsign the bytes and put it into a IntBuffer for comparison to the IntBuffer RIFF
			IntBuffer is_riff = IntBuffer.wrap(this.unsign_byte(buffer));

			if(RIFF.compareTo(is_riff) != 0)
			{
				new IncorrectFormatException(IncorrectFormatException.NOT_A_RIFF);
				return;
			}
			
			//The next 4 bytes describe the total filesize minus 8.
			dir.read(buffer);
			
			int length = turn_byte_buffer_into_int(buffer);
			
			if(length+8 != potential_wav.length())
			{
				new IncorrectFormatException(IncorrectFormatException.INCORRECT_FILESIZE);