Encode mono PCM file to MP3 with libmp3lame/liblame/lame
<p>Looking at the API of libmp3lame, all the functions:</p>

<p>1- Either take left and right channels, like this one:</p>

<pre><code>int CDECL lame_encode_buffer (
    lame_global_flags*  gfp,           /* global context handle         */
    const short int     buffer_l [],   /* PCM data for left channel     */
    const short int     buffer_r [],   /* PCM data for right channel    */
    const int           nsamples,      /* number of samples per channel */
    unsigned char*      mp3buf,        /* pointer to encoded MP3 stream */
    const int           mp3buf_size ); /* number of valid octets in this
                                          stream                        */
</code></pre>

<p>2- Take interleaved data, like this one:</p>

<pre><code>int CDECL lame_encode_buffer_interleaved(
    lame_global_flags*  gfp,           /* global context handlei        */
    short int           pcm[],         /* PCM data for left and right
                                          channel, interleaved          */
    int                 num_samples,   /* number of samples per channel,
                                          _not_ number of samples in
                                          pcm[]                         */
    unsigned char*      mp3buf,        /* pointer to encoded MP3 stream */
    int                 mp3buf_size ); /* number of valid octets in this
                                          stream                        */
</code></pre>

<p>This is the case, although one can choose MONO instead of stereo. Using:</p>

<pre><code>lame_set_mode(lame,MPEG_mode_e::MONO);
</code></pre>

<p>But then how can I get libmp3lame to take MONO PCM data and encode mono mp3 audio? What's the right API to use for that if I don't have a second channel?</p>