@@ -12,27 +12,14 @@ class AutoPlaylistUsermod : public Usermod {
1212
1313 private:
1414
15- #if 1
1615 // experimental parameters by softhack007 - more balanced but need testing
1716 const uint_fast32_t MAX_DISTANCE_TRACKER = 184 ; // maximum accepted distance_tracker
1817 const uint_fast32_t ENERGY_SCALE = 1500 ;
19- const float FILTER_SLOW1 = 0 .0075f ; // for "slow" energy
20- const float FILTER_SLOW2 = 0 .005f ; // for "slow" lfc / zcr
21- const float FILTER_FAST1 = 0 .2f ; // for "fast" energy
22- const float FILTER_FAST2 = 0 .25f ; // for "fast" lfc / zcr
18+ const float FILTER_SLOW1 = 0 .0075f ; // for "slow" energy - was 0.01f
19+ const float FILTER_SLOW2 = 0 .005f ; // for "slow" lfc / zcr - was 0.01f
20+ const float FILTER_FAST1 = 0 .2f ; // for "fast" energy - was 0.10f
21+ const float FILTER_FAST2 = 0 .25f ; // for "fast" lfc / zcr - was 0.10f
2322 const float FILTER_VOLUME = 0 .03f ; // for volumeSmth averaging - takes 8-10sec until "silence"
24- #else
25- // parameters used by TroyHacks / netmindz - behaviour is mainly driven by "energy"
26- const uint_fast32_t MAX_DISTANCE_TRACKER = 128; // maximum accepted distance_tracker
27- //const uint_fast32_t ENERGY_SCALE = 10000;
28- const uint_fast32_t ENERGY_SCALE = 2000;
29- // softhack007: original code used FILTER_SLOW = 0.002f
30- const float FILTER_SLOW1 = 0.01f; // for "slow" energy
31- const float FILTER_SLOW2 = 0.01f; // for "slow" lfc / zcr
32- const float FILTER_FAST1 = 0.1f; // for "fast" energy
33- const float FILTER_FAST2 = 0.1f; // for "fast" lfc / zcr
34- const float FILTER_VOLUME = 0.03f; // for volumeSmth averaging - takes 8-10sec until "silence"
35- #endif
3623
3724 bool initDone = false ;
3825 bool functionality_enabled = false ;
@@ -126,7 +113,7 @@ class AutoPlaylistUsermod : public Usermod {
126113
127114 energy /= ENERGY_SCALE; // scale down so we get 0 sometimes
128115
129- uint8_t lfc = fftResult[0 ];
116+ uint8_t lfc = float ( fftResult[0 ]) * fftDeScaler[ 0 ] / 0 . 85f ; // might as well undo pink noise here too.
130117 uint16_t zcr = *(uint16_t *)um_data->u_data [11 ];
131118
132119 // WLED-MM/TroyHacks: Calculate the long- and short-running averages
@@ -168,6 +155,7 @@ class AutoPlaylistUsermod : public Usermod {
168155 distance_tracker = distance;
169156 }
170157
158+ // Debug for adjusting formulas, etc:
171159 // USER_PRINTF("Distance: %5lu - v_lfc: %5lu v_energy: %5lu v_zcr: %5lu\n",(unsigned long)distance,(unsigned long)vector_lfc,(unsigned long)vector_energy,(unsigned long)vector_zcr);
172160
173161 if ((millis () - change_timer) > ideal_change_min) { // softhack007 same result as "millis() > change_timer + ideal_change_min", but more robust against unsigned overflow
0 commit comments