Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It depends how ' real-time ' you need it</p> <p>if you need it very crisp, go down right at the bottom level and use audio units. that means setting up an INPUT callback. remember, when this fires you need to allocate your own buffers and then request the audio from the microphone.</p> <p>ie don't get fooled by the presence of a buffer pointer in the parameters... it is only there because Apple are using the same function declaration for the input and render callbacks.</p> <p>here is a paste out of one of my projects:</p> <pre><code>OSStatus dataArrivedFromMic( void * inRefCon, AudioUnitRenderActionFlags * ioActionFlags, const AudioTimeStamp * inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList * dummy_notused ) { OSStatus status; RemoteIOAudioUnit* unitClass = (RemoteIOAudioUnit *)inRefCon; AudioComponentInstance myUnit = unitClass.myAudioUnit; AudioBufferList ioData; { int kNumChannels = 1; // one channel... enum { kMono = 1, kStereo = 2 }; ioData.mNumberBuffers = kNumChannels; for (int i = 0; i &lt; kNumChannels; i++) { int bytesNeeded = inNumberFrames * sizeof( Float32 ); ioData.mBuffers[i].mNumberChannels = kMono; ioData.mBuffers[i].mDataByteSize = bytesNeeded; ioData.mBuffers[i].mData = malloc( bytesNeeded ); } } // actually GET the data that arrived status = AudioUnitRender( (void *)myUnit, ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, &amp; ioData ); // take MONO from mic const int channel = 0; Float32 * outBuffer = (Float32 *) ioData.mBuffers[channel].mData; // get a handle to our game object static KPRing* kpRing = nil; if ( ! kpRing ) { //AppDelegate * appDelegate = [UIApplication sharedApplication].delegate; kpRing = [Game singleton].kpRing; assert( kpRing ); } // ... and send it the data we just got from the mic [ kpRing floatsArrivedFromMic: outBuffer count: inNumberFrames ]; return status; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload