0
\$\begingroup\$

I wonder about the feasibility of this idea, and whether this is something worth doing more research on.

I am trying to send 16-bit 16 kHz single channel microphone audio via bluetooth, from one android device to another in real time.

For this I use the AudioRecord class to capture mic data in the transmitter phone. I capture 64 samples at a time (64 samples of 16 kHz audio = 4 msec) and store it in a short array. I have already connected the transmitter and receiver via bluetooth and I am running Google's sample bluetooth chat application.

What I want to do is send the 64 shorts as chat message to the receiver, and play it back in the receiver as AudioTrack.

For this I am assuming that getting the 4 msec worth of audio samples from AudioRecord and the time required to play them back in AudioTrack happen quickly.

Also I am assuming that all data I send through the Bluetooth chat app are using RFCOMM, although I haven't really found anything explicitly stating this. I have read after some google searches that Bluetooth's maximum data transfer capability is somewhere between 2 to 3 Mbps, and even considering a lot of this is used up by Bluetooth profile overheads, RFCOMM should have a data transmission rate of around 400 kbps (I only read this in someone's blog so might not be accurate and it's possible this is where I went wrong).

Audio at 16 kHz would be 16000 samples/sec, which is 16000 sample/sec*16 bits/sample = 256 kbps which seems to be lower than the maximum data transmission rate for bluetooth that I have been able to find online.

In my first attempt the received audio sounds very choppy and is completely unrecognizable. I have tried reducing the sampling frequency to 8000 Hz which gives similar results. Is what I am trying to do even possible using bluetooth?

I did find some sample code which transmitted audio over bluetooth using the Serial Port Profile, but there is a very long delay in the transfer and the app is prone is crashing, and sometimes the audio transmission just doesn't work. My question is not about just transmitting the microphone audio samples from transmitter to receiver, which I am fairly sure is possible, but about doing this in real time.

\$\endgroup\$
2
  • \$\begingroup\$ You most likely need to use larger block sizes. That is, more than just 4 milliseconds of data. It will take more than 4 milliseconds for each block to be transferred, and you can't send the next until the first is done. On the receive side, you do playback in a thread seperate from the receive thread. While the next block is coming in, you play the previous one. The problem isn't so much bandwidth as latency. \$\endgroup\$ – JRE Jan 17 '20 at 10:23
  • \$\begingroup\$ also, is "bluetooth microphone audio possible?": um, considering I have a working bluetooth headset... yes, it is. In fact, there's a bluetooth hands-free profile, and it's quite possible it supports your sample format. \$\endgroup\$ – Marcus Müller Jan 17 '20 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.