diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index b4409572e4..79bb130a38 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -712,6 +712,11 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr bool _feedback_exists; void resize_text_widgets (); + +#ifdef USE_SOUNDGRID + void soundgrid_init (); +#endif + }; #endif /* __ardour_gui_h__ */ diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index 05addb98e3..be6ce36df4 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -603,6 +603,10 @@ ARDOUR_UI::editor_realized () boost::function pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1)); Config->map_parameters (pc); +#ifdef USE_SOUNDGRID + soundgrid_init (); +#endif + reset_dpi (); } diff --git a/gtk2_ardour/ardour_ui_sg.mm b/gtk2_ardour/ardour_ui_sg.mm new file mode 100644 index 0000000000..fbe409cca4 --- /dev/null +++ b/gtk2_ardour/ardour_ui_sg.mm @@ -0,0 +1,52 @@ +/* + Copyright (C) 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "ardour/soundgrid.h" + +#include "ardour_ui.h" +#include "public_editor.h" + +#ifdef __APPLE__ +#define Marker MarkerStupidApple +#include +#undef Marker + +#ifdef check +#undef check +#endif +#ifdef NO +#undef NO +#endif +#ifdef YES +#undef YES +#endif +#endif + +#ifdef USE_SOUNDGRID + +void +ARDOUR_UI::soundgrid_init () +{ +#ifdef __APPLE__ + NSView* nsview = gdk_quartz_window_get_nsview (editor->get_window()->gobj()); + ARDOUR::SoundGrid::instance().initialize (nsview); +#endif +} + +#endif diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 338a585dca..8c57ea0b4d 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -39,6 +39,7 @@ gtk2_ardour_sources = [ 'ardour_ui_dialogs.cc', 'ardour_ui_ed.cc', 'ardour_ui_mixer.cc', + 'ardour_ui_sg.mm', 'ardour_ui_options.cc', 'ardour_window.cc', 'audio_clock.cc', diff --git a/libs/ardour/ardour/soundgrid.h b/libs/ardour/ardour/soundgrid.h index f85cd36779..d935801c42 100644 --- a/libs/ardour/ardour/soundgrid.h +++ b/libs/ardour/ardour/soundgrid.h @@ -24,6 +24,9 @@ #include #include +#include +#include + #include "ardour/ardour.h" namespace ARDOUR { @@ -33,6 +36,9 @@ class SoundGrid : public boost::noncopyable public: ~SoundGrid (); + int initialize (void* window_handle); + int teardown (); + static SoundGrid& instance(); static bool available (); static std::vector lan_port_names(); @@ -64,11 +70,15 @@ class SoundGrid : public boost::noncopyable private: SoundGrid (); static SoundGrid* _instance; - + void* dl_handle; - + void* _sg; // handle managed by SoundGrid library + void display_update (); static void _display_update (); + + static WTErr _sg_callback (const WSControlID* pControlID); + static WTErr sg_callback (const WSControlID* pControlID); }; } // namespace ARDOUR diff --git a/libs/ardour/soundgrid.cc b/libs/ardour/soundgrid.cc index 6fb1b05e39..a1de23d31d 100644 --- a/libs/ardour/soundgrid.cc +++ b/libs/ardour/soundgrid.cc @@ -18,28 +18,35 @@ */ #include +#include + +#include #include "ardour/soundgrid.h" #ifdef __APPLE__ -const char* sndgrid_dll_name = "sndgrid.dylib"; +const char* sndgrid_dll_name = "mixerapplicationcore.dylib"; #else -const char* sndgrid_dll_name = "sndgrid.so"; +const char* sndgrid_dll_name = "mixerapplicationcore.so"; #endif using namespace ARDOUR; using std::vector; using std::string; +using std::cerr; +using std::endl; SoundGrid* SoundGrid::_instance = 0; SoundGrid::SoundGrid () : dl_handle (0) { + cerr << "Loading " << sndgrid_dll_name << endl; if ((dl_handle = dlopen (sndgrid_dll_name, RTLD_NOW)) == 0) { + cerr << "...failed\n"; return; } - + cerr << "...worked\n"; } SoundGrid::~SoundGrid() @@ -49,6 +56,28 @@ SoundGrid::~SoundGrid() } } +int +SoundGrid::initialize (void* window_handle) +{ + WTErr ret; + ret = InitializeMixerCoreDLL (window_handle, sg_callback, &_sg); + cerr << "Initialized SG core, ret = " << ret << endl; + return 0; +} + +int +SoundGrid::teardown () +{ + WTErr retval = eNoErr; + + if (_sg) { + retval = UnInitializeMixerCoreDLL (_sg); + _sg = 0; + } + + return retval == eNoErr ? 0 : -1; +} + SoundGrid& SoundGrid::instance () { @@ -142,3 +171,21 @@ SoundGrid::current_network_buffer_size () { return 256; } + +/* callback */ +WTErr +SoundGrid::_sg_callback (const WSControlID* cid) +{ + return SoundGrid::instance().sg_callback (cid); +} + +WTErr +SoundGrid::sg_callback (const WSControlID* cid) +{ + cerr << "SG Callback, cluster " << cid->clusterID.clusterType << " (index " + << cid->clusterID.clusterTypeIndex + << ") control " << cid->clusterControlID.controlType + << " (index " << cid->clusterControlID.controlTypeIndex << ')' + << endl; + return eNoErr; +} diff --git a/wscript b/wscript index 0d70d25f2b..ae3a7a9b2e 100644 --- a/wscript +++ b/wscript @@ -542,10 +542,20 @@ def configure(conf): print ('No Carbon support available for this build\n') if Options.options.soundgrid: - conf.env.append_value ('CXXFLAGS_SOUNDGRID', [ '-D__MACOS__', '-DUSE_SOUNDGRID', '-I/Volumes/Work/paul/ardour/3.0-SG/soundgrid' ]) - conf.env.append_value ('CFLAGS_SOUNDGRID', [ '-D__MACOS__', '-DUSE_SOUNDGRID', '-I/Volumes/Work/paul/ardour/3.0-SG/soundgrid' ]) - sglib = ''.join ([ '-L', os.path.expanduser ('/Volumes/Work/paul/ardour/3.0-SG/soundgrid') ]) - conf.env.append_value ('LINKFLAGS_SOUNDGRID', [ sglib, '-lmixerapplicationcore' ]) + conf.env.append_value ('CXXFLAGS_SOUNDGRID', + [ '-D__MACOS__', + '-DUSE_SOUNDGRID', + '-I/Volumes/Work/paul/ardour/3.0-SG/soundgrid', + '-I/Volumes/Work/paul/ardour/3.0-SG/soundgrid/WavesPublicAPI/WavesMixerAPI/1.0', + '-I/Volumes/Work/paul/ardour/3.0-SG/soundgrid/WavesPublicAPI/1.0', + ]) + conf.env.append_value ('CFLAGS_SOUNDGRID', + [ '-D__MACOS__', + '-DUSE_SOUNDGRID', + '-I/Volumes/Work/paul/ardour/3.0-SG/soundgrid', + '-I/Volumes/Work/paul/ardour/3.0-SG/soundgrid/WavesPublicAPI/WavesMixerAPI/1.0', + '-I/Volumes/Work/paul/ardour/3.0-SG/soundgrid/WavesPublicAPI/1.0', + ]) conf.check_cxx (header_name='WavesPublicAPI/WavesMixerAPI/1.0/WavesMixerAPI.h', mandatory=True, use='SOUNDGRID') conf.define('HAVE_SOUNDGRID', 1)