first commit
Build AsminVoicechat / prepare-release (push) Successful in 14s
Build AsminVoicechat / build-and-test (17) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (18) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (19) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (20) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (21) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (22) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (23) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (24) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (25) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (26) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (27-ea) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (16) (push) Canceled after 38s
Build AsminVoicechat / prepare-release (push) Successful in 14s
Build AsminVoicechat / build-and-test (17) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (18) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (19) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (20) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (21) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (22) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (23) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (24) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (25) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (26) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (27-ea) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (16) (push) Canceled after 38s
This commit is contained in:
commit
bbccd4a815
454 files changed
+45050
No files matched your search
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.voice.common;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
public class AudioUtils {
|
||||
public static final int MAX_OPUS_PAYLOAD_SIZE = 1275;
|
||||
|
||||
public static short[] bytesToShorts(byte[] bytes) {
|
||||
if (bytes.length % 2 != 0) {
|
||||
throw new IllegalArgumentException("Input bytes need to be divisible by 2");
|
||||
}
|
||||
ShortBuffer sb = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer();
|
||||
short[] out = new short[sb.remaining()];
|
||||
sb.get(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
public static byte[] shortsToBytes(short[] shorts) {
|
||||
ByteBuffer bb = ByteBuffer.allocate(shorts.length * 2).order(ByteOrder.LITTLE_ENDIAN);
|
||||
for (short s : shorts) {
|
||||
bb.putShort(s);
|
||||
}
|
||||
return bb.array();
|
||||
}
|
||||
|
||||
public static short[] floatsToShorts(float[] floats) {
|
||||
short[] shorts = new short[floats.length];
|
||||
for (int i = 0; i < floats.length; ++i) {
|
||||
shorts[i] = Float.valueOf(floats[i]).shortValue();
|
||||
}
|
||||
return shorts;
|
||||
}
|
||||
|
||||
public static float[] shortsToFloats(short[] shorts) {
|
||||
float[] floats = new float[shorts.length];
|
||||
for (int i = 0; i < shorts.length; ++i) {
|
||||
floats[i] = Short.valueOf(shorts[i]).floatValue();
|
||||
}
|
||||
return floats;
|
||||
}
|
||||
|
||||
public static byte[] floatsToBytes(float[] floats) {
|
||||
byte[] bytes = new byte[floats.length * 2];
|
||||
for (int i = 0; i < floats.length; ++i) {
|
||||
short x = Float.valueOf(floats[i]).shortValue();
|
||||
bytes[i * 2] = (byte)(x & 0xFF);
|
||||
bytes[i * 2 + 1] = (byte)((x & 0xFF00) >> 8);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static float[] bytesToFloats(byte[] bytes) {
|
||||
float[] floats = new float[bytes.length / 2];
|
||||
for (int i = 0; i < bytes.length / 2; ++i) {
|
||||
floats[i] = (bytes[i * 2 + 1] & 0x80) != 0 ? (float)(Short.MIN_VALUE + ((bytes[i * 2 + 1] & 0x7F) << 8) | bytes[i * 2] & 0xFF) : (float)(bytes[i * 2 + 1] << 8 & 0xFF00 | bytes[i * 2] & 0xFF);
|
||||
}
|
||||
return floats;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user