2013-05-13 23:04:12 +02:00
|
|
|
|
|
|
|
#ifndef LUPPP_LOOPER_H
|
|
|
|
#define LUPPP_LOOPER_H
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "buffers.hxx"
|
2013-05-15 03:55:51 +02:00
|
|
|
#include "observer/observer.hxx"
|
|
|
|
|
2013-05-13 23:04:12 +02:00
|
|
|
using namespace std;
|
|
|
|
|
2013-05-15 03:55:51 +02:00
|
|
|
class Looper : public Observer // for notifications
|
2013-05-13 23:04:12 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum State {
|
2013-05-16 02:38:11 +02:00
|
|
|
STATE_PLAYING = 0,
|
|
|
|
STATE_PLAY_QUEUED,
|
|
|
|
STATE_RECORDING,
|
|
|
|
STATE_RECORD_QUEUED,
|
|
|
|
STATE_STOPPED,
|
|
|
|
STATE_STOP_QUEUED,
|
2013-05-13 23:04:12 +02:00
|
|
|
};
|
|
|
|
|
2013-05-15 03:17:08 +02:00
|
|
|
Looper(int t) :
|
|
|
|
track(t),
|
2013-05-15 05:20:10 +02:00
|
|
|
state(STATE_STOPPED),
|
2013-05-16 02:38:11 +02:00
|
|
|
numBeats (4),
|
|
|
|
playedBeats(0),
|
2013-05-16 17:14:14 +02:00
|
|
|
stopRecordOnBar(false),
|
2013-05-13 23:04:12 +02:00
|
|
|
endPoint (0),
|
2013-05-15 05:05:36 +02:00
|
|
|
playPoint (0),
|
|
|
|
lastWrittenSampleIndex(0)
|
2013-05-16 16:17:49 +02:00
|
|
|
{}
|
2013-05-13 23:04:12 +02:00
|
|
|
|
2013-05-16 16:17:49 +02:00
|
|
|
void bar();
|
2013-05-16 17:14:14 +02:00
|
|
|
void beat();
|
2013-05-15 05:05:36 +02:00
|
|
|
|
2013-05-16 16:17:49 +02:00
|
|
|
void setFpb(int f) { fpb = f; }
|
2013-05-13 23:04:12 +02:00
|
|
|
|
2013-05-15 03:55:51 +02:00
|
|
|
void setState(State s);
|
2013-05-16 16:17:49 +02:00
|
|
|
void setLoopLength(float l);
|
2013-05-15 03:55:51 +02:00
|
|
|
|
2013-05-16 14:38:46 +02:00
|
|
|
void process(int nframes, Buffers* buffers);
|
2013-05-13 23:04:12 +02:00
|
|
|
|
|
|
|
private:
|
2013-05-15 03:17:08 +02:00
|
|
|
int track;
|
2013-05-15 05:20:10 +02:00
|
|
|
State state;
|
2013-05-15 05:05:36 +02:00
|
|
|
|
|
|
|
int fpb;
|
2013-05-16 02:38:11 +02:00
|
|
|
int numBeats;
|
|
|
|
int playedBeats;
|
2013-05-16 17:14:14 +02:00
|
|
|
bool stopRecordOnBar;
|
2013-05-13 23:04:12 +02:00
|
|
|
|
|
|
|
int endPoint, playPoint, lastWrittenSampleIndex;
|
|
|
|
float sample[44100*60];
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LUPPP_LOOPER_H
|