summaryrefslogtreecommitdiff
path: root/libs/surfaces
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-12-12 13:29:54 +0100
committerRobin Gareus <robin@gareus.org>2017-12-12 14:08:45 +0100
commite3340cdf0197ef326536b24102d076e9399f48c3 (patch)
tree25ca804f30278e6b9069cdd44398102f9f92b27d /libs/surfaces
parentb117910c29cf45fad5a2fa37fe683868fd0b028c (diff)
Prepare for FaderPort16 (ctrl-protocol)
Diffstat (limited to 'libs/surfaces')
-rw-r--r--libs/surfaces/faderport8/faderport8.cc51
-rw-r--r--libs/surfaces/faderport8/faderport8.h2
-rw-r--r--libs/surfaces/faderport8/fp8_base.h4
-rw-r--r--libs/surfaces/faderport8/fp8_strip.cc60
-rw-r--r--libs/surfaces/faderport8/fp8_strip.h6
-rw-r--r--libs/surfaces/faderport8/gui.cc4
6 files changed, 104 insertions, 23 deletions
diff --git a/libs/surfaces/faderport8/faderport8.cc b/libs/surfaces/faderport8/faderport8.cc
index 2e52926183..bc48261c0a 100644
--- a/libs/surfaces/faderport8/faderport8.cc
+++ b/libs/surfaces/faderport8/faderport8.cc
@@ -86,7 +86,11 @@ debug_2byte_msg (std::string const& msg, int b0, int b1)
}
FaderPort8::FaderPort8 (Session& s)
+#ifdef FADERPORT16
+ : ControlProtocol (s, _("PreSonus FaderPort16"))
+#else
: ControlProtocol (s, _("PreSonus FaderPort8"))
+#endif
, AbstractUI<FaderPort8Request> (name())
, _connection_state (ConnectionState (0))
, _device_active (false)
@@ -95,6 +99,7 @@ FaderPort8::FaderPort8 (Session& s)
, _parameter_off (0)
, _show_presets (false)
, _showing_well_known (0)
+ , _timer_divider (0)
, _blink_onoff (false)
, _shift_lock (false)
, _shift_pressed (0)
@@ -109,8 +114,13 @@ FaderPort8::FaderPort8 (Session& s)
boost::shared_ptr<ARDOUR::Port> inp;
boost::shared_ptr<ARDOUR::Port> outp;
+#ifdef FADERPORT16
inp = AudioEngine::instance()->register_input_port (DataType::MIDI, "FaderPort8 Recv", true);
outp = AudioEngine::instance()->register_output_port (DataType::MIDI, "FaderPort8 Send", true);
+#else
+ inp = AudioEngine::instance()->register_input_port (DataType::MIDI, "FaderPort16 Recv", true);
+ outp = AudioEngine::instance()->register_output_port (DataType::MIDI, "FaderPort16 Send", true);
+#endif
_input_port = boost::dynamic_pointer_cast<AsyncMIDIPort>(inp);
_output_port = boost::dynamic_pointer_cast<AsyncMIDIPort>(outp);
@@ -118,8 +128,13 @@ FaderPort8::FaderPort8 (Session& s)
throw failed_constructor();
}
+#ifdef FADERPORT16
_input_bundle.reset (new ARDOUR::Bundle (_("FaderPort8 (Receive)"), true));
_output_bundle.reset (new ARDOUR::Bundle (_("FaderPort8 (Send) "), false));
+#else
+ _input_bundle.reset (new ARDOUR::Bundle (_("FaderPort16 (Receive)"), true));
+ _output_bundle.reset (new ARDOUR::Bundle (_("FaderPort16 (Send) "), false));
+#endif
_input_bundle->add_channel (
inp->name(),
@@ -241,6 +256,14 @@ FaderPort8::periodic ()
_musical_time.clear ();
}
+#ifdef FADERPORT16
+ /* every second, send "running" */
+ if (++_timer_divider == 10) {
+ _timer_divider = 0;
+ tx_midi3 (0xa0, 0x00, 0x00);
+ }
+#endif
+
/* update stripables */
Periodic ();
return true;
@@ -322,6 +345,7 @@ FaderPort8::connected ()
_blink_onoff = false;
_shift_lock = false;
_shift_pressed = 0;
+ _timer_divider = 0;
start_midi_handling ();
_ctrls.initialize ();
@@ -553,13 +577,25 @@ void
FaderPort8::controller_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb)
{
debug_2byte_msg ("CC", tb->controller_number, tb->value);
- // encoder
- // val Bit 7 = direction, Bits 0-6 = number of steps
+ /* encoder
+ * FaderPort8:
+ * val Bit 7 = direction, Bits 0-6 = number of steps
+ * FaderPort16:
+ * val Bit 6 = direction, Bits 0-5 = number of steps
+ */
+#ifdef FADERPORT16
+ static const uint8_t dir_mask = 0x20;
+ static const uint8_t step_mask = 0x1f;
+#else
+ static const uint8_t dir_mask = 0x40;
+ static const uint8_t step_mask = 0x3f;
+#endif
+
if (tb->controller_number == 0x3c) {
- encoder_navigate (tb->value & 0x40 ? true : false, tb->value & 0x3f);
+ encoder_navigate (tb->value & dir_mask ? true : false, tb->value & step_mask);
}
if (tb->controller_number == 0x10) {
- encoder_parameter (tb->value & 0x40 ? true : false, tb->value & 0x3f);
+ encoder_parameter (tb->value & dir_mask ? true : false, tb->value & step_mask);
}
}
@@ -569,7 +605,12 @@ FaderPort8::note_on_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb)
debug_2byte_msg ("ON", tb->note_number, tb->velocity);
/* fader touch */
- if (tb->note_number >= 0x68 && tb->note_number <= 0x6f) {
+#ifdef FaderPort16
+ static const uint8_t touch_id_uppper = 0x77;
+#else
+ static const uint8_t touch_id_uppper = 0x6f;
+#endif
+ if (tb->note_number >= 0x68 && tb->note_number <= touch_id_uppper) {
_ctrls.midi_touch (tb->note_number - 0x68, tb->velocity);
return;
}
diff --git a/libs/surfaces/faderport8/faderport8.h b/libs/surfaces/faderport8/faderport8.h
index 4058ea248b..30a3f10d18 100644
--- a/libs/surfaces/faderport8/faderport8.h
+++ b/libs/surfaces/faderport8/faderport8.h
@@ -228,6 +228,8 @@ private:
std::string const& timecode () const { return _timecode; }
std::string const& musical_time () const { return _musical_time; }
+ int _timer_divider;
+
bool show_meters () const { return _scribble_mode & 1; }
bool show_panner () const { return _scribble_mode & 2; }
diff --git a/libs/surfaces/faderport8/fp8_base.h b/libs/surfaces/faderport8/fp8_base.h
index f83b916738..70f7779894 100644
--- a/libs/surfaces/faderport8/fp8_base.h
+++ b/libs/surfaces/faderport8/fp8_base.h
@@ -127,7 +127,11 @@ private:
d.push_back (0x00);
d.push_back (0x01);
d.push_back (0x06);
+#ifdef FADERPORT16
+ d.push_back (0x16);
+#else
d.push_back (0x02);
+#endif
}
};
diff --git a/libs/surfaces/faderport8/fp8_strip.cc b/libs/surfaces/faderport8/fp8_strip.cc
index be1122a03f..0aa64e1cb9 100644
--- a/libs/surfaces/faderport8/fp8_strip.cc
+++ b/libs/surfaces/faderport8/fp8_strip.cc
@@ -37,23 +37,49 @@ uint8_t /* static */
FP8Strip::midi_ctrl_id (CtrlElement type, uint8_t id)
{
assert (id < N_STRIPS);
- switch (type) {
- case BtnSolo:
- return 0x08 + id;
- case BtnMute:
- return 0x10 + id;
- case BtnSelect:
- return 0x18 + id;
- case Fader:
- return 0xe0 + id;
- case Meter:
- return 0xd0 + id;
- case Redux:
- return 0xd8 + id;
- case BarVal:
- return 0x30 + id;
- case BarMode:
- return 0x38 + id;
+ if (id < 8) {
+ switch (type) {
+ case BtnSolo:
+ return 0x08 + id;
+ case BtnMute:
+ return 0x10 + id;
+ case BtnSelect:
+ return 0x18 + id;
+ case Fader:
+ return 0xe0 + id;
+ case Meter:
+ return 0xd0 + id;
+ case Redux:
+ return 0xd8 + id;
+ case BarVal:
+ return 0x30 + id;
+ case BarMode:
+ return 0x38 + id;
+ }
+ } else {
+ id -= 8;
+ switch (type) {
+ case BtnSolo:
+ return 0x50 + id;
+ case BtnMute:
+ return 0x78 + id;
+ case BtnSelect:
+ if (id == 0) { // strip 8
+ return 0x07;
+ } else {
+ return 0x21 + id;
+ }
+ case Fader:
+ return 0xe8 + id;
+ case Meter:
+ return 0xc0 + id;
+ case Redux:
+ return 0xc8 + id;
+ case BarVal:
+ return 0x40 + id;
+ case BarMode:
+ return 0x48 + id;
+ }
}
assert (0);
return 0;
diff --git a/libs/surfaces/faderport8/fp8_strip.h b/libs/surfaces/faderport8/fp8_strip.h
index c301dad7ed..c3fc749f97 100644
--- a/libs/surfaces/faderport8/fp8_strip.h
+++ b/libs/surfaces/faderport8/fp8_strip.h
@@ -28,7 +28,11 @@
#include "fp8_base.h"
#include "fp8_button.h"
-#define N_STRIPS 8
+#ifdef FADERPORT16
+# define N_STRIPS 16
+#else
+# define N_STRIPS 8
+#endif
namespace ARDOUR {
class Stripable;
diff --git a/libs/surfaces/faderport8/gui.cc b/libs/surfaces/faderport8/gui.cc
index 3a620d3607..b9543d12c6 100644
--- a/libs/surfaces/faderport8/gui.cc
+++ b/libs/surfaces/faderport8/gui.cc
@@ -93,7 +93,11 @@ FP8GUI::FP8GUI (FaderPort8& p)
table.set_homogeneous (false);
std::string data_file_path;
+#ifdef FADERPORT16
+ string name = "faderport16-small.png";
+#else
string name = "faderport8-small.png";
+#endif
Searchpath spath(ARDOUR::ardour_data_search_path());
spath.add_subdirectory_to_paths ("icons");
find_file (spath, name, data_file_path);