package com.danitheskunk.skunkworks.audio;

public class Samplei implements ISample {
	private final short[] left;
	private final short[] right;

	public Samplei(int length, boolean stereo) {
		left = new short[length];
		right = stereo ? new short[length] : left;
	}

	public Samplei(short[] left, short[] right) {
		this.left = left;
		this.right = right == null ? left : right;
	}

	@Override
	public int getLength() {
		return left.length;
	}

	@Override
	public double getSampleLeft(int pos) {
		return (double) left[pos] / 32768.0;
	}

	@Override
	public double getSampleRight(int pos) {
		return (double) right[pos] / 32768.0;
	}

	@Override
	public boolean isStereo() {
		return left != right;
	}

	@Override
	public void setSamplei(int pos, short left, short right) {
		this.left[pos] = left;
		this.right[pos] = right;
	}

	@Override
	public void setSamplei(int pos, short left) {
		this.left[pos] = left;
	}
}
