mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
Some tweaks + Display number of bars recorded (and to be recorded)!
This commit is contained in:
parent
fd4ac1676a
commit
8cf5e19848
7 changed files with 106 additions and 12 deletions
|
@ -45,7 +45,7 @@ ClipSelector::ClipSelector( int _x, int _y, int _w, int _h,
|
||||||
_master = master;
|
_master = master;
|
||||||
|
|
||||||
if ( _master ) {
|
if ( _master ) {
|
||||||
for(int i = 0; i < 10; i++ ) {
|
for(int i = 0; i < numClips; i++ ) {
|
||||||
stringstream s;
|
stringstream s;
|
||||||
s << "Scene " << i + 1;
|
s << "Scene " << i + 1;
|
||||||
clips[i].setName( s.str() );
|
clips[i].setName( s.str() );
|
||||||
|
@ -62,6 +62,10 @@ ClipSelector::ClipSelector( int _x, int _y, int _w, int _h,
|
||||||
void ClipSelector::setID( int id )
|
void ClipSelector::setID( int id )
|
||||||
{
|
{
|
||||||
ID = 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() );
|
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?
|
// special indicator?
|
||||||
if ( i == special ) {
|
if ( i == special ) {
|
||||||
cairo_rectangle( cr, x+2, drawY, clipWidth -1, clipHeight - 3 );
|
cairo_rectangle( cr, x+2, drawY, clipWidth -1, clipHeight - 3 );
|
||||||
|
|
|
@ -41,7 +41,8 @@ class ClipState
|
||||||
public:
|
public:
|
||||||
ClipState() :
|
ClipState() :
|
||||||
state(GridLogic::STATE_EMPTY),
|
state(GridLogic::STATE_EMPTY),
|
||||||
name("")
|
name(""),
|
||||||
|
lclip(0) // I would use nullptr, but thats not common here...
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void setName(std::string n)
|
void setName(std::string n)
|
||||||
|
@ -64,9 +65,29 @@ public:
|
||||||
return state;
|
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:
|
private:
|
||||||
GridLogic::State state;
|
GridLogic::State state;
|
||||||
std::string name;
|
std::string name;
|
||||||
|
LooperClip* lclip;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ClipSelector : public Fl_Button
|
class ClipSelector : public Fl_Button
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* Author: Harry van Haaren 2013
|
* Author: Harry van Haaren 2013
|
||||||
* harryhaaren@gmail.com
|
* harryhaaren@gmail.com
|
||||||
*
|
*
|
||||||
|
@ -31,11 +31,14 @@
|
||||||
#include "looper.hxx"
|
#include "looper.hxx"
|
||||||
#include "gridlogic.hxx"
|
#include "gridlogic.hxx"
|
||||||
#include "transport.hxx"
|
#include "transport.hxx"
|
||||||
|
|
||||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace Avtk {
|
||||||
|
class ClipState;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Event
|
namespace Event
|
||||||
{
|
{
|
||||||
enum SEND_TYPE {
|
enum SEND_TYPE {
|
||||||
|
@ -79,7 +82,7 @@ enum EVENT_TYPE {
|
||||||
GRID_SELECT_CLIP_ENABLE, // enable selecting a clip from the grid
|
GRID_SELECT_CLIP_ENABLE, // enable selecting a clip from the grid
|
||||||
GRID_SELECT_CLIP_EVENT, // a press / release on the selected clip
|
GRID_SELECT_CLIP_EVENT, // a press / release on the selected clip
|
||||||
GRID_SELECT_NEW_CHOSEN, // a different clip is now "special"
|
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
|
||||||
TRACK_JACKSEND,
|
TRACK_JACKSEND,
|
||||||
|
@ -98,6 +101,7 @@ enum EVENT_TYPE {
|
||||||
LOOPER_PROGRESS,
|
LOOPER_PROGRESS,
|
||||||
LOOPER_LOOP_LENGTH,
|
LOOPER_LOOP_LENGTH,
|
||||||
LOOPER_LOOP_USE_AS_TEMPO,
|
LOOPER_LOOP_USE_AS_TEMPO,
|
||||||
|
LOOPER_BARS_TO_RECORD, // choose how many bars to record
|
||||||
|
|
||||||
/// Transport etc
|
/// Transport etc
|
||||||
METRONOME_ACTIVE,
|
METRONOME_ACTIVE,
|
||||||
|
@ -273,7 +277,7 @@ class EventLooperBarsToRecord : public EventBase
|
||||||
public:
|
public:
|
||||||
int type()
|
int type()
|
||||||
{
|
{
|
||||||
return int(EVENT_LOOPER_BARS_TO_RECORD);
|
return int(LOOPER_BARS_TO_RECORD);
|
||||||
}
|
}
|
||||||
uint32_t size()
|
uint32_t size()
|
||||||
{
|
{
|
||||||
|
@ -600,6 +604,26 @@ public:
|
||||||
EventStateSaveFinish() {};
|
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
|
class EventGridEvent : public EventBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -625,6 +649,7 @@ public:
|
||||||
EventGridEvent(int t, int s, bool p): track(t), scene(s), pressed(p) {}
|
EventGridEvent(int t, int s, bool p): track(t), scene(s), pressed(p) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class EventGridState : public EventBase
|
class EventGridState : public EventBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -172,6 +172,14 @@ void handleDspEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========= GRID =====
|
// ========= 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: {
|
case Event::GRID_STATE: {
|
||||||
if ( availableRead >= sizeof(EventGridState) ) {
|
if ( availableRead >= sizeof(EventGridState) ) {
|
||||||
EventGridState ev;
|
EventGridState ev;
|
||||||
|
@ -265,10 +273,12 @@ void handleDspEvents()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Event::EVENT_LOOPER_BARS_TO_RECORD: {
|
case Event::LOOPER_BARS_TO_RECORD: {
|
||||||
|
if ( availableRead >= sizeof(EventLooperBarsToRecord) ) {
|
||||||
EventLooperBarsToRecord ev;
|
EventLooperBarsToRecord ev;
|
||||||
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperBarsToRecord) );
|
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperBarsToRecord) );
|
||||||
jack->getLogic()->looperBarsToRecord( ev.track, ev.scene, ev.bars );
|
jack->getLogic()->looperBarsToRecord( ev.track, ev.scene, ev.bars );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Event::LOOPER_LOOP_USE_AS_TEMPO: {
|
case Event::LOOPER_LOOP_USE_AS_TEMPO: {
|
||||||
|
|
|
@ -140,6 +140,13 @@ void handleGuiEvents()
|
||||||
//jack->setLooperLoopLength( ev.track, ev.scale );
|
//jack->setLooperLoopLength( ev.track, ev.scale );
|
||||||
} break;
|
} 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: {
|
case Event::LOOPER_PROGRESS: {
|
||||||
if ( availableRead >= sizeof(EventLooperProgress) ) {
|
if ( availableRead >= sizeof(EventLooperProgress) ) {
|
||||||
EventLooperProgress ev;
|
EventLooperProgress ev;
|
||||||
|
|
|
@ -156,8 +156,20 @@ void Logic::looperBarsToRecord(int t, int s, int b)
|
||||||
{
|
{
|
||||||
if ( t >= 0 && t < NTRACKS ) {
|
if ( t >= 0 && t < NTRACKS ) {
|
||||||
jack->getLooper( t )->getClip( s )->setBarsToRecord(b);
|
jack->getLooper( t )->getClip( s )->setBarsToRecord(b);
|
||||||
} else {
|
} else { LUPPP_WARN("invalid track number %i: check controller map has \"track\" field.", t );
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#define LUPPP_LOGIC_H
|
#define LUPPP_LOGIC_H
|
||||||
|
|
||||||
#include "event.hxx"
|
#include "event.hxx"
|
||||||
|
#include "avtk/clipselector.hxx"
|
||||||
|
|
||||||
/** Logic
|
/** Logic
|
||||||
* This class contains an interface exposing most functionality in Luppp. The
|
* This class contains an interface exposing most functionality in Luppp. The
|
||||||
|
@ -63,6 +64,7 @@ public:
|
||||||
void looperUseAsTempo(int track, int scene);
|
void looperUseAsTempo(int track, int scene);
|
||||||
void looperClipLenght(int track, int scene, int lenght);
|
void looperClipLenght(int track, int scene, int lenght);
|
||||||
void looperBarsToRecord(int track, int scene, int bars);
|
void looperBarsToRecord(int track, int scene, int bars);
|
||||||
|
void setupClips(Avtk::ClipState clips[], int clipNum, int t);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LUPPP_LOGIC_H
|
#endif // LUPPP_LOGIC_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue