Menu

GetBPM(() in SoundTouchDLL.

fred vs
2017-11-09
2017-12-03
  • fred vs

    fred vs - 2017-11-09

    Hello.

    Could it be possible to add/export GetBPM(() method in library SoundTouchDLL ?

    Thanks.

    Fre;D

     
  • oparviai

    oparviai - 2017-11-10

    Added.

     
  • fred vs

    fred vs - 2017-11-11

    PERFECT. ;-)

    Many thanks.

    Fre;D

     
  • fred vs

    fred vs - 2017-11-23

    Hello Olli.

    OK, compiled SoundTouchDLL.so with exported methods:
    bpm_createInstance, bpm_destroyInstance, bpm_getBpm, bpm_putSamples, bpm_putSamples_i16.

    I did: theinstance = bpm_createInstance(2, 44100) and used the same parameters for bpm_putSamples() that used (sucessfully) for soundtouch_putSamples() (to do a stretching).

    But I get always bpm_getBpm() = 0.

    Is a minimum of samples needed ? I did try with 65536 * channels but still ---> bpm_getBpm(theinstance) = 0.

    Or maybe I am missing something ?

    Thanks.

    Fre;D

     
  • fred vs

    fred vs - 2017-11-25

    Re-hello Olli.

    Ok, I get it.

    On all the songs that I tested, with a buffer of minimum 1 mega (1048576) x channels of samples I get excellent result.

    Many thanks.

    Fre;D

    PS: The Pascal header of SoundTouchDLL library for Unix and Windows OS was updated with last bpm methods.
    https://github.com/fredvs/uos/blob/master/src/uos_soundtouch.pas

     

    Last edit: fred vs 2017-11-27
  • oparviai

    oparviai - 2017-11-26

    Hello Fred,

    yes, sufficient amount of data is the key. 65536 samples correspond to bit less than 1½ seconds of musi and it's difficult to estimate beat for such short a song clip. 1M samples means already about 24 seconds of music, making it easier for beat detection.

    please notice that you don't need to feed all data in a single large buffer, you can also call the bpm->putSamples several times in sequence with time feeding a smaller block of samples to the bpm algorithm.

    I'll grab your pascal edits.

     

    Last edit: oparviai 2017-11-26
  • fred vs

    fred vs - 2017-11-27

    Hello Olli.

    Your SoundTouch library is one of my favorite.

    Lot of years ago I was super-impressed by the Bass audio library because of his BassFX plugin.
    That BassFX could make stretching (= changing the tempo of a song, keeping the original tuning).

    The dream of every musician (in my vinyl time, you may change the tempo but the tuning changed too --> must detune the guitar --> the hell ).

    Later I noted that all the code that BassFX used for stretching was your SoundTouch code.

    I am really happy that you still maintain that brillant project.

    I am fan of SoundTouchDLL stretching features and use it in many open-source projects, included:
    https://github.com/fredvs/uos
    https://github.com/fredvs/strumpract/releases

    This days I did play with last SoundTouchDLL and bpm_getBpm() on Linux 64 bit.

    Playing a virtual drums-set together with a mp3 song, with same bpm detected by bpm_getBpm() is impressive.

    Now the challenge is to synchronize the pick of beat detected by SoundTouch with the timer of the drums-set.

    I am exploring some ways.

    Here one of them:

    Before to play the song, bpm_getBpm() find his BPM (let say 100 BPM).

    100 BPM = 100 Beats each 60000 mseconds.
    1 BPM = 60000/100 = 600 mseconds.

    In the drums-set, each beat has 4 ticks --> 1 tick = 600/4 = 150 ms
    So 150 ms will be the interval of the timer that will run 4 times in one beat.

    Now time to play the song and synchronize the drums-set when a pick-beat is found.
    For this I need to know how to recognize a pick-beat when a buffer is given to the sound device.

    Maybe SoundTouch could help for this.

    How do you do to recognize a pick-beat?

    When a song is playing, each loop of decoding gives a buffer of to the sound card.

    What minimum size should have that buffer to contain a pick?

    With a resolution of 44100 samples/seconds, with 100 BPM, each beat needs 600 mseconds, so 26460 samples.

    (If I am wrong, please correct me)

    It is big to have a good latency.

    Maybe all the size of beat is not needeed to find a pick.

    How litle the buffer how better would be the result.

    The dream would be a kind of bpm_hasBeatPick() with result = position of first pick in the buffer (-1 if none).

    It would be used like this:
    bpm_putSamples() + bpm_hasBeatPick().

    But of course, all idea are welcome.

    Thanks.

    Fre;D

     
  • fred vs

    fred vs - 2017-12-03

    Hello Olli.

    please notice that you don't need to feed all data in a single large buffer, you can also call the bpm->putSamples several times in sequence with time feeding a smaller block of samples to the bpm algorithm.

    OK but there is something I am not sure.
    Does bpm_getBpm() freed the previous data added by bpm-putSamples ?

    This because I do not see a bpm_clear.

    Or must the instance be deleted by bpm_destroyInstance' before to do a new BPM search (and so recreate a new bpm_createInstance())?

    I hope you did understand something...

    Fre;D

     

    Last edit: fred vs 2017-12-03

Log in to post a comment.