diff options
Diffstat (limited to 'plugin/src/Caelestia/beattracker.hpp')
| -rw-r--r-- | plugin/src/Caelestia/beattracker.hpp | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/plugin/src/Caelestia/beattracker.hpp b/plugin/src/Caelestia/beattracker.hpp index fda0ddc..c7737e1 100644 --- a/plugin/src/Caelestia/beattracker.hpp +++ b/plugin/src/Caelestia/beattracker.hpp @@ -1,51 +1,49 @@ #pragma once -#include <QAudioSource> -#include <QIODevice> -#include <QObject> +#include "audioprovider.hpp" #include <aubio/aubio.h> #include <qqmlintegration.h> namespace caelestia { -class BeatTracker : public QObject { +class BeatProcessor : public AudioProcessor { + Q_OBJECT + +public: + explicit BeatProcessor(QObject* parent = nullptr); + ~BeatProcessor(); + +signals: + void beat(smpl_t bpm); + +private: + aubio_tempo_t* m_tempo; + fvec_t* m_in; + fvec_t* m_out; + + void process() override; +}; + +class BeatTracker : public AudioProvider { Q_OBJECT QML_ELEMENT QML_SINGLETON Q_PROPERTY(smpl_t bpm READ bpm NOTIFY bpmChanged) - Q_PROPERTY(int refCount READ refCount WRITE setRefCount NOTIFY refCountChanged) public: - explicit BeatTracker(uint_t sampleRate = 44100, uint_t hopSize = 512, QObject* parent = nullptr); - ~BeatTracker(); + explicit BeatTracker(QObject* parent = nullptr); [[nodiscard]] smpl_t bpm() const; - [[nodiscard]] int refCount() const; - void setRefCount(int refCount); - signals: void bpmChanged(); - void refCountChanged(); void beat(smpl_t bpm); private: - QAudioSource* m_source; - QIODevice* m_device; - - aubio_tempo_t* m_tempo; - fvec_t* m_in; - fvec_t* m_out; - uint_t m_hopSize; - smpl_t m_bpm; - int m_refCount; - void start(); - void stop(); - void process(); - void handleStateChanged(QtAudio::State state) const; + void updateBpm(smpl_t bpm); }; } // namespace caelestia |