0

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();


    }
  • What do you mean by "getting the Amplitude/Decibel value"? Are you trying to determine the appropriate values for `threshold/sensitivity`, from your previous question? – greeble31 Nov 19 '19 at 21:52
  • I just want to get the Amplitude reading from when I detect the clapping sound – Mathew Nuval Nov 19 '19 at 21:59
  • I still couldn't figure this out. – Mathew Nuval Nov 20 '19 at 00:04
  • What makes you think tarsos supports this? The `PercussionOnsetDetector` certainly doesn't. I looked at the source code. You'd have to re-write it. – greeble31 Nov 20 '19 at 01:12
  • I figured it wouldn't but my other attempt is utilizing the getMaxAmplitude() from MediaRecorder but it keeps getting me IllegalStateException or 0 on the getMaxAmplitude() – Mathew Nuval Nov 20 '19 at 04:59
  • Yes, it doesn't surprise me that `MediaRecorder` wouldn't work that well if tarsos was already using the mic. You could implement your own `AudioProcessor` subclass, and add it using `addAudioProcessor()`. That'll give you a copy of the streaming audio, just like `PercussionOnsetDetector` gets. Then you'll have to figure out your own amplitude, from there. – greeble31 Nov 20 '19 at 13:30

0 Answers0