Write Audio To Disk From IO Unit

后端 未结 1 998
遥遥无期
遥遥无期 2020-12-05 12:08

Rewriting this question to be a little more succient.

My problem is that I cant successfully write an audio file to disk from a remote IO Unit.

The steps I t

相关标签:
1条回答
  • 2020-12-05 12:42

    After a couple of days of tears & hair pulling I have a solution.

    In my code and in other examples I have seen extaudiofilewriteasync was called in the callback for the remoteio unit like so.

    ** remoteiounit callback **

    static OSStatus masterChannelMixerUnitCallback(void *inRefCon, 
                                  AudioUnitRenderActionFlags *ioActionFlags, 
                                  const AudioTimeStamp *inTimeStamp, 
                                  UInt32 inBusNumber, 
                                  UInt32 inNumberFrames, 
                                  AudioBufferList *ioData)
    
    {
    
    
        AudioUnitRender(engineDescribtion.equnit, ioActionFlags, inTimeStamp, 0, inNumberFrames, ioData);
    
    
        if(isrecording)
        {
            ExtAudioFileWriteAsync(engine->recordingfileref, inNumberFrames, ioData);
    
    
        }
    
    
    
        return 0;
    
    }
    

    In this callback I'm pulling audio data from another audio unit that applies eqs and mixes audio.

    I removed the extaudiofilewriteasync call from the remoteio callback to this other callback that the remoteio pulls and the file writes successfully!!

    *equnits callback function *

    static OSStatus outputCallback(void *inRefCon, 
                                   AudioUnitRenderActionFlags *ioActionFlags, 
                                   const AudioTimeStamp *inTimeStamp, 
                                   UInt32 inBusNumber, 
                                   UInt32 inNumberFrames, 
                                   AudioBufferList *ioData) {  
    
    
        AudioUnitRender(engineDescribtion.masterChannelMixerUnit, ioActionFlags, inTimeStamp, 0, inNumberFrames, ioData);
    
       //process audio here    
    
        Engine *engine= (Engine *) inRefCon;
    
    
        OSStatus s;
    
        if(engine->isrecording)
        {
            s=ExtAudioFileWriteAsync(engine->recordingfileref, inNumberFrames, ioData);
    
    
        }
    
    
        return noErr;
    
    }
    

    In the interest of fully understanding why my solution worked could somebody explain to me why writing data to file from the iodata bufferlist of the remoteio causes distorted audio but writing data one further step down the chain results in perfect audio?

    0 讨论(0)
提交回复
热议问题