了解网络音频中的 getByteTimeDomainData 和 getByteFrequencyData [英] understanding getByteTimeDomainData and getByteFrequencyData in web audio

查看:44
本文介绍了了解网络音频中的 getByteTimeDomainData 和 getByteFrequencyData的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论我在哪里看,这两种方法的文档都非常通用.我想知道我从每个方法获得的返回数组到底在看什么.

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,每次传递覆盖的时间段是什么?我相信大多数示波器每次通过都覆盖 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 fftSizefrequencyBinCount 将是 1024,如果您的设备以 44.1kHz 运行,则相当于大约 23 毫秒的数据.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