lppro: scroll text method (doesn't seem to work) and new sysex header vector

This commit is contained in:
Paul Davis 2023-07-05 09:46:17 -06:00
parent 599998bd1f
commit 36ada549b2
2 changed files with 45 additions and 15 deletions

View file

@ -71,15 +71,13 @@ using namespace Gtkmm2ext;
#define NOVATION 0x1235 #define NOVATION 0x1235
#define LAUNCHPADPROMK3 0x0123 #define LAUNCHPADPROMK3 0x0123
static const std::vector<MIDI::byte> sysex_header ({ 0xf0, 0x00, 0x20, 0x29, 0x2, 0xe });
bool bool
LaunchPadPro::available () LaunchPadPro::available ()
{ {
bool rv = LIBUSB_SUCCESS == libusb_init (0); /* no preconditions other than the device being present */
if (rv) { return true;
libusb_exit (0);
}
return rv;
} }
bool bool
@ -197,8 +195,8 @@ LaunchPadPro::begin_using_device ()
DEBUG_TRACE (DEBUG::Launchpad, "begin using device\n"); DEBUG_TRACE (DEBUG::Launchpad, "begin using device\n");
set_device_mode (Programmer); set_device_mode (Programmer);
// all_pads_off (); scroll_text ("hello, world", 13, true, 3);
all_pads_on ();
#if 0 #if 0
init_buttons (true); init_buttons (true);
init_touch_strip (false); init_touch_strip (false);
@ -531,32 +529,38 @@ void
LaunchPadPro::set_device_mode (DeviceMode m) LaunchPadPro::set_device_mode (DeviceMode m)
{ {
/* LP Pro MK3 programming manual, pages 14 and 18 */ /* LP Pro MK3 programming manual, pages 14 and 18 */
MidiByteArray msg (9, 0xf0, 0x00, 0x20, 0x29, 0x2, 0xe, 0x10, 0x0, 0xf7); MidiByteArray msg (sysex_header);
switch (m) { switch (m) {
case Standalone: case Standalone:
/* no edit necessary */ msg.push_back (0x10);
msg.push_back (0x0);
break; break;
case DAW: case DAW:
msg.push_back (0x10);
msg.push_back (0x1);
msg[6] = 0x10;
msg[7] = 0x1; msg[7] = 0x1;
break; break;
case LiveSession: case LiveSession:
msg[6] = 0xe; msg.push_back (0xe);
msg[7] = 0x0; msg.push_back (0x0);
break; break;
case Programmer: case Programmer:
msg[6] = 0xe; msg.push_back (0xe);
msg[7] = 0x1; msg.push_back (0x1);
break; break;
} }
msg.push_back (0xf7);
if (m == Programmer) { if (m == Programmer) {
std::cerr << "Send to port 1 " << msg << " to enter mode " << m << std::endl; std::cerr << "Send to port 1 " << msg << " of size " << msg.size() << " to enter mode " << m << std::endl;
write (msg); write (msg);
} else { } else {
std::cerr << "back to live mode\n"; std::cerr << "back to live mode\n";
MidiByteArray first_msg (9, 0xf0, 0x00, 0x20, 0x29, 0x2, 0xe, 0xe, 0x0, 0xf7); MIDI::byte m[] = {0xf0, 0x00, 0x20, 0x29, 0x2, 0xe, 0xe, 0x0, 0xf7};
MidiByteArray first_msg (9, m);
write (first_msg); write (first_msg);
} }
} }
@ -684,3 +688,27 @@ LaunchPadPro::daw_write (MIDI::byte const * data, size_t size)
{ {
_daw_out_port->write (data, size, 0); _daw_out_port->write (data, size, 0);
} }
void
LaunchPadPro::scroll_text (std::string const & txt, int color, bool loop, float speed)
{
MidiByteArray msg (sysex_header);
msg.push_back (0x32);
msg.push_back (color);
msg.push_back (loop ? 1: 0);
for (std::string::size_type i = 0; i < txt.size(); ++i) {
msg.push_back (txt[i] & 0xf7);
}
msg.push_back (0xf7);
write (msg);
if (speed != 0.f) {
msg[sysex_header.size() + 3] = (MIDI::byte) (floor (1.f + (speed * 6.f)));
msg[sysex_header.size() + 4] = 0xf7;
msg.resize (sysex_header.size() + 5);
write (msg);
}
}

View file

@ -246,6 +246,8 @@ class LaunchPadPro : public MIDISurface
void reconnect_for_programmer (); void reconnect_for_programmer ();
void reconnect_for_session (); void reconnect_for_session ();
void scroll_text (std::string const &, int color, bool loop, float speed = 0);
mutable LPPRO_GUI* _gui; mutable LPPRO_GUI* _gui;
void build_gui (); void build_gui ();
}; };