-
-
Notifications
You must be signed in to change notification settings - Fork 418
new BeatDetect implementation #312
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
Conversation
revmischa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks I'll give it a go!
PCM sample rate can vary wildly.
| this->vol_history=0; | ||
| this->vol_instant=0; | ||
| this->vol_history=0; | ||
| for (unsigned y=0;y<80;y++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the magic 80 number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's from the previous code. Would be better as a constant (like I did for FFT_LENGTH)
src/libprojectM/PCM.hpp
Outdated
|
|
||
|
|
||
| // 1024 is more computationally intensive, but maybe better at detecting lower bass | ||
| #define FFT_LENGTH 512 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be cool if this was variable, based on the current audio input sample rate some day
| vol=0; | ||
|
|
||
| // TODO: get sample rate from PCM? Assume 44100 | ||
| getBeatVals(44100.0f, FFT_LENGTH, pcm->pcmdataL, pcm->pcmdataR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't assume this, it can be anything (8k 22k 48k 96k)
| unsigned *ranges = fft_length==1024 ? ranges1024 : ranges512; | ||
|
|
||
| bass_instant = 0; | ||
| for (unsigned i=ranges[0]+1 ; i<=ranges[1] ; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments on these calculations and magic numbers would be nice to have
| //work0around | ||
| #endif /** WIN32 */ | ||
| return 0.5f / std::max(0.0001f,sqrtf(vol_history)); | ||
| return 4.0f / std::max(0.0001f,sqrtf(vol_history)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
| float vol_history; | ||
| float vol_instant; | ||
|
|
||
| // /** Vars */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this unless some reason to keep it
|
|
||
| { | ||
| // NOTE some presets set bSpectrum=1 and samples!=2^n, not sure what rdft() does with that | ||
| assert(samples <= 1024); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hitting this assert on linux. What to do about it?
This is a proposed fix for #309
I think this simpler implementation does what it says it does. At least it makes more sense to me. It doesn't really seem to have that much noticeable affect how the presets render. I wrote a new test preset so you can more directly evaluate the output.
https://github.com/projectM-visualizer/projectm/blob/master/presets/tests/300-beatdetect-bassmidtreb.milk
It would be great if the regular contributors could
a) review the code change carefully (not that big)
b) verify your favorite presets
c) if you like, play with various parameters (e.g. freq cutoffs) and see if the current version seems best.