re-enable old peak detect algo, plus ripplepeak bugfix
* re-enabled old detector which does not detect beats. However something bad may still be better than nothing... * fixed a typo in RipplePeak and Waterfall effect, which cased wrong configuration of the peak detector. resolves https://github.com/MoonModules/WLED/issues/43
This commit is contained in:
@@ -786,18 +786,19 @@ static void postProcessFFTResults(bool noiseGateOpen, int numberOfChannels) // p
|
|||||||
// peak detection is called from FFT task when vReal[] contains valid FFT results
|
// peak detection is called from FFT task when vReal[] contains valid FFT results
|
||||||
static void detectSamplePeak(void) {
|
static void detectSamplePeak(void) {
|
||||||
bool havePeak = false;
|
bool havePeak = false;
|
||||||
#if 0
|
#if 1
|
||||||
|
// softhack007: this code continuously triggers while volume in the selected bin is above a certain threshold. So it does not detect peaks - it detects volume in a frequency bin.
|
||||||
// Poor man's beat detection by seeing if sample > Average + some value.
|
// Poor man's beat detection by seeing if sample > Average + some value.
|
||||||
// This goes through ALL of the 255 bins - but ignores stupid settings
|
// This goes through ALL of the 255 bins - but ignores stupid settings
|
||||||
// Then we got a peak, else we don't. The peak has to time out on its own in order to support UDP sound sync.
|
// Then we got a peak, else we don't. The peak has to time out on its own in order to support UDP sound sync.
|
||||||
if ((sampleAvg > 1) && (maxVol > 0) && (binNum > 1) && (vReal[binNum] > maxVol) && ((millis() - timeOfPeak) > 100)) {
|
if ((sampleAvg > 1) && (maxVol > 0) && (binNum > 4) && (vReal[binNum] > maxVol) && ((millis() - timeOfPeak) > 100)) {
|
||||||
havePeak = true;
|
havePeak = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// alternate detection, based on FFT_MajorPeak and FFT_Magnitude. Not much better...
|
// alternate detection, based on FFT_MajorPeak and FFT_Magnitude. Not much better...
|
||||||
if ((binNum > 1) && (binNum < 10) && (sampleAgc > 127) &&
|
if ((binNum > 1) && (maxVol > 8) && (binNum < 10) && (sampleAgc > 127) &&
|
||||||
(FFT_MajorPeak > 50) && (FFT_MajorPeak < 250) && (FFT_Magnitude > (16.0f * (maxVol+42.0)) /*my_magnitude > 136.0f*16.0f*/) &&
|
(FFT_MajorPeak > 50) && (FFT_MajorPeak < 250) && (FFT_Magnitude > (16.0f * (maxVol+42.0)) /*my_magnitude > 136.0f*16.0f*/) &&
|
||||||
(millis() - timeOfPeak > 80)) {
|
(millis() - timeOfPeak > 80)) {
|
||||||
havePeak = true;
|
havePeak = true;
|
||||||
@@ -1224,8 +1225,8 @@ class AudioReactive : public Usermod {
|
|||||||
if ((sampleMax < sampleReal) && (sampleReal > 0.5f)) {
|
if ((sampleMax < sampleReal) && (sampleReal > 0.5f)) {
|
||||||
sampleMax = sampleMax + 0.5f * (sampleReal - sampleMax); // new peak - with some filtering
|
sampleMax = sampleMax + 0.5f * (sampleReal - sampleMax); // new peak - with some filtering
|
||||||
#if 1
|
#if 1
|
||||||
// another simple way to detect samplePeak
|
// another simple way to detect samplePeak - cannot detect beats, but reacts on peak volume
|
||||||
if ((binNum < 10) && (millis() - timeOfPeak > 80) && (sampleAvg > 1)) {
|
if (((binNum < 12) || ((maxVol < 1))) && (millis() - timeOfPeak > 80) && (sampleAvg > 1)) {
|
||||||
samplePeak = true;
|
samplePeak = true;
|
||||||
timeOfPeak = millis();
|
timeOfPeak = millis();
|
||||||
udpSamplePeak = true;
|
udpSamplePeak = true;
|
||||||
|
|||||||
@@ -6057,8 +6057,8 @@ uint16_t mode_ripplepeak(void) { // * Ripple peak. By Andrew Tuli
|
|||||||
SEGMENT.custom1 = *binNum;
|
SEGMENT.custom1 = *binNum;
|
||||||
SEGMENT.custom2 = *maxVol * 2;
|
SEGMENT.custom2 = *maxVol * 2;
|
||||||
}
|
}
|
||||||
if (SEGMENT.custom1 < 2) SEGMENT.custom1 = 2; // WLEDMM prevent stupid settings
|
if (SEGMENT.custom1 < 1) SEGMENT.custom1 = 1; // WLEDMM prevent stupid settings for bin
|
||||||
if (SEGMENT.custom2 < 48) SEGMENT.custom1 = 48; // WLEDMM prevent stupid settings
|
if (SEGMENT.custom2 < 48) SEGMENT.custom2 = 48; // WLEDMM prevent stupid settings for maxVol (below 24 = noise)
|
||||||
|
|
||||||
*binNum = SEGMENT.custom1; // Select a bin.
|
*binNum = SEGMENT.custom1; // Select a bin.
|
||||||
*maxVol = SEGMENT.custom2 / 2; // Our volume comparator.
|
*maxVol = SEGMENT.custom2 / 2; // Our volume comparator.
|
||||||
@@ -6689,8 +6689,8 @@ uint16_t mode_puddlepeak(void) { // Puddlepeak. By Andrew Tuline.
|
|||||||
SEGMENT.custom1 = *binNum;
|
SEGMENT.custom1 = *binNum;
|
||||||
SEGMENT.custom2 = *maxVol * 2;
|
SEGMENT.custom2 = *maxVol * 2;
|
||||||
}
|
}
|
||||||
if (SEGMENT.custom1 < 2) SEGMENT.custom1 = 2; // WLEDMM prevent stupid settings
|
if (SEGMENT.custom1 < 1) SEGMENT.custom1 = 1; // WLEDMM prevent stupid settings for bin
|
||||||
if (SEGMENT.custom2 < 48) SEGMENT.custom2 = 48; // WLEDMM prevent stupid settings
|
if (SEGMENT.custom2 < 48) SEGMENT.custom2 = 48; // WLEDMM prevent stupid settings for maxVol (below 24 = noise)
|
||||||
|
|
||||||
*binNum = SEGMENT.custom1; // Select a bin.
|
*binNum = SEGMENT.custom1; // Select a bin.
|
||||||
*maxVol = SEGMENT.custom2 / 2; // Our volume comparator.
|
*maxVol = SEGMENT.custom2 / 2; // Our volume comparator.
|
||||||
@@ -7296,8 +7296,8 @@ uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tulin
|
|||||||
SEGMENT.custom2 = *maxVol * 2;
|
SEGMENT.custom2 = *maxVol * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SEGMENT.custom1 < 2) SEGMENT.custom1 = 2; // WLEDMM prevent stupid settings
|
if (SEGMENT.custom1 < 1) SEGMENT.custom1 = 1; // WLEDMM prevent stupid settings for bin
|
||||||
if (SEGMENT.custom2 < 48) SEGMENT.custom1 = 48; // WLEDMM prevent stupid settings
|
if (SEGMENT.custom2 < 48) SEGMENT.custom2 = 48; // WLEDMM prevent stupid settings for maxVol (below 24 = noise)
|
||||||
|
|
||||||
*binNum = SEGMENT.custom1; // Select a bin.
|
*binNum = SEGMENT.custom1; // Select a bin.
|
||||||
*maxVol = SEGMENT.custom2 / 2; // Our volume comparator.
|
*maxVol = SEGMENT.custom2 / 2; // Our volume comparator.
|
||||||
|
|||||||
Reference in New Issue
Block a user