Compare commits

...

1 Commits

Author SHA1 Message Date
Robin Gareus a3eb57bd90 Code skeleton for openAV-ctrla/mappa support 2018-07-19 15:00:43 +02:00
8 changed files with 398 additions and 1 deletions

View File

@ -13,7 +13,7 @@ export GTK2_RC_FILES=/nonexistent
# can find all the components.
#
export ARDOUR_SURFACES_PATH=$libs/surfaces/osc:$libs/surfaces/faderport8:$libs/surfaces/faderport:$libs/surfaces/generic_midi:$libs/surfaces/tranzport:$libs/surfaces/powermate:$libs/surfaces/mackie:$libs/surfaces/us2400:$libs/surfaces/wiimote:$libs/surfaces/push2:$libs/surfaces/maschine2:$libs/surfaces/cc121
export ARDOUR_SURFACES_PATH=$libs/surfaces/osc:$libs/surfaces/faderport8:$libs/surfaces/faderport:$libs/surfaces/generic_midi:$libs/surfaces/tranzport:$libs/surfaces/powermate:$libs/surfaces/mackie:$libs/surfaces/us2400:$libs/surfaces/wiimote:$libs/surfaces/push2:$libs/surfaces/maschine2:$libs/surfaces/cc121:$libs/surfaces/mappa
export ARDOUR_PANNER_PATH=$libs/panners
export ARDOUR_DATA_PATH=$TOP:$TOP/build:$TOP/gtk2_ardour:$TOP/build/gtk2_ardour:.
export ARDOUR_MIDIMAPS_PATH=$TOP/midi_maps:.

View File

@ -83,6 +83,7 @@ namespace PBD {
LIBARDOUR_API extern DebugBits DiskIO;
LIBARDOUR_API extern DebugBits FaderPort;
LIBARDOUR_API extern DebugBits FaderPort8;
LIBARDOUR_API extern DebugBits Mappa;
LIBARDOUR_API extern DebugBits CC121;
LIBARDOUR_API extern DebugBits VCA;
LIBARDOUR_API extern DebugBits Push2;

View File

@ -80,6 +80,7 @@ PBD::DebugBits PBD::DEBUG::VSTCallbacks = PBD::new_debug_bit ("vstcallbacks");
PBD::DebugBits PBD::DEBUG::DiskIO = PBD::new_debug_bit ("diskio");
PBD::DebugBits PBD::DEBUG::FaderPort = PBD::new_debug_bit ("faderport");
PBD::DebugBits PBD::DEBUG::FaderPort8 = PBD::new_debug_bit ("faderport8");
PBD::DebugBits PBD::DEBUG::Mappa = PBD::new_debug_bit ("mappa");
PBD::DebugBits PBD::DEBUG::CC121 = PBD::new_debug_bit ("cc121");
PBD::DebugBits PBD::DEBUG::VCA = PBD::new_debug_bit ("vca");
PBD::DebugBits PBD::DEBUG::Push2 = PBD::new_debug_bit ("push2");

View File

@ -0,0 +1,81 @@
/*
* Copyright (C) 2017-2018 Robin Gareus <robin@gareus.org>
* Copyright (C) 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 <pbd/failed_constructor.h>
#include "control_protocol/control_protocol.h"
#include "oav_mappa.h"
using namespace ARDOUR;
using namespace ArdourSurface;
static ControlProtocol*
new_mappa_protocol (ControlProtocolDescriptor* /*descriptor*/, Session* s)
{
Mappa* mp;
try {
mp = new Mappa (*s);
} catch (failed_constructor& err) {
return 0;
}
if (mp->set_active (true)) {
delete mp;
return 0;
}
return mp;
}
static void
delete_mappa_protocol (ControlProtocolDescriptor* /*descriptor*/, ControlProtocol* cp)
{
delete cp;
}
static bool
probe_mappa_protocol (ControlProtocolDescriptor* /*descriptor*/)
{
return Mappa::probe ();
}
static void*
mappa_request_buffer_factory (uint32_t num_requests)
{
return Mappa::request_factory (num_requests);
}
static ControlProtocolDescriptor mappa_descriptor = {
/*name : */ "Mappa",
/*id : */ "uri://ardour.org/surfaces/mappa:0",
/*ptr : */ 0,
/*module : */ 0,
/*mandatory : */ 0,
/*supports_feedback : */ true,
/*probe : */ probe_mappa_protocol,
/*initialize : */ new_mappa_protocol,
/*destroy : */ delete_mappa_protocol,
/*request_buffer_factory */ mappa_request_buffer_factory
};
extern "C" ARDOURSURFACE_API
ControlProtocolDescriptor* protocol_descriptor () {
return &mappa_descriptor;
}

