diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-13 14:38:44 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-13 14:38:44 +1000 |
| commit | 306cfc06ed38a2f86616c1f2fe64de45321f21a6 (patch) | |
| tree | a27c79d9c4d01c2dadeeae74c844875ab7ab4eed /plugin/src/Caelestia/Services/cavaprovider.hpp | |
| parent | popouts/tray: better interaction (diff) | |
| download | caelestia-shell-306cfc06ed38a2f86616c1f2fe64de45321f21a6.tar.gz caelestia-shell-306cfc06ed38a2f86616c1f2fe64de45321f21a6.tar.bz2 caelestia-shell-306cfc06ed38a2f86616c1f2fe64de45321f21a6.zip | |
plugin: refactor into modules
Diffstat (limited to 'plugin/src/Caelestia/Services/cavaprovider.hpp')
| -rw-r--r-- | plugin/src/Caelestia/Services/cavaprovider.hpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/plugin/src/Caelestia/Services/cavaprovider.hpp b/plugin/src/Caelestia/Services/cavaprovider.hpp new file mode 100644 index 0000000..6dab635 --- /dev/null +++ b/plugin/src/Caelestia/Services/cavaprovider.hpp @@ -0,0 +1,67 @@ +#pragma once + +#include "audiocollector.hpp" +#include "audioprovider.hpp" +#include <cava/cavacore.h> +#include <qqmlintegration.h> + +namespace caelestia { + +class CavaProcessor : public AudioProcessor { + Q_OBJECT + +public: + explicit CavaProcessor(AudioCollector* collector, QObject* parent = nullptr); + ~CavaProcessor(); + +signals: + void valuesChanged(QVector<double> values); + +protected: + void setCollector(AudioCollector* collector) override; + +private: + struct cava_plan* m_plan; + double* m_in; + double* m_out; + + int m_bars; + QVector<double> m_values; + + Q_INVOKABLE void setBars(int bars); + + void reload(); + void initCava(); + void cleanup(); + + void process() override; +}; + +class CavaProvider : public AudioProvider { + Q_OBJECT + QML_ELEMENT + + Q_PROPERTY(int bars READ bars WRITE setBars NOTIFY barsChanged) + + Q_PROPERTY(QVector<double> values READ values NOTIFY valuesChanged) + +public: + explicit CavaProvider(QObject* parent = nullptr); + + [[nodiscard]] int bars() const; + void setBars(int bars); + + [[nodiscard]] QVector<double> values() const; + +signals: + void barsChanged(); + void valuesChanged(); + +private: + int m_bars; + QVector<double> m_values; + + void updateValues(QVector<double> values); +}; + +} // namespace caelestia |