FastLED 3.10.6
Loading...
Searching...
No Matches

◆ setup()

void setup ( )

Definition at line 252 of file hydropack.ino.

252 {
253 Serial.begin(115200);
254
256 .setScreenMap(previewMap);
257 FastLED.setBrightness(255);
258
259 stageThresholdDbSpl.setGroup("Stage Music Gate");
260 minimumBeatConfidence.setGroup("Stage Music Gate");
261#if defined(FL_IS_WASM)
262 streamDetectorFrames.setGroup("Debug");
263#endif
264
265 // The unified input is browser audio on WASM and INMP441 I2S on ESP32.
266 gAudio = FastLED.add(audioUi);
267 if (!gAudio) {
268 FL_WARN("HydroPack: no audio processor available");
269 return;
270 }
271
272 gAudio->setNoiseFloorTrackingEnabled(true);
273 gAudio->onVibeLevels([](const fl::audio::detector::VibeLevels &levels) {
274 // Feed every block so the calibrated meter observes the actual quiet
275 // floor, rather than only the relatively loud blocks that trigger a
276 // beat callback.
279#if defined(FL_IS_WASM)
280 // Keep this as one compact line per analysis frame. It deliberately
281 // polls both independent rhythm detectors: raw Beat is an onset
282 // detector; Tempo is the recurring-rhythm estimator. Calling these
283 // getters also enables their lazy detector instances for the next
284 // audio frame, so the trace diagnoses the real WASM signal path.
285 if (streamDetectorFrames.value()) {
286 const fl::audio::Sample &sample = gAudio->getSample();
288 "HYDRO frame=%lu spl=%.1f zcf=%.3f silent=%u "
289 "beat=%.3f bpm=%.1f tempo=%.3f tempo_bpm=%.1f "
290 "vibe_bass=%.3f vibe_att=%.3f vibe_conf=%.3f spike=%u "
291 "bass_raw=%.3f gate=%u\\n",
292 static_cast<unsigned long>(millis()), gSoundPressureDbSpl,
293 sample.zcf(), gAudio->isSilent() ? 1U : 0U,
294 gAudio->getBeatConfidence(), gAudio->getBPM(),
295 gAudio->getTempoConfidence(), gAudio->getTempoBPM(),
296 levels.bass, gAudio->getVibeBassAtt(), gBeatConfidence,
297 levels.bassSpike ? 1U : 0U, levels.bassRaw,
298 isMusicModeActive() ? 1U : 0U);
299 }
300#endif
301 if (gBeatConfidence >= minimumBeatConfidence.value() &&
304 }
305 if (!levels.bassSpike ||
308 return;
309 }
312 if (levels.bass > kTriangleBassThreshold) {
316 }
317 });
318}
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
constexpr EOrder GRB
Definition eorder.h:19
float gBeatConfidence
#define PIN_PREVIEW
Definition hydropack.ino:40
fl::UISlider stageThresholdDbSpl("Minimum Music Level (dB SPL)", kDefaultStageThresholdDbSpl, 60.0f, 105.0f, 1.0f)
CRGB previewLeds[kPreviewLedCount]
Definition hydropack.ino:65
void updateSoundLevel()
uint32_t gTriangleFireAtMs
constexpr uint8_t kPreviewLedCount
Definition hydropack.ino:46
float gSoundPressureDbSpl
constexpr float kTriangleBassThreshold
Definition hydropack.ino:59
void fireAnalyzer(float bass, float threshold, float minIntensity, float &trigger)
fl::UISlider minimumBeatConfidence("Minimum Vibe Beat Confidence", kDefaultMinimumBeatConfidence, 0.0f, 1.0f, 0.05f)
float gCenterTrigger
float getVibeBeatConfidence(const fl::audio::detector::VibeLevels &levels)
bool isMusicModeActive()
fl::ScreenMap previewMap
Definition hydropack.ino:89
constexpr uint32_t kTriangleLaunchDelayMs
Definition hydropack.ino:47
fl::shared_ptr< fl::audio::Processor > gAudio
fl::UIAudio audioUi("Audio Input", audioConfig)
float gPendingTriangleLevel
constexpr float kCenterBassThreshold
Definition hydropack.ino:58
bool isMusicPresent()
#define FL_WARN(...)
Definition log.h:440
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
void printf(const char *format) FL_NO_EXCEPT
CRGB sample(const CRGB *grid, const XYMap &xyMap, float x, float y, SampleMode mode)
Sample a pixel from a 2D CRGB grid at floating-point coordinates.
Definition sample.cpp.hpp:9
#define Serial
Definition serial.h:304

References audioUi, fl::audio::detector::VibeLevels::bass, fl::audio::detector::VibeLevels::bassRaw, fl::audio::detector::VibeLevels::bassSpike, FastLED, fireAnalyzer(), FL_WARN, gAudio, gBeatConfidence, gCenterTrigger, getVibeBeatConfidence(), gPendingTriangleLevel, GRB, gSoundPressureDbSpl, gTriangleFireAtMs, isMusicModeActive(), isMusicPresent(), kCenterBassThreshold, kPreviewLedCount, kTriangleBassThreshold, kTriangleLaunchDelayMs, minimumBeatConfidence, PIN_PREVIEW, previewLeds, previewMap, fl::printf(), Serial, stageThresholdDbSpl, updateSoundLevel(), and WS2812B.

+ Here is the call graph for this function: