TarsosDSP
TarsosDSP copied to clipboard
When SilenceDetector used, continuous pitch causes processing to break
I've been implementing an Android app that uses TarsosDSP. Now I've noticed a strange problem:
If I test my app's pitch detection with a tone generator, continuous stable pitch causes processing to break after few seconds, ie. no pitch reported anymore. But if I change the generated pitch or briefly stop the sound and start again, pitch reporting resumes...for that few seconds again.
If I remove SilenceDetector from the code, breaking does not happen.
Any idea why? And am I using this the right way, code snippet:
public void handleResume()
{
dispatcher = AudioDispatcherFactory.fromDefaultMicrophone(
EngineConstants.recorderSampleRate,
EngineConstants.sourceSampleSize,
0);
double threshold = PreferenceUtils.silenceThreshold(context);
boolean breakProcessingOnSilence = true;
ambientFilter = new SilenceDetector(threshold, breakProcessingOnSilence);
dispatcher.addAudioProcessor(ambientFilter);
AudioProcessor p = new PitchProcessor(
PitchProcessor.PitchEstimationAlgorithm.FFT_YIN,
EngineConstants.recorderSampleRate,
EngineConstants.sourceSampleSize,
this);
dispatcher.addAudioProcessor(p);
new Thread(dispatcher, "Audio Dispatcher").start();
}
Hi,
When an Audio Processor returns false the processing chain is stopped. The silence detector stops the chain when it is below a chosen threshold. In the example above pitch detection will only happen if the incoming sound is loud enough (above the given threshold).
I suspect that the loudness of the incoming sound is around the threshold? So sometimes the pitch is detected (and reported) sometimes (loudness below threshold) not.
Good luck with your project
Joren