2013-08-01 20:58:26 +02:00
|
|
|
|
|
|
|
#ifndef LUPPP_GRID_LOGIC_H
|
|
|
|
#define LUPPP_GRID_LOGIC_H
|
|
|
|
|
|
|
|
#include "config.hxx"
|
|
|
|
#include "observer/time.hxx"
|
|
|
|
|
2013-08-22 01:05:00 +02:00
|
|
|
class AudioBuffer;
|
|
|
|
|
2013-08-01 20:58:26 +02:00
|
|
|
/** GridLogic
|
|
|
|
* The logic code for the luppp tracks / grid resides here. This logic is
|
|
|
|
* separtated from the Looper class so it can be repurposed by different
|
|
|
|
* controllers and input devices. The UI and eg. APC / Launchpad all have a
|
2013-08-13 01:02:59 +02:00
|
|
|
* similar grid style interface: the logic is implemented here once.
|
2013-08-01 20:58:26 +02:00
|
|
|
*
|
|
|
|
* The class sends Looper messages to change its state, thus abstracting away
|
|
|
|
* the details of the Looper control, and exposing its functionality using a
|
|
|
|
* convinient API.
|
|
|
|
*
|
|
|
|
* When the state of a block changes, it will update the state of the grid on
|
|
|
|
* the controller.
|
|
|
|
*
|
|
|
|
* It inherits from TimeObserver so it can change the state of the clip on the
|
|
|
|
* bar / beat.
|
|
|
|
**/
|
|
|
|
class GridLogic : public TimeObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// possible states of each square. Public so Controller subclasses can
|
|
|
|
/// determine the state of the square
|
|
|
|
enum State {
|
|
|
|
STATE_EMPTY = 0,
|
|
|
|
STATE_PLAYING,
|
|
|
|
STATE_PLAY_QUEUED,
|
2013-08-22 01:26:01 +02:00
|
|
|
STATE_STOPPED,
|
2013-08-01 20:58:26 +02:00
|
|
|
STATE_STOP_QUEUED,
|
|
|
|
STATE_RECORDING,
|
|
|
|
STATE_RECORD_QUEUED,
|
|
|
|
};
|
|
|
|
|
|
|
|
GridLogic();
|
|
|
|
|
|
|
|
/// button press / click event
|
|
|
|
void pressed( int track, int scene );
|
|
|
|
|
|
|
|
/// button release / click-release event
|
|
|
|
void released( int track, int scene );
|
|
|
|
|
2013-08-22 06:48:59 +02:00
|
|
|
/// master controls, launches a horizontal scene with one event
|
|
|
|
void launchScene( int scene );
|
2013-08-26 00:36:08 +02:00
|
|
|
int getLaunchedScene();
|
2013-08-22 06:48:59 +02:00
|
|
|
|
2013-08-13 01:41:17 +02:00
|
|
|
/// GUI load event
|
2013-08-22 01:05:00 +02:00
|
|
|
void load(int track, int scene, AudioBuffer* ab);
|
2013-08-13 01:41:17 +02:00
|
|
|
|
2013-08-04 19:04:26 +02:00
|
|
|
/// resend entire grid state to controllers
|
2013-08-01 20:58:26 +02:00
|
|
|
void updateState();
|
2013-08-04 19:04:26 +02:00
|
|
|
|
|
|
|
/// time functions, not for use by Controller subclasses
|
|
|
|
void bar();
|
|
|
|
void beat();
|
2013-08-01 20:58:26 +02:00
|
|
|
|
2013-08-22 01:46:58 +02:00
|
|
|
/// for debug purposes: use static_cast<int>(GridLogic::State) to access
|
2013-08-13 17:35:27 +02:00
|
|
|
static const char* StateString[8];
|
2013-08-01 20:58:26 +02:00
|
|
|
|
2013-08-26 00:36:08 +02:00
|
|
|
private:
|
|
|
|
/// holds last scene launch
|
|
|
|
int sceneLaunch;
|
2013-08-01 20:58:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LUPPP_GRID_LOGIC_H
|