gpt4 book ai didi

java - 将增益应用于 PCM 时避免过度调制/失真

转载 作者:行者123 更新时间:2023-12-02 05:53:14 25 4
gpt4 key购买 nike

我使用录音机(Google Play 上的 AudioRec)。

我可以选择adjust the gain with [-20dB, + 20dB]范围。

它在我的手机上运行得很好,但用户使用连接到其设备的专业麦克风 had complained about the gain because when selecting -20dB, the output is distorted .

请参阅下面我如何实现。增益函数:

for(int frameIndex=0; frameIndex<numFrames; frameIndex++){
for(int c=0; c<nChannels; c++){
if(rGain != 1){
// gain
long accumulator=0;
for(int b=0; b<bytesPerSample; b++){
accumulator+=((long)(source[byteIndex++]&0xFF))<<(b*8+emptySpace);
}
double sample = ((double)accumulator/(double)Long.MAX_VALUE);
sample *= rGain;

int intValue = (int)((double)sample*(double)Integer.MAX_VALUE);
for(int i=0; i<bytesPerSample; i++){
source[i+byteIndex2]=(byte)(intValue >>> ((i+2)*8) & 0xff);
}
byteIndex2 += bytesPerSample;
}

}//end for(channel)
}//end for(frameIndex)

也许我应该在 samle *= rGain; 之后应用一些低/高过滤器?类似 if(sample < MINIMUM_VALUE || sample > MAXIMUM_VALUE) ?在这种情况下,请让我知道这些最小最大值是多少...

最佳答案

简单地将值削波到阈值以上肯定会导致失真。如果你能想象出一个纯正弦波,当你把顶部剪掉时,它就会开始类似于方波。

也就是说,如果您有一个输入信号,并且将其乘以一个小于 1 的值,则不可能引入任何(显着的)失真。您需要进一步查看信号路径。也许输入处发生了削波。

关于java - 将增益应用于 PCM 时避免过度调制/失真,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23357621/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com