im applying DSP effects to my raw audio input which is in byte[2] array format.To apply DSP i need to convert the byte array to float array and back.To convert byte array to float array i use the following code:
private byte[] buffer;
/*
*
* Converts a byte[2] to a float, in LITTLE_ENDIAN format
*/
private float getFloat(byte argB1, byte argB2) {
return (float) (argB1 | (argB2 << 8));
}
for (int i = 0; i < N / 2; i++) {
curSample[i] = getFloat(buffer[i * 2],
buffer[i * 2 + 1]);}
I need to convert back curSample(which is a float array) to the byte[2] array.How to do that?