// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_SAMPLE_ID.java
// public class ALLEGRO_SAMPLE_ID extends Structure {
// 	public int _index;
// 	public int _id;
// 	public ALLEGRO_SAMPLE_ID() {
// 		super();
// 		setAutoSynch(false);
// 	}
// 	protected List<? > getFieldOrder() {
// 		return Arrays.asList("_index", "_id");
// 	}
// 	public ALLEGRO_SAMPLE_ID(int _index, int _id) {
// 		super();
// 		this._index = _index;
// 		this._id = _id;
// 	}
// 	public ALLEGRO_SAMPLE_ID(Pointer peer) {
// 		super(peer);
// 	}
// 	public static class ByReference extends ALLEGRO_SAMPLE_ID implements Structure.ByReference {
// 		
// 	};
// 	public static class ByValue extends ALLEGRO_SAMPLE_ID implements Structure.ByValue {
// 		
// 	};
// }
// 
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static final float ALLEGRO_AUDIO_PAN_NONE = (float)(-1000.0f);
// 
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native boolean al_play_sample(ALLEGRO_SAMPLE data, float gain, float pan, float speed, int loop, ALLEGRO_SAMPLE_ID ret_id);
// 
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native void al_stop_sample(ALLEGRO_SAMPLE_ID spl_id);


import org.gillius.jalleg.binding.ALLEGRO_SAMPLE_ID;
import java.io.Closeable;
import java.io.IOException;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_AUDIO_PAN_NONE;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_PLAYMODE.ALLEGRO_PLAYMODE_LOOP;
import static org.gillius.jalleg.binding.AllegroLibrary.al_play_sample;
import static org.gillius.jalleg.binding.AllegroLibrary.al_stop_sample;
	}

	public SampleData getSampleData() {
		return sampleData;
	}

	public boolean isPlaying() {
		return playing;
	}

	public double getEndTime() {
		return endTime;
	}

	/**
	 * Updates this sample. If t is greater than or equal to the endTime, stop playing the sample.
	 */
	public void update(double t) {
		if (playing && t >= endTime) {
			stop();
		}
	}

	public void play(double endTime) {
		play(gain, pan, speed, endTime);
	}

	private void play(float gain, float pan, float speed, double endTime) {
		stop();

// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_SAMPLE_ID.java
// public class ALLEGRO_SAMPLE_ID extends Structure {
// 	public int _index;
// 	public int _id;
// 	public ALLEGRO_SAMPLE_ID() {
// 		super();
// 		setAutoSynch(false);
// 	}
// 	protected List<? > getFieldOrder() {
// 		return Arrays.asList("_index", "_id");
// 	}
// 	public ALLEGRO_SAMPLE_ID(int _index, int _id) {
// 		super();
// 		this._index = _index;
// 		this._id = _id;
// 	}
// 	public ALLEGRO_SAMPLE_ID(Pointer peer) {
// 		super(peer);
// 	}
// 	public static class ByReference extends ALLEGRO_SAMPLE_ID implements Structure.ByReference {
// 		
// 	};
// 	public static class ByValue extends ALLEGRO_SAMPLE_ID implements Structure.ByValue {
// 		
// 	};
// }
// 
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static final float ALLEGRO_AUDIO_PAN_NONE = (float)(-1000.0f);
// 
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native boolean al_play_sample(ALLEGRO_SAMPLE data, float gain, float pan, float speed, int loop, ALLEGRO_SAMPLE_ID ret_id);
// 
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native void al_stop_sample(ALLEGRO_SAMPLE_ID spl_id);


// Path: jalleg-framework/src/main/java/org/gillius/jalleg/framework/audio/LoopingSingleInstanceSample.java
import org.gillius.jalleg.binding.ALLEGRO_SAMPLE_ID;
import java.io.Closeable;
import java.io.IOException;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_AUDIO_PAN_NONE;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_PLAYMODE.ALLEGRO_PLAYMODE_LOOP;
import static org.gillius.jalleg.binding.AllegroLibrary.al_play_sample;
import static org.gillius.jalleg.binding.AllegroLibrary.al_stop_sample;

	}

	public SampleData getSampleData() {
		return sampleData;
	}

	public boolean isPlaying() {
		return playing;
	}

	public double getEndTime() {
		return endTime;
	}

	/**
	 * Updates this sample. If t is greater than or equal to the endTime, stop playing the sample.
	 */
	public void update(double t) {
		if (playing && t >= endTime) {
			stop();
		}
	}

	public void play(double endTime) {
		play(gain, pan, speed, endTime);
	}

	private void play(float gain, float pan, float speed, double endTime) {
		stop();

		playing = al_play_sample(sampleData.getSample(), gain, pan, speed, ALLEGRO_PLAYMODE_LOOP, id);