B4A Library Pitchdetection

Hey everyone,

I would like to share this new library.
This library is based upon the pitchdetection from the TarsosDSP library(https://github.com/JorenSix/TarsosDSP).
The wrapper has been been made by @somed3v3loper , many thanks to him !!

This library has just one function and that is to do the pitchdetection, but this library is easier to implement than FFT and I think this library is more accurate than FFT is.
The library has only been tested in B4a 9.0 which is currently the most recent version, other version are not tested but could work.

The library consist of three files:


All three files should be copied to your additional libraries folder.

To use the library, you can use this example :
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim dp As DSP
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
End Sub

Sub Activity_Resume

End Sub

Sub dp_pitchdata(data As Float)
    Log("dp_pitchdata: "&data)
End Sub
Sub Activity_Pause (UserClosed As Boolean)

End Sub

Keep in mind that this library is making use of the PERMISSION.RECORD_AUDIO permission which is a dangerous permission. Make sure you use the runtimepermission to ask for permission to use audio record.

A working sample app, with runtimepermissions is attached.

A working B4A example with this library can be found in the play store under https://play.google.com/store/apps/details?id=nl.daxsoft.notelearner

Furthermore, this is the first time I post a library here on the forum. If something is missing, please let me know! :)


  • DSP-pitchdetection-library.zip
    140 KB · Views: 242
  • pitch_detection_sample_app.zip
    8.2 KB · Views: 243