Skip to content

Conversation

@mbellew
Copy link
Collaborator

@mbellew mbellew commented Jan 27, 2020

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.

Copy link
Member

@revmischa revmischa left a 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++)
Copy link
Member

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?

Copy link
Collaborator Author

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)



// 1024 is more computationally intensive, but maybe better at detecting lower bass
#define FFT_LENGTH 512
Copy link
Member

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);
Copy link
Member

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++)
Copy link
Member

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));
Copy link
Member

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 */
Copy link
Member

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

@revmischa revmischa merged commit 9ba6dce into master Feb 1, 2020

{
// NOTE some presets set bSpectrum=1 and samples!=2^n, not sure what rdft() does with that
assert(samples <= 1024);
Copy link
Member

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?

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.

2 participants