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);
}
}
标签:1.0,float,0.999999,sample,S16P,PCM,return,FLTP
From: https://www.cnblogs.com/zjacky/p/17095601.html