You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
484B

  1. #pragma once
  2. #include "common.hpp"
  3. namespace rack {
  4. struct Light {
  5. float value = 0.f;
  6. float getBrightness();
  7. void setBrightness(float brightness) {
  8. value = (brightness > 0.f) ? std::pow(brightness, 2) : 0.f;
  9. }
  10. /** Emulates slow fall (but immediate rise) of LED brightness.
  11. `frames` rescales the timestep. For example, if your module calls this method every 16 frames, use 16.f.
  12. */
  13. void setBrightnessSmooth(float brightness, float frames = 1.f);
  14. };
  15. } // namespace rack