本文介绍了[portaudio]传输和检测频率-Windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是portaudio的新手,我看了如何提取频率..."问题,但我仍然希望获得一些帮助.我需要传输一个频率(使用扬声器),然后我想检查该频率是否已传输(在麦克风中捕获),当然我想使用portaudio进行发送和检测.另外,我不知道如何使用fft进行检测,因为我看到了记录示例,并且他们使用了SAMPLE数据类型,并且使用此数据类型,他们可以找到最大幅度,我可以使用它来查找频率吗?

I'm new to portaudio and i looked at "How to extract frequency..." question but still i would like to have some help.i need to transmit a frequency (using the speakers) and then i would like to check if this frequency was transmitted (catching it in the microphone), of course that i would like to use portaudio for the sending and detecting.also,i have no idea how to use the fft for detection because i saw the record example and they use a SAMPLE data type and with this data type they can find the max amplitude can i use it for finding the frequency?

tnx.

推荐答案

播放简单音调为示例代码在PortAudio中.

Playing a simple tone is given as sample code in PortAudio.

尽管音高不是由特定数字计算出来的,但很容易找出:

Although the pitch there is not calculated from a specific number, it's easy to figure out:

amplitude[n] = sin( n * desiredFreq * 2 * pi / samplerate )

就像在PortAudio示例代码中一样,您可能要考虑使用查找表,而不是针对每个调用都依赖sin(),这既提高了性能(又提高了sin的准确性,这可能很好,但是我我不确定).

As in the PortAudio example code, you may want to consider using a lookup table rather than counting on sin() for each call, both for performance (and accuracy of sin at large numbers, which might be fine, but I'm not sure about).

确定播放频率是一个关于SO的问题. 此处是我最近给出的答案.

Detecting what frequency is being played is a question that has been asked here on SO. Here is an answer I gave recently.

结果是有很多方法取决于您的技能水平以及背景噪音等问题.如果您只是检测到一个简单的波形并且不希望有太多的噪声,则在确定信号高于某个阈值之后,最好对零交叉点进行计数.如果您确实希望听到噪音,那您就得变得更高级了.

The upshot is that there are many ways depending on your skill level, and issues such as background noise. If you are just detecting a simple sin wav and don't expect a lot of noise, you might do well to just count zero crossings after making sure that the signal is above a certain threshold. If you do expect noise, you'll have to get fancier.

这篇关于[portaudio]传输和检测频率-Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 01:05