我有 2 个或更多音频帧,其结构如下:
int sample_rate; // The sample-rate of this buffer (48000 or 44100 normaly)
int no_channels; // The number of audio channels
int no_samples; // The number of audio samples per channel (n elements in data array)
float* p_data; // The audio data
添加 2 个音频缓冲区非常简单:frameInput1; 帧输入2;
frameOutput.sample_rate = 48000;
frameOutput.no_channel = 1;
frameOutput.no_sample = 1000;
frameOutput.p_data = (float*)malloc(frameOutput.no_sample * frameOutput.no_channel * sizeof(float))
for(int i=0; i<frameOutput.no_sample; i++){
frameOutput.p_data[i] = frameInput1.p_data[i] + frameInput2.p_data[i];
}
我创建了一个具有相同样本的音频缓冲区,并为数据数组中的每个样本添加了输入帧
但是如果我有不同 no_sample 或不同 sample_rate 的音频缓冲区?
例如:
input1.sample_rate = 48000hz; input1.no_sample = 1000 ;
input2.sample_rate = 44100hz; input2.no_sample = 600 ;
如何添加这两个输入?