Gain.h 888 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include <memory> // for unique_ptr
  3. #include <mutex> // for scoped_lock
  4. #include <vector> // for vector
  5. #include "AudioTransform.h" // for AudioTransform
  6. #include "StreamInfo.h" // for StreamInfo
  7. #include "TransformConfig.h" // for TransformConfig
  8. namespace bell {
  9. class Gain : public bell::AudioTransform {
  10. private:
  11. float gainFactor = 1.0f;
  12. std::vector<int> channels;
  13. public:
  14. Gain();
  15. ~Gain(){};
  16. float gainDb = 0.0;
  17. void configure(std::vector<int> channels, float gainDB);
  18. std::unique_ptr<StreamInfo> process(
  19. std::unique_ptr<StreamInfo> data) override;
  20. void reconfigure() override {
  21. std::scoped_lock lock(this->accessMutex);
  22. float gain = config->getFloat("gain");
  23. this->channels = config->getChannels();
  24. if (gainDb == gain) {
  25. return;
  26. }
  27. this->configure(channels, gain);
  28. }
  29. };
  30. } // namespace bell