Normalizing audio, how to convert a float array to a byte array?

后端 未结 5 1779
南旧
南旧 2021-02-04 21:52

Hi all, I am playing an audio file. I read it as a byte[] and then I need to normalize the audio by putting values into range of [-1,1]. I want to then put each flo

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-04 22:22

    You can use Buffer.BlockCopy like this:

    float[] floats = new float[] { 0.43f, 0.45f, 0.47f };
    byte[] result = new byte[sizeof(float) * floats.Length];
    Buffer.BlockCopy(floats, 0, result, 0, result.Length);
    

提交回复
热议问题