Question

I'd like to capture the outgoing audio from a game and record it into an audio file as it's played. Is this possible within the framework in OpenSL? Like by connecting the OutputMix to an AudioRecorder, or something?

Thanks in advanced.

Was it helpful?

Solution

You could register a callback to the queue and obtain the output buffer before / after it is enqueued into the buffer queue for output. You could have a wavBuffer (a short array the length of the buffer size) that is written into on each enqueueing of a new buffer. The contents of this buffer are then written to a file.

outBuffer = p->outputBuffer[p->currentOutputBuffer];  // obtain float buffer

for ( int i = 0; i < bufferSize; ++i )
    wavBuffer = ( short ) outBuffer[ i ] * 32768; // convert float to short

// now append contents of wavBuffer into a file

The basic OpenSL setup for the queue callback is explained in some detail on this page

And a very basic means of creating a WAV file in C++ can be found here note that you must have a pretty definitive idea of the actual size of the total WAV file as it's part of its header.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top