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

后端 未结 5 1781
南旧
南旧 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:19

    if (Math.Abs(sample) > biggest) biggest = sample;
    

    I would change this to:

    if (Math.Abs(sample) > biggest) biggest = Math.Abs(sample);
    

    Because if the biggest value is negative you will multiply all values with a negative.

提交回复
热议问题