Help to record app audio output? Microphone input works, not [_audioController addOutputReceiver:_re

Hi I am wanting to capture the audio output from my app.
I have used the example code and with
[_audioController addInputReceiver:_recorder];
I can capture the microphone input without any problem.
However when I just use
[_audioController addOutputReceiver:_recorder];
The file is created but nothing plays back.
Do I need to either create an Objective-C class that implements the AEAudioReceiver protocol or use the AEBlockAudioReceiver class ?
If so what do I put in
AudioBufferList *audio) {
// Do something with 'audio'
}?
Hope my beginner level query is not too annoying.
Mark

Comments

  • Hi Mark. How are you generating audio in your app? It has to be through TAAE, or TAAE won't be able to capture the output.

  • Thanks for your reply. I am using a soundfont and midi. Code I borrowed which works but I don't really understand.
    Is there a simple way to use TAAE with this?
    - (id) init{
    if ( self = [super init] ) {
    [self createAUGraph];
    [self startGraph];
    [self setupSampler:self.presetNumber];
    }
    return self;
    }
    - (BOOL) createAUGraph{
    NewAUGraph(&_processingGraph);
    AudioComponentDescription cd = {};
    cd.componentType = kAudioUnitType_MusicDevice;
    cd.componentSubType = kAudioUnitSubType_Sampler;
    cd.componentManufacturer = kAudioUnitManufacturer_Apple;
    cd.componentFlags = 0;
    cd.componentFlagsMask = 0;

    AUGraphAddNode(self.processingGraph, &cd, &_samplerNode);
    
    // I/O unit
    AudioComponentDescription iOUnitDescription;
    iOUnitDescription.componentType          = kAudioUnitType_Output;
    iOUnitDescription.componentSubType       = kAudioUnitSubType_RemoteIO;
    iOUnitDescription.componentManufacturer  = kAudioUnitManufacturer_Apple;
    iOUnitDescription.componentFlags         = 0;
    iOUnitDescription.componentFlagsMask     = 0;
    
    AUGraphAddNode(self.processingGraph, &iOUnitDescription, &_ioNode);
    AUGraphOpen(self.processingGraph);
    
    AUGraphNodeInfo(self.processingGraph, self.samplerNode, NULL, &_samplerUnit);
    
    AUGraphNodeInfo(self.processingGraph, self.ioNode, NULL, &_ioUnit);
    
    AudioUnitElement ioUnitOutputElement = 0;
    AudioUnitElement samplerOutputElement = 0;
    AUGraphConnectNodeInput(self.processingGraph,
                            self.samplerNode, samplerOutputElement,
                            self.ioNode, ioUnitOutputElement);
    return YES;
    

    }
    - (void) startGraph{
    if (self.processingGraph) {
    Boolean outIsInitialized;
    AUGraphIsInitialized(self.processingGraph,
    &outIsInitialized);
    if(!outIsInitialized)
    AUGraphInitialize(self.processingGraph);

        Boolean isRunning;
        AUGraphIsRunning(self.processingGraph,
                         &isRunning);
        if(!isRunning)
            AUGraphStart(self.processingGraph);
        self.playing = YES;
    }
    

    }
    - (void) setupSampler:(UInt8) pn;{
    // propagates stream formats across the connections
    Boolean outIsInitialized;
    AUGraphIsInitialized(self.processingGraph,
    &outIsInitialized);
    if(!outIsInitialized) {
    return;
    }
    if(pn < 0 || pn > 127) {
    return;
    }
    NSURL *bankURL;
    if(!selectPiano){
    bankURL = [[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle]
    pathForResource:@gpo-concert-steinway-ver2 ofType:@sf2]];}

    // fill out a bank preset data structure
    AUSamplerBankPresetData bpdata;
    bpdata.bankURL  = (__bridge CFURLRef) bankURL;
    bpdata.bankMSB  = kAUSampler_DefaultMelodicBankMSB;
    bpdata.bankLSB  = kAUSampler_DefaultBankLSB;
    bpdata.presetID = (UInt8) pn;
    AudioUnitSetProperty(self.samplerUnit,
                         kAUSamplerProperty_LoadPresetFromBank,
                         kAudioUnitScope_Global,
                         0,
                         &bpdata,
                         sizeof(bpdata));
    

    }

    -(void)playNote{
    UInt8 midiChannelInUse = 0; //we're using midi channel 1...
    UInt32 noteOnCommand = kMidiMessage_NoteOn << 4 | midiChannelInUse;
    MusicDeviceMIDIEvent(self.samplerUnit, noteOnCommand, 80,80, 0);
    }

  • No, I'm afraid not - this is not integrated into TAAE, but is interacting with Core Audio directly. You need to create an AEAudioUnitChannel instead, with the kAudioUnitType_MusicDevice, kAudioUnitSubType_Sampler, kAudioUnitManufacturer_Apple type, and configure and add it to AEAudioController.

Sign In or Register to comment.