Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beat Detection Tweak #9

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

OfficialIncubo
Copy link

@OfficialIncubo OfficialIncubo commented Apr 24, 2023

I fixed the beat detection from reacting the treble (high frequencies) to bass, mid and treb variables.
Now I made the perfect and accurate beat detection for any music you want.

Check this video demo how I fixed the beat detection.

Plus, this can be reacted on both channels (mono), like projectM.

I fixed the beat detection from hearing the treble (high frequencies) to bass, mid and treb variables.
Now I made the perfect and accurate beat detection for any music you want.

Check [this video demo](https://twitter.com/OctobellaMilkD/status/1625587045174476800?s=20) how I fixed the beat detection.

Plus, this can be reacted on both channels (mono), like projectM.
@milkdrop2077
Copy link
Owner

MilkDrop has been like this for the past 20 years, and changing the beat detection will make many presets react differently than intended.
I'm not sure what I prefer : https://www.youtube.com/watch?v=Ip6AsX1Tdao
It really depends on the kind of music you're listening and the kind of preset you're watching.

@milkdrop2077
Copy link
Owner

With the first minute of that song for example : https://www.youtube.com/watch?v=s_nc1IVoMxc
I prefer the old beat detection.

@OfficialIncubo
Copy link
Author

OfficialIncubo commented Apr 25, 2023

If you prefer the old beat detection, i don't like it :(

If you hear some low frequencies, then boom, the red dot goes up!
For the high frequencies, you need some cymbals, hats, snakes and so on. The blue dot goes up if the treble (high frequencies) reacted.
Also mids for human voice, flute, saxophone etc.

Why don't you see the 20hz-20000hz frequency test with the new beat detection to show how it works?
...you should look closely.

First, you should try to listen the music or tests with headphones or speakers with bass (or subwoofers).

EDIT: Well, I can record more if I have time. Note that all the beat detections are auto-gained. If you hear some quiet songs, it can react the same level (aprox. to 1).

@munibtahir
Copy link

munibtahir commented Apr 27, 2023

I think with any change, beat detection or otherwise, backwards compatibility is a big concern. There aren't many people actively authoring new presets, so we are essentially just stuck with the old ones.

@OfficialIncubo
Copy link
Author

OfficialIncubo commented Apr 29, 2023

You see a little white dot that reacts in a different beat detections using my improved one.

DotinDifferentBeatDetectionsExpl.MP4

I created the q1 variable in per-frame code and added the changeable beat detection mode with smoothing, such as bass_att, mid_att and treb_att. I recommend you to use headphones or subwoofers (or speakers with bass) before trying that.

In conclusion, my improved beat detection that I implemented gone too accurate than before. The old one reacts only high frequencies to bass, mid and treb values.

Song: Deeplowdog feat. Ryan Konline - Been a While (Deepjack Remix)

Also, sorry for the notification sound in the end.

@Cmely
Copy link

Cmely commented May 1, 2023

First, thank you Milkdrop2077, for your work : I was looking for a easy to use, nice looking visualizer for my music, and it seems you've made the perfect combination :)

I'm not sure however the beat detection is worrking : would it be possible to use it to have it change only at the end of each songs ? And if 'yes', how would I achieve that ? And if 'no', do you think it could be possible / doable ?

@OfficialIncubo
Copy link
Author

OfficialIncubo commented May 16, 2023

...changing the beat detection will make many presets react differently than intended.

Well, the problem is not on presets using beat detection variables. It's the beat detection itself because it only jumps to the high frequencies reacting to bass, mid and treb variables. That's pretty old and trash.

@MrKlorox
Copy link

MrKlorox commented Jun 4, 2023

What if the new beat detection algorithm was just used for transitioning presets? Or if presets built with the new detection were flagged to use that algorithm, while the rest use the original? I think there's definitely use for better beat detection, though I get the compatibility issue.

@JosepMaJAZ
Copy link

JosepMaJAZ commented Dec 17, 2023

backwards compatibility issue aside, I believe the implementation of this PR is wrong.

First, let's understand what we have in fSpecLeft/fSpecRight:
https://github.com/milkdrop2077/MilkDrop3/blob/7569814634436b4470ebf25c0f9c13f435169b9e/code/vis_milk2/fft.cpp

First, it says that the range of that FFT is from 0 to 1/4th of the sampling rate.
So 0 = 0Hz and 576 = 1/4th or 11Khz for a 44Khz file.

It also says that the frequency linearly increases. With that, 11Khz/576 samples = 19.14Hz each output sample
It also suggests these 3 ranges for bass/mid/treble:

    //          1) 200 - 200*2^1.928                    or  200  - 761   Hz
    //          2) 200*2^1.928 - 200*2^(1.928*2)        or  761  - 2897  Hz
    //          3) 200*2^(1.928*2) - 200*2^(1.928*3)    or  2897 - 11025 Hz

This turns into samples like this:
761/19.14 = 39 ( 1 to 40 -1 ) (Note: I recommend avoiding sample zero. That one is the DC offset). 200Hz is sample 10.
2897/19.14 = 149 ( 40 to 150 -1 )
And obviously, 11025 = 576 ( 150 to 576 -1)

The old implementation does:
0 to 1/6th ( 0-1837 Hz ) bass (0 to 96 -1)
1/6th to 2/6th ( 1837-3675 Hz) mid (96 to 192 -1)
2/6th to 3/6th ( 3675-5512 Hz) high ( 192 to 288 - 1)

The proposed implementation in this PR does:
0 to 1/192th ( 0-57 Hz) bass ( 0 to 3 - 1)
1/64th to 2/64th ( 172-344 Hz) mid ( 9 to 18 - 1)
2/6th to 3/6th ( 3675-5512 Hz) high ( 192 to 288 -1)

One can argue that the old bass range is too wide, but the proposed bass and mid range is way off and leaves holes between ranges.

So, In case anyone pretends to fix this, the fix should obviously be what the FFT algorithm comemnts suggest.

Then, it could be a user option to choose between old and new beat detector.

Last edit note: One should also be aware that this depends on the sampling rate. So the actual samples limits should be dynamically determined from the input sampling rate

@OfficialIncubo
Copy link
Author

OfficialIncubo commented Dec 17, 2023

Just looked at the loopback-capture's supported sample rate and it only supports 44100hz and 48000hz. Did you try to change any sample rate and try it with Milkdrop3 if it works?
If not, then I'll try myself.

I recommend to try this tone generator website to test it if it works good or not. I tried this today and the bass actually reacts as a real middle and almost a treble.

EDIT: The recommended sample rate of the new beat detection I've made is 44000hz. So I think you should look at fft.cpp and make some changes if you want.

@milkdrop2077
Copy link
Owner

Thank you @JosepMaJAZ for the technical details!
I have a question for you since you seem to know a lot about audio, I can't get MilkDrop3/BeatDrop to react to the microphone device with the loopback-capture. Any idea what could cause the problem? Many thanks

@damianofalcioni
Copy link

What if the new beat detection algorithm was just used for transitioning presets? Or if presets built with the new detection were flagged to use that algorithm, while the rest use the original? I think there's definitely use for better beat detection, though I get the compatibility issue.

I think is easy to just add an option in the configuration to specify which algorithm to use

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants