PCM:FLTP和S16P

PCM数据格式:

  • 如果数据是 float 格式,则值域为 [-1.0, 1.0]
  • 如果数据是 S16 (int16) 格式,则值域为 [-32767, +32767]
#include <stdint.h>
inline int16_t PCMFloat32ToInt16FmtConvert(float sample)
{
   if (sample < -0.999999f)
   {
      return INT16_MIN;
   }
   else if (sample > 0.999999f)
   {
     return INT16_MAX;
   }
   else
   {
     return static_cast<int16_t>(sample*32767.0f);
   }
}
posted @ 2023-02-06 15:37  小超不挑食  阅读(262)  评论(0编辑  收藏  举报