View File

@ -0,0 +1,186 @@
/*
* Copyright (C) 2017 Robin Gareus <robin@gareus.org>
* Copyright (C) 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 <cstdlib>
#include <cassert>
#include <sstream>
#include <algorithm>
#include "ardour/debug.h"
#include "ardour/session.h"
#include "oav_mappa.h"
#include "pbd/i18n.h"
#include "pbd/abstract_ui.cc" // implementation
using namespace ARDOUR;
using namespace PBD;
using namespace ArdourSurface;
Mappa::Mappa (Session& s)
: ControlProtocol (s, _("Mappa"))
, AbstractUI<MappaRequest> (name())
{
}
Mappa::~Mappa ()
{
mappa_destroy (_mappa);
stop ();
//tear_down_gui ();
}
/* ****************************************************************************
* Event Loop
*/
void*
Mappa::request_factory (uint32_t num_requests)
{
/* AbstractUI<T>::request_buffer_factory() is a template method only
* instantiated in this source module. To provide something visible for
* use in the interface/descriptor, we have this static method that is
* template-free.
*/
return request_buffer_factory (num_requests);
}
void
Mappa::do_request (MappaRequest* req)
{
if (req->type == CallSlot) {
call_slot (MISSING_INVALIDATOR, req->the_slot);
} else if (req->type == Quit) {
stop ();
}
}
void
Mappa::thread_init ()
{
pthread_set_name (event_loop_name().c_str());
PBD::notify_event_loops_about_thread_creation (pthread_self(), event_loop_name(), 2048);
ARDOUR::SessionEvent::create_per_thread_pool (event_loop_name(), 128);
set_thread_priority ();
}
/* ****************************************************************************
* Initialization, Desinitialization
*/
int
Mappa::set_active (bool yn)
{
DEBUG_TRACE (DEBUG::Mappa, string_compose("set_active init with yn: '%1'\n", yn));
if (yn == active()) {
return 0;
}
if (yn) {
_mappa = mappa_create(NULL);
if (!_mappa) {
return -1;
}
start ();
} else {
stop ();
}
ControlProtocol::set_active (yn);
DEBUG_TRACE (DEBUG::Mappa, string_compose("set_active done with yn: '%1'\n", yn));
return 0;
}
void
Mappa::start ()
{
DEBUG_TRACE (DEBUG::Mappa, "BaseUI::run ()\n");
BaseUI::run ();
register_with_mappa ();
connect_session_signals ();
Glib::RefPtr<Glib::TimeoutSource> periodic_timer = Glib::TimeoutSource::create (50);
_periodic_connection = periodic_timer->connect (sigc::mem_fun (*this, &Mappa::periodic));
periodic_timer->attach (main_loop()->get_context());
}
void
Mappa::stop ()
{
DEBUG_TRACE (DEBUG::Mappa, "BaseUI::quit ()\n");
BaseUI::quit ();
/* now drop references, disconnect from signals */
_session_connections.drop_connections ();
_periodic_connection.disconnect ();
}
bool
Mappa::periodic ()
{
mappa_iter (_mappa);
return true;
}
/* ****************************************************************************
* Actions & Callbacks
*/
void
Mappa::_cb_target_float (uint32_t target_id, float value, void* token, uint32_t token_size, void* userdata)
{
static_cast<Mappa*> (userdata)->cb_target_float (target_id, value, token, token_size);
}
void
Mappa::cb_target_float (uint32_t target_id, float value, void* token, uint32_t token_size)
{
DEBUG_TRACE (DEBUG::Mappa, string_compose("cb_target_float '%1' '%2'\n", target_id, value));
}
void
Mappa::register_with_mappa ()
{
struct mappa_target_t t = {
.name = "t_1",
.func = _cb_target_float,
.userdata = (void*)this,
};
uint32_t tid = 0;
int ret = mappa_target_add (_mappa, &t, &tid, 0, 0);
assert (ret == 0);
}
void
Mappa::connect_session_signals ()
{
}
void
Mappa::stripable_selection_changed ()
{
/* invoked by libardour whenever strip selection changed */
}

