Sunday, July 19, 2026
HomeiOS Developmentios - how one can course of enter with AVAudioEngine handbook rendering...

ios – how one can course of enter with AVAudioEngine handbook rendering mode?

[ad_1]

I am having hassle getting AVAudioEngine handbook rendering working when processing enter. It is easy to get it working when there is no enter node and audio comes from a participant node.

This is the code I’ve received, which might be pasted right into a check:

- (void)testManualRendering {

    auto engine = [[AVAudioEngine alloc] init];

    auto format = [[AVAudioFormat alloc] initStandardFormatWithSampleRate:44100.0
                                                                 channels:2];

    auto inputBuffer = [[AVAudioPCMBuffer alloc] initWithPCMFormat:format
                                                     frameCapacity:1024];

    auto abl = inputBuffer.mutableAudioBufferList;
    XCTAssert(abl != NULL);
    XCTAssertEqual(abl->mNumberBuffers, 2);

    [engine connect:engine.inputNode to:engine.mainMixerNode format:format];

    NSError* error;
    [engine enableManualRenderingMode:AVAudioEngineManualRenderingModeOffline
                               format:format
                    maximumFrameCount:1024 error:&error];
    XCTAssertNil(error);
    XCTAssert([format isEqual:engine.manualRenderingFormat]);
    NSLog(@"manualRenderingFormat: %@", engine.manualRenderingFormat);

    auto success = [engine.inputNode setManualRenderingInputPCMFormat:format
                                                           inputBlock:^const AudioBufferList * _Nullable(AVAudioFrameCount inNumberOfFrames) {
        XCTAssert(abl->mBuffers[0].mDataByteSize <= inNumberOfFrames * sizeof(float));
        XCTAssert(abl->mBuffers[1].mDataByteSize <= inNumberOfFrames * sizeof(float));
        return abl;
    }];
    XCTAssert(success);

    [engine startAndReturnError:&error];
    XCTAssertNil(error);

    auto outputBuffer = [[AVAudioPCMBuffer alloc] initWithPCMFormat:format
                                                      frameCapacity:1024];
    XCTAssertNotNil(outputBuffer);

    XCTAssert(engine.isInManualRenderingMode);
    auto standing = [engine renderOffline:32 toBuffer:outputBuffer error:&error];
    if(standing == AVAudioEngineManualRenderingStatusInsufficientDataFromInputNode) {
        printf("handbook rendering failed: AVAudioEngineManualRenderingStatusInsufficientDataFromInputNoden");
    }
    XCTAssertEqual(standing, AVAudioEngineManualRenderingStatusSuccess);

    if (error) {
        NSLog(@"error: %@", error);
    }
    XCTAssertNil(error);
}

I am getting AVAudioEngineManualRenderingStatusInsufficientDataFromInputNode however the enter buffer has loads of information. What am I lacking? Having hassle discovering instance code for this.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments