I am having trouble from getting the Amplitude/Decibel value while using PercussionOnsetDetector from TarsosDSP. I have researched everywhere and found nothing from my searches that are relevant to my problem. I have tried using MediaRecorder while using TarsosDSP but I am running with processing issues with that one. Is there a method or a way around to approach this? Please let me know. Thank you.
Here is my code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Checks Permission
checkPermission(Manifest.permission.RECORD_AUDIO,REQUEST_RECORD_AUDIO_PERMISSION);
pitchText = (TextView) findViewById(R.id.pitch);
counterText = (TextView) findViewById(R.id.note);
double threshold = 4.5;
double sensitivity = 45;
PercussionOnsetDetector mPercussionDetector = new PercussionOnsetDetector(22050, 1024,
new OnsetHandler() {
@Override
public void handleOnset(double time, double salience) {
runOnUiThread(new Runnable() {
@Override
public void run() {
counterText.setText("Counter: " + counter++);
}
});
}
}, sensitivity, threshold);
dispatcher.addAudioProcessor(mPercussionDetector);
new Thread(dispatcher,"Audio Dispatcher").start();
}