Skip to content
Permalink
Browse files

Byte array samples to short array samples

  • Loading branch information
bear101 committed Mar 25, 2020
1 parent c19a88c commit 5dcbf8ddf5b7d7bcd4216b8cbdd55c733b19890c
Showing with 7 additions and 0 deletions.
  1. +7 −0 Library/TeamTalkJNI/test/dk/bearware/TeamTalkTestCaseBase.java
@@ -27,6 +27,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import junit.framework.TestCase;

@@ -496,6 +497,12 @@ static FileOutputStream newWaveFile(String filename, int samplerate, int channel
return buf.array();
}

static short[] audioToShortArray(byte[] audio) {
short[] converted = new short[audio.length / 2];
ByteBuffer.wrap(audio).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer().get(converted);
return converted;
}

static short[] generateTone(int freq, int samplerate, int channels, int durationMSec) {
double volume = 8000;
double duration = durationMSec;

0 comments on commit 5dcbf8d

Please sign in to comment.
You can’t perform that action at this time.