Record system / application output

edited June 2013

Hey there,

I'm currently attempting to record all the sounds my app is making. I.e. I have a library that connects to a web radio and plays the stream on the device. Now (independently) I'd like to record that output after passing it through some filters etc. So right now, I'm stuck at getting anything recorded bar microphone input - which at this point is not desired thus I initialise the audio controller like so:

    self.audioController = [[AEAudioController alloc] initWithAudioDescription:[AEAudioController nonInterleaved16BitStereoAudioDescription] inputEnabled:NO];

Whenever I start recording using this method (note that radio is already playing through the device's speakers):

- (void)startRecording
{
    self.audioRecorder = [[AERecorder alloc] initWithAudioController:self.audioController];
    
    [self.audioController addOutputReceiver:self.audioRecorder];
    
    NSError *error = nil;
    if ( ![self.audioRecorder beginRecordingToFileAtPath:[self filePathForRecorderFile] fileType:kAudioFileAIFFType error:&error] )
    {
        NSLog(@error recording: %@", error);
    }
}

…all I get is a file ("Recording.aiff") containing a bunch of 0's bar the first few bytes (header).

Can someone point me to the right direction? Thanks a lot!

Comments

  • I have the same problem. I've been going through TAAE code and apparently there is no output from AEMixerBuffer that is used in AERecorder, that is why nothing gets saved to a file. The error apparently has something to do with that, could nonInterleavedStereo float cause this?

    Thanks!

  • I have fixed the error myself. I am not sure that this is a bug in TAAE, it might be due to project configuration.

    First thing you need to do is: addInputReceiver, to receive data from Microphone (my first mistake). You might also need outputReceiver if you use web radio of course.

    Second thing is a bug in AEMixerBuffer apparently. The problem is in AEMixerBufferEnqueue function in AEMixerBuffer.m file.

    Change this code:

            if ( pthread_main_np() != 0 ) {
                dprintf(THIS, 3, "Preparing new source %p\n", sourceID);
                prepareNewSource(THIS, sourceID);
                source = sourceWithID(THIS, sourceID, NULL);
            }
    

    To:

            if ( pthread_main_np() == 0 ) {
                dprintf(THIS, 3, "Preparing new source %p\n", sourceID);
                prepareNewSource(THIS, sourceID);
                source = sourceWithID(THIS, sourceID, NULL);
            }
    

    In my case the audio was always enqueued only in main thread, which kept preparing for new source, but never actually prepared it, that is why no audio was enqueued. The problem is now fixed by changing the condition of first IF-clause, so if the main thread enqueues audio, new source is prepared.

    My application now finally records audio like it should.

    Regards,

    Dal

Sign In or Register to comment.