* fix compiler warnings (uninitialized vars, ambiguous functions calls)
* restore some lost function prototypes
* avoid negative pixel indices
* only use "fast" color_add when there is no risk of "overshooting" results
* minor optimizations
On a matrix with 52 columns, popcorn was requesting around 30Kb of segment data.
This patch reduces the data to the actually necessary amount based on the "intensity" slider. If intensity is increased, it means that the effect will get a bigger chunk of data allocated - zero'd out but this does not hurt much.
* adding suspendPlaylist() to playlist engine code
* autoplaylist usermod calls suspendPlaylist() before switching to another preset
* fix a potential overflow on `lfc` (uint8_t -> uint16_t)
fftResult[] is indended to look good on GEQ, and has a very "twisted" representation of FFT results only. This change improves reconstruction of signal energy, by on-doing some of the "GEQ enhancements" in fftResults[].
fixing mis-optimized math when calculating energy.
energy = sum(amplitude^2). this is not the same as sum(amplitude)^2.
Example:
1+5+7 = 13; 13 * 13 = 169
1*1 + 5*5 + 7*7 = 75
* initialize slow and fast filters with current values (first call only) - reduces time for filter stabilization
* use slightly optimized variant of "rolling average" filter (result is exactly the same)
--> replaced `xX = xX * (1-a) + newX * a;` by `xX = xX + a * (newX - Xx);`
* use constants for filter parameters (for tinkering and improved readability)
zero crossing counter is often larger than in the prototype by @troyhacks - due to calculation after filtering (catches more crossings), and due to the fixed condition for detecting zero crossings (doubles the number of crossings).
This patch reduces the final value to 2/3, so it typically stays below 256.
Troy's zeroCrossingCount - counts zero crossings inside audioreactive, and makes the number availeable to other usermods and effects.
This PR is a prerequisite for PR #124 (auto playlist)
* make filters work (requires float instead of integer)
* avoid "expression propagation to double" by using float constants
* use unsigned long for all variables that depend on millis()
* calculate zero crossings after filtering out DC offsets
* update effect variable only once
* fix a logic error when detecting zero crossings
* fix array bounds violation when creating umdata entries