diff --git a/html/hello.html b/html/hello.html index a28c08e..8d1339c 100644 --- a/html/hello.html +++ b/html/hello.html @@ -2,11 +2,10 @@ - - - - + + + test diff --git a/html/uac_pcm_data_convert.html b/html/uac_pcm_data_convert.html new file mode 100644 index 0000000..80badb4 --- /dev/null +++ b/html/uac_pcm_data_convert.html @@ -0,0 +1,69 @@ + + + + + + + + + + + uac_pcm_data_convert + + + +
+ +
+
+

UAC PCM data convert

+ + +
+
+ +

+ +

+ +
+
+ + +
+
+
+ + + + + + \ No newline at end of file diff --git a/index.html b/index.html index 6955b2c..56e9749 100644 --- a/index.html +++ b/index.html @@ -14,24 +14,24 @@
- +
+ + + \ No newline at end of file diff --git a/js/hex_to_int_16bit.js b/js/hex_to_int_16bit.js new file mode 100644 index 0000000..c14b88d --- /dev/null +++ b/js/hex_to_int_16bit.js @@ -0,0 +1,33 @@ +function hex2int(hexStr) { + let twoStr = parseInt(hexStr, 16).toString(2); // 将十六转十进制,再转2进制 + let bitNum = hexStr.length * 4; // 1个字节 = 8bit ,0xff 一个 "f"就是4位 + if (twoStr.length < bitNum) { + while (twoStr.length < bitNum) { + twoStr = "0" + twoStr; + } + } + if (twoStr.substring(0, 1) == "0") { + // 正数 + twoStr = parseInt(twoStr, 2); // 二进制转十进制 + return twoStr; + } else { + // 负数 + let twoStr_unsign = ""; + + // console.log("hex2int--->" + parseInt(twoStr, 2)); + twoStr = parseInt(twoStr, 2) - 1; // 补码:(负数)反码+1,符号位不变;相对十进制来说也是 +1,但这里是负数,+1就是绝对值数据-1 + // console.log("hex2int--->" + twoStr); + + twoStr = twoStr.toString(2); + twoStr_unsign = twoStr.substring(1, bitNum); // 舍弃首位(符号位) + // 去除首字符,将0转为1,将1转为0 反码 + twoStr_unsign = twoStr_unsign.replace(/0/g, "z"); + twoStr_unsign = twoStr_unsign.replace(/1/g, "0"); + twoStr_unsign = twoStr_unsign.replace(/z/g, "1"); + + // console.log("hex2int--->" + twoStr_unsign); + // console.log("hex2int--->" + (-twoStr_unsign)); + twoStr = parseInt(-twoStr_unsign, 2); + return twoStr; + } +} diff --git a/logo.png b/logo.png new file mode 100644 index 0000000..2c83c7c Binary files /dev/null and b/logo.png differ diff --git a/plugin.json b/plugin.json new file mode 100644 index 0000000..da7730f --- /dev/null +++ b/plugin.json @@ -0,0 +1,11 @@ +{ + "main": "index.html", + "logo": "logo.png", + "features": [ + { + "code": "impress", + "explain": "impressionyang's impress tools", + "cmds":["impress", "imt"] + } + ] +} \ No newline at end of file