2013-05-14 01:03:43 +02:00
|
|
|
|
|
|
|
#ifndef LUPPP_TIME_H
|
|
|
|
#define LUPPP_TIME_H
|
|
|
|
|
|
|
|
#include <iostream>
|
2013-05-16 16:17:49 +02:00
|
|
|
#include <cstdio>
|
2013-05-14 01:03:43 +02:00
|
|
|
|
|
|
|
#include "buffers.hxx"
|
2013-05-16 16:17:49 +02:00
|
|
|
#include "eventhandler.hxx"
|
2013-05-14 01:03:43 +02:00
|
|
|
|
2013-07-31 11:55:48 +02:00
|
|
|
#include "observer/time.hxx"
|
2013-05-15 03:55:51 +02:00
|
|
|
|
2013-05-14 01:03:43 +02:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
class TimeManager
|
|
|
|
{
|
|
|
|
public:
|
2013-08-15 22:05:19 +02:00
|
|
|
TimeManager();
|
2013-05-15 03:55:51 +02:00
|
|
|
|
2013-08-15 22:05:19 +02:00
|
|
|
int getFpb();
|
|
|
|
void setBpm(float bpm);
|
2013-12-01 20:01:58 +01:00
|
|
|
void setBpmZeroOne(float bpm);
|
2013-08-15 22:05:19 +02:00
|
|
|
void setFpb(float f);
|
2013-05-15 03:55:51 +02:00
|
|
|
|
2013-08-15 22:05:19 +02:00
|
|
|
void registerObserver(TimeObserver* o);
|
2013-05-16 18:45:46 +02:00
|
|
|
|
2013-08-15 22:05:19 +02:00
|
|
|
void tap();
|
|
|
|
|
|
|
|
void process(Buffers* buffers);
|
2013-10-13 01:20:00 +02:00
|
|
|
|
|
|
|
/// returns the number of samples till beat if a beat exists in this process
|
|
|
|
/// Otherwise returns nframes
|
|
|
|
int getNframesToBeat();
|
2013-05-14 01:03:43 +02:00
|
|
|
|
|
|
|
private:
|
2013-09-17 14:11:11 +02:00
|
|
|
int samplerate;
|
|
|
|
|
2013-10-13 01:20:00 +02:00
|
|
|
/// holds the number of frames before a beat
|
2013-12-02 00:23:50 +01:00
|
|
|
//int nframesToBeat;
|
2013-12-05 20:57:17 +01:00
|
|
|
|
|
|
|
long long totalFrameCounter;
|
2013-10-13 01:20:00 +02:00
|
|
|
|
2013-12-01 18:35:45 +01:00
|
|
|
/// counts down frames until the next beat
|
2013-12-05 20:57:17 +01:00
|
|
|
long beatFrameCountdown;
|
2013-12-01 18:35:45 +01:00
|
|
|
|
2013-05-16 18:45:46 +02:00
|
|
|
float fpb;
|
2013-12-01 18:35:45 +01:00
|
|
|
int beatCounter;
|
2013-05-14 01:03:43 +02:00
|
|
|
|
2013-12-01 18:35:45 +01:00
|
|
|
/// tap tempo measurements
|
2013-05-16 18:45:46 +02:00
|
|
|
int frame;
|
|
|
|
|
|
|
|
int tapTempoPos;
|
|
|
|
int tapTempo[3];
|
|
|
|
|
2013-07-31 11:55:48 +02:00
|
|
|
std::vector<TimeObserver*> observers;
|
2013-05-14 01:03:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LUPPP_TIME_H
|