| Updated: October 28, 2024 | 
You can record audio content by attaching an audio capture device (microphone) as the input and a file (instead of a device) as the output.
[plugin] dll=mmr-mmfrip-routing.soTo ensure the plugin is loaded, this configuration must be defined when you launch mm-renderer.
The following example shows how to give mm-renderer an output URL of type file: to target a file, and an input URL of type snd: to select and configure a microphone, and then start and stop recording captured audio content to the targeted file. An snd: input URL targeting a microphone works only with the file output type, so your code must obey this design.
/* Code to connect to mm-renderer and create a context goes here 
   (see "Playing audio content" for an example of doing this) */
const mmr_error_info_t* errorInfo;
// Specify a file output so the audio content is recorded to a file
const char* outputPath = "file:/tmp/testFile.amr";
int outputID = mmr_output_attach( ctxt_audiorec, outputPath, "file" );
if (outputID == -1) {
    errorInfo = mmr_error_info(ctxt_audiorec);
    /* Remaining error-handling code goes here */
    return EXIT_FAILURE;
}
        
// Specify which audio device under /dev/snd you want to use for
// recording and the recording details, in the input URL
int inputID = mmr_input_attach( ctxt_audiorec,
                     "snd:/dev/snd/pcmPreferredc?nchan=1&frate=8000",
                                "track" );
if (inputID == -1) {
    /* Error-handling code goes here */
    return EXIT_FAILURE;
}
        With the output and input attached, we can define output parameters; there are no input parameters for audio capture devices. For file outputs, mm-renderer supports the audio_fourcc and audio_bitrate parameters, to select an encoder and enable compression. For more details, see Parameters that affect how the output is delivered.
if ( mmr_play(ctxt_audiorec) < 0 ) {
    /* Error-handling code goes here */
}
sleep(30); // Delay for the length of time you want to record
if ( mmr_stop(ctxt_audiorec) < 0 ) {
    /* Error-handling code goes here */
}