[portaudio]Transmit and Detect frequency - Windows

我的未来我决定 提交于 2019-12-12 06:36:50

问题


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 in advance.


回答1:


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 )

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).

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.



来源:https://stackoverflow.com/questions/11451934/portaudiotransmit-and-detect-frequency-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!