gpt4 book ai didi

macos - osx 音频单元多 channel 输出

转载 作者:行者123 更新时间:2023-12-02 03:49:10 24 4
gpt4 key购买 nike

我已经在网上搜索了数周但没有找到答案。

我有一个 maudio profire 610 多 channel 音频接口(interface)。我如何正确设置 AudioStreamBasicDescription 以使用所有 8 个输出 channel ?目前它仅适用于前 2 个 channel 。

    UInt32 busCount = 3; //numberOfOutputBusses;
AudioStreamBasicDescription outputASBD2 = {
.mSampleRate = 44100,
.mFormatID = kAudioFormatLinearPCM,
.mFormatFlags = kAudioFormatFlagsAudioUnitCanonical,
.mChannelsPerFrame = busCount,
.mFramesPerPacket = 1,
.mBitsPerChannel = sizeof(Float32) * 8,
.mBytesPerPacket = sizeof(Float32) * busCount,
.mBytesPerFrame = sizeof(Float32) * busCount
};

AudioUnitSetProperty(*_unit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output,
1,
&outputASBD2,
sizeof(AudioStreamBasicDescription);

我正在为 openframeworks 开发 ofxaudiounit 插件: https://github.com/antimodular/ofxAudioUnit

谢谢。

最佳答案

     UInt32 propertySize;
Boolean writable = false;
OSStatus status = AudioUnitGetPropertyInfo(*_unit,
kAudioOutputUnitProperty_ChannelMap,
kAudioUnitScope_Output,
0,
&propertySize, &writable);
//SignalIf_(writable == false);
cout<<"writable "<<&writable<<endl;

long nChannels = propertySize / sizeof(SInt32);
long* channelMapPtr = (long*)malloc(propertySize);

cout<<"nChannels "<<nChannels<<endl;

UInt32 scratch = propertySize;
status = AudioUnitGetProperty(*_unit,
kAudioOutputUnitProperty_ChannelMap,
kAudioUnitScope_Output,
0,
channelMapPtr,
&scratch);

// channelMapPtr[0] = 0;
for (long i = 0; i < nChannels; i++)
{
channelMapPtr[i] = -1;
}

channelMapPtr[3] = 0;
channelMapPtr[5] = 1;

OFXAU_RET_BOOL(AudioUnitSetProperty(*_unit,
kAudioOutputUnitProperty_ChannelMap,
kAudioUnitScope_Output,
0,
channelMapPtr,
scratch),"setting output unit's device ID");

free((void *)channelMapPtr);

关于macos - osx 音频单元多 channel 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15076194/

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