Sample Spresense-Arduino Sketch pcm_capture Voice Data Structure

Asked 2 years ago, Updated 2 years ago, 87 views

I would like to retrieve audio data from the microphone by referring to the example sketch pcm_capture in Spresense-Arduino and send the data via Wifi.

Sketch example: I understand that the following code in pcm_capture shows the contents of the captured audio data, but I don't know exactly what kind of structure the audio data is stored in.

printf("Size%d[%02x%02x%02x%02x%02x%02x...]\n",
         size,
         s_buffer[0],
         s_buffer[1],
         s_buffer[2],
         s_buffer[3],
         s_buffer[4],
         s_buffer[5],
         s_buffer[6],
         s_buffer[7]);

What should I do if I want MIC_A audio data while recording with 4CH?

Thank you for your cooperation.

spresense arduino

2022-09-30 19:28

1 Answers

I am in charge of SPRESENSE support for Sony.

I will answer your inquiry.

The PCM capture data is stored in the buffer as follows:

  • Little Endian, listed in order Mic A, Mic B, Mic C, Mic D, ...
  • Use 16-bit audio per sample and 32-bit data per 24-bit audio

These data are easier to process when you define a structure and cast the contents of the buffer.
Provides a brief sample code for 16-bit and 24-bit audio.

for 16-bit 4Ch recordings

structure channel_bit16 {
   uint16_tmicA;
   uint16_tmicB;
   uint16_tmicC;
   uint16_tmicD;
};

struct channel_bit16*mic_data=(struct channel_bit16*)s_buffer;// Access 0th data
uint16_tmic_a =mic_data[0].micA;
uint16_tmic_b =mic_data[0].micB;
uint16_tmic_c =mic_data[0].micC;
uint16_tmic_d =mic_data[0].micD;

For 24-bit 4Ch recordings

structure channel_bit24 {
   uint32_tmicA;
   uint32_tmicB;
   uint32_tmicC;
   uint32_tmicD;
};

struct channel_bit24*mic_data=(struct channel_bit24*)s_buffer;// Access 0th data
uint32_tmic_a =mic_data[0].micA;
uint32_tmic_b =mic_data[0].micB;
uint32_tmic_c =mic_data[0].micC;
uint32_tmic_d =mic_data[0].micD;

I hope that you will be able to you.
Thank you for your continued support at SPRESENSE.

SPRESENSE Support Team


2022-09-30 19:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.