了解网络音频中的getByteTimeDomainData和getByteFrequencyData [英] understanding getByteTimeDomainData and getByteFrequencyData in web audio
问题描述
无论我在哪里,这两种方法的文档都非常通用。我想知道我正在查看我从每个方法得到的返回数组到底是什么。
The documentation for both of these methods are both very generic wherever I look. I would like to know what exactly I'm looking at with the returned arrays I'm getting from each method.
对于getByteTimeDomainData,每次传递涵盖的时间段?我相信大多数的oscopes每次传球覆盖32毫秒的跨度。这也包括在内吗?对于实际的元素值本身,范围似乎是0 - 255.这相当于-1 - +1伏?
For getByteTimeDomainData, what time period is covered with each pass? I believe most oscopes cover a 32 millisecond span for each pass. Is that what is covered here as well? For the actual element values themselves, the range seems to be 0 - 255. Is this equivalent to -1 - +1 volts?
对于getByteFrequencyData,所涵盖的频率基于采样率,所以每个指标都是一个实际频率,但实际的元素值本身呢?是否有一个dB范围等于返回数组中返回的值?
For getByteFrequencyData the frequencies covered is based on the sampling rate, so each index is an actual frequency, but what about the actual element values themselves? Is there a dB range that is equivalent to the values returned in the returned array?
推荐答案
getByteTimeDomainData
(以及较新的 getFloatTimeDomainData
)返回您请求的大小数组 - 其 frequencyBinCount
,计算为所请求的 fftSize
的一半。当然,该数组是在 AudioContext
上公开的当前 sampleRate
,所以如果它是默认的2048 fftSize
, frequencyBinCount
将为1024,如果您的设备以44.1kHz运行,则相当于大约23ms的数据。
getByteTimeDomainData
(and the newer getFloatTimeDomainData
) return an array of the size you requested - its frequencyBinCount
, which is calculated as half of the requested fftSize
. That array is, of course, at the current sampleRate
exposed on the AudioContext
, so if it's the default 2048 fftSize
, frequencyBinCount
will be 1024, and if your device is running at 44.1kHz, that will equate to around 23ms of data.
字节值的范围介于0-255之间,是的,映射到-1到+1,因此128为零。 (它不是伏特,而是全范围无单位值。)
The byte values do range between 0-255, and yes, that maps to -1 to +1, so 128 is zero. (It's not volts, but full-range unitless values.)
如果你使用 getFloatFrequencyData
,返回的值是以dB为单位;如果您使用 Byte 版本,则会根据 minDecibels
/ maxDecibels
映射值(参见 minDecibels
/ maxDecibels
描述)。
If you use getFloatFrequencyData
, the values returned are in dB; if you use the Byte version, the values are mapped based on minDecibels
/maxDecibels
(see the minDecibels
/maxDecibels
description).
这篇关于了解网络音频中的getByteTimeDomainData和getByteFrequencyData的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!