Aircoookie / WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi!
https://kno.wled.ge
MIT License
15.01k stars 3.24k forks source link

Remove repeating code to fetch audio data #4103

Closed netmindz closed 3 months ago

netmindz commented 3 months ago

Remove pointless code duplication

blazoncek commented 3 months ago

This optimisation is great, however..

Instead of modifying usermod manager with a single usermod extension it would be much better IMO to add a static function in FX.cpp to work arround the underlying issue.

I.e..

static um_data_t *getAudioData() {
  um_data_t *um_data;
  if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
    // add support for no audio
    um_data = simulateSound(SEGMENT.soundSim);
  }
  return um_data;
}
netmindz commented 3 months ago

Updated to suggested form, I was going to add to utils.cpp at first, the top of FX.cpp makes more sense though

This version is also more performant than when I moved to the UserModManager so definitely good suggestion @blazoncek