From c6bdf8f2ff9429ddc7a4bbce29e0749ad7c883a8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 17 Jun 2021 09:56:46 -0400 Subject: [PATCH] Factor out duplicated MidiByteArray --- libs/surfaces/cc121/cc121.h | 2 - .../control_protocol}/midi_byte_array.h | 3 + .../midi_byte_array.cc | 6 +- libs/surfaces/control_protocol/wscript | 3 +- libs/surfaces/faderport/faderport.h | 2 - .../launch_control_xl/launch_control_xl.h | 3 +- libs/surfaces/launch_control_xl/wscript | 1 - .../MSVCardour_mackie/ardour_mackie.vcproj | 8 -- libs/surfaces/mackie/controls.h | 2 +- libs/surfaces/mackie/led.h | 3 +- .../mackie/mackie_control_protocol.cc | 2 +- .../surfaces/mackie/mackie_control_protocol.h | 2 +- .../mackie/mackie_control_protocol_poll.cc | 3 +- libs/surfaces/mackie/meter.h | 3 +- libs/surfaces/mackie/midi_byte_array.cc | 97 --------------- libs/surfaces/mackie/midi_byte_array.h | 77 ------------ libs/surfaces/mackie/strip.h | 2 +- libs/surfaces/mackie/surface_port.h | 2 +- libs/surfaces/mackie/test.cc | 2 +- libs/surfaces/mackie/wscript | 1 - libs/surfaces/push2/midi_byte_array.cc | 115 ------------------ libs/surfaces/push2/midi_byte_array.h | 78 ------------ libs/surfaces/push2/push2.h | 3 +- libs/surfaces/push2/wscript | 1 - libs/surfaces/us2400/controls.h | 3 +- libs/surfaces/us2400/led.h | 3 +- libs/surfaces/us2400/meter.h | 3 +- libs/surfaces/us2400/midi_byte_array.cc | 96 --------------- libs/surfaces/us2400/midi_byte_array.h | 76 ------------ libs/surfaces/us2400/strip.h | 2 +- libs/surfaces/us2400/surface_port.h | 2 +- libs/surfaces/us2400/test.cc | 2 +- .../us2400/us2400_control_protocol.cc | 3 +- .../surfaces/us2400/us2400_control_protocol.h | 2 +- .../us2400/us2400_control_protocol_poll.cc | 3 +- libs/surfaces/us2400/wscript | 1 - 36 files changed, 38 insertions(+), 579 deletions(-) rename libs/surfaces/{launch_control_xl => control_protocol/control_protocol}/midi_byte_array.h (93%) rename libs/surfaces/{launch_control_xl => control_protocol}/midi_byte_array.cc (92%) delete mode 100644 libs/surfaces/mackie/midi_byte_array.cc delete mode 100644 libs/surfaces/mackie/midi_byte_array.h delete mode 100644 libs/surfaces/push2/midi_byte_array.cc delete mode 100644 libs/surfaces/push2/midi_byte_array.h delete mode 100644 libs/surfaces/us2400/midi_byte_array.cc delete mode 100644 libs/surfaces/us2400/midi_byte_array.h diff --git a/libs/surfaces/cc121/cc121.h b/libs/surfaces/cc121/cc121.h index 8d31a79042..37d209ab33 100644 --- a/libs/surfaces/cc121/cc121.h +++ b/libs/surfaces/cc121/cc121.h @@ -43,8 +43,6 @@ namespace PBD { //#include "pbd/signals.h" - -//#include "midi_byte_array.h" #include "types.h" #include "glibmm/main.h" diff --git a/libs/surfaces/launch_control_xl/midi_byte_array.h b/libs/surfaces/control_protocol/control_protocol/midi_byte_array.h similarity index 93% rename from libs/surfaces/launch_control_xl/midi_byte_array.h rename to libs/surfaces/control_protocol/control_protocol/midi_byte_array.h index c7d66c1b44..2b8cfaba4c 100644 --- a/libs/surfaces/launch_control_xl/midi_byte_array.h +++ b/libs/surfaces/control_protocol/control_protocol/midi_byte_array.h @@ -1,4 +1,7 @@ /* + * Copyright (C) 2006-2007 John Anderson + * Copyright (C) 2008-2016 Paul Davis + * Copyright (C) 2017 Ben Loftis * Copyright (C) 2018 Térence Clastres * * This program is free software; you can redistribute it and/or modify diff --git a/libs/surfaces/launch_control_xl/midi_byte_array.cc b/libs/surfaces/control_protocol/midi_byte_array.cc similarity index 92% rename from libs/surfaces/launch_control_xl/midi_byte_array.cc rename to libs/surfaces/control_protocol/midi_byte_array.cc index e25c25ea55..3380f65c61 100644 --- a/libs/surfaces/launch_control_xl/midi_byte_array.cc +++ b/libs/surfaces/control_protocol/midi_byte_array.cc @@ -1,4 +1,7 @@ /* + * Copyright (C) 2006-2007 John Anderson + * Copyright (C) 2008-2016 Paul Davis + * Copyright (C) 2017 Ben Loftis * Copyright (C) 2018 Térence Clastres * * This program is free software; you can redistribute it and/or modify @@ -15,7 +18,8 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "midi_byte_array.h" + +#include "control_protocol/midi_byte_array.h" #include #include diff --git a/libs/surfaces/control_protocol/wscript b/libs/surfaces/control_protocol/wscript index 76dda1118e..a16bedf949 100644 --- a/libs/surfaces/control_protocol/wscript +++ b/libs/surfaces/control_protocol/wscript @@ -9,7 +9,8 @@ out = 'build' controlcp_sources = [ 'basic_ui.cc', 'control_protocol.cc', - ] + 'midi_byte_array.cc', +] def options(opt): autowaf.set_options(opt) diff --git a/libs/surfaces/faderport/faderport.h b/libs/surfaces/faderport/faderport.h index e6ef738a4f..af9eeefd77 100644 --- a/libs/surfaces/faderport/faderport.h +++ b/libs/surfaces/faderport/faderport.h @@ -40,8 +40,6 @@ namespace PBD { //#include "pbd/signals.h" - -//#include "midi_byte_array.h" #include "types.h" #include "glibmm/main.h" diff --git a/libs/surfaces/launch_control_xl/launch_control_xl.h b/libs/surfaces/launch_control_xl/launch_control_xl.h index 4147260524..e07a97ed7d 100644 --- a/libs/surfaces/launch_control_xl/launch_control_xl.h +++ b/libs/surfaces/launch_control_xl/launch_control_xl.h @@ -36,10 +36,9 @@ #include "ardour/types.h" #include "control_protocol/control_protocol.h" +#include "control_protocol/midi_byte_array.h" #include "control_protocol/types.h" -#include "midi_byte_array.h" - namespace MIDI { class Parser; class Port; diff --git a/libs/surfaces/launch_control_xl/wscript b/libs/surfaces/launch_control_xl/wscript index e573101331..718dfa1480 100644 --- a/libs/surfaces/launch_control_xl/wscript +++ b/libs/surfaces/launch_control_xl/wscript @@ -22,7 +22,6 @@ def build(bld): launch_control_xl.cc controllers.cc interface.cc - midi_byte_array.cc leds.cc gui.cc ''' diff --git a/libs/surfaces/mackie/MSVCardour_mackie/ardour_mackie.vcproj b/libs/surfaces/mackie/MSVCardour_mackie/ardour_mackie.vcproj index 32383c2398..f235f1f7bc 100644 --- a/libs/surfaces/mackie/MSVCardour_mackie/ardour_mackie.vcproj +++ b/libs/surfaces/mackie/MSVCardour_mackie/ardour_mackie.vcproj @@ -319,10 +319,6 @@ RelativePath="..\meter.cc" > - - @@ -425,10 +421,6 @@ RelativePath="..\meter.h" > - - diff --git a/libs/surfaces/mackie/controls.h b/libs/surfaces/mackie/controls.h index d1a2b2931b..fe4345783e 100644 --- a/libs/surfaces/mackie/controls.h +++ b/libs/surfaces/mackie/controls.h @@ -29,11 +29,11 @@ #include +#include "control_protocol/midi_byte_array.h" #include "pbd/controllable.h" #include "pbd/signals.h" #include "mackie_control_exception.h" -#include "midi_byte_array.h" namespace ARDOUR { class AutomationControl; diff --git a/libs/surfaces/mackie/led.h b/libs/surfaces/mackie/led.h index 7bfbe4739c..4ee14bc24e 100644 --- a/libs/surfaces/mackie/led.h +++ b/libs/surfaces/mackie/led.h @@ -20,8 +20,9 @@ #ifndef __ardour_mackie_control_protocol_led_h__ #define __ardour_mackie_control_protocol_led_h__ +#include "control_protocol/midi_byte_array.h" + #include "controls.h" -#include "midi_byte_array.h" #include "types.h" namespace ArdourSurface { diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index d1015b915c..8bee58ea0d 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -66,10 +66,10 @@ #include "ardour/types.h" #include "ardour/audioengine.h" #include "ardour/vca_manager.h" +#include "control_protocol/midi_byte_array.h" #include "mackie_control_protocol.h" -#include "midi_byte_array.h" #include "mackie_control_exception.h" #include "device_profile.h" #include "subview.h" diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index aceea338fb..6e59a1fec0 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -38,9 +38,9 @@ #include "midi++/types.h" #include "ardour/types.h" #include "control_protocol/control_protocol.h" +#include "control_protocol/midi_byte_array.h" #include "types.h" -#include "midi_byte_array.h" #include "controls.h" #include "jog_wheel.h" #include "timer.h" diff --git a/libs/surfaces/mackie/mackie_control_protocol_poll.cc b/libs/surfaces/mackie/mackie_control_protocol_poll.cc index cdb9429354..f81fbee9ff 100644 --- a/libs/surfaces/mackie/mackie_control_protocol_poll.cc +++ b/libs/surfaces/mackie/mackie_control_protocol_poll.cc @@ -19,7 +19,8 @@ #include "mackie_control_protocol.h" -#include "midi_byte_array.h" +#include "control_protocol/midi_byte_array.h" + #include "surface_port.h" #include "pbd/pthread_utils.h" diff --git a/libs/surfaces/mackie/meter.h b/libs/surfaces/mackie/meter.h index 5046d1ca55..cb119f7591 100644 --- a/libs/surfaces/mackie/meter.h +++ b/libs/surfaces/mackie/meter.h @@ -20,8 +20,9 @@ #ifndef __ardour_mackie_control_protocol_meter_h__ #define __ardour_mackie_control_protocol_meter_h__ +#include "control_protocol/midi_byte_array.h" + #include "controls.h" -#include "midi_byte_array.h" namespace ArdourSurface { diff --git a/libs/surfaces/mackie/midi_byte_array.cc b/libs/surfaces/mackie/midi_byte_array.cc deleted file mode 100644 index d7eb38ac54..0000000000 --- a/libs/surfaces/mackie/midi_byte_array.cc +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2006-2007 John Anderson - * Copyright (C) 2008-2015 Paul Davis - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#include "midi_byte_array.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -MidiByteArray::MidiByteArray (size_t size, MIDI::byte array[]) - : std::vector() -{ - for (size_t i = 0; i < size; ++i) - { - push_back (array[i]); - } -} - -MidiByteArray::MidiByteArray (size_t count, MIDI::byte first, ...) - : vector() -{ - push_back (first); - va_list var_args; - va_start (var_args, first); - for (size_t i = 1; i < count; ++i) - { - MIDI::byte b = va_arg (var_args, int); - push_back (b); - } - va_end (var_args); -} - - -void MidiByteArray::copy (size_t count, MIDI::byte * arr) -{ - for (size_t i = 0; i < count; ++i) { - push_back (arr[i]); - } -} - -MidiByteArray & operator << (MidiByteArray & mba, const MIDI::byte & b) -{ - mba.push_back (b); - return mba; -} - -MidiByteArray & operator << (MidiByteArray & mba, const MidiByteArray & barr) -{ - back_insert_iterator bit (mba); - copy (barr.begin(), barr.end(), bit); - return mba; -} - -ostream & operator << (ostream & os, const MidiByteArray & mba) -{ - os << "["; - char fill = os.fill('0'); - for (MidiByteArray::const_iterator it = mba.begin(); it != mba.end(); ++it) { - if (it != mba.begin()) os << " "; - os << hex << setw(2) << (int)*it; - } - os.fill (fill); - os << dec; - os << "]"; - return os; -} - -MidiByteArray & operator << (MidiByteArray & mba, const std::string & st) -{ - /* note that this assumes that "st" is ASCII encoded - */ - - mba.insert (mba.end(), st.begin(), st.end()); - return mba; -} diff --git a/libs/surfaces/mackie/midi_byte_array.h b/libs/surfaces/mackie/midi_byte_array.h deleted file mode 100644 index 99497ad2d9..0000000000 --- a/libs/surfaces/mackie/midi_byte_array.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2006-2007 John Anderson - * Copyright (C) 2008-2012 Paul Davis - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef midi_byte_array_h -#define midi_byte_array_h - -#include -#include - -#include - -//#include -namespace MIDI { - typedef unsigned char byte; -} - -/** - To make building arrays of bytes easier. Thusly: - - MidiByteArray mba; - mba << 0xf0 << 0x00 << 0xf7; - - MidiByteArray buf; - buf << mba; - - MidiByteArray direct( 3, 0xf0, 0x00, 0xf7 ); - - cout << mba << endl; - cout << buf << endl; - cout << direct << endl; - - will all result in "f0 00 f7" being output to stdout -*/ -class MidiByteArray : public std::vector -{ -public: - MidiByteArray() : std::vector() {} - - MidiByteArray( size_t count, MIDI::byte array[] ); - - /** - Accepts a preceding count, and then a list of bytes - */ - MidiByteArray( size_t count, MIDI::byte first, ... ); - - /// copy the given number of bytes from the given array - void copy( size_t count, MIDI::byte arr[] ); -}; - -/// append the given byte to the end of the array -MidiByteArray & operator << ( MidiByteArray & mba, const MIDI::byte & b ); - -/// append the given string to the end of the array -MidiByteArray & operator << ( MidiByteArray & mba, const std::string & ); - -/// append the given array to the end of this array -MidiByteArray & operator << ( MidiByteArray & mba, const MidiByteArray & barr ); - -/// output the bytes as hex to the given stream -std::ostream & operator << ( std::ostream & os, const MidiByteArray & mba ); - -#endif diff --git a/libs/surfaces/mackie/strip.h b/libs/surfaces/mackie/strip.h index 377999ba0f..efb73345fc 100644 --- a/libs/surfaces/mackie/strip.h +++ b/libs/surfaces/mackie/strip.h @@ -30,12 +30,12 @@ #include "pbd/signals.h" #include "ardour/types.h" +#include "control_protocol/midi_byte_array.h" #include "control_protocol/types.h" #include "control_group.h" #include "types.h" #include "mackie_control_protocol.h" -#include "midi_byte_array.h" #include "device_info.h" namespace ARDOUR { diff --git a/libs/surfaces/mackie/surface_port.h b/libs/surfaces/mackie/surface_port.h index 4465667c4c..0656419e7d 100644 --- a/libs/surfaces/mackie/surface_port.h +++ b/libs/surfaces/mackie/surface_port.h @@ -24,8 +24,8 @@ #include "pbd/signals.h" +#include "control_protocol/midi_byte_array.h" -#include "midi_byte_array.h" #include "types.h" namespace MIDI { diff --git a/libs/surfaces/mackie/test.cc b/libs/surfaces/mackie/test.cc index 9befb1e931..5f9f52fa13 100644 --- a/libs/surfaces/mackie/test.cc +++ b/libs/surfaces/mackie/test.cc @@ -25,7 +25,7 @@ #include #include -#include "midi_byte_array.h" +#include "control_protocol/midi_byte_array.h" using namespace std; diff --git a/libs/surfaces/mackie/wscript b/libs/surfaces/mackie/wscript index 2ed12fb10b..24cd62db65 100644 --- a/libs/surfaces/mackie/wscript +++ b/libs/surfaces/mackie/wscript @@ -28,7 +28,6 @@ def build(bld): mackie_control_protocol.cc mcp_buttons.cc meter.cc - midi_byte_array.cc pot.cc strip.cc subview.cc diff --git a/libs/surfaces/push2/midi_byte_array.cc b/libs/surfaces/push2/midi_byte_array.cc deleted file mode 100644 index 28c2b46db4..0000000000 --- a/libs/surfaces/push2/midi_byte_array.cc +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2016 Paul Davis - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#include "midi_byte_array.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -MidiByteArray::MidiByteArray (size_t size, MIDI::byte array[]) - : std::vector() -{ - for (size_t i = 0; i < size; ++i) - { - push_back (array[i]); - } -} - -MidiByteArray::MidiByteArray (size_t count, MIDI::byte first, ...) - : vector() -{ - push_back (first); - va_list var_args; - va_start (var_args, first); - for (size_t i = 1; i < count; ++i) - { - MIDI::byte b = va_arg (var_args, int); - push_back (b); - } - va_end (var_args); -} - - -void MidiByteArray::copy (size_t count, MIDI::byte * arr) -{ - for (size_t i = 0; i < count; ++i) { - push_back (arr[i]); - } -} - -MidiByteArray & operator << (MidiByteArray & mba, const MIDI::byte & b) -{ - mba.push_back (b); - return mba; -} - -MidiByteArray & operator << (MidiByteArray & mba, const MidiByteArray & barr) -{ - back_insert_iterator bit (mba); - copy (barr.begin(), barr.end(), bit); - return mba; -} - -ostream & operator << (ostream & os, const MidiByteArray & mba) -{ - os << "["; - char fill = os.fill('0'); - for (MidiByteArray::const_iterator it = mba.begin(); it != mba.end(); ++it) { - if (it != mba.begin()) os << " "; - os << hex << setw(2) << (int)*it; - } - os.fill (fill); - os << dec; - os << "]"; - return os; -} - -MidiByteArray & operator << (MidiByteArray & mba, const std::string & st) -{ - /* note that this assumes that "st" is ASCII encoded - */ - - mba.insert (mba.end(), st.begin(), st.end()); - return mba; -} - -bool -MidiByteArray::compare_n (const MidiByteArray& other, MidiByteArray::size_type n) const -{ - MidiByteArray::const_iterator us = begin(); - MidiByteArray::const_iterator them = other.begin(); - - while (n && us != end() && them != other.end()) { - if ((*us) != (*them)) { - return false; - } - --n; - ++us; - ++them; - } - - return true; -} - diff --git a/libs/surfaces/push2/midi_byte_array.h b/libs/surfaces/push2/midi_byte_array.h deleted file mode 100644 index e336399849..0000000000 --- a/libs/surfaces/push2/midi_byte_array.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2016 Paul Davis - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef midi_byte_array_h -#define midi_byte_array_h - -#include -#include - -#include - -//#include -namespace MIDI { - typedef unsigned char byte; -} - -/** - To make building arrays of bytes easier. Thusly: - - MidiByteArray mba; - mba << 0xf0 << 0x00 << 0xf7; - - MidiByteArray buf; - buf << mba; - - MidiByteArray direct( 3, 0xf0, 0x00, 0xf7 ); - - cout << mba << endl; - cout << buf << endl; - cout << direct << endl; - - will all result in "f0 00 f7" being output to stdout -*/ -class MidiByteArray : public std::vector -{ -public: - MidiByteArray() : std::vector() {} - - MidiByteArray( size_t count, MIDI::byte array[] ); - - bool compare_n (const MidiByteArray& other, MidiByteArray::size_type len) const; - - /** - Accepts a preceding count, and then a list of bytes - */ - MidiByteArray( size_t count, MIDI::byte first, ... ); - - /// copy the given number of bytes from the given array - void copy( size_t count, MIDI::byte arr[] ); -}; - -/// append the given byte to the end of the array -MidiByteArray & operator << ( MidiByteArray & mba, const MIDI::byte & b ); - -/// append the given string to the end of the array -MidiByteArray & operator << ( MidiByteArray & mba, const std::string & ); - -/// append the given array to the end of this array -MidiByteArray & operator << ( MidiByteArray & mba, const MidiByteArray & barr ); - -/// output the bytes as hex to the given stream -std::ostream & operator << ( std::ostream & os, const MidiByteArray & mba ); - -#endif diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h index 220753d409..0395dc7f4f 100644 --- a/libs/surfaces/push2/push2.h +++ b/libs/surfaces/push2/push2.h @@ -36,12 +36,11 @@ #include "ardour/types.h" #include "control_protocol/control_protocol.h" +#include "control_protocol/midi_byte_array.h" #include "control_protocol/types.h" #include "gtkmm2ext/colors.h" -#include "midi_byte_array.h" - namespace Pango { class Layout; } diff --git a/libs/surfaces/push2/wscript b/libs/surfaces/push2/wscript index b595b1702b..dbeb66c598 100644 --- a/libs/surfaces/push2/wscript +++ b/libs/surfaces/push2/wscript @@ -22,7 +22,6 @@ def build(bld): buttons.cc canvas.cc interface.cc - midi_byte_array.cc leds.cc level_meter.cc gui.cc diff --git a/libs/surfaces/us2400/controls.h b/libs/surfaces/us2400/controls.h index 16f70e6c34..d1ca8ae42f 100644 --- a/libs/surfaces/us2400/controls.h +++ b/libs/surfaces/us2400/controls.h @@ -29,8 +29,9 @@ #include "pbd/controllable.h" #include "pbd/signals.h" +#include "control_protocol/midi_byte_array.h" + #include "us2400_control_exception.h" -#include "midi_byte_array.h" namespace ARDOUR { class AutomationControl; diff --git a/libs/surfaces/us2400/led.h b/libs/surfaces/us2400/led.h index c969c1a1d1..cae70b5029 100644 --- a/libs/surfaces/us2400/led.h +++ b/libs/surfaces/us2400/led.h @@ -19,8 +19,9 @@ #ifndef __ardour_us2400_control_protocol_led_h__ #define __ardour_us2400_control_protocol_led_h__ +#include "control_protocol/midi_byte_array.h" + #include "controls.h" -#include "midi_byte_array.h" #include "types.h" namespace ArdourSurface { diff --git a/libs/surfaces/us2400/meter.h b/libs/surfaces/us2400/meter.h index 8154282651..ede8f9a1cd 100644 --- a/libs/surfaces/us2400/meter.h +++ b/libs/surfaces/us2400/meter.h @@ -19,8 +19,9 @@ #ifndef __ardour_us2400_control_protocol_meter_h__ #define __ardour_us2400_control_protocol_meter_h__ +#include "control_protocol/midi_byte_array.h" + #include "controls.h" -#include "midi_byte_array.h" namespace ArdourSurface { diff --git a/libs/surfaces/us2400/midi_byte_array.cc b/libs/surfaces/us2400/midi_byte_array.cc deleted file mode 100644 index 1713a66d3f..0000000000 --- a/libs/surfaces/us2400/midi_byte_array.cc +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2017 Ben Loftis - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#include "midi_byte_array.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -MidiByteArray::MidiByteArray (size_t size, MIDI::byte array[]) - : std::vector() -{ - for (size_t i = 0; i < size; ++i) - { - push_back (array[i]); - } -} - -MidiByteArray::MidiByteArray (size_t count, MIDI::byte first, ...) - : vector() -{ - push_back (first); - va_list var_args; - va_start (var_args, first); - for (size_t i = 1; i < count; ++i) - { - MIDI::byte b = va_arg (var_args, int); - push_back (b); - } - va_end (var_args); -} - - -void MidiByteArray::copy (size_t count, MIDI::byte * arr) -{ - for (size_t i = 0; i < count; ++i) { - push_back (arr[i]); - } -} - -MidiByteArray & operator << (MidiByteArray & mba, const MIDI::byte & b) -{ - mba.push_back (b); - return mba; -} - -MidiByteArray & operator << (MidiByteArray & mba, const MidiByteArray & barr) -{ - back_insert_iterator bit (mba); - copy (barr.begin(), barr.end(), bit); - return mba; -} - -ostream & operator << (ostream & os, const MidiByteArray & mba) -{ - os << "["; - char fill = os.fill('0'); - for (MidiByteArray::const_iterator it = mba.begin(); it != mba.end(); ++it) { - if (it != mba.begin()) os << " "; - os << hex << setw(2) << (int)*it; - } - os.fill (fill); - os << dec; - os << "]"; - return os; -} - -MidiByteArray & operator << (MidiByteArray & mba, const std::string & st) -{ - /* note that this assumes that "st" is ASCII encoded - */ - - mba.insert (mba.end(), st.begin(), st.end()); - return mba; -} diff --git a/libs/surfaces/us2400/midi_byte_array.h b/libs/surfaces/us2400/midi_byte_array.h deleted file mode 100644 index 0f4469c8df..0000000000 --- a/libs/surfaces/us2400/midi_byte_array.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2017 Ben Loftis - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef midi_byte_array_h -#define midi_byte_array_h - -#include -#include - -#include - -//#include -namespace MIDI { - typedef unsigned char byte; -} - -/** - To make building arrays of bytes easier. Thusly: - - MidiByteArray mba; - mba << 0xf0 << 0x00 << 0xf7; - - MidiByteArray buf; - buf << mba; - - MidiByteArray direct( 3, 0xf0, 0x00, 0xf7 ); - - cout << mba << endl; - cout << buf << endl; - cout << direct << endl; - - will all result in "f0 00 f7" being output to stdout -*/ -class MidiByteArray : public std::vector -{ -public: - MidiByteArray() : std::vector() {} - - MidiByteArray( size_t count, MIDI::byte array[] ); - - /** - Accepts a preceding count, and then a list of bytes - */ - MidiByteArray( size_t count, MIDI::byte first, ... ); - - /// copy the given number of bytes from the given array - void copy( size_t count, MIDI::byte arr[] ); -}; - -/// append the given byte to the end of the array -MidiByteArray & operator << ( MidiByteArray & mba, const MIDI::byte & b ); - -/// append the given string to the end of the array -MidiByteArray & operator << ( MidiByteArray & mba, const std::string & ); - -/// append the given array to the end of this array -MidiByteArray & operator << ( MidiByteArray & mba, const MidiByteArray & barr ); - -/// output the bytes as hex to the given stream -std::ostream & operator << ( std::ostream & os, const MidiByteArray & mba ); - -#endif diff --git a/libs/surfaces/us2400/strip.h b/libs/surfaces/us2400/strip.h index ac983e1738..34196106e0 100644 --- a/libs/surfaces/us2400/strip.h +++ b/libs/surfaces/us2400/strip.h @@ -29,12 +29,12 @@ #include "pbd/signals.h" #include "ardour/types.h" +#include "control_protocol/midi_byte_array.h" #include "control_protocol/types.h" #include "control_group.h" #include "types.h" #include "us2400_control_protocol.h" -#include "midi_byte_array.h" #include "device_info.h" namespace ARDOUR { diff --git a/libs/surfaces/us2400/surface_port.h b/libs/surfaces/us2400/surface_port.h index 53c53b2cc6..79ab96ffd7 100644 --- a/libs/surfaces/us2400/surface_port.h +++ b/libs/surfaces/us2400/surface_port.h @@ -22,8 +22,8 @@ #include "pbd/signals.h" +#include "control_protocol/midi_byte_array.h" -#include "midi_byte_array.h" #include "types.h" namespace MIDI { diff --git a/libs/surfaces/us2400/test.cc b/libs/surfaces/us2400/test.cc index 351058523f..b6670214d5 100644 --- a/libs/surfaces/us2400/test.cc +++ b/libs/surfaces/us2400/test.cc @@ -6,7 +6,7 @@ #include #include -#include "midi_byte_array.h" +#include "control_protocol/midi_byte_array.h" using namespace std; diff --git a/libs/surfaces/us2400/us2400_control_protocol.cc b/libs/surfaces/us2400/us2400_control_protocol.cc index 5aa7eb5ccf..d1400d0514 100644 --- a/libs/surfaces/us2400/us2400_control_protocol.cc +++ b/libs/surfaces/us2400/us2400_control_protocol.cc @@ -60,9 +60,10 @@ #include "ardour/audioengine.h" #include "ardour/vca_manager.h" +#include "control_protocol/midi_byte_array.h" + #include "us2400_control_protocol.h" -#include "midi_byte_array.h" #include "us2400_control_exception.h" #include "device_profile.h" #include "surface_port.h" diff --git a/libs/surfaces/us2400/us2400_control_protocol.h b/libs/surfaces/us2400/us2400_control_protocol.h index 53eda53cf1..e464b37d12 100644 --- a/libs/surfaces/us2400/us2400_control_protocol.h +++ b/libs/surfaces/us2400/us2400_control_protocol.h @@ -33,9 +33,9 @@ #include "midi++/types.h" #include "ardour/types.h" #include "control_protocol/control_protocol.h" +#include "control_protocol/midi_byte_array.h" #include "types.h" -#include "midi_byte_array.h" #include "controls.h" #include "jog_wheel.h" #include "timer.h" diff --git a/libs/surfaces/us2400/us2400_control_protocol_poll.cc b/libs/surfaces/us2400/us2400_control_protocol_poll.cc index 53cd1c994c..4d0db69444 100644 --- a/libs/surfaces/us2400/us2400_control_protocol_poll.cc +++ b/libs/surfaces/us2400/us2400_control_protocol_poll.cc @@ -18,7 +18,8 @@ #include "us2400_control_protocol.h" -#include "midi_byte_array.h" +#include "control_protocol/midi_byte_array.h" + #include "surface_port.h" #include "pbd/pthread_utils.h" diff --git a/libs/surfaces/us2400/wscript b/libs/surfaces/us2400/wscript index f8bddf8d58..58d3505396 100644 --- a/libs/surfaces/us2400/wscript +++ b/libs/surfaces/us2400/wscript @@ -28,7 +28,6 @@ def build(bld): us2400_control_protocol.cc mcp_buttons.cc meter.cc - midi_byte_array.cc pot.cc strip.cc surface.cc