使用 TarsosDSP 检测低于 40 赫兹的频率 java android
Detecting frequency lower than 40 hz using TarsosDSP java android
我正在制作一个 Android 移动应用程序,我一直在尝试使用 TarsosDSP. Which has been working great, only if it is greater than 43hz. But I have a requirement to make it work with 40hz. When I play the sound, it doesn't even give results below 43. This 检测音高,您可以在其中以所需的频率在线生成乐曲。这是代码。
void connectsAudioDispatchertoMicrophone() {
AudioDispatcher dispatcher = AudioDispatcherFactory.fromDefaultMicrophone(22050, 1024, 0);
PitchDetectionHandler pdh = new PitchDetectionHandler() {
@Override
public void handlePitch(final PitchDetectionResult result, AudioEvent e) {
final float pitchInHz = result.getPitch();
runOnUiThread(new Runnable() {
@Override
public void run() {
if (pitchInHz > 1)
Log.d(TAG, "pitchInHz: " + pitchInHz);
}
});
}
};
AudioProcessor p = new PitchProcessor(PitchProcessor.PitchEstimationAlgorithm.FFT_YIN,
22050,
1024,
pdh);
dispatcher.addAudioProcessor(p);
thread = new Thread(dispatcher, "Audio Dispatcher");
thread.start();
}
这听起来像是 Tarsos 内部使用的 FFT 的限制。 FFT 将检测到的声音分成几个频率“区间”之一。每个 bin 的中心频率是以下函数:
- 采样率,以及:
- FFT 的宽度(样本)。
对于 22050Hz 的采样率,具有 1024 个样本宽的 FFT:
Fmin = 22050 / 1024 * 2 = 43.066Hz
(Fmin
是第二低“bin”的中心频率。显然这是算法可以检测到的最低频率。)
要降低 Fmin
,A.) 降低采样率,或 B.) 增加 FFT 的宽度:
Fmin = 16000 / 1024 * 2 = 31.25Hz
Fmin = 22050 / 2048 * 2 = 21.53Hz
请务必坚持 FFT 宽度为 2 的幂,并批准采样率的有效设置。
我正在制作一个 Android 移动应用程序,我一直在尝试使用 TarsosDSP. Which has been working great, only if it is greater than 43hz. But I have a requirement to make it work with 40hz. When I play the sound, it doesn't even give results below 43. This 检测音高,您可以在其中以所需的频率在线生成乐曲。这是代码。
void connectsAudioDispatchertoMicrophone() {
AudioDispatcher dispatcher = AudioDispatcherFactory.fromDefaultMicrophone(22050, 1024, 0);
PitchDetectionHandler pdh = new PitchDetectionHandler() {
@Override
public void handlePitch(final PitchDetectionResult result, AudioEvent e) {
final float pitchInHz = result.getPitch();
runOnUiThread(new Runnable() {
@Override
public void run() {
if (pitchInHz > 1)
Log.d(TAG, "pitchInHz: " + pitchInHz);
}
});
}
};
AudioProcessor p = new PitchProcessor(PitchProcessor.PitchEstimationAlgorithm.FFT_YIN,
22050,
1024,
pdh);
dispatcher.addAudioProcessor(p);
thread = new Thread(dispatcher, "Audio Dispatcher");
thread.start();
}
这听起来像是 Tarsos 内部使用的 FFT 的限制。 FFT 将检测到的声音分成几个频率“区间”之一。每个 bin 的中心频率是以下函数:
- 采样率,以及:
- FFT 的宽度(样本)。
对于 22050Hz 的采样率,具有 1024 个样本宽的 FFT:
Fmin = 22050 / 1024 * 2 = 43.066Hz
(Fmin
是第二低“bin”的中心频率。显然这是算法可以检测到的最低频率。)
要降低 Fmin
,A.) 降低采样率,或 B.) 增加 FFT 的宽度:
Fmin = 16000 / 1024 * 2 = 31.25Hz
Fmin = 22050 / 2048 * 2 = 21.53Hz
请务必坚持 FFT 宽度为 2 的幂,并批准采样率的有效设置。