24 lines
483 B
C
24 lines
483 B
C
|
#pragma once
|
||
|
|
||
|
#include "tools/music.h"
|
||
|
#include <memory>
|
||
|
#include <vector>
|
||
|
|
||
|
class BPMCalculator
|
||
|
{
|
||
|
public:
|
||
|
explicit BPMCalculator(const std::shared_ptr<Music>& music);
|
||
|
void setMusic(const std::shared_ptr<Music>& music);
|
||
|
|
||
|
void startListening(const microsec& offset);
|
||
|
void stopListening();
|
||
|
|
||
|
void click();
|
||
|
int getCurrentApproximation() const;
|
||
|
|
||
|
private:
|
||
|
std::shared_ptr<Music> _music;
|
||
|
std::vector<microsec> _deltas;
|
||
|
microsec _previous_click_offset;
|
||
|
};
|