ThingPulse / esp32-icon64-a2dp

Stock firmware for the Icon64. Bluetooth speaker with graphical spectrum analyzer
68 stars 10 forks source link

Questions about the voice data processing part #3

Open anla-xu opened 2 years ago

anla-xu commented 2 years ago

Hi. Thank you for enlightening me a lot with your project. As for the code of sound data processing, I don't quite understand it. Could you help me answer it? Thank you very much.

      int byteOffset = 0;
      for (int i = 0; i < SAMPLES; i++)
      {
          sample_l_int = (int16_t)(((*(data + byteOffset + 1) << 8) | *(data + byteOffset)));
          sample_r_int = (int16_t)(((*(data + byteOffset + 3) << 8) | *(data + byteOffset + 2)));
          vReal[i] = (sample_l_int + sample_r_int) / 2.0f;
          vImag[i] = 0;
          byteOffset = byteOffset + 4;
      }