检测音频输入的频率 - Java?
我已经断断续续地研究了几个月。
我正在寻找一个库或工作示例代码来检测声卡音频输入中的频率,或检测给定组的存在频率。我倾向于 Java,但真正的要求是它应该比 C 更高级别/更简单,并且最好是跨平台的。 Linux 将是目标平台,但我希望为 Mac 甚至 Windows 保留选项。 Python 也是可以接受的,如果有人知道一种语言可以使这更容易/具有更好的预编写库,我愿意考虑它。
本质上,我有一组定义的频率对,它们将出现在声卡音频输入中,我需要能够检测到这对频率对,然后......做一些事情,例如录制以下音频直到最长持续时间,然后执行某些操作。 潜在的运行可能会包含 5-10 对,在运行时定义,无法编译:例如频率 1 约 1 秒,最大延迟约 1 秒,频率 2 约 1 秒1秒。
我找到了执行 FFT 或 Goertzel 算法的建议,但除了最简单的示例代码之外找不到任何其他内容,这些代码似乎没有给出任何有用的结果。我还发现 Java 音频存在一些局限性,无法以足够高的速率进行采样以获得我需要的分辨率。
对库使用或工作代码有什么建议吗?我承认我不太擅长数学,所以我迷失在一些关于算法实际工作原理的更技术性的描述中。
I've been researching this off-and-on for a few months.
I'm looking for a library or working example code to detect the frequency in sound card audio input, or detect presence of a given set of frequencies. I'm leaning towards Java, but the real requirement is that it should be something higher-level/simpler than C, and preferably cross-platform. Linux will be the target platform but I want to leave options open for Mac or possibly even Windows. Python would be acceptable too, and if anyone knows of a language that would make this easier/has better pre-written libraries, I'd be willing to consider it.
Essentially I have a defined set of frequency pairs that will appear in the soundcard audio input and I need to be able to detect this pair and then... do something, such as for example record the following audio up to a maximum duration, and then perform some action. A potential run could feature say 5-10 pairs, defined at runtime, can't be compiled in: something like frequency 1 for ~ 1 second, a maximum delay of ~1 second, frequency 2 for ~1 second.
I found suggestions of either doing an FFT or Goertzel algorithm, but was unable to find any more than the simplest example code that seemed to give no useful results. I also found some limitations with Java audio and not being able to sample at a high enough rate to get the resolution I need.
Any suggestions for libraries to use or maybe working code? I'll admit that I'm not the most mathematically inclined, so I've been lost in some of the more technical descriptions of how the algorithms actually work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的目标是检测频率对,那么您的工作与DTMF 检测器。
尝试在 sourgeforge 等地方搜索
DTMF
,您会发现探测器 在许多编程语言中。沿着频谱放置的频率对似乎比您的规格更严格,因此您应该可以根据您的输入调整 DTMF 检测器。If you are aiming at detecting frequency pairs then your job is very similar to a DTMF detector.
Try searching for
DTMF
in places like sourgeforge, you'll find detectors in many programming languages. The frequency pairs placing along the spectrum seems to be even more stringent than your specs so you should be fine adapting a DTMF detector to your input.查看 SNDPeek,它是一个跨平台 C++ 应用程序,可以从现场音频中提取各种信息; https://github.com/RobQuistNL/sndpeek
Check out SNDPeek, its a cross-platform C++ application that extracts all kinds of information from live audio; https://github.com/RobQuistNL/sndpeek