added audio sample class

This commit is contained in:
DaniTheSkunk 2022-10-14 17:29:57 +00:00
parent abc460e59b
commit a05892e677
2 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,16 @@
package com.danitheskunk.skunkworks.audio;
//todo: samplerate stuffs?
public interface ISample {
int getLength();
double getSampleLeft(int pos);
double getSampleRight(int pos);
void setSample(int pos, int left);
void setSample(int pos, int left, int right);
void isStereo();
}

View File

@ -0,0 +1,42 @@
package com.danitheskunk.skunkworks.audio;
public class Samplei implements ISample {
private double[] left;
private double[] right;
public Samplei(int length, boolean stereo) {
left = new double[length];
right = stereo ? new double[length] : left;
}
@Override
public int getLength() {
return left.length;
}
@Override
public double getSampleLeft(int pos) {
return left[pos];
}
@Override
public double getSampleRight(int pos) {
return right[pos];
}
@Override
public void setSample(int pos, int left) {
this.left[pos] = left;
}
@Override
public void setSample(int pos, int left, int right) {
this.left[pos] = left;
this.right[pos] = right;
}
@Override
public void isStereo() {
}
}