Android Question Using two audio channels at the same time (Bluetooth and USB audio)

yo3ggx

Active Member
Licensed User
Longtime User
As I'm aware, in Android, when you connect an USB audio device this automatically replace internal audio device, but when a Bluetooth audio headset is connected, you can select between Bluetooth, Speaker or earpiece (as in the Phone app). It is possible to simultaneously use in an application Bluetooth audio and internal phone audio(or USB audio if connected) and make a duplex or semi-duplex bridge between them? How can I manually select in my application between internal audio and Bluetooth audio?
Thank you.
 

yo3ggx

Active Member
Licensed User
Longtime User
Hello Erel. Reading through the documentation, I was still not able to find a way to stream audio between USB audio and Bluetooth (or Phone) audio. It is possible to select different audio channels for 2 separate Audiostreamer objects? I want to stream phone microphone audio to an USB audio playback device and to stream the USB microphone audio to the phone speaker or a Bluetooth headset.
 
Upvote 0

yo3ggx

Active Member
Licensed User
Longtime User
I was able to make it work. Audio in the smartphone is played over Alarm audio channel.

Audio bridge between USB audio and phone mic/speaker.:
    Dim TxStreamer As AudioStreamer
    Dim RxStreamer As AudioStreamer

    Dim REC_DEFAULT As Int = 0
    Dim REC_CAMCORDER As Int = 5
    Dim PLAY_STREAM_VOICE_CALL As Int = 0
    Dim PLAY_STREAM_ALARM As Int = 4

    TxStreamer.Initialize2(REC_CAMCORDER,"TxStreamer",44100,True,16,PLAY_STREAM_VOICE_CALL)
    RxStreamer.Initialize2(REC_DEFAULT,"RxStreamer",44100,True,16,PLAY_STREAM_ALARM)
    RxStreamer.StartRecording
    RxStreamer.StartPlaying
    TxStreamer.StartRecording
    TxStreamer.StartPlaying
 
...

Private Sub RxStreamer_RecordBuffer(buffer() As Byte)
        RxStreamer.Write(buffer)
End Sub

Private Sub TxStreamer_RecordBuffer(buffer() As Byte)
     TxStreamer.Write(buffer)
End Sub

Now I'm trying to make it work with a Bluetooth Headset instead of phone mic/speaker.
 
Upvote 0

yo3ggx

Active Member
Licensed User
Longtime User
Now I'm trying to make it work with a Bluetooth Headset instead of phone mic/speaker.
Unfortunately, for an unknown reason, audio is played on both smartphone speaker and Bluetooth headset. When I set the audio level for the Notifications/Alarm channel, is modified on both phone and headset.
 
Upvote 0
Top