-Master track has BPM dial, working but scrubbing trought metro

main
Harry van Haaren 2013-05-16 17:16:18 +01:00
parent dbf12a4407
commit d39fe8b948
6 changed files with 58 additions and 36 deletions

View File

@ -40,6 +40,8 @@ class Dial : public Fl_Slider
w = _w;
h = _h;
drawLabel = true;
// * 0.9 for line width to remain inside redraw area
if ( w > h )
radius = (h / 2.f)*0.9;
@ -65,11 +67,16 @@ class Dial : public Fl_Slider
int mouseClickedY;
bool mouseClicked;
bool drawLabel;
void draw()
{
if (damage() & FL_DAMAGE_ALL)
{
draw_label();
if ( drawLabel )
{
draw_label();
}
cairo_t *cr = Fl::cairo_cc();
@ -96,8 +103,6 @@ class Dial : public Fl_Slider
cairo_stroke(cr);
cairo_restore( cr );
}
}

View File

@ -27,6 +27,8 @@ namespace Event
METRONOME_ACTIVE,
TIME_BPM,
GUI_PRINT,
};
};
@ -134,6 +136,18 @@ class EventMetronomeActive : public EventBase
EventMetronomeActive(bool a) : active(a) {}
};
class EventTimeBPM : public EventBase
{
public:
int type() { return int(TIME_BPM); }
uint32_t size() { return sizeof(EventTimeBPM); }
float bpm;
EventTimeBPM(){}
EventTimeBPM(float b) : bpm(b) {}
};
// prints the string S in the GUI console
class EventGuiPrint : public EventBase

View File

@ -68,6 +68,12 @@ void handleDspEvents()
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperLoopLength) );
jack->setLooperLoopLength( ev.track, ev.scale );
} break; }
case Event::TIME_BPM: {
if ( availableRead >= sizeof(EventTimeBPM) ) {
EventTimeBPM ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventTimeBPM) );
jack->getTimeManager()->setBpm(ev.bpm);
} break; }
default:
{
// just do nothing

View File

@ -26,38 +26,21 @@ static void gmastertrack_button_callback(Fl_Widget *w, void *data) {
cout << "Button " << track << " " << w->label() << " clicked" << endl;
if ( strcmp( w->label() , "Rec" ) == 0 )
{
EventLooperState e = EventLooperState(track,Looper::STATE_RECORD_QUEUED);
writeToDspRingbuffer( &e );
}
else if ( strcmp( w->label() , "Play" ) == 0 )
{
EventLooperState e = EventLooperState(track,Looper::STATE_PLAY_QUEUED);
writeToDspRingbuffer( &e );
}
else if ( strcmp( w->label() , "Stop" ) == 0 )
{
EventLooperState e = EventLooperState(track,Looper::STATE_STOP_QUEUED);
writeToDspRingbuffer( &e );
}
else if ( strcmp( w->label() , "+" ) == 0 )
{
EventLooperLoopLength e = EventLooperLoopLength(track, 2);
writeToDspRingbuffer( &e );
}
else if ( strcmp( w->label() , "-" ) == 0 )
{
EventLooperLoopLength e = EventLooperLoopLength(track, 0.5);
writeToDspRingbuffer( &e );
}
else if ( strcmp( w->label(), "Metro" ) == 0 )
if ( strcmp( w->label(), "Metro" ) == 0 )
{
Avtk::Button* b = (Avtk::Button*)w;
b->value( !b->value() );
EventMetronomeActive e = EventMetronomeActive( b->value() );
writeToDspRingbuffer( &e );
}
else if ( strcmp( w->label(), "BPM" ) == 0 )
{
Avtk::Dial* b = (Avtk::Dial*)w;
float bpm = b->value() * 160 + 60; // 60 - 220
EventTimeBPM e = EventTimeBPM( bpm );
writeToDspRingbuffer( &e );
cout << "GUI writing bpm = " << bpm << endl;
}
else
{
cout << __FILE__ << __LINE__ << " Error: unknown command string" << endl;
@ -79,9 +62,10 @@ class GMasterTrack : public Fl_Group
button5(x +57, y + 84, 48, 18,"+"),
button6(x + 5, y +104, 18, 18,"6"),
*/
metronomeButton(x + 5,y + 24,140,30,"Metro")
metronomeButton(x + 5,y + 24,140,30,"Metro"),
dial1(x+25-22, y +75, 44, 44, "BPM")
/*
dial1(x+15, y +155, 24, 24, "A"),
dial2(x+45, y +155, 24, 24, "B"),
dial3(x+75, y +155, 24, 24, "C")
*/
@ -96,6 +80,7 @@ class GMasterTrack : public Fl_Group
button6.callback( gmastertrack_button_callback, &ID );
*/
metronomeButton.callback( gmastertrack_button_callback, 0 );
dial1.callback( gmastertrack_button_callback, 0 );
end(); // close the group
}
@ -121,8 +106,9 @@ class GMasterTrack : public Fl_Group
Avtk::Button button6;
*/
Avtk::LightButton metronomeButton;
/*
Avtk::Dial dial1;
/*
Avtk::Dial dial2;
Avtk::Dial dial3;
*/

View File

@ -47,6 +47,11 @@ static void gtrack_button_callback(Fl_Widget *w, void *data) {
EventLooperLoopLength e = EventLooperLoopLength(track, 0.5);
writeToDspRingbuffer( &e );
}
else if ( strcmp( w->label() , "Vol" ) == 0 )
{
EventLooperLoopLength e = EventLooperLoopLength(track, 0.5);
writeToDspRingbuffer( &e );
}
else
{
cout << __FILE__ << __LINE__ << " Error: unknown command string" << endl;
@ -69,9 +74,11 @@ class GTrack : public Fl_Group
button6(x + 5, y +104, 18, 18,"6"),
dial1(x+15, y +155, 24, 24, "A"),
dial2(x+45, y +155, 24, 24, "B"),
dial3(x+75, y +155, 24, 24, "C"),
volume(x+55-22, y +175, 34, 34, "Vol"),
dial1(x+15, y +135, 24, 24, "A"),
dial2(x+45, y +135, 24, 24, "B"),
dial3(x+75, y +135, 24, 24, "C"),
progress(x+5, y+3, 100, 15, "prog")
{
@ -84,6 +91,8 @@ class GTrack : public Fl_Group
button5.callback( gtrack_button_callback, &ID );
button6.callback( gtrack_button_callback, &ID );
volume.callback( gtrack_button_callback, 0 );
progress.maximum(1.0f);
progress.minimum(0.0f);
@ -108,6 +117,8 @@ class GTrack : public Fl_Group
Avtk::Button button5;
Avtk::Button button6;
Avtk::Dial volume;
Avtk::Dial dial1;
Avtk::Dial dial2;
Avtk::Dial dial3;

View File

@ -23,7 +23,7 @@ class TimeManager
{
}
void setBpm(int b)
void setBpm(float b)
{
char buffer [50];
sprintf (buffer, "%d", b);