Skip to content

Commit 1e1b428

Browse files
authored
Merge pull request #315 from projectM-visualizer/beatdetect_309
Beatdetect 309
2 parents f66b534 + 324a5c1 commit 1e1b428

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/libprojectM/Renderer/BeatDetect.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@ void BeatDetect::detectFromSamples()
109109
}
110110

111111

112+
113+
float BeatDetect::getPCMScale()
114+
{
115+
// the constant here just depends on the particulars of getBeatVals(), the
116+
// range of vol_history, and what "looks right".
117+
// larger value means larger, more jagged waveform.
118+
return 1.5 / fmax(0.0001f,sqrtf(vol_history));
119+
}
120+
121+
122+
112123
void BeatDetect::getBeatVals( float samplerate, unsigned fft_length, float *vdataL, float *vdataR )
113124
{
114125
assert( 512==fft_length || 1024==fft_length ); // should be power of 2, expect >= 512

src/libprojectM/Renderer/BeatDetect.hpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,7 @@ class DLLEXPORT BeatDetect
6767
// getPCMScale() was added to address https://github.com/projectM-visualizer/projectm/issues/161
6868
// Returning 1.0 results in using the raw PCM data, which can make the presets look pretty unresponsive
6969
// if the application volume is low.
70-
float getPCMScale()
71-
{
72-
// the constant here just depends on the particulars of getBeatVals(), the
73-
// range of vol_history, and what "looks right".
74-
// larger value means larger, more jagged waveform.
75-
#ifdef WIN32
76-
// this is broken?
77-
#undef max
78-
//work0around
79-
#endif /** WIN32 */
80-
return 4.0f / std::max(0.0001f,sqrtf(vol_history));
81-
}
70+
float getPCMScale();
8271

8372
private:
8473
int beat_buffer_pos;

0 commit comments

Comments
 (0)