2

私は iOS で AudioUnits を研究しており、そのようなグラフを実装しようとしています:

    ------------------- -----------------
   | | | | | | | |
-->| フォーマットコンバータ | --->| バス 0 |
   | | (バリスピード) | | | | |
   -------------------- | マルチチャンネル |
   -------------------- | ミキサーユニット |
   | | | | | | | | --------------------
-->| フォーマットコンバータ | --->| バス 1 | | | | |
   | | (バリスピード) | | | | | --->| リモート IO | ------>
   -------------------- | | | | | ユニット |
   -------------------- | | | | | | |
  | | | | | | | | --------------------
->| フォーマットコンバータ | --->| バス 2 |
  | | (バリスピード) | | | | |
  --------------------- | | |         
                              -----------------

まず、kAudioUnitSubType_Varispeed Unit なしで AudioUnits を操作しようとしました。正常に動作し、サウンドが再生されました。しかし、今はすべての音のピッチを(個別に)実現したいので、各音のピッチを制御するVarispeed Unitを追加することにしました。

私は次のコードを使用しています:

OSStatus 結果 = noErr;

    //................................................................ ...................................
    // オーディオ ユニットのオーディオ ユニット コンポーネントの説明を指定します。
    // グラフに追加。

    // I/Oユニット
    AudioComponentDescription iOUnitDescription;
    iOUnitDescription.componentType = kAudioUnitType_Output;
    iOUnitDescription.componentSubType = kAudioUnitSubType_RemoteIO;
    iOUnitDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
    iOUnitDescription.componentFlags = 0;
    iOUnitDescription.componentFlagsMask = 0;

    // マルチチャンネル ミキサー ユニット
    AudioComponentDescription MixerUnitDescription;
    MixerUnitDescription.componentType = kAudioUnitType_Mixer;
    MixerUnitDescription.componentSubType = kAudioUnitSubType_MultiChannelMixer;
    MixerUnitDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
    MixerUnitDescription.componentFlags = 0;
    MixerUnitDescription.componentFlagsMask = 0;

    // バリス​​ピードユニット
    AudioComponentDescription varispeedUnitDescription;
    MixerUnitDescription.componentType = kAudioUnitType_FormatConverter;
    MixerUnitDescription.componentSubType = kAudioUnitSubType_Varispeed;
    MixerUnitDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
    MixerUnitDescription.componentFlags = 0;
    MixerUnitDescription.componentFlagsMask = 0;

    //................................................................ ...................................
    // オーディオ処理グラフにノードを追加します。
    NSLog (@"オーディオ処理グラフへのノードの追加");

    AUNode iONode; // I/O ユニットのノード
    AUNode ミキサーノード; // マルチチャンネル ミキサー ユニットのノード
    AUNode varispeedNode0;
    AUNode varispeedNode1;
    AUNode varispeedNode2;

    //................................................................ ...................................
    // 新しいオーディオ処理グラフを作成します。
    結果 = NewAUGraph(&processingGraph);

    if (noErr != 結果) {[self printErrorMessage: @"NewAUGraph" withStatus: 結果]; 戻る;}

    //................................................................ ...................................
    // オーディオ処理グラフを開く
    結果 = AUGraphOpen(処理グラフ);

    if (noErr != 結果) {
        [self printErrorMessage: @"AUGraphOpen" withStatus: 結果];
        戻る;
    }

    //................................................................ ...................................
    // ノードをオーディオ処理グラフに追加します
    結果 = AUGraphAddNode(
                             処理グラフ、
                             &varispeedUnitDescription,
                             &varispeedNode0);

    if (noErr != 結果) {
        [self printErrorMessage: @"AUGraphNewNode failed for varispeedNode0 unit" withStatus: result];
        戻る;
    }

    結果 = AUGraphAddNode (
                             処理グラフ、
                             &varispeedUnitDescription,
                             &varispeedNode1);

    if (noErr != 結果) {
        [self printErrorMessage: @"AUGraphNewNode failed for varispeedNode1 unit" withStatus: result];
        戻る;
    }

    結果 = AUGraphAddNode (
                             処理グラフ、
                             &varispeedUnitDescription,
                             &varispeedNode2);

    if (noErr != 結果) {
        [self printErrorMessage: @"AUGraphNewNode failed for varispeedNode2 unit" withStatus: result];
        戻る;
    }

    結果 = AUGraphAddNode (
                             処理グラフ、
                             &iOUnitDescription,
                             &iONode);

    if (noErr != 結果) {
        [self printErrorMessage: @"AUGraphNewNode failed for I/O unit" withStatus: result];
        戻る;
    }

    結果 = AUGraphAddNode (
                             処理グラフ、
                             &MixerUnitDescription,
                             &mixerNode);

    if (noErr != 結果) {
        [self printErrorMessage: @"AUGraphNewNode failed for Mixer unit" withStatus: result];
        戻る;
    }

アプリを実行すると、次のエラーが発生しました。

2013-04-24 21:44:59.335 Drumpads[327:c07] *** AUGraphNewNode が varispeedNode0 ユニット エラーで失敗しました: ˇˇ¯+
2013-04-24 21:44:59.338 Drumpads[327:c07] Error.domain = NSOSStatusErrorDomain、code=-2005、descr =Error Domain=NSOSStatusErrorDomain Code=-2005 「操作を完了できませんでした。(OSStatus エラー - 2005.)」

MacErrors.h -2005 によると、「badComponentType」を意味します。

そのため、バリスピードユニットをAUGraphに追加することすらできないようです。すべてが正しいように見えるので、Varispeed Node を追加するとエラーが発生する理由がわかりません。

developers.apple.com コードのサンプル コードを参考にしました ( OSx用ですが、Varispeed は iOS5 と 6 で利用できるようになったので、このコードを参考にすることにしました)。

音ごとにピッチシフトをコントロールする必要があります。私は Varispeed を選択しましたが、NewTimePitch Nodes についても読みました。(同じグラフで) NewTimePitch を試しましたが、成功しませんでした。

私のコードで何が間違っているのか、Varispeed Node を追加するとエラーが発生する理由を知っている人はいますか?

前もって感謝します!

4

1 に答える 1