Search code examples
androidoboe

When using oboe is it possible to mismatch channel count when setting up input and output stream?


When using the Android oboe library, is it possible to set the input channel to be mono and the output channel to be stereo? And then write the mono sample values to the stereo output channel through using a similar method given in Mono to Stereo conversion?

Without any conversion and directly setting the channels to be mono and stereo results in the output to be high pitched.


Solution

  • is it possible to set the input channel to be mono and the output channel to be stereo?

    Yes, you can set the channel count to whatever you like, although there's no guarantee that the stream will actually open if you set it to some weird value.

    And then write the mono sample values to the stereo output channel through using a similar method given in Mono to Stereo conversion?

    Yes, that will also work. Write every sample from your mono stream twice into the stereo stream.

    Without any conversion and directly setting the channels to be mono and stereo results in the output to be high pitched.

    That's to be expected because the stereo stream is rendering the samples at twice the rate so the output frequency = 2 * input frequency.

    You may be better off opening both input and output streams with the same channel count and letting Oboe do the conversion for you. The convention is to open the output stream first without specifying the channel count, then explicitly specify that channel count for the input stream. Example here: https://github.com/google/oboe/blob/master/samples/LiveEffect/src/main/cpp/LiveEffectEngine.cpp#L81