如何计算频率和频率Flash AS3 中的振幅与 Flash Player 9
我如何计算频率和频率FP9 的 As3 中的振幅。 获得所有原始字节吗
SoundMixer.computeSpectrum(_testbytes, false, 0);
var g:Graphics = this.graphics;
g.clear();
g.lineStyle(0, 0x6600CC);
g.moveTo(0, PLOT_HEIGHT);
var m:Number = 0;
for (var i:int = 0; i < 256; i++) {
m = (_testbytes.readFloat() * 100);
g.lineTo(i*2 , 100 - m);
}
g.lineTo(CHANNEL_LENGTH * 2, PLOT_HEIGHT);
我使用“现在可以获取频率和频率” ?幅度数据来自吗?
How can I calculate Frequency & Amplitude in As3 with FP9. I got the all raw byte using
SoundMixer.computeSpectrum(_testbytes, false, 0);
var g:Graphics = this.graphics;
g.clear();
g.lineStyle(0, 0x6600CC);
g.moveTo(0, PLOT_HEIGHT);
var m:Number = 0;
for (var i:int = 0; i < 256; i++) {
m = (_testbytes.readFloat() * 100);
g.lineTo(i*2 , 100 - m);
}
g.lineTo(CHANNEL_LENGTH * 2, PLOT_HEIGHT);
Now Can I get the frequency & amplitude data from it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您仔细查看 computeSpectrum() 文档,你会看到
第二个参数设置 FFT 模式。
FFT 代表快速傅里叶变换,基本上,如果您对波形使用 FFT,您将进入频域,这意味着您将获得按频率排序的值,而不是原始值。
您需要在代码中更改的是:
现在在 _testbytes 中您将有 512 个值,其中 256 个用于左通道,256 个用于右通道。对于每个频道,数字按频率从低到高排序(我猜是低、中低、中高、高)。
就这样,你现在得到了频率。 SoundTransform 具有音量,我猜这是表示幅度的另一种方式。如果您想对其中一些频率或 leftPeak 和 rightPeak 执行 Math.max(),那就去做吧。
如果你想对此感到迷惑,只需在维基百科或 DSP(数字信号处理)或声音处理上查找 FFT,否则,computeSpectrum 的 as3 文档就足够了。
至于采样率,这个很酷的库似乎可以为您完成艰苦的工作。
哈特哈,
乔治
If you have a closer look at the computeSpectrum() documentation, you will see
the second parameter sets the FFT mode.
FFT stands for FastFourierTransform, basically if you use FFT over a waveform you go to the frequency domain which means instead of raw values, you have values that are sorted for you by frequency.
All you need to change in your code is :
Now in _testbytes you will have 512 values, 256 for the left channel and 256 for the right channel. For each channel the numbers are sorted by frequencies, low to high ( low, mid-low, mid-high, high I guess ).
That's all, you got the frequencies now. SoundTransform has volume, which is another way of saying amplitude I guess. If you feel like doing Math.max() on some of those frequencies or the leftPeak and rightPeak, go for it.
If you want to get nerdy with this, just lookup FFT on wikipedia or DSP(Digital Signal Processing) or Sound Processing, otherwise, the as3 documentation for computeSpectrum should be enough.
As for sample rate, this cool as library seems to do the hard work for you.
HTH,
George