View File

@ -0,0 +1,87 @@
/*
* Copyright (C) 2017 Robin Gareus <robin@gareus.org>
* Copyright (C) 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.
*/
#ifndef ardour_surface_mappa_h
#define ardour_surface_mappa_h
#include <ctlra/mappa.h>
#define ABSTRACT_UI_EXPORTS
#include "pbd/abstract_ui.h"
#include "pbd/properties.h"
#include "pbd/controllable.h"
#include "ardour/types.h"
#include "control_protocol/control_protocol.h"
namespace ARDOUR {
class Session;
}
namespace ArdourSurface {
struct MappaRequest : public BaseUI::BaseRequestObject
{
public:
MappaRequest () {}
~MappaRequest () {}
};
class Mappa : public ARDOUR::ControlProtocol, public AbstractUI<MappaRequest>
{
public:
Mappa (ARDOUR::Session&);
virtual ~Mappa ();
int set_active (bool yn);
static bool probe() { return true; }
static void* request_factory (uint32_t);
void do_request (MappaRequest*);
void thread_init ();
#if 0
/* configuration GUI */
void* get_gui () const;
void tear_down_gui ();
#endif
bool has_editor () const { return false; }
private:
void start ();
void stop ();
bool periodic ();
void stripable_selection_changed ();
void connect_session_signals ();
void register_with_mappa ();
static void _cb_target_float (uint32_t, float, void*, uint32_t, void*);
void cb_target_float (uint32_t target_id, float value, void* token, uint32_t token_size);
struct mappa_t* _mappa;
sigc::connection _periodic_connection;
PBD::ScopedConnectionList _session_connections;
};
} /* namespace */
#endif

View File

@ -0,0 +1,32 @@
#!/usr/bin/env python
from waflib.extras import autowaf as autowaf
import os
# Mandatory variables
top = '.'
out = 'build'
def options(opt):
autowaf.set_options(opt)
def configure(conf):
autowaf.configure(conf)
def build(bld):
obj = bld(features = 'cxx cxxshlib')
obj.source = '''
oav_mappa.cc
mappa_interface.cc
'''
obj.export_includes = ['.']
obj.defines = [ 'PACKAGE="ardour_mappa"' ]
obj.defines += [ 'ARDOURSURFACE_DLL_EXPORTS' ]
obj.includes = [ '.', './mappa']
obj.name = 'libardour_mappa'
obj.target = 'ardour_mappa'
obj.uselib = 'USB OAV_CTRLA'
obj.use = 'libardour libardour_cp libgtkmm2ext libpbd'
obj.install_path = os.path.join(bld.env['LIBDIR'], 'surfaces')
def shutdown():
autowaf.shutdown()

View File

@ -43,6 +43,7 @@ def configure(conf):
autowaf.configure(conf)
autowaf.check_pkg(conf, 'libusb-1.0', uselib_store='USB', mandatory=False)
autowaf.check_pkg(conf, 'openav_ctlra', uselib_store='OAV_CTRLA', mandatory=False)
#if Options.options.tranzport and conf.is_defined('HAVE_USB'):
# conf.define('BUILD_TRANZPORT', 1)
@ -50,6 +51,12 @@ def configure(conf):
children += [ 'push2' ]
else:
print ('You are missing the libusb-1.0 development package needed to compile Push2 support')
if conf.is_defined('HAVE_USB') and conf.is_defined('HAVE_OAV_CTRLA'):
children += [ 'mappa' ]
conf.define('BUILD_MAPPA', 1)
else:
print ('You are missing the openAV ctrla/mappa to compile MAPPA support')
if conf.is_defined('HAVE_HIDAPI') and Options.options.maschine:
children += [ 'maschine2' ]
@ -96,6 +103,8 @@ def build(bld):
bld.recurse('push2')
if bld.is_defined('BUILD_MASCHINE'):
bld.recurse('maschine2')
if bld.is_defined('BUILD_MAPPA'):
bld.recurse('mappa')
def shutdown():
autowaf.shutdown()