【问题标题】:Change audio volume of some channels using AVAudioEngine使用 AVAudioEngine 更改某些频道的音量
【发布时间】:2018-11-08 12:44:01
【问题描述】:

我正在开发一个混合来自 VideoCard 和外部声卡的音频的 mac 应用程序。

如何使用 AVAudioEngine 独立更改每个通道(不是每个源)的音量。

假设我有一个 16 个通道交错的 AVAudioPCMBuffer,我希望通道 1 和 2 的音量分别为 50% 和其他 100%

我是否应该从 1 个具有 16 个通道的 AVAudioPCMBuffer 转换为 16 个单声道 AVAudioPCMBuffer 并为每个通道设置一个 AVPlayerNode ?然后在每个 AVPlayerNode 上改变音量?

或者我可以保留 o 有没有办法从 AVAudioMixerNode 更改底层音频单元?

还是应该直接使用 CoreAudio AudioUnits?

【问题讨论】:

    标签: macos audio-processing avaudioengine avaudioplayernode avaudioconverter


    【解决方案1】:

    按通道而不是按输入更改音频音量,需要 MatrixMixer。 AVAudioEngine MainMixer 不是矩阵混音器(mxmx),而是多声道混音器(mcmx)。

    要使用矩阵混音器,请使用以下代码:

    AudioComponentDescription   mixerUnitDescription;
    
    mixerUnitDescription.componentType          = kAudioUnitType_Mixer;
    mixerUnitDescription.componentSubType       = kAudioUnitSubType_MatrixMixer;
    mixerUnitDescription.componentManufacturer  = kAudioUnitManufacturer_Apple;
    mixerUnitDescription.componentFlags         = 0;
    mixerUnitDescription.componentFlagsMask     = 0;
    
    [AVAudioUnit instantiateWithComponentDescription:mixerUnitDescription options:0 completionHandler:^(__kindof AVAudioUnit * _Nullable mixer, NSError * _Nullable error) {
    

    }];

    并使用改变音频电平

    AudioUnitSetParameter([_mixer audioUnit], kMatrixMixerParam_Volume, kAudioUnitScope_Input, i, volume, 0);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-19
      • 2014-08-14
      • 1970-01-01
      • 1970-01-01
      • 2020-08-13
      • 2016-02-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多