This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Thingy audio streaming

Hello,

I'm playing with two thingy and I'm trying to make a sort of walkie talkie with them.

I wrote the code for the sound service client, then modified other parts for making them scanning, connecting and discovering services, exchange mtu, and till here everything works.

At the moment, when I press the button (on the gatt client side) I start the microphone and I start receiving mic frames from the driver. Now I want to write that audio to the gatt server on the peer. Anyway the mic data is provided from the driver with ADPCM encoding, while the speaker characteristic is in PCM 8bit.

At this point I think I need a ADPCM decoder, is that right? Do anybody know where I can find the code for a routine that does this without the need of implementing it? Or is it better to get the PCM from the raw PDM data of the mic?

Thanks, Davide

Parents
  • Hi Davide, yes you are correct. Comparing the second link I sent you to the dvi_adpcm.c file in the Thingy_sdk_v2.1.0 shows that the two files are very similar (some small differences). Talked to an expert here at Nordic: the Thingy microphone uses ADPCM. The Thingy speaker uses 8-bit PCM.

    Two small examples to clarify: when you stream music from a smartphone to the Thingy:52 using the Thingy app, the smartphone mic picks up 16-bit PCM. This 16-bit PCM is converted to 8-bit PCM in the Thingy app & then sent to the Thingy speaker, which outputs 8-bit PCM.

    Conversely, the Thingy mic uses ADPCM, which is then sent over to the smartphone. The Thingy app then decodes the ADPCM into 16-bit PCM, which is sent to the smartphone speaker.

    So to answer your question, the drv_mic.c file is encoded in ADPCM. Since no encoding & decoding is done inside the Thingy device, it might be helpful for you to check out the Android or iOS Thingy app and look for the decoder function from ADPCM to PCM (see the decodeADPCM() function in iOS for example).

Reply
  • Hi Davide, yes you are correct. Comparing the second link I sent you to the dvi_adpcm.c file in the Thingy_sdk_v2.1.0 shows that the two files are very similar (some small differences). Talked to an expert here at Nordic: the Thingy microphone uses ADPCM. The Thingy speaker uses 8-bit PCM.

    Two small examples to clarify: when you stream music from a smartphone to the Thingy:52 using the Thingy app, the smartphone mic picks up 16-bit PCM. This 16-bit PCM is converted to 8-bit PCM in the Thingy app & then sent to the Thingy speaker, which outputs 8-bit PCM.

    Conversely, the Thingy mic uses ADPCM, which is then sent over to the smartphone. The Thingy app then decodes the ADPCM into 16-bit PCM, which is sent to the smartphone speaker.

    So to answer your question, the drv_mic.c file is encoded in ADPCM. Since no encoding & decoding is done inside the Thingy device, it might be helpful for you to check out the Android or iOS Thingy app and look for the decoder function from ADPCM to PCM (see the decodeADPCM() function in iOS for example).

Children
No Data
Related