mid_layout[n]->set_text (string_compose ("Inst %1", n));
}
+ build_maps ();
+
if (open ()) {
throw failed_constructor ();
}
- build_maps ();
}
Push2::~Push2 ()
return 0;
}
+void
+Push2::init_buttons ()
+{
+ ButtonID buttons[] = { Mute, Solo, Master, Up, Right, Left, Down, Note, Session, Mix, AddTrack, Delete, Undo,
+ Metronome, Shift, Select, Play, RecordEnable, Automate, Repeat, Note, Session, DoubleLoop,
+ Quantize, Duplicate,
+ };
+
+ for (size_t n = 0; n < sizeof (buttons) / sizeof (buttons[0]); ++n) {
+ Button* b = id_button_map[buttons[n]];
+
+ b->set_color (LED::White);
+ b->set_state (LED::OneShot24th);
+ write (b->state_msg());
+ }
+}
+
bool
Push2::probe ()
{
context->move_to (650, 25);
tc_clock_layout->update_from_cairo_context (context);
tc_clock_layout->show_in_cairo_context (context);
- context->move_to (650, 60);
+ context->move_to (650, 60);
bbt_clock_layout->update_from_cairo_context (context);
bbt_clock_layout->show_in_cairo_context (context);
periodic_connection = periodic_timeout->connect (sigc::mem_fun (*this, &Push2::periodic));
periodic_timeout->attach (main_loop()->get_context());
+ init_buttons ();
+
} else {
stop ();
MAKE_COLOR_BUTTON (Lower5, 25);
MAKE_COLOR_BUTTON (Lower6, 26);
MAKE_COLOR_BUTTON (Lower7, 27);
+ MAKE_COLOR_BUTTON (Master, 28);
MAKE_COLOR_BUTTON (Mute, 60);
MAKE_COLOR_BUTTON_PRESS (Solo, 61, &Push2::button_solo);
MAKE_COLOR_BUTTON (Stop, 29);
MAKE_WHITE_BUTTON (DoubleLoop, 117);
MAKE_WHITE_BUTTON (Quantize, 116);
MAKE_WHITE_BUTTON (Duplicate, 88);
- MAKE_WHITE_BUTTON (New, 87);
- MAKE_WHITE_BUTTON (FixedLength, 90);
+ MAKE_WHITE_BUTTON_PRESS (New, 87, &Push2::button_new);
+ MAKE_WHITE_BUTTON_PRESS (FixedLength, 90, &Push2::button_fixed_length);
MAKE_WHITE_BUTTON_PRESS (Up, 46, &Push2::button_up);
MAKE_WHITE_BUTTON_PRESS (Right, 45, &Push2::button_right);
MAKE_WHITE_BUTTON_PRESS (Down, 47, &Push2::button_down);
MAKE_WHITE_BUTTON (Accent, 57);
MAKE_WHITE_BUTTON (Scale, 58);
MAKE_WHITE_BUTTON (Layout, 31);
+ MAKE_WHITE_BUTTON (Note, 50);
+ MAKE_WHITE_BUTTON (Session, 51);
+ MAKE_WHITE_BUTTON (Layout, 31);
MAKE_WHITE_BUTTON (OctaveUp, 55);
MAKE_WHITE_BUTTON (PageRight, 63);
MAKE_WHITE_BUTTON (OctaveDown, 54);
return;
}
- b->second->set_color (LED::Red);
-
switch (session->record_status ()) {
case Session::Disabled:
- b->second->set_state (LED::Off);
+ b->second->set_color (LED::White);
+ b->second->set_state (LED::NoTransition);
break;
case Session::Enabled:
+ b->second->set_color (LED::Red);
b->second->set_state (LED::Blinking4th);
break;
case Session::Recording:
+ b->second->set_color (LED::Red);
b->second->set_state (LED::OneShot24th);
break;
}
void
Push2::notify_transport_state_changed ()
{
- IDButtonMap::iterator b = id_button_map.find (Play);
-
- if (b == id_button_map.end()) {
- return;
- }
+ Button* b = id_button_map[Play];
if (session->transport_rolling()) {
- b->second->set_state (LED::OneShot24th);
- b->second->set_color (LED::Green);
+ b->set_state (LED::OneShot24th);
+ b->set_color (LED::Green);
} else {
- b->second->set_state (LED::Off);
+
+ /* disable any blink on FixedLength from pending edit range op */
+ Button* fl = id_button_map[FixedLength];
+
+ fl->set_color (LED::Black);
+ fl->set_state (LED::NoTransition);
+ write (fl->state_msg());
+
+ b->set_color (LED::White);
+ b->set_state (LED::NoTransition);
}
- write (b->second->state_msg());
+ write (b->state_msg());
}
void
b->second->set_state (LED::Blinking4th);
b->second->set_color (LED::White);
} else {
- b->second->set_state (LED::Off);
+ b->second->set_color (LED::White);
+ b->second->set_state (LED::NoTransition);
}
write (b->second->state_msg ());
}
void
Push2::notify_solo_active_changed (bool yn)
{
- IDButtonMap::iterator b = id_button_map.find (Solo);
+ IDButtonMap::iterator b = id_button_map.find (Solo);
if (b == id_button_map.end()) {
return;
b->second->set_state (LED::Blinking4th);
b->second->set_color (LED::Red);
} else {
- b->second->set_state (LED::Off);
+ b->second->set_state (LED::NoTransition);
+ b->second->set_color (LED::White);
}
write (b->second->state_msg());
struct LED
{
enum State {
- Off,
+ NoTransition,
OneShot24th,
OneShot16th,
OneShot8th,
};
enum Colors {
+ Black = 0,
Red = 127,
Green = 126,
Blue = 125,
White = 122
};
- LED (uint8_t e) : _extra (e), _color_index (0), _state (Off) {}
+ LED (uint8_t e) : _extra (e), _color_index (0), _state (NoTransition) {}
virtual ~LED() {}
uint8_t extra () const { return _extra; }
, x (xx)
, y (yy) {}
- MidiByteArray state_msg () const { return MidiByteArray (3, 0x90|_state, _extra, (_state == Off) ? 0 : _color_index); }
+ MidiByteArray state_msg () const { return MidiByteArray (3, 0x90|_state, _extra, _color_index); }
int coord () const { return (y * 8) + x; }
int note_number() const { return extra(); }
, release_method (release)
{}
- MidiByteArray state_msg () const { return MidiByteArray (3, 0xb0|_state, _extra, (_state == Off) ? 0 : _color_index); }
+ MidiByteArray state_msg () const { return MidiByteArray (3, 0xb0|_state, _extra, _color_index); }
int controller_number() const { return extra(); }
ButtonID id;
typedef std::map<ButtonID,Button*> IDButtonMap;
IDButtonMap id_button_map;
+ void init_buttons ();
+
/* map of Pads by note number */
typedef std::map<int,Pad*> NNPadMap;
NNPadMap nn_pad_map;
void button_metronome ();
void button_repeat ();
void button_solo ();
+ void button_fixed_length ();
+ void button_new ();
/* widgets */