我正在制作一个 Android 移动应用程序,我一直在尝试使用TarsosDSP检测音高。只有当它大于 43hz 时,它才能很好地工作。但我有一个要求,让它在 40hz 下工作。当我播放声音时,它甚至不会给出低于 43 的结果。这是您可以在线生成具有所需频率的曲调的地方。这是代码。
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();
}