更新时间:2021-08-26 22:18:00
你分别装入.wav-文件PCM-数据?如果是这样,那么你就可以轻松阅读每个通道的每个样本,它们叠加和渠道的数量除以他们得到一个单声道信号。
Do you load .wav- files respectively PCM- data? If so then you could easily read each sample of each channel, superpose them and divide them by the amount of channels to get a mono signal.
如果您存储在交错的签署短裤形式的立体声信号时,code,计算所得的单声道信号可能是这样的:
If you store your stereo signal in form of interleaved signed shorts, the code to calculate the resulting mono signal might look like this:
short[] stereoSamples;//get them from somewhere
//output array, which will contain the mono signal
short[] monoSamples= new short[stereoSamples.length/2];
//length of the .wav-file header-> 44 bytes
final int HEADER_LENGTH=22;
//additional counter
int k=0;
for(int i=0; i< monoSamples.length;i++){
//skip the header andsuperpose the samples of the left and right channel
if(k>HEADER_LENGTH){
monoSamples[i]= (short) ((stereoSamples[i*2]+ stereoSamples[(i*2)+1])/2);
}
k++;
}
我希望,我能帮助你。
I hope, I was able to help you.
***的问候, G_J
Best regards, G_J