OfficialIncubo / BeatDrop-Music-Visualizer

The Milkdrop2 Music Visualization Standalone, only for Windows
https://twitter.com/BeatDropVis
Other
34 stars 2 forks source link

BeatDrop only reacts to the treble at bass variable, but not the accurate bass, mid, treb (compared to projectM) - Beat Detection Issue #9

Closed OfficialIncubo closed 1 year ago

OfficialIncubo commented 1 year ago

Compared to projectM, this reacts very accurate. ...but the BeatDrop only reacts to treble and the half mid, which isn't very accurate. Same as Milkdrop2 initiatives.

Example:

https://user-images.githubusercontent.com/74858188/204282062-d39613ea-a1a0-4b70-9ef9-f9159cc84713.mp4

Please compare: https://github.com/projectM-visualizer/projectm/blob/master/src/libprojectM/Renderer/BeatDetect.cpp with https://github.com/OfficialIncubo/BeatDrop-Music-Visualizer/blob/master/vis_milk2/plugin.cpp (at line 8790).

See more: http://forums.winamp.com/showthread.php?t=457125 http://forums.winamp.com/showthread.php?t=345795 http://forums.winamp.com/showthread.php?t=453054 http://forums.winamp.com/showthread.php?t=380483 http://forums.winamp.com/showthread.php?t=334147

OfficialIncubo commented 1 year ago

In plugin.cpp at line 8792, there is a possible tweak for bass, mid and treb variable at line 8811, for example:

        // note: only look at bottom half of spectrum!  (hence divide by 6 instead of 3)
        int start = MY_FFT_SAMPLES*i/6;
    int end   = MY_FFT_SAMPLES*(i+1)/6;

...and changed to

        // note: only look at bottom half of spectrum!  (hence divide by 6 instead of 3)
        int start = MY_FFT_SAMPLES*i/64;
    int end   = MY_FFT_SAMPLES*(i+1)/64;

or

        // note: only look at bottom half of spectrum!  (hence divide by 6 instead of 3)
        int start = MY_FFT_SAMPLES*i/64;
    int end   = MY_FFT_SAMPLES*(i+1)/32;

Anyways, the treb cannot react better than before, so this should be a beta tweak.

Here is a clip how I tweaked BeatDrop's beat detection.

https://user-images.githubusercontent.com/74858188/210275624-fc858992-6792-43ba-b6b5-420f375d84e3.mp4

OfficialIncubo commented 1 year ago

...and the beat detection is now fixed!

Here is the code that I implemented:

.
.
.

// sum spectrum up into 3 bands
    for (i=0; i<3; i++)
    {
        //note: only look at bottom half of spectrum!  (hence divide by 6 instead of 3)
        int start = MY_FFT_SAMPLES*i/171;
        int end = MY_FFT_SAMPLES*(i+1)/171;
        int j;

        if (i == 1)
        {
            start = MY_FFT_SAMPLES * i / 36;
            end = MY_FFT_SAMPLES * (i + 1) / 36;
        }

        if (i == 2)
        {
            start = MY_FFT_SAMPLES*i/6;
            end = MY_FFT_SAMPLES*(i + 1)/6;
        }

        mysound.imm[i] = 0;
.
.
.

I splitted the i to the correct bass, mid, and treb and the results is: PERFECT!

Here is the comparison of my beat detection final tweak and the projectM one:

https://user-images.githubusercontent.com/74858188/218179959-e2138afd-19b1-475f-9593-3f1812a9721b.mp4

OfficialIncubo commented 1 year ago

I made the beat detection more stable and accurate. Check this commit.

OfficialIncubo commented 1 year ago

Oops, accidental reverted the beat detection official tweak. Please look at this commit again.

OfficialIncubo commented 9 months ago

I have upgraded my beat detection implementation to respect all the frequencies: Bass: 20hz - 250hz Mid: 250hz - 4000hz Treb: 4000hz - 20000hz

In overall, it supports the frequencies from 20hz to 20000hz!

Code: in plugin.cpp, at void CPlugin::DoCustomSoundAnalysis.

for (i=0; i<3; i++)
    {
        //This upgraded beat detection algorithm respects all the frequency range:
        //Bass: 20hz - 250hz
        //Mid: 250hz - 4000hz
        //Treb: 4000hz - 20000hz

        int start = MY_FFT_SAMPLES*i/194;
        int end = MY_FFT_SAMPLES*(i+1)/194; //bass
        int j;

        if (i == 1)
        {
            start = MY_FFT_SAMPLES * i / 68;
            end = MY_FFT_SAMPLES * (i + 1) / 32; //mid
        }

        if (i == 2)
        {
            start = MY_FFT_SAMPLES*i/8;
            end = MY_FFT_SAMPLES*(i + 1)/3; //treb
        }

Later, I'll update the source code if I have time or this milestone is done.