none
Bluetooth SCO - I'm receiving voice data, how do I convert to PCM? RRS feed

  • Question

  • Hi All,

    I'm working to enable phone call audio via a Bluetooth connected phone on the PC. I've gotten the RFCCOMM channel up and running, and have gotten a basic Bluetooth driver in place. I can successfully open an SCO Connection which causes my phone to change it's audio output source. So far so good.

    Doing reads on the SCO channel yields a bunch of data (primarily 0's) but when I talk into the calling phone, I see the data changing. Again so far so good.

    By checking the SCO fields it appears it's using CVSD which sounds about right. Now here's where I'm at an impasse, what do I do with the data?

    Is the data I'm receiving raw audio data, or am I receiving packet headers plus data (HV1 headers for example)?

    The next question is what's the best way to get this audio out to my speakers. For simplicity I'm allowing the data read to occur in a Windows application so I have access to the data at the OS level. 

    My gut instinct was to use the Audio Compression manager to convert to RAW PCM audio and output that, however it does not appear there is a built-in CVSD codec in Windows.

    So my question for you fine folks is have I made a mistake in my assumptions and can anyone provide a pointer on where to head next?

    Many thanks in advance.


    • Edited by DJScrib Monday, July 1, 2013 6:00 PM
    Friday, June 28, 2013 4:46 AM

Answers

  • To help anyone else who wanders into this thread here's an update

    The data we get from the radio seems to be 16 bit PCM audio. However on some systems it appears to be Big-Endian, others Little Endian. Go figure. More testing is needed but it's rather odd. I'm not sure if there's a flag which indicates which byte order the PCM data is in.

    Now for the writes, we sort of got those working. If we write data in chunk sizes of 6000 bytes then it works. Multiples of 6000 also work. If we use different chunk sizes the write never completes. That's the current mystery. No such size problem exists for reads.

    Thursday, July 25, 2013 6:32 AM

All replies

  • Well my thinking this was answered was incorrect. On one system we get PCM audio we can easily decode. On other systems we get data which does not appear to actually be PCM. Sometimes you can sort of hear the real audio within the data, for others it's just garbage.

    Again if anyone has any ideas I'd love to hear them. Also I have the ability to pay for consulting around this issue (nights/weekends/email) if that strikes anyone's fancy.

    Thanks

    Tuesday, July 2, 2013 10:17 PM
  • my guess is that different radios are negotiating different encoding algorithms

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, July 3, 2013 1:23 AM

  • Recently I had the same problem. What I had concluded is the Linear PCM has some troubles (signed/unsigned PCM issue or something else). Try A-law PCM encoding.

    • Edited by RedSoftk Wednesday, July 3, 2013 7:44 AM edit
    • Proposed as answer by Pavel A Wednesday, July 3, 2013 11:55 PM
    • Unproposed as answer by Pavel A Wednesday, July 3, 2013 11:55 PM
    Wednesday, July 3, 2013 7:42 AM
  • Thanks RedSoftk. I saw your earlier thread around SCO which we used to make part of our progress. The data received from the SCO reads, is it generally PCM data no matter what? And what you seem to be saying is it may require A-law encoding.

    I've seen the various Content Format fields but they seem to infer that CVSD encoding is being used and my assumption is that this is what is used for transmitting from radio to radio. But it seems like the radio is doing the conversion to PCM before we read it from the SCO or is this not a safe assumption. Is there any way to determine what audio format we're getting out of the SCO? It seems like we're really close but are missing something.

    On another topic, did you have any issues with Writes? We've tried doing some but they just seem to hang. Is there any special sequencing where you must do a write followed by a read and so-forth or can you just read/write to the SCO channel in any order you feel like.

    Again thanks for any help.

    Wednesday, July 3, 2013 8:14 AM
  • I had some issues with Writes. If you have russian speaker you can talk to me +972 545 331 803. Sorry, but i am speaking English not very nice. Another variant is to send me e-mail redsoftk @ yahoo.com

    My hour is GMT +2
    • Edited by RedSoftk Thursday, July 4, 2013 11:47 AM Edit
    Thursday, July 4, 2013 11:41 AM
  • To help anyone else who wanders into this thread here's an update

    The data we get from the radio seems to be 16 bit PCM audio. However on some systems it appears to be Big-Endian, others Little Endian. Go figure. More testing is needed but it's rather odd. I'm not sure if there's a flag which indicates which byte order the PCM data is in.

    Now for the writes, we sort of got those working. If we write data in chunk sizes of 6000 bytes then it works. Multiples of 6000 also work. If we use different chunk sizes the write never completes. That's the current mystery. No such size problem exists for reads.

    Thursday, July 25, 2013 6:32 AM
  • I've done quite a bit of testing on the write thing.  It looks like 48 is the magic, smallest write buffer size, at least on my systems.  Let me know if 48 doesn't work for you.

    No clue about the Endian issue.  I have data that I've saved from the SAME system, with the SAME two phones and find that todays files are Big-end and files from several days ago are Little-end.  I'd be really interested in a flag if you find one, but so far all of the connections have looked the same.

    • Proposed as answer by huntzinger Monday, August 26, 2013 4:19 PM
    • Unproposed as answer by huntzinger Monday, August 26, 2013 11:18 PM
    Thursday, July 25, 2013 11:54 PM
  • Hello,

    I have paired my phone to PC and configured PC as a handsfree device. Now I want to read phone call audio data in my application. I don't have any experience in Bluetooth communication.

    Now I come to know there needs to be a RFCOMM channel and SCO connection for reading audio data.

    However, I am not able to establish communication with device from my program.

    Can anybody suggest some sample\pointer regarding it?

    Thanks.


    • Edited by HarshTheOne Thursday, December 12, 2013 12:54 PM
    Thursday, December 12, 2013 12:54 PM