How to convert an AudioInputStream from ULAW stereo to GSM06010 stereo – in Java

I have to convert an AudioInputStream from ULAW stereo to GSM06010 stereo.

To be more precise:

  • MY_AudioInputStream_Input: PCM_SIGNED, 8000.0 Hz, 16 bit, stereo, 4
    bytes/frame, 4000.0 frame/sec, big-endian
  • MY_AudioFormat_Target: GSM0610, 8000.0 Hz, 1 bit, stereo, 66
    bytes/frame, 25.0 frame/sec

If I do it in Mono it works, but not in stereo.
To do the conversion (that is to get the ‘Target_AudioInputStream’), that in Mono works, I use:

FormatConversionProvider MY_FormatConversionProvider=org.tritonus.sampled.convert.gsm.GSMFormatConversionProvider();
AudioInputStream MY_Target_AudioInputStream= MY_FormatConversionProvider_Arg.getAudioInputStream(MY_AudioFormat_Target, MY_AudioInputStream_Input);

I suppose that the problem is that, when I see the list of Audioformat supported in the system (by ‘AudioSystem.getTargetFormats()’ ), the GSM06010 at 8000 Hz with 1 channel (mono) is supported, while the GSM06010 at 8000 Hz with 2 channels (stereo) is not supported.

The reason why I need in stereo mode, is that in same PCs the audio can be get from microphone only in stereo (also if that PC support the AudioFormat mono); so I need to get the Audio in stereo from microphone (in ULAW stereo format because the GSM stero format is not supported) and then I have to convert in GSM stereo format.

Any idea?