Unicode 中数字 93 有何含义?
由于目前没有通用的方法可以从 JavaScript 中的音轨读取实时数据,因此我使用了一个小的 library/API 用于从我从 MP3 离线转换的文本文件中读取音量数据。
字符串看起来像这样
<前><代码>!!!!!!!!!!!!!!!!!!!!!!!!!!!####"~{~||ysvgfiw`gXg}i}|mbnTaac[ Wb~v|xqsfSeYiV`R ][\Z^RdZ\XX`Ihb\O`3Z1W*I'D'H&J&J'O&M&O%O&I&M&S&R&R%U&W&T&V& ;m%\%n%[%Y%I&O'P'G 'L(V'X&I'F(O&a&h'[&W'P&C'](I&R&Y'\)\'Y'G(O'X'b'f&) N&S&U'N&P&J'N)O'R)K'T(f|`|d //ETC...
这个想法基本上是,在歌曲中的给定点,文本文件中相应点的字符的 Unicode 编号产生一个标称值来表示音量。
该库使用以下内容(此处进行了简化)转换数据(在本例中为立体声轨道):
getVolume = function(sampleIndex,o) { o.left = Math.min(1,(this.data.charCodeAt(sampleIndex*2|0)-33)/93); o.right = Math.min(1,(this.data.charCodeAt(sampleIndex*2+1|0)-33)/93); }
我想深入了解该文件最初是如何编码的,以及我在这里如何使用它。
93
和 33
有何意义?
按位 |
的用途是什么?
这是移植信息的常见方法(即它是否有名称),还是有更好的方法?
Since there is currently no universal way to read live data from an audio track in JavaScript I'm using a small library/API to read volume data from a text file that I converted from an MP3 offline.
The string looks like this
!!!!!!!!!!!!!!!!!!!!!!!!!!###"~{~||ysvgfiw`gXg}i}|mbnTaac[Wb~v|xqsfSeYiV`R ][\Z^RdZ\XX`Ihb\O`3Z1W*I'D'H&J&J'O&M&O%O&I&M&S&R&R%U&W&T&V&m%\%n%[%Y%I&O'P'G 'L(V'X&I'F(O&a&h'[&W'P&C'](I&R&Y'\)\'Y'G(O'X'b'f&N&S&U'N&P&J'N)O'R)K'T(f|`|d //etc...
and the idea is basically that at a given point in the song the Unicode number of the character at the corresponding point in the text file yields a nominal value to represent volume.
The library translates the data (in this case, a stereo track) with the following (simplified here):
getVolume = function(sampleIndex,o) { o.left = Math.min(1,(this.data.charCodeAt(sampleIndex*2|0)-33)/93); o.right = Math.min(1,(this.data.charCodeAt(sampleIndex*2+1|0)-33)/93); }
I'd like some insight into how the file was encoded in the first place, and how I'm making use of it here.
What is the significance of 93
and 33
?
What is the purpose of the bitwise |
?
Is this a common means of porting information (ie, does it have a name), or is there a better way to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看起来该文件中的字符范围是从
!
到~
。!
的 ASCII 代码为 33,~
的 ASCII 代码为 126。126-33 = 93。It looks like the range of the characters in that file are from
!
to~
.!
has an ASCII code of 33 and~
has an ASCII code of 126. 126-33 = 93.33
和93
用于标准化!
和~
之间的值。|0
之所以存在,是因为sampleIndex*2
或sampleIndex*2+1
在传递时会产生非整数值非整数sampleIndex
。|0
会截断小数部分,以防有人发送格式不正确的sampleIndex
(即非整数)。33
and93
are used for normalizing values beween!
and~
.The
|0
is there due to the fact thatsampleIndex*2
orsampleIndex*2+1
will yield a non-integer value when being passed a non-integersampleIndex
.|0
truncates the decimal part just in case someone sends in an incorrectly formattedsampleIndex
(i.e. non-integer).与零进行按位或运算会将 LHS 上的数字截断为整数。但不确定你的问题的其余部分,抱歉。
93 和 33 是字符“]”和“!”的 ASCII 代码(不是 unicode)分别。希望能有所帮助。
Doing a bitwise OR with zero will truncate the number on the LHS to a integer. Not sure about the rest of your question though, sorry.
93 and 33 are ASCII codes (not unicode) for the characters "]" and "!" respectively. Hope that helps a bit.
这将永远帮助您:
http://www.asciitable.com/
一切的 ASCIII 代码。
享受!
This will help you forever:
http://www.asciitable.com/
ASCIII codes for everything.
Enjoy!