knowledge:electronic:2019032101
差别
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版上一修订版两侧同时换到之后的修订记录 | ||
knowledge:electronic:2019032101 [2023/07/07 03:12] – [理论] ob | knowledge:electronic:2019032101 [2023/07/07 05:31] – [使用 FHT 进行频率分析] ob | ||
---|---|---|---|
行 162: | 行 162: | ||
当使用低于样本(感知阈值)的参考值时,您的 dB 值将是正值,并且随着接近最大值而变大。 | 当使用低于样本(感知阈值)的参考值时,您的 dB 值将是正值,并且随着接近最大值而变大。 | ||
- | 有几个因素会影响实践中的测量而使这一情况变得更加复杂。首先,人耳对所有频率的敏感度并不相同。通常会对不同频段应用不同的权重。一种这样的测量单位被称为dBA,但还有其他一些略微不同的权重。其次,您的麦克风可能不会对所有频率都具有相同的灵敏度。第三,您的扬声器可能无法以相同的精确水平再现所有频率。这些复杂性需要非常精确和昂贵的设备以及特殊的校准程序,以便能够根据标准正确测量声级。要知道,这篇文章描述的设置测量声级的能力非常初级,仅适合粗略的相对测量。 | + | 有几个因素会影响实践中的测量而使这一情况变得更加复杂。首先,人耳对所有频率的敏感度并不相同。通常会对不同频段应用不同的权重。一种这样的测量单位被称为dBA,但还有其他一些略微不同的权重。其次,您的麦克风可能不会对所有频率都具有相同的灵敏度。第三,您的扬声器可能无法以相同的精确水平再现所有频率。这些复杂性需要非常精确和昂贵的设备以及特殊的校准程序,以便能够根据标准正确测量声级。要知道,这篇文章介绍的测量声级的能力非常有限,仅适合粗略的相对测量。 |
- | ===== Implementation | + | ===== 执行 |
- | Let’s recap that our values are 0 to 1024 which stand for [-max, | + | 让我们回顾一下,我们的值是 |
< | < | ||
行 216: | 行 216: | ||
</ | </ | ||
- | So now with proper module and calibration you can measure sound level of different events or devices and compare them one to the other. | + | 因此,现在通过适当的模块和校准,您可以测量不同事件或设备的声级,并将它们相互比较。 |
- | ===== Frequency analysis with FHT ===== | + | ===== 使用 |
- | What if you want to “break” the sound into individual frequencies and measure or visualize each individual frequency? Can this be done with Arduino? The answer is that it can be done relatively easily thanks to some existing libraries. To turn signals from a time domain to a frequency domain you would generally use a Fourier transform. Such transforms are used for signals of different types, sound, images, radio transmissions, | + | 如果您想将声音“分解”为单独的频率并测量或可视化每个单独的频率,该怎么办?这可以用Arduino来完成吗?答案是肯定的,使用一些现有的库,这可以相对容易地完成。要将信号从时域转换到频域,通常会使用傅里叶变换。这种变换用于不同类型的信号,声音、图像、无线电传输等。每种信号类型都有其自己的属性,最适合声音信号的变换是离散哈莱特变换(DHT)。DHT 将使用形成波形的离散真实值。为了实现 |
- | The Arduino FHT library works with vectors of 16 to 256 samples. This size is denoted as N. In this project I will be using N=256 to achieve maximum resolution, but you may use smaller values if you are short on memory or processing power. | + | Arduino FHT 库可处理 |
- | First, the algorithm takes N real numbers and results in N/2 complex numbers. Then we can pass the data to another function to calculate the magnitude of the complex numbers to get N/2 bins. In the end we get N/2 bins, each covering a frequency range of sampling_rate/ | + | 首先,该算法接受N个实数,并得到N/2个复数。然后我们可以将数据传递给另一个函数,计算复数的幅度,得到N/2个频率区间。最终,我们得到N/2个频率区间,每个区间覆盖sampling_rate/ |
- | + | 因此对于N=256和采样率为38.4KHz,我们得到128个150Hz的频率区间,其中第一个区间保存了0-150Hz的幅度值,最后一个区间保存了19050-19200Hz的幅度值。现在我们可以专注于我们感兴趣的特定频率区间,通过串行连接发送所有频率区间的值,存储这些值,以某种方式显示它们等等。 | |
- | So for N=256 and sampling_rate=38.4Khz we get 128 150hz bins with the first been holding the magnitude value of 0-150hz and the last bin holding the magnitude value of 19050-19200hz. We can now focus on specific bins that interest us, send the values of all the bins over serial connection, store the values, display them in some way, etc. | + | 使用数据的有趣方法之一是使用分析器进行可视化,尤其是在故障排除和开发时。将以下 |
- | + | ||
- | One of the fun ways to use the data, especially when troubleshooting and developing is to visualize with an analyser. Load the following | + | |
{{: | {{: | ||
- | Another way to analyze the data is for the Arduino | + | 分析数据的另一种方法是 |
< | < | ||
void MeasureFHT() | void MeasureFHT() | ||
行 267: | 行 264: | ||
</ | </ | ||
- | Then you can format the data in a spreadsheet, | + | 然后,您可以将电子表格(例如 |
{{: | {{: | ||
knowledge/electronic/2019032101.txt · 最后更改: 2023/07/07 05:32 由 ob