Naudio声音正常化 [英] Naudio sound normalize
本文介绍了Naudio声音正常化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Naudio,我有一个流,我需要将其读取为数组,然后当发现最大值时,我需要将每个值乘以(1/maximum),然后我的数组中的值应为[- 1,1].
I am using Naudio and I have a stream which I need to read as array and then when I have found maximum I need to multiply each value with ( 1/ biggest ) and then I should have values in my array as [-1,1].
推荐答案
我并没有真正理解转换"的含义,但是您可以编写代码来代替您编写的代码:
I don't see really what you mean by "convert", but instead of the code you wrote you could just do:
var bytes = stream.ToArray();
var biggest = (float)bytes.Max();
var floats = bytes.Select(b => b / biggest).ToArray();
由于字节总是正数,因此浮点数介于0和1之间.
This will result with floats between 0 and 1, since bytes are always positive.
这篇关于Naudio声音正常化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文