Audio 将多个输入通道组合到一个输出通道音频直播

Audio 将多个输入通道组合到一个输出通道音频直播,audio,audio-processing,pyo,Audio,Audio Processing,Pyo,我正在尝试制作我自己的基本混音器,我想知道如何获得多个输入音频通道,并将所有通道作为一个混合音频源输出,每个输入通道的电平可控。现在我正在尝试使用pyo,但我无法实时混合频道 下面是一些伪代码,用于将多个输入通道组合到单个输出通道中,其中每个输入通道在阵列混合音量中都有自己的音量控制 max_index = length(all_chan[0]) // identify audio buffer size all_chan // assume all channels live in a

我正在尝试制作我自己的基本混音器,我想知道如何获得多个输入音频通道,并将所有通道作为一个混合音频源输出,每个输入通道的电平可控。现在我正在尝试使用pyo,但我无法实时混合频道

下面是一些伪代码,用于将多个输入通道组合到单个输出通道中,其中每个输入通道在阵列混合音量中都有自己的音量控制

max_index = length(all_chan[0])  // identify audio buffer size

all_chan   // assume all channels live in a two dimensional array where 
           // dimension 0 is which channel and dim 1 is index into each audio sample

mix_volume  // array holding multiplication factor to control volume per channel
            // each element a floating point value between 0.0 and 1.0

output_chan  //  define and/or allocate your output channel buffer

for index := 0; index < max_index; index++ {

    curr_sample := 0  // output audio curve height for current audio sample

    for curr_chan := 0; curr_chan < num_channels; curr_chan++ {

        curr_sample += (all_chan[curr_chan][index] * mix_volume[curr_chan])
    }

    output_chan[index] = curr_sample / num_channels  // output audio buffer
}
max\u index=length(all\u chan[0])//标识音频缓冲区大小
all_chan//假设所有通道都位于二维数组中,其中
//维度0是每个音频样本的索引通道和维度1
mix_volume//阵列保持乘法因子以控制每个通道的音量
//每个元素都有一个介于0.0和1.0之间的浮点值
输出\u chan//定义和/或分配输出通道缓冲区
对于索引:=0;指数
在直播流上执行上述操作的诀窍是在事件循环内填充所有音频缓冲区,在这些缓冲区中复制每个通道的音频采样值,然后在该事件循环内执行上述代码。。。通常你会希望你的音频缓冲区有大约2^12(4096)个音频样本。。。使用较大或较小的缓冲区大小进行实验。。。太小,这个事件循环将变得非常cpu密集,但太大,您将招致音频延迟。。。玩得开心


您可能需要使用像golang YMMV这样的编译语言这里有一些伪代码将多个输入通道组合成一个输出通道,其中每个输入通道在阵列混音中都有自己的音量控制

max_index = length(all_chan[0])  // identify audio buffer size

all_chan   // assume all channels live in a two dimensional array where 
           // dimension 0 is which channel and dim 1 is index into each audio sample

mix_volume  // array holding multiplication factor to control volume per channel
            // each element a floating point value between 0.0 and 1.0

output_chan  //  define and/or allocate your output channel buffer

for index := 0; index < max_index; index++ {

    curr_sample := 0  // output audio curve height for current audio sample

    for curr_chan := 0; curr_chan < num_channels; curr_chan++ {

        curr_sample += (all_chan[curr_chan][index] * mix_volume[curr_chan])
    }

    output_chan[index] = curr_sample / num_channels  // output audio buffer
}
max\u index=length(all\u chan[0])//标识音频缓冲区大小
all_chan//假设所有通道都位于二维数组中,其中
//维度0是每个音频样本的索引通道和维度1
mix_volume//阵列保持乘法因子以控制每个通道的音量
//每个元素都有一个介于0.0和1.0之间的浮点值
输出\u chan//定义和/或分配输出通道缓冲区
对于索引:=0;指数
在直播流上执行上述操作的诀窍是在事件循环内填充所有音频缓冲区,在这些缓冲区中复制每个通道的音频采样值,然后在该事件循环内执行上述代码。。。通常你会希望你的音频缓冲区有大约2^12(4096)个音频样本。。。使用较大或较小的缓冲区大小进行实验。。。太小,这个事件循环将变得非常cpu密集,但太大,您将招致音频延迟。。。玩得开心


您可能需要使用像golang YMMV这样的编译语言,因为据我所知,混音器无法播放现场声音。除非有我不知道的解决方法,我不明白为什么不。最好的办法是从一个输入流示例开始,然后发布到目前为止的内容。这会让其他人更容易提供建议。据我所知,混音器无法播放现场声音。除非有我不知道的解决方法,我不明白为什么不。最好的办法是从一个输入流示例开始,然后发布到目前为止的内容。这将使其他人更容易提供建议。