Some tweaks + Display number of bars recorded (and to be recorded)!

This commit is contained in:
Valentin Boettcher 2018-03-27 17:52:41 +02:00
parent fd4ac1676a
commit 8cf5e19848
7 changed files with 106 additions and 12 deletions

View file

@ -45,7 +45,7 @@ ClipSelector::ClipSelector( int _x, int _y, int _w, int _h,
_master = master;
if ( _master ) {
for(int i = 0; i < 10; i++ ) {
for(int i = 0; i < numClips; i++ ) {
stringstream s;
s << "Scene " << i + 1;
clips[i].setName( s.str() );
@ -62,6 +62,10 @@ ClipSelector::ClipSelector( int _x, int _y, int _w, int _h,
void ClipSelector::setID( int id )
{
ID = id;
if(!_master){
EventGridInit e (clips, numClips, ID);
writeToDspRingbuffer( &e );
}
}
@ -205,6 +209,19 @@ void ClipSelector::draw()
cairo_show_text( cr, tmp.c_str() );
// clip bars
if(!_master) {
int bars = clips[i].getBeats() / 4;
int barsToRecord = clips[i].getBarsToRecord();
bars = (bars == 0) ? barsToRecord : bars;
if(bars > 0) {
cairo_move_to( cr, x + clipHeight + 5, drawY + textHeight + 8);
cairo_set_source_rgba( cr, 255 / 255.f, 255 / 255.f , 255 / 255.f , 0.9 );
cairo_set_font_size( cr, 8 );
cairo_show_text( cr, std::to_string(bars).c_str());
}
}
// special indicator?
if ( i == special ) {
cairo_rectangle( cr, x+2, drawY, clipWidth -1, clipHeight - 3 );

View file

@ -41,7 +41,8 @@ class ClipState
public:
ClipState() :
state(GridLogic::STATE_EMPTY),
name("")
name(""),
lclip(0) // I would use nullptr, but thats not common here...
{}
void setName(std::string n)
@ -64,9 +65,29 @@ public:
return state;
}
void setLooperClip(LooperClip* lc){
lclip = lc;
}
// we wrap it here, so there may be no
// fuzz with the looperclip
int getBeats(){
if(!lclip)
return 0;
return lclip->getBeats();
}
int getBarsToRecord(){
if(!lclip)
return 0;
return lclip->getBarsToRecord();
}
private:
GridLogic::State state;
std::string name;
LooperClip* lclip;
};
class ClipSelector : public Fl_Button

View file

@ -1,4 +1,4 @@
/*
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
*
@ -31,11 +31,14 @@
#include "looper.hxx"
#include "gridlogic.hxx"
#include "transport.hxx"
#pragma GCC diagnostic ignored "-Wunused-parameter"
using namespace std;
namespace Avtk {
class ClipState;
}
namespace Event
{
enum SEND_TYPE {
@ -79,7 +82,7 @@ enum EVENT_TYPE {
GRID_SELECT_CLIP_ENABLE, // enable selecting a clip from the grid
GRID_SELECT_CLIP_EVENT, // a press / release on the selected clip
GRID_SELECT_NEW_CHOSEN, // a different clip is now "special"
EVENT_LOOPER_BARS_TO_RECORD, // choose how many bars to record
GRID_INIT, // init the cells with references to the looper clips
/// Track
TRACK_JACKSEND,
@ -98,6 +101,7 @@ enum EVENT_TYPE {
LOOPER_PROGRESS,
LOOPER_LOOP_LENGTH,
LOOPER_LOOP_USE_AS_TEMPO,
LOOPER_BARS_TO_RECORD, // choose how many bars to record
/// Transport etc
METRONOME_ACTIVE,
@ -273,7 +277,7 @@ class EventLooperBarsToRecord : public EventBase
public:
int type()
{
return int(EVENT_LOOPER_BARS_TO_RECORD);
return int(LOOPER_BARS_TO_RECORD);
}
uint32_t size()
{
@ -600,6 +604,26 @@ public:
EventStateSaveFinish() {};
};
class EventGridInit : public EventBase
{
public:
int type()
{
return int(GRID_INIT);
}
uint32_t size()
{
return sizeof(EventGridInit);
}
int numClips;
int track;
Avtk::ClipState *clips;
EventGridInit() {};
EventGridInit(Avtk::ClipState * c, int n, int t): clips(c), numClips(n), track(t) {}
};
class EventGridEvent : public EventBase
{
public:
@ -625,6 +649,7 @@ public:
EventGridEvent(int t, int s, bool p): track(t), scene(s), pressed(p) {}
};
class EventGridState : public EventBase
{
public:

View file

@ -172,6 +172,14 @@ void handleDspEvents()
}
// ========= GRID =====
case Event::GRID_INIT: {
if ( availableRead >= sizeof(EventGridInit) ) {
EventGridInit ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventGridInit) );
jack->getLogic()->setupClips( ev.clips, ev.numClips, ev.track );
}
break;
}
case Event::GRID_STATE: {
if ( availableRead >= sizeof(EventGridState) ) {
EventGridState ev;
@ -265,10 +273,12 @@ void handleDspEvents()
}
break;
}
case Event::EVENT_LOOPER_BARS_TO_RECORD: {
EventLooperBarsToRecord ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperBarsToRecord) );
jack->getLogic()->looperBarsToRecord( ev.track, ev.scene, ev.bars );
case Event::LOOPER_BARS_TO_RECORD: {
if ( availableRead >= sizeof(EventLooperBarsToRecord) ) {
EventLooperBarsToRecord ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperBarsToRecord) );
jack->getLogic()->looperBarsToRecord( ev.track, ev.scene, ev.bars );
}
break;
}
case Event::LOOPER_LOOP_USE_AS_TEMPO: {

View file

@ -140,6 +140,13 @@ void handleGuiEvents()
//jack->setLooperLoopLength( ev.track, ev.scale );
} break;
}
case Event::LOOPER_BARS_TO_RECORD: {
if ( availableRead >= sizeof(EventLooperLoopLength) ) {
EventLooperBarsToRecord ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventLooperBarsToRecord) );
}
break;
}
case Event::LOOPER_PROGRESS: {
if ( availableRead >= sizeof(EventLooperProgress) ) {
EventLooperProgress ev;

View file

@ -156,8 +156,20 @@ void Logic::looperBarsToRecord(int t, int s, int b)
{
if ( t >= 0 && t < NTRACKS ) {
jack->getLooper( t )->getClip( s )->setBarsToRecord(b);
} else {
LUPPP_WARN("invalid track number %i: check controller map has \"track\" field.", t );
} else { LUPPP_WARN("invalid track number %i: check controller map has \"track\" field.", t );
}
}
void Logic::setupClips(Avtk::ClipState clips[], int clipNum, int t)
{
if(!clips)
return;
Looper * looper = jack->getLooper( t );
for(int i = 0; i < clipNum; i++){
LooperClip * tmp = looper->getClip(i);
if(tmp)
clips[i].setLooperClip(tmp);
}
}

View file

@ -20,6 +20,7 @@
#define LUPPP_LOGIC_H
#include "event.hxx"
#include "avtk/clipselector.hxx"
/** Logic
* This class contains an interface exposing most functionality in Luppp. The
@ -63,6 +64,7 @@ public:
void looperUseAsTempo(int track, int scene);
void looperClipLenght(int track, int scene, int lenght);
void looperBarsToRecord(int track, int scene, int bars);
void setupClips(Avtk::ClipState clips[], int clipNum, int t);
};
#endif // LUPPP_LOGIC_H