我試圖將PCM流轉換爲可讀的float32Array。我想用下面的方法轉換將PCM流轉換爲Javascript可讀流
function parseHexString(str) {
var result = [];
while (str.length >= 8) {
int16 = parseInt(str.substring(0, 8), 16);
float32 = (int16/32767) - 1;
result.push(float32);
str = str.substring(8, str.length);
}
return result;
}
輸入(INT16)
\x86%\x03%>$\xb1#\x06#8"\xc0!E!\xc5 \xad \xa4 \x97 \xe4 \x1e!/!\x80!\xb5!\xcb!+"u"\x8e"\xd2"\xdd"\xa4"\x98"l"$"3">"<"\x8a"\xc4"\xd9"$#I#@#h#j#8#2#\t#\xbf"\xc1"\xcb"\xd3")#h#t#\x9c#\x8d#?#\x15#\xbb"("\xbc!*!w \r \xa3\x1f2\x1f\x13\x1f\xf1\x1e\xbe\x1e\xd3\x1e\xd4\x1e\xae\x1e\xb1\x1e\x81\x1e\x16\x1e\xda\x1d\x84\x1d\x19\x1d\xfa\x1c\xd2\x1c\x9c\x1c\xb4\x1c\xd0\x1c\xe5\x1cK\x1d\x9b\x1d\xb0\x1d\xd2\x1d\x9d\x1d\x0b\x1d\x90\x1c\xf3\x1bF\x1b\x02...
返回這樣
[NaN, NaN, -0.9929502243110446, -0.999603259376812, NaN, -0.99954222235786, NaN, -0.9929502243110446, NaN, -0.9929502243110446, NaN, -0.9929502243110446, NaN, -0.9929502243110446, NaN, -0.9929502243110446, NaN, NaN, -0.9929502243110446, NaN, -0.999664296395764, NaN, -0.999877925962096, NaN, NaN, -0.999908444471572, NaN, NaN, -0.999908444471572, NaN, NaN, -0.999877925962096, NaN, NaN,
東西,我不知道爲什麼我得到的NaN的。任何人?我也不確定PCM數據流的格式是否正確
您輸入的內容並不太清楚 –
我以int16格式從Python應用程序接收PCM輸入,並通過websocket連接將其發送到瀏覽器 – boortmans