basic code to get/set pressure mode to/from the push2
This commit is contained in:
parent
6946bdc083
commit
b822d8be36
@ -141,6 +141,7 @@ Push2::Push2 (ARDOUR::Session& s)
|
|||||||
, _in_key (true)
|
, _in_key (true)
|
||||||
, octave_shift (0)
|
, octave_shift (0)
|
||||||
, percussion (false)
|
, percussion (false)
|
||||||
|
, _pressure_mode (AfterTouch)
|
||||||
{
|
{
|
||||||
context = Cairo::Context::create (frame_buffer);
|
context = Cairo::Context::create (frame_buffer);
|
||||||
|
|
||||||
@ -709,6 +710,19 @@ void
|
|||||||
Push2::handle_midi_sysex (MIDI::Parser&, MIDI::byte* raw_bytes, size_t sz)
|
Push2::handle_midi_sysex (MIDI::Parser&, MIDI::byte* raw_bytes, size_t sz)
|
||||||
{
|
{
|
||||||
DEBUG_TRACE (DEBUG::Push2, string_compose ("Sysex, %1 bytes\n", sz));
|
DEBUG_TRACE (DEBUG::Push2, string_compose ("Sysex, %1 bytes\n", sz));
|
||||||
|
MidiByteArray msg (sz, raw_bytes);
|
||||||
|
MidiByteArray aftertouch_mode_response (9, 0xF0, 0x00, 0x21, 0x1D, 0x01, 0x01, 0x1F, 0x0, 0xF7);
|
||||||
|
MidiByteArray polypress_mode_response (9, 0xF0, 0x00, 0x21, 0x1D, 0x01, 0x01, 0x1F, 0x1, 0xF7);
|
||||||
|
|
||||||
|
if (msg == aftertouch_mode_response) {
|
||||||
|
_pressure_mode = AfterTouch;
|
||||||
|
PressureModeChange (AfterTouch);
|
||||||
|
cerr << "Pressure mod eis after\n";
|
||||||
|
} else if (msg == polypress_mode_response) {
|
||||||
|
_pressure_mode = PolyPressure;
|
||||||
|
PressureModeChange (PolyPressure);
|
||||||
|
cerr << "Pressure mod eis poly\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1336,7 +1350,7 @@ Push2::connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boo
|
|||||||
|
|
||||||
g_usleep (100000);
|
g_usleep (100000);
|
||||||
DEBUG_TRACE (DEBUG::FaderPort, "device now connected for both input and output\n");
|
DEBUG_TRACE (DEBUG::FaderPort, "device now connected for both input and output\n");
|
||||||
// connected ();
|
connected ();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_TRACE (DEBUG::FaderPort, "Device disconnected (input or output or both) or not yet fully connected\n");
|
DEBUG_TRACE (DEBUG::FaderPort, "Device disconnected (input or output or both) or not yet fully connected\n");
|
||||||
@ -1349,6 +1363,12 @@ Push2::connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boo
|
|||||||
return true; /* connection status changed */
|
return true; /* connection status changed */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Push2::connected ()
|
||||||
|
{
|
||||||
|
request_pressure_mode ();
|
||||||
|
}
|
||||||
|
|
||||||
boost::shared_ptr<Port>
|
boost::shared_ptr<Port>
|
||||||
Push2::output_port()
|
Push2::output_port()
|
||||||
{
|
{
|
||||||
@ -1735,3 +1755,29 @@ Push2::set_current_layout (Push2Layout* layout)
|
|||||||
_current_layout->on_show ();
|
_current_layout->on_show ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Push2::request_pressure_mode ()
|
||||||
|
{
|
||||||
|
MidiByteArray msg (8, 0xF0, 0x00, 0x21, 0x1D, 0x01, 0x01, 0x1F, 0xF7);
|
||||||
|
write (msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Push2::set_pressure_mode (PressureMode pm)
|
||||||
|
{
|
||||||
|
MidiByteArray msg (9, 0xF0, 0x00, 0x21, 0x1D, 0x01, 0x01, 0x1E, 0x0, 0xF7);
|
||||||
|
|
||||||
|
switch (pm) {
|
||||||
|
case AfterTouch:
|
||||||
|
/* nothing to do, message is correct */
|
||||||
|
break;
|
||||||
|
case PolyPressure:
|
||||||
|
msg[7] = 0x1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
write (msg);
|
||||||
|
}
|
||||||
|
@ -303,6 +303,11 @@ class Push2 : public ARDOUR::ControlProtocol
|
|||||||
KnobBorder,
|
KnobBorder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum PressureMode {
|
||||||
|
AfterTouch,
|
||||||
|
PolyPressure,
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Push2 (ARDOUR::Session&);
|
Push2 (ARDOUR::Session&);
|
||||||
~Push2 ();
|
~Push2 ();
|
||||||
@ -355,6 +360,10 @@ class Push2 : public ARDOUR::ControlProtocol
|
|||||||
static const int cols;
|
static const int cols;
|
||||||
static const int rows;
|
static const int rows;
|
||||||
|
|
||||||
|
PressureMode pressure_mode () const { return _pressure_mode; }
|
||||||
|
void set_pressure_mode (PressureMode);
|
||||||
|
PBD::Signal1<void,PressureMode> PressureModeChange;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
libusb_device_handle *handle;
|
libusb_device_handle *handle;
|
||||||
uint8_t frame_header[16];
|
uint8_t frame_header[16];
|
||||||
@ -540,6 +549,7 @@ class Push2 : public ARDOUR::ControlProtocol
|
|||||||
int connection_state;
|
int connection_state;
|
||||||
bool connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool yn);
|
bool connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool yn);
|
||||||
PBD::ScopedConnection port_connection;
|
PBD::ScopedConnection port_connection;
|
||||||
|
void connected ();
|
||||||
|
|
||||||
/* GUI */
|
/* GUI */
|
||||||
|
|
||||||
@ -574,6 +584,9 @@ class Push2 : public ARDOUR::ControlProtocol
|
|||||||
typedef std::map<ColorName,uint32_t> Colors;
|
typedef std::map<ColorName,uint32_t> Colors;
|
||||||
Colors colors;
|
Colors colors;
|
||||||
void fill_color_table ();
|
void fill_color_table ();
|
||||||
|
|
||||||
|
PressureMode _pressure_mode;
|
||||||
|
void request_pressure_mode ();
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace */
|
} /* namespace */
|
||||||
|
Loading…
Reference in New Issue
Block a user