-
-
Save alekseytimoshchenko/1cebccf6b0f54bde56dde2df36821c9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static float[] Convert16BitByteArrayToAudioClipData(byte[] source) | |
{ | |
int x = sizeof(Int16); | |
int convertedSize = source.Length / x; | |
float[] data = new float[convertedSize]; | |
Int16 maxValue = Int16.MaxValue; | |
for (int i = 0; i < convertedSize; i++) | |
{ | |
int offset = i * x; | |
data[i] = (float)BitConverter.ToInt16(source, offset) / maxValue; | |
++i; | |
} | |
return data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment