如何将PCM样本从麦克风转换为React Native的字节

时间:2019-06-27 06:40:19

标签: javascript react-native websocket audio-recording microphone

我正在做一个本机项目,该项目从麦克风读取音频样本并将其通过websocket发送进行处理。我读取的样本具有以下格式258,-403,-595,-740,-643,-595 ,-836,-1109,-1141,-1317,-1428,-1059,-804,-884,-980,-788,-451,-419,-387,-82,61,157,366,462,446,606,574,478,767,767,1038,1088,1216 ,1505,1617,1248,991,1007,751,494,398,221,-50,-419,-690,-788,-948,-1059,-1027,-980,-1027,-1141,-1075,-1093,- 1205,-996,-706,-435,-146,29,-162,-338,-178,-50,-162,-322,-499,-531,-306,-18,269,574,863,783,622,558,685,1022,1104, 1136,1070,815,606,348,205,61,-274,-611,-852,-884,-675,-595,-611,-483,-242,-66,0,269,430,269,269,398,430,269,125,333,253,-258,-162,45,-338 ,-627,-371,-98,-146,0,205,109,189,285,366,430,414,382,173,205,414,382,13,-419,-353,-403,-627,-675,-722,-675,-900,-1093,-932,-836, -772,-627,-611,-595,-451,-274,-162,-387,-242,-130,-322,-98,0,-34,237,462,526,462,526,799,895,991,1104,1200,1407,1537,1697 ,1697,1423,1328,1184,1070,799,221,-194,-531,-884,-996,-1043,-1189,-11 73,-1027,-916,-868,-980,-980,-868,-722,-531,-483,-515,-611,-595,-690,-900,-868,-932, -916,-804,-980,-1012,-788,-483,-114,45,45,29,253,478,382,348,510,767,1022,1054,1136,1296,1360,1136,1022,1216,1136,911,767,478

如果我将它们写入文件,它们将照原样写入。如何在将它们转储到文件之前进行转换,以便以后可以使用Audacity播放?

1 个答案:

答案 0 :(得分:1)

最后,我找到了一种方法。

Multer