I receive an audio wave stream, store it in byte[] and want to play it. I found this online & tested it:
//byte[] data
float[] arr = new float[data.Length / 2];
for(int i= 0; i < arr.Length; i++) {
arr[i] = (float)BitConverter.ToInt16(data, i*2) / 32767.0f;
}
I also tested this https://stackoverflow.com/a/76858809/15107271.
Voices are recognizable, but are very noisy. It sounds like a bad walkie talkie. Does anyone know how to interpret the data correctly?
Edit:
I use this launch file with wave format to send the data. https://github.com/ros-drivers/audio_common/blob/master/audio_capture/launch/capture_wave.launch
In Unity the received data of the message is then stored in byte[] data