3

私は何週間もの間、ネットで答えを探していましたが、運が悪かったです。

私はmaudio profire 610マルチチャンネルオーディオインターフェースを持っています。AudioStreamBasicDescription を正しく設定して、8 つの出力チャンネルすべてで動作するようにするにはどうすればよいですか? 現在、最初の 2 チャンネルのみで動作します。

    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

ありがとう。

4

2 に答える 2

1
     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);
于 2013-05-25T20:58:04.520 に答える
0

Canonical 形式はインターリーブされていないため、各バッファーには 1 つのチャネルしかないため.mBytesPerPacket、. 次に、複数の ( ) バッファーを作成して、次のようなもので AudioUnit に渡す必要があります。.mBytesPerFramesizeof(Float32)busCount

AudioBufferList *bufferList = (AudioBufferList*)malloc(sizeof(AudioBufferList) + (sizeof(AudioBuffer) * (busCount - 1)));
bufferList->mNumberBuffers = busCount;
for ( int i=0; i < bufferList->mNumberBuffers; i++ ) {
    bufferList->mBuffers[i].mNumberChannels = 1;
    bufferList->mBuffers[i].mDataByteSize = BUFFER_SIZE * sizeof(float);
    bufferList->mBuffers[i].mData = malloc(BUFFER_SIZE * sizeof(float));
}
于 2013-02-25T21:18:13.033 に答える