added Samplei.fromMonoDoubleArray

This commit is contained in:
DaniTheSkunk 2022-11-27 06:59:57 +00:00
parent 59c918299d
commit 7063bbee37
1 changed files with 8 additions and 0 deletions

View File

@ -14,6 +14,14 @@ public class Samplei implements ISample {
this.right = right == null ? left : right; this.right = right == null ? left : right;
} }
public static Samplei fromMonoDoubleArray(double[] d) {
var sample = new Samplei(d.length, false);
for(int i = 0; i < d.length; ++i) {
sample.setSamplei(i, (short)(d[i] * 32768));
}
return sample;
}
@Override @Override
public int getLength() { public int getLength() {
return left.length; return left.length;