MCPcopy Create free account
hub / github.com/FastLED/FastLED / checkEqBounds

Function checkEqBounds

tests/fl/audio/audio_reactive.cpp:1659–1682  ·  view source on GitHub ↗

Helper: assert every field in the audio::detector::Equalizer snapshot is in valid range

Source from the content-addressed store, hash-verified

1657
1658/// Helper: assert every field in the audio::detector::Equalizer snapshot is in valid range
1659static void checkEqBounds(const audio::detector::Equalizer& eq) {
1660 FL_CHECK_GE(eq.bass, 0.0f);
1661 FL_CHECK_LE(eq.bass, 1.0f);
1662 FL_CHECK_GE(eq.mid, 0.0f);
1663 FL_CHECK_LE(eq.mid, 1.0f);
1664 FL_CHECK_GE(eq.treble, 0.0f);
1665 FL_CHECK_LE(eq.treble, 1.0f);
1666 FL_CHECK_GE(eq.volume, 0.0f);
1667 FL_CHECK_LE(eq.volume, 1.0f);
1668 FL_CHECK_GE(eq.zcf, 0.0f);
1669 FL_CHECK_LE(eq.zcf, 1.0f);
1670 FL_CHECK_GE(eq.volumeNormFactor, 0.0f);
1671 // Check all 16 bins
1672 for (int b = 0; b < audio::detector::Equalizer::kNumBins; ++b) {
1673 FL_CHECK_GE(eq.bins[b], 0.0f);
1674 FL_CHECK_LE(eq.bins[b], 1.0f);
1675 }
1676 // NaN check: a value != itself means NaN
1677 FL_CHECK_FALSE(eq.bass != eq.bass);
1678 FL_CHECK_FALSE(eq.mid != eq.mid);
1679 FL_CHECK_FALSE(eq.treble != eq.treble);
1680 FL_CHECK_FALSE(eq.volume != eq.volume);
1681 FL_CHECK_FALSE(eq.volumeNormFactor != eq.volumeNormFactor);
1682}
1683
1684FL_TEST_CASE("Loud - bass sine detected in bass band, all values bounded") {
1685 // 100 Hz sine at amplitude 16000 → should land in bass bins (0-3)

Callers 1

FL_TEST_FILEFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected