breakout control protocol code into LGPL library; fix panner buttons even more than nick did, plus some other bits and pieces

git-svn-id: svn://localhost/trunk/ardour2@522 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2006-05-23 19:54:52 +00:00
parent a222c19737
commit 2fba6d0925
25 changed files with 414 additions and 142 deletions

View file

@ -392,6 +392,13 @@ libraries['libgnomecanvas2'].ParseConfig ('pkg-config --cflags --libs libgnomeca
#libraries['flowcanvas'] = LibraryInfo(LIBS='flowcanvas', LIBPATH='#/libs/flowcanvas', CPPPATH='#libs/flowcanvas') #libraries['flowcanvas'] = LibraryInfo(LIBS='flowcanvas', LIBPATH='#/libs/flowcanvas', CPPPATH='#libs/flowcanvas')
# The Ardour Control Protocol Library
libraries['ardour_cp'] = LibraryInfo (LIBS='ardour_cp', LIBPATH='#libs/surfaces/control_protocol',
CPPPATH='#libs/surfaces/control_protocol')
# The Ardour backend/engine
libraries['ardour'] = LibraryInfo (LIBS='ardour', LIBPATH='#libs/ardour', CPPPATH='#libs/ardour') libraries['ardour'] = LibraryInfo (LIBS='ardour', LIBPATH='#libs/ardour', CPPPATH='#libs/ardour')
libraries['midi++2'] = LibraryInfo (LIBS='midi++', LIBPATH='#libs/midi++2', CPPPATH='#libs/midi++2') libraries['midi++2'] = LibraryInfo (LIBS='midi++', LIBPATH='#libs/midi++2', CPPPATH='#libs/midi++2')
libraries['pbd3'] = LibraryInfo (LIBS='pbd', LIBPATH='#libs/pbd3', CPPPATH='#libs/pbd3') libraries['pbd3'] = LibraryInfo (LIBS='pbd', LIBPATH='#libs/pbd3', CPPPATH='#libs/pbd3')
@ -564,9 +571,11 @@ else:
surface_subdirs = [] surface_subdirs = []
if env['SURFACES']: if env['SURFACES']:
surface_subdirs += [ 'libs/surfaces/generic_midi' ] surface_subdirs += [ 'libs/surfaces/control_protocol', 'libs/surfaces/generic_midi' ]
if have_libusb: if have_libusb:
surface_subdirs += [ 'libs/surfaces/tranzport' ] surface_subdirs += [ 'libs/surfaces/tranzport' ]
if os.access ('libs/surfaces/sony9pin', os.F_OK):
surface_subdirs += [ 'libs/surfaces/sony9pin' ]
opts.Save('scache.conf', env) opts.Save('scache.conf', env)
Help(opts.GenerateHelpText(env)) Help(opts.GenerateHelpText(env))

View file

@ -24,6 +24,7 @@ gtkardour.Append(POTFILE=domain + '.pot')
gtkardour.Merge ([ gtkardour.Merge ([
libraries['ardour'], libraries['ardour'],
libraries['ardour_cp'],
libraries['gtkmm2ext'], libraries['gtkmm2ext'],
# libraries['flowcanvas'], # libraries['flowcanvas'],
libraries['midi++2'], libraries['midi++2'],

View file

@ -2,7 +2,7 @@
export ARDOUR_PATH=./glade:./pixmaps:.:.. export ARDOUR_PATH=./glade:./pixmaps:.:..
export LD_LIBRARY_PATH=../libs/ardour:../libs/midi++2:../libs/pbd3:../libs/soundtouch:../libs/gtkmm2ext:../libs/sigc++2:../libs/glibmm2:../libs/gtkmm2/atk:../libs/gtkmm2/pango:../libs/gtkmm2/gdk:../libs/gtkmm2/gtk:../libs/libgnomecanvasmm:../libs/libglademm:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=../libs/surfaces/control_protocol:../libs/ardour:../libs/midi++2:../libs/pbd3:../libs/soundtouch:../libs/gtkmm2ext:../libs/sigc++2:../libs/glibmm2:../libs/gtkmm2/atk:../libs/gtkmm2/pango:../libs/gtkmm2/gdk:../libs/gtkmm2/gtk:../libs/libgnomecanvasmm:../libs/libglademm:$LD_LIBRARY_PATH
# DYLD_LIBRARY_PATH is for darwin. # DYLD_LIBRARY_PATH is for darwin.
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH

View file

@ -34,7 +34,8 @@
#include <ardour/session.h> #include <ardour/session.h>
#include <ardour/control_protocol_manager.h> #include <ardour/control_protocol_manager.h>
#include <ardour/control_protocol.h>
#include "control_protocol.h"
#include "i18n.h" #include "i18n.h"

View file

@ -47,7 +47,8 @@
#include <ardour/session_route.h> #include <ardour/session_route.h>
#include <ardour/tempo.h> #include <ardour/tempo.h>
#include <ardour/utils.h> #include <ardour/utils.h>
#include <ardour/control_protocol.h>
#include "control_protocol.h"
#include "ardour_ui.h" #include "ardour_ui.h"
#include "editor.h" #include "editor.h"

View file

@ -123,9 +123,9 @@ PannerUI::PannerUI (IO& io, Session& s)
(mem_fun(*this, &PannerUI::panning_link_direction_clicked)); (mem_fun(*this, &PannerUI::panning_link_direction_clicked));
panning_link_button.signal_button_press_event().connect panning_link_button.signal_button_press_event().connect
(mem_fun(*this, &PannerUI::panning_link_button_press)); (mem_fun(*this, &PannerUI::panning_link_button_press), false);
panning_link_button.signal_button_release_event().connect panning_link_button.signal_button_release_event().connect
(mem_fun(*this, &PannerUI::panning_link_button_release)); (mem_fun(*this, &PannerUI::panning_link_button_release), false);
panning_up.set_border_width (3); panning_up.set_border_width (3);
panning_down.set_border_width (3); panning_down.set_border_width (3);
@ -154,19 +154,21 @@ PannerUI::PannerUI (IO& io, Session& s)
pan_automation_state_changed (); pan_automation_state_changed ();
} }
gint bool
PannerUI::panning_link_button_press (GdkEventButton* ev) PannerUI::panning_link_button_press (GdkEventButton* ev)
{ {
return stop_signal (panning_link_button, "button-press-event"); cerr << "link press\n";
return true;
} }
gint bool
PannerUI::panning_link_button_release (GdkEventButton* ev) PannerUI::panning_link_button_release (GdkEventButton* ev)
{ {
cerr << "link release\n";
if (!ignore_toggle) { if (!ignore_toggle) {
_io.panner().set_linked (!_io.panner().linked()); _io.panner().set_linked (!_io.panner().linked());
} }
return TRUE; return true;
} }
void void
@ -395,7 +397,7 @@ PannerUI::setup_pan ()
} }
} }
gint bool
PannerUI::pan_button_event (GdkEventButton* ev, uint32_t which) PannerUI::pan_button_event (GdkEventButton* ev, uint32_t which)
{ {
switch (ev->button) { switch (ev->button) {
@ -406,13 +408,13 @@ PannerUI::pan_button_event (GdkEventButton* ev, uint32_t which)
} }
build_pan_menu (which); build_pan_menu (which);
pan_menu->popup (1, ev->time); pan_menu->popup (1, ev->time);
return TRUE; return true;
break; break;
default: default:
return FALSE; return false;
} }
return FALSE; // what's wrong with gcc? return false; // what's wrong with gcc?
} }
void void

View file

@ -90,22 +90,20 @@ class PannerUI : public Gtk::HBox
Gtk::Arrow panning_down_arrow; Gtk::Arrow panning_down_arrow;
Gtk::VBox pan_vbox; Gtk::VBox pan_vbox;
Width _width; Width _width;
gint panning_scroll_button_press_event (GdkEventButton*, int32_t dir);
gint panning_scroll_button_release_event (GdkEventButton*, int32_t dir);
Gtk::ToggleButton panning_link_button; Gtk::ToggleButton panning_link_button;
Gtk::Button panning_link_direction_button; Gtk::Button panning_link_direction_button;
Gtk::HBox panning_link_box; Gtk::HBox panning_link_box;
bool panning_link_button_press (GdkEventButton*);
bool panning_link_button_release (GdkEventButton*);
Gtk::Menu pan_astate_menu; Gtk::Menu pan_astate_menu;
Gtk::Menu pan_astyle_menu; Gtk::Menu pan_astyle_menu;
Gtk::Button pan_automation_style_button; Gtk::Button pan_automation_style_button;
Gtk::ToggleButton pan_automation_state_button; Gtk::ToggleButton pan_automation_state_button;
gint panning_link_button_press (GdkEventButton*);
gint panning_link_button_release (GdkEventButton*);
void panning_link_direction_clicked (); void panning_link_direction_clicked ();
vector<Gtk::Adjustment*> pan_adjustments; vector<Gtk::Adjustment*> pan_adjustments;
@ -128,7 +126,8 @@ class PannerUI : public Gtk::HBox
gint start_pan_touch (GdkEventButton*); gint start_pan_touch (GdkEventButton*);
gint end_pan_touch (GdkEventButton*); gint end_pan_touch (GdkEventButton*);
gint pan_button_event (GdkEventButton*, uint32_t which); bool pan_button_event (GdkEventButton*, uint32_t which);
Gtk::Menu* pan_menu; Gtk::Menu* pan_menu;
Gtk::CheckMenuItem* bypass_menu_item; Gtk::CheckMenuItem* bypass_menu_item;
void build_pan_menu (uint32_t which); void build_pan_menu (uint32_t which);

View file

@ -20,6 +20,12 @@ ardour.Append(CXXFLAGS="-DLIBSIGC_DISABLE_DEPRECATED")
ardour.Append(PACKAGE = domain) ardour.Append(PACKAGE = domain)
ardour.Append(POTFILE = domain + '.pot') ardour.Append(POTFILE = domain + '.pot')
#
# explicitly reference the control protocol LGPL library for includes
#
ardour.Append(CPPPATH = '#libs/surfaces/control_protocol')
ardour_files=Split(""" ardour_files=Split("""
audio_library.cc audio_library.cc
audio_playlist.cc audio_playlist.cc
@ -30,10 +36,8 @@ audioregion.cc
auditioner.cc auditioner.cc
automation.cc automation.cc
automation_event.cc automation_event.cc
basic_ui.cc
configuration.cc configuration.cc
connection.cc connection.cc
control_protocol.cc
control_protocol_manager.cc control_protocol_manager.cc
crossfade.cc crossfade.cc
curve.cc curve.cc

View file

@ -1,43 +0,0 @@
#ifndef __ardour_basic_ui_h__
#define __ardour_basic_ui_h__
namespace ARDOUR {
class Session;
}
class BasicUI {
public:
BasicUI (ARDOUR::Session&);
virtual ~BasicUI ();
void add_marker ();
/* transport control */
void loop_toggle ();
void goto_start ();
void goto_end ();
void rewind ();
void ffwd ();
void transport_stop ();
void transport_play ();
void set_transport_speed (float speed);
float get_transport_speed (float speed);
void save_state ();
void prev_marker ();
void next_marker ();
void undo ();
void redo ();
void toggle_punch_in ();
void toggle_punch_out ();
void rec_enable_toggle ();
void toggle_all_rec_enables ();
protected:
BasicUI ();
ARDOUR::Session* session;
};
#endif /* __ardour_basic_ui_h__ */

View file

@ -31,7 +31,8 @@
#include <sigc++/sigc++.h> #include <sigc++/sigc++.h>
#include <ardour/types.h> #include <ardour/types.h>
#include <ardour/basic_ui.h>
#include "basic_ui.h"
namespace ARDOUR { namespace ARDOUR {
class Session; class Session;

View file

@ -360,6 +360,9 @@ class Session : public sigc::trackable, public Stateful
void request_diskstream_speed (DiskStream&, float speed); void request_diskstream_speed (DiskStream&, float speed);
void request_input_change_handling (); void request_input_change_handling ();
bool locate_pending() const { return static_cast<bool>(post_transport_work&PostTransportLocate); }
bool transport_locked () const;
int wipe (); int wipe ();
int wipe_diskstream (DiskStream *); int wipe_diskstream (DiskStream *);

View file

@ -4,10 +4,14 @@
#include <pbd/error.h> #include <pbd/error.h>
#include <pbd/pathscanner.h> #include <pbd/pathscanner.h>
#include "control_protocol.h"
#include <ardour/session.h> #include <ardour/session.h>
#include <ardour/control_protocol.h>
#include <ardour/control_protocol_manager.h> #include <ardour/control_protocol_manager.h>
using namespace ARDOUR; using namespace ARDOUR;
using namespace PBD; using namespace PBD;
using namespace std; using namespace std;
@ -168,18 +172,23 @@ ControlProtocolManager::control_protocol_discover (string path)
if ((descriptor = get_descriptor (path)) != 0) { if ((descriptor = get_descriptor (path)) != 0) {
ControlProtocolInfo* info = new ControlProtocolInfo (); ControlProtocolInfo* cpi = new ControlProtocolInfo ();
info->descriptor = descriptor; if (!descriptor->probe (descriptor)) {
info->name = descriptor->name; info << string_compose (_("Control protocol %1 not usable"), descriptor->name) << endmsg;
info->path = path; } else {
info->protocol = 0;
info->requested = false;
info->mandatory = descriptor->mandatory;
control_protocol_info.push_back (info); cpi->descriptor = descriptor;
cpi->name = descriptor->name;
cpi->path = path;
cpi->protocol = 0;
cpi->requested = false;
cpi->mandatory = descriptor->mandatory;
cerr << "discovered control surface protocol \"" << info->name << '"' << endl; control_protocol_info.push_back (cpi);
info << string_compose(_("Control surface protocol discovered: \"%1\""), cpi->name) << endmsg;
}
dlclose (descriptor->module); dlclose (descriptor->module);
} }

View file

@ -421,6 +421,18 @@ Session::reset_slave_state ()
slave_state = Stopped; slave_state = Stopped;
} }
bool
Session::transport_locked () const
{
Slave* sl = _slave;
if (!locate_pending() && ((_slave_type == None) || (sl && sl->ok() && sl->locked()))) {
return true;
}
return false;
}
bool bool
Session::follow_slave (jack_nframes_t nframes, jack_nframes_t offset) Session::follow_slave (jack_nframes_t nframes, jack_nframes_t offset)
{ {

View file

@ -0,0 +1,54 @@
# -*- python -*-
import os
import os.path
import glob
Import('env final_prefix install_prefix final_config_prefix libraries i18n')
cp = env.Copy()
#
# this defines the version number of libardour_cp
#
domain = 'ardour_cp'
cp.Append(DOMAIN = domain, MAJOR = 1, MINOR = 0, MICRO = 0)
cp.Append(CXXFLAGS = "-DPACKAGE=\\\"" + domain + "\\\"")
cp.Append(CXXFLAGS="-DLIBSIGC_DISABLE_DEPRECATED")
cp.Append(PACKAGE = domain)
cp.Append(POTFILE = domain + '.pot')
cp_files=Split("""
basic_ui.cc
control_protocol.cc
""")
cp.Append(CCFLAGS="-D_REENTRANT -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE")
cp.Append(CXXFLAGS="-DDATA_DIR=\\\""+final_prefix+"/share\\\"")
cp.Append(CXXFLAGS="-DCONFIG_DIR=\\\""+final_config_prefix+"\\\"")
cp.Append(CXXFLAGS="-DLOCALEDIR=\\\""+final_prefix+"/share/locale\\\"")
cp.Merge ([
libraries['ardour'],
libraries['sigc2'],
libraries['pbd3'],
libraries['midi++2'],
libraries['xml'],
libraries['usb']
])
libardour_cp = cp.SharedLibrary('ardour_cp', cp_files)
Default(libardour_cp)
if env['NLS']:
i18n (cp, cp_files, env)
env.Alias('install', env.Install(os.path.join(install_prefix, 'lib/ardour2/surfaces'), libardour_cp))
env.Alias('tarball', env.Distribute (env['DISTTREE'],
[ 'SConscript', 'i18n.h', 'gettext.h' ] +
cp_files +
glob.glob('po/*.po') + glob.glob('*.h')))

View file

@ -1,10 +1,11 @@
/* /*
Copyright (C) 2006 Paul Davis Copyright (C) 2006 Paul Davis
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it
it under the terms of the GNU General Public License as published by and/or modify it under the terms of the GNU Lesser
the Free Software Foundation; either version 2 of the License, or General Public License as published by the Free Software
(at your option) any later version. 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, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -18,10 +19,10 @@
$Id$ $Id$
*/ */
#include <ardour/basic_ui.h>
#include <ardour/session.h> #include <ardour/session.h>
#include <ardour/location.h> #include <ardour/location.h>
#include "basic_ui.h"
#include "i18n.h" #include "i18n.h"
using namespace ARDOUR; using namespace ARDOUR;
@ -92,7 +93,7 @@ BasicUI::transport_stop ()
} }
void void
BasicUI::transport_play () BasicUI::transport_play (bool from_last_start)
{ {
bool rolling = session->transport_rolling (); bool rolling = session->transport_rolling ();
@ -104,7 +105,7 @@ BasicUI::transport_play ()
session->request_play_range (false); session->request_play_range (false);
} }
if (rolling) { if (from_last_start && rolling) {
session->request_locate (session->last_transport_start(), true); session->request_locate (session->last_transport_start(), true);
} }
@ -167,6 +168,12 @@ BasicUI::set_transport_speed (float speed)
session->request_transport_speed (speed); session->request_transport_speed (speed);
} }
float
BasicUI::get_transport_speed ()
{
return session->transport_speed ();
}
void void
BasicUI::undo () BasicUI::undo ()
{ {
@ -200,3 +207,67 @@ BasicUI::toggle_punch_out ()
{ {
session->set_punch_out (!session->get_punch_out()); session->set_punch_out (!session->get_punch_out());
} }
bool
BasicUI::get_record_enabled ()
{
return session->get_record_enabled();
}
void
BasicUI::set_record_enable (bool yn)
{
if (yn) {
session->maybe_enable_record ();
} else {
session->disable_record (false, true);
}
}
jack_nframes_t
BasicUI::transport_frame ()
{
return session->transport_frame();
}
void
BasicUI::locate (jack_nframes_t where, bool roll_after_locate)
{
session->request_locate (where, roll_after_locate);
}
bool
BasicUI::locating ()
{
return session->locate_pending();
}
bool
BasicUI::locked ()
{
return session->transport_locked ();
}
jack_nframes_t
BasicUI::smpte_frames_per_hour ()
{
return session->smpte_frames_per_hour ();
}
void
BasicUI::smpte_time (jack_nframes_t where, SMPTE_t& smpte)
{
session->smpte_time (where, *((SMPTE_Time *) &smpte));
}
void
BasicUI::smpte_to_sample (SMPTE_t& smpte, jack_nframes_t& sample, bool use_offset, bool use_subframes) const
{
session->smpte_to_sample (*((SMPTE_Time*)&smpte), sample, use_offset, use_subframes);
}
void
BasicUI::sample_to_smpte (jack_nframes_t sample, SMPTE_t& smpte, bool use_offset, bool use_subframes) const
{
session->sample_to_smpte (sample, *((SMPTE_Time*)&smpte), use_offset, use_subframes);
}

View file

@ -0,0 +1,98 @@
/*
Copyright (C) 2006 Paul Davis
This program is free software; you can redistribute it
and/or modify it under the terms of the GNU Lesser
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., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id$
*/
#ifndef __ardour_basic_ui_h__
#define __ardour_basic_ui_h__
#include <jack/types.h>
namespace ARDOUR {
class Session;
}
class BasicUI {
public:
BasicUI (ARDOUR::Session&);
virtual ~BasicUI ();
void add_marker ();
/* transport control */
void loop_toggle ();
void goto_start ();
void goto_end ();
void rewind ();
void ffwd ();
void transport_stop ();
void transport_play (bool jump_back = true);
void set_transport_speed (float speed);
float get_transport_speed ();
jack_nframes_t transport_frame ();
void locate (jack_nframes_t frame, bool play = false);
bool locating ();
bool locked ();
void save_state ();
void prev_marker ();
void next_marker ();
void undo ();
void redo ();
void toggle_punch_in ();
void toggle_punch_out ();
void set_record_enable (bool yn);
bool get_record_enabled ();
void rec_enable_toggle ();
void toggle_all_rec_enables ();
jack_nframes_t smpte_frames_per_hour ();
struct SMPTE_t {
bool negative;
uint32_t hours;
uint32_t minutes;
uint32_t seconds;
uint32_t frames;
uint32_t subframes; // mostly not used
SMPTE_t () {
negative = false;
hours = 0;
minutes = 0;
seconds = 0;
frames = 0;
subframes = 0;
}
};
void smpte_time (jack_nframes_t where, SMPTE_t&);
void smpte_to_sample (SMPTE_t& smpte, jack_nframes_t& sample, bool use_offset, bool use_subframes) const;
void sample_to_smpte (jack_nframes_t sample, SMPTE_t& smpte, bool use_offset, bool use_subframes) const;
protected:
BasicUI ();
ARDOUR::Session* session;
};
#endif /* __ardour_basic_ui_h__ */

View file

@ -1,10 +1,11 @@
/* /*
Copyright (C) 2006 Paul Davis Copyright (C) 2006 Paul Davis
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it
it under the terms of the GNU General Public License as published by and/or modify it under the terms of the GNU Lesser
the Free Software Foundation; either version 2 of the License, or General Public License as published by the Free Software
(at your option) any later version. 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, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -18,11 +19,12 @@
$Id$ $Id$
*/ */
#include <ardour/control_protocol.h>
#include <ardour/session.h> #include <ardour/session.h>
#include <ardour/route.h> #include <ardour/route.h>
#include <ardour/audio_track.h> #include <ardour/audio_track.h>
#include "control_protocol.h"
using namespace ARDOUR; using namespace ARDOUR;
using namespace std; using namespace std;
@ -135,6 +137,24 @@ ControlProtocol::set_route_table (uint32_t table_index, ARDOUR::Route*)
{ {
} }
bool
ControlProtocol::set_route_table (uint32_t table_index, uint32_t remote_control_id)
{
if (table_index >= route_table.size()) {
return false;
}
Route* r = session->route_by_remote_id (remote_control_id);
if (!r) {
return false;
}
route_table[table_index] = r;
return true;
}
void void
ControlProtocol::route_set_rec_enable (uint32_t table_index, bool yn) ControlProtocol::route_set_rec_enable (uint32_t table_index, bool yn)
{ {

View file

@ -1,3 +1,24 @@
/*
Copyright (C) 2006 Paul Davis
This program is free software; you can redistribute it
and/or modify it under the terms of the GNU Lesser
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., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id$
*/
#ifndef ardour_control_protocols_h #ifndef ardour_control_protocols_h
#define ardour_control_protocols_h #define ardour_control_protocols_h
@ -6,7 +27,7 @@
#include <list> #include <list>
#include <sigc++/sigc++.h> #include <sigc++/sigc++.h>
#include <ardour/basic_ui.h> #include "basic_ui.h"
namespace ARDOUR { namespace ARDOUR {
@ -25,7 +46,6 @@ class ControlProtocol : public sigc::trackable, public BasicUI {
sigc::signal<void> ActiveChanged; sigc::signal<void> ActiveChanged;
/* signals that a control protocol can emit and other (presumably graphical) /* signals that a control protocol can emit and other (presumably graphical)
user interfaces can respond to user interfaces can respond to
*/ */
@ -54,6 +74,7 @@ class ControlProtocol : public sigc::trackable, public BasicUI {
void set_route_table_size (uint32_t size); void set_route_table_size (uint32_t size);
void set_route_table (uint32_t table_index, ARDOUR::Route*); void set_route_table (uint32_t table_index, ARDOUR::Route*);
bool set_route_table (uint32_t table_index, uint32_t remote_control_id);
void route_set_rec_enable (uint32_t table_index, bool yn); void route_set_rec_enable (uint32_t table_index, bool yn);
bool route_get_rec_enable (uint32_t table_index); bool route_get_rec_enable (uint32_t table_index);
@ -88,6 +109,7 @@ extern "C" {
void* ptr; /* protocol can store a value here */ void* ptr; /* protocol can store a value here */
void* module; /* not for public access */ void* module; /* not for public access */
int mandatory; /* if non-zero, always load and do not make optional */ int mandatory; /* if non-zero, always load and do not make optional */
bool (*probe)(ControlProtocolDescriptor*);
ControlProtocol* (*initialize)(ControlProtocolDescriptor*,Session*); ControlProtocol* (*initialize)(ControlProtocolDescriptor*,Session*);
void (*destroy)(ControlProtocolDescriptor*,ControlProtocol*); void (*destroy)(ControlProtocolDescriptor*,ControlProtocol*);

View file

@ -32,6 +32,7 @@ genericmidi.Append(CXXFLAGS="-DLOCALEDIR=\\\""+final_prefix+"/share/locale\\\"")
genericmidi.Merge ([ genericmidi.Merge ([
libraries['ardour'], libraries['ardour'],
libraries['ardour_cp'],
libraries['midi++2'], libraries['midi++2'],
libraries['pbd3'], libraries['pbd3'],
libraries['sigc2'], libraries['sigc2'],

View file

@ -1,7 +1,7 @@
#ifndef ardour_generic_midi_control_protocol_h #ifndef ardour_generic_midi_control_protocol_h
#define ardour_generic_midi_control_protocol_h #define ardour_generic_midi_control_protocol_h
#include <ardour/control_protocol.h> #include "control_protocol.h"
namespace MIDI { namespace MIDI {
class Port; class Port;
@ -15,6 +15,7 @@ class GenericMidiControlProtocol : public ControlProtocol {
virtual ~GenericMidiControlProtocol(); virtual ~GenericMidiControlProtocol();
int set_active (bool yn); int set_active (bool yn);
static bool probe() { return true; }
void set_port (MIDI::Port*); void set_port (MIDI::Port*);
MIDI::Port* port () const { return _port; } MIDI::Port* port () const { return _port; }

View file

@ -1,4 +1,4 @@
#include <ardour/control_protocol.h> #include "control_protocol.h"
#include "generic_midi_control_protocol.h" #include "generic_midi_control_protocol.h"
@ -23,12 +23,19 @@ delete_generic_midi_protocol (ControlProtocolDescriptor* descriptor, ControlProt
delete cp; delete cp;
} }
bool
probe_generic_midi_protocol (ControlProtocolDescriptor* descriptor)
{
return GenericMidiControlProtocol::probe ();
}
static ControlProtocolDescriptor generic_midi_descriptor = { static ControlProtocolDescriptor generic_midi_descriptor = {
name : "Generic MIDI", name : "Generic MIDI",
id : "uri://ardour.org/surfaces/generic_midi:0", id : "uri://ardour.org/surfaces/generic_midi:0",
ptr : 0, ptr : 0,
module : 0, module : 0,
mandatory : 0, mandatory : 0,
probe : probe_generic_midi_protocol,
initialize : new_generic_midi_protocol, initialize : new_generic_midi_protocol,
destroy : delete_generic_midi_protocol destroy : delete_generic_midi_protocol
}; };

View file

@ -32,6 +32,7 @@ tranzport.Append(CXXFLAGS="-DLOCALEDIR=\\\""+final_prefix+"/share/locale\\\"")
tranzport.Merge ([ tranzport.Merge ([
libraries['ardour'], libraries['ardour'],
libraries['ardour_cp'],
libraries['sigc2'], libraries['sigc2'],
libraries['pbd3'], libraries['pbd3'],
libraries['midi++2'], libraries['midi++2'],

View file

@ -1,4 +1,4 @@
#include <ardour/control_protocol.h> #include "control_protocol.h"
#include "tranzport_control_protocol.h" #include "tranzport_control_protocol.h"
@ -24,12 +24,19 @@ delete_tranzport_protocol (ControlProtocolDescriptor* descriptor, ControlProtoco
delete cp; delete cp;
} }
bool
probe_tranzport_protocol (ControlProtocolDescriptor* descriptor)
{
return TranzportControlProtocol::probe();
}
static ControlProtocolDescriptor tranzport_descriptor = { static ControlProtocolDescriptor tranzport_descriptor = {
name : "Tranzport", name : "Tranzport",
id : "uri://ardour.org/surfaces/tranzport:0", id : "uri://ardour.org/surfaces/tranzport:0",
ptr : 0, ptr : 0,
module : 0, module : 0,
mandatory : 0, mandatory : 0,
probe : probe_tranzport_protocol,
initialize : new_tranzport_protocol, initialize : new_tranzport_protocol,
destroy : delete_tranzport_protocol destroy : delete_tranzport_protocol
}; };

View file

@ -66,9 +66,7 @@ slider_position_to_gain (double pos)
TranzportControlProtocol::TranzportControlProtocol (Session& s) TranzportControlProtocol::TranzportControlProtocol (Session& s)
: ControlProtocol (s, X_("Tranzport")), : ControlProtocol (s, X_("Tranzport"))
AbstractUI<TranzportRequest> (X_("Tranzport"), false)
{ {
/* tranzport controls one track at a time */ /* tranzport controls one track at a time */
@ -106,6 +104,28 @@ TranzportControlProtocol::~TranzportControlProtocol ()
set_active (false); set_active (false);
} }
bool
TranzportControlProtocol::probe ()
{
struct usb_bus *bus;
struct usb_device *dev;
usb_init();
usb_find_busses();
usb_find_devices();
for (bus = usb_busses; bus; bus = bus->next) {
for(dev = bus->devices; dev; dev = dev->next) {
if (dev->descriptor.idVendor == VENDORID && dev->descriptor.idProduct == PRODUCTID) {
return true;
}
}
}
return false;
}
int int
TranzportControlProtocol::set_active (bool yn) TranzportControlProtocol::set_active (bool yn)
{ {
@ -559,7 +579,7 @@ TranzportControlProtocol::monitor_work ()
if ((err = pthread_setschedparam (pthread_self(), SCHED_FIFO, &rtparam)) != 0) { if ((err = pthread_setschedparam (pthread_self(), SCHED_FIFO, &rtparam)) != 0) {
// do we care? not particularly. // do we care? not particularly.
info << string_compose (_("%1: thread not running with realtime scheduling (%2)"), BaseUI::name(), strerror (errno)) << endmsg; info << string_compose (_("%1: thread not running with realtime scheduling (%2)"), name(), strerror (errno)) << endmsg;
} }
pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, 0); pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, 0);
@ -1554,18 +1574,3 @@ TranzportControlProtocol::print (int row, int col, const char *text)
} }
} }
bool
TranzportControlProtocol::caller_is_ui_thread ()
{
return (pthread_self() == thread);
}
void
TranzportControlProtocol::do_request (TranzportRequest* req)
{
if (req->type == SetCurrentTrack) {
route_table[0] = req->track;
}
return;
}

View file

@ -7,24 +7,12 @@
#include <pbd/lockmonitor.h> #include <pbd/lockmonitor.h>
#include <pthread.h> #include <pthread.h>
#include <usb.h> #include <usb.h>
#include <ardour/control_protocol.h>
#include <ardour/types.h> #include <ardour/types.h>
#include <pbd/abstract_ui.h> #include "control_protocol.h"
extern BaseUI::RequestType LEDChange; class TranzportControlProtocol : public ARDOUR::ControlProtocol
extern BaseUI::RequestType Print;
extern BaseUI::RequestType SetCurrentTrack;
struct TranzportRequest : public BaseUI::BaseRequestObject {
int led;
int row;
int col;
char* text;
ARDOUR::Route* track;
};
class TranzportControlProtocol : public ARDOUR::ControlProtocol, public AbstractUI<TranzportRequest>
{ {
public: public:
TranzportControlProtocol (ARDOUR::Session&); TranzportControlProtocol (ARDOUR::Session&);
@ -32,7 +20,7 @@ class TranzportControlProtocol : public ARDOUR::ControlProtocol, public Abstract
int set_active (bool yn); int set_active (bool yn);
bool caller_is_ui_thread(); static bool probe ();
private: private:
static const int VENDORID = 0x165b; static const int VENDORID = 0x165b;
@ -107,8 +95,6 @@ class TranzportControlProtocol : public ARDOUR::ControlProtocol, public Abstract
DisplayMode display_mode; DisplayMode display_mode;
ARDOUR::gain_t gain_fraction; ARDOUR::gain_t gain_fraction;
void do_request (TranzportRequest*);
PBD::Lock update_lock; PBD::Lock update_lock;
char current_screen[2][20]; char current_screen[2][20];
char pending_screen[2][20]; char pending_screen[2][20];