iOS 音频数据bytes转float
2022-01-19 本文已影响0人
发疯的code
#define MAX_INT_FLOAT 32768.0
将每两个字节转换成一个float数据
Byte *bytes = (Byte *)[inputData bytes];
for(int i=0;i<[inputData length];i = i + 2){
Byte tByte[2];
tByte[0] = bytes[i];
tByte[1] = bytes[i + 1];
short number;
memcpy(&number, &tByte, sizeof(tByte));
[self.cacheData addObject:[NSNumber numberWithFloat:number/(double)MAX_INT_FLOAT]];
}