diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2011-09-20 20:29:47 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2011-09-20 20:29:47 +0000 |
commit | d4433b9ab384196bb5b8876890863d7939339ee2 (patch) | |
tree | 669f503a04696c7869a14d5c5f6239024ba43e76 /gtk2_ardour | |
parent | e09e0035a62ce9f8876b6204682bbb3db474d477 (diff) |
(native) Linux VST support from LinuxDSP
git-svn-id: svn://localhost/ardour2/branches/3.0@10101 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/export_range_markers_dialog.cc | 2 | ||||
-rwxr-xr-x | gtk2_ardour/lxvst_plugin_ui.h | 69 | ||||
-rwxr-xr-x | gtk2_ardour/lxvst_pluginui.cc | 277 | ||||
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 6 | ||||
-rw-r--r-- | gtk2_ardour/plugin_selector.cc | 19 | ||||
-rw-r--r-- | gtk2_ardour/plugin_selector.h | 1 | ||||
-rw-r--r-- | gtk2_ardour/plugin_ui.cc | 38 | ||||
-rw-r--r-- | gtk2_ardour/plugin_ui.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/wscript | 9 |
9 files changed, 421 insertions, 2 deletions
diff --git a/gtk2_ardour/export_range_markers_dialog.cc b/gtk2_ardour/export_range_markers_dialog.cc index 06f590758c..c6bf578a32 100644 --- a/gtk2_ardour/export_range_markers_dialog.cc +++ b/gtk2_ardour/export_range_markers_dialog.cc @@ -76,7 +76,7 @@ ExportRangeMarkersDialog::process_range_markers_export(Locations::LocationList& string filepath = get_target_filepath( get_selected_file_name(), currentLocation->name(), - sndfile_file_ending_from_string(get_selected_header_format())); + get_selected_header_format()); initSpec(filepath); diff --git a/gtk2_ardour/lxvst_plugin_ui.h b/gtk2_ardour/lxvst_plugin_ui.h new file mode 100755 index 0000000000..fc46ede8a3 --- /dev/null +++ b/gtk2_ardour/lxvst_plugin_ui.h @@ -0,0 +1,69 @@ +#ifndef __lxvst_plugin_ui_h__ +#define __lxvst_plugin_ui_h__ + +#include <vector> +#include <map> +#include <list> + +#include <sigc++/signal.h> +#include <gtkmm/widget.h> + +#include <ardour_dialog.h> +#include <ardour/types.h> +#include "plugin_ui.h" + +#ifdef LXVST_SUPPORT + +namespace ARDOUR { + class PluginInsert; + class LXVSTPlugin; +} + +class LXVSTPluginUI : public PlugUIBase, public Gtk::VBox +{ + public: + LXVSTPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>, boost::shared_ptr<ARDOUR::LXVSTPlugin>); + ~LXVSTPluginUI (); + + gint get_preferred_height (); + gint get_preferred_width (); + bool start_updating(GdkEventAny*); + bool stop_updating(GdkEventAny*); + + int package (Gtk::Window&); + void forward_key_event (GdkEventKey *); + bool non_gtk_gui() const { return true; } + + private: + boost::shared_ptr<ARDOUR::LXVSTPlugin> lxvst; + Gtk::Socket socket; + Gtk::HBox preset_box; + Gtk::VBox vpacker; + + sigc::connection _screen_update_connection; + + bool configure_handler (GdkEventConfigure*, Gtk::Socket*); + void save_plugin_setting (); + + struct PresetModelColumns : public Gtk::TreeModel::ColumnRecord { + PresetModelColumns() { + add (name); + add (number); + } + Gtk::TreeModelColumn<Glib::ustring> name; + Gtk::TreeModelColumn<int> number; + }; + + PresetModelColumns preset_columns; + Glib::RefPtr<Gtk::ListStore> preset_model; + Gtk::ComboBox lxvst_preset_combo; + + void create_preset_store (); + void preset_chosen (); + void preset_selected (); + void resize_callback(); +}; + +#endif //LXVST_SUPPORT + +#endif diff --git a/gtk2_ardour/lxvst_pluginui.cc b/gtk2_ardour/lxvst_pluginui.cc new file mode 100755 index 0000000000..dc62d907ae --- /dev/null +++ b/gtk2_ardour/lxvst_pluginui.cc @@ -0,0 +1,277 @@ +/* + Copyright (C) 2004 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. + +*/ + +/******************************************************************/ +/*linuxDSP - pluginui variant for LXVST (native Linux VST) Plugins*/ +/******************************************************************/ + +#include <ardour/vstfx.h> +#include <gtk/gtk.h> +#include <gtk/gtksocket.h> +#include <ardour/processor.h> +#include <ardour/lxvst_plugin.h> + +#include "ardour_ui.h" +#include "plugin_ui.h" +#include "lxvst_plugin_ui.h" + +#include <gdk/gdkx.h> + +#define LXVST_H_FIDDLE 40 + +using namespace Gtk; +using namespace ARDOUR; +using namespace PBD; + +LXVSTPluginUI::LXVSTPluginUI (boost::shared_ptr<PluginInsert> pi, boost::shared_ptr<LXVSTPlugin> lxvp) + : PlugUIBase (pi), + lxvst (lxvp) +{ + create_preset_store (); + + vstfx_run_editor (lxvst->vstfx()); + + preset_box.set_spacing (6); + preset_box.set_border_width (6); + preset_box.pack_end (bypass_button, false, false, 10); + preset_box.pack_end (save_button, false, false); + preset_box.pack_end (lxvst_preset_combo, false, false); + + lxvst_preset_combo.signal_changed().connect (mem_fun (*this, &LXVSTPluginUI::preset_chosen)); + + bypass_button.set_active (!insert->active()); + + pack_start (preset_box, false, false); + pack_start (socket, true, true); +} + +LXVSTPluginUI::~LXVSTPluginUI () +{ + + _screen_update_connection.disconnect(); + + // plugin destructor destroys the custom GUI, via the vstfx engine, + // and then our PluginUIWindow does the rest +} + + +bool +LXVSTPluginUI::start_updating (GdkEventAny* ignored) +{ + _screen_update_connection.disconnect(); + _screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect + (mem_fun(*this, &LXVSTPluginUI::resize_callback)); + return false; +} + +bool +LXVSTPluginUI::stop_updating (GdkEventAny* ignored) +{ + _screen_update_connection.disconnect(); + return false; +} + + +void +LXVSTPluginUI::resize_callback() +{ + /*We could maybe use this to resize the plugin GTK parent window + if required*/ + + if(lxvst->vstfx()->want_resize) + { + int new_height = lxvst->vstfx()->height; + int new_width = lxvst->vstfx()->width; + + void* gtk_parent_window = lxvst->vstfx()->extra_data; + + if(gtk_parent_window) + ((Gtk::Window*)gtk_parent_window)->resize(new_width, new_height + LXVST_H_FIDDLE); + + lxvst->vstfx()->want_resize = 0; + } +} + +void +LXVSTPluginUI::preset_selected () +{ + socket.grab_focus (); + PlugUIBase::preset_selected (); +} + +void +LXVSTPluginUI::preset_chosen () +{ + // we can't dispatch directly here, too many plugins only expects one GUI thread. + + lxvst->vstfx()->want_program = lxvst_preset_combo.get_active_row_number (); + socket.grab_focus (); +} + +int +LXVSTPluginUI::get_preferred_height () +{ + /*FIXME*/ + + /*We have to return the required height of the plugin UI window + a fiddle factor + because we can't know how big the preset menu bar is until the window is realised + and we can't realise it until we have told it how big we would like it to be + which we can't do until it is realised etc*/ + + return (lxvst->vstfx()->height) + LXVST_H_FIDDLE; //May not be 40 for all screen res etc +} + +int +LXVSTPluginUI::get_preferred_width () +{ + return lxvst->vstfx()->width; +} + +int +LXVSTPluginUI::package (Gtk::Window& win) +{ + /* forward configure events to plugin window */ + + win.signal_configure_event().connect (bind (mem_fun (*this, &LXVSTPluginUI::configure_handler), &socket), false); + + /*Map the UI start and stop updating events to 'Map' events on the Window*/ + + win.signal_map_event().connect (mem_fun (*this, &LXVSTPluginUI::start_updating)); + win.signal_unmap_event().connect (mem_fun (*this, &LXVSTPluginUI::stop_updating)); + + /* this assumes that the window's owner understands the XEmbed protocol. */ + + socket.add_id (vstfx_get_XID (lxvst->vstfx())); + + vstfx_move_window_into_view (lxvst->vstfx()); + + lxvst->vstfx()->extra_data = (void*)(&win); + lxvst->vstfx()->want_resize = 0; + + return 0; +} + +bool +LXVSTPluginUI::configure_handler (GdkEventConfigure* ev, Gtk::Socket *socket) +{ + XEvent event; + gint x, y; + GdkWindow* w; + + if (socket == 0 || ((w = socket->gobj()->plug_window) == 0)) { + return false; + } + + event.xconfigure.type = ConfigureNotify; + event.xconfigure.event = GDK_WINDOW_XWINDOW (w); + event.xconfigure.window = GDK_WINDOW_XWINDOW (w); + + /* The ICCCM says that synthetic events should have root relative + * coordinates. We still aren't really ICCCM compliant, since + * we don't send events when the real toplevel is moved. + */ + gdk_error_trap_push (); + gdk_window_get_origin (w, &x, &y); + gdk_error_trap_pop (); + + event.xconfigure.x = x; + event.xconfigure.y = y; + event.xconfigure.width = GTK_WIDGET(socket->gobj())->allocation.width; + event.xconfigure.height = GTK_WIDGET(socket->gobj())->allocation.height; + + event.xconfigure.border_width = 0; + event.xconfigure.above = None; + event.xconfigure.override_redirect = False; + + gdk_error_trap_push (); + XSendEvent (GDK_WINDOW_XDISPLAY (w), GDK_WINDOW_XWINDOW (w), False, StructureNotifyMask, &event); + gdk_error_trap_pop (); + + return false; +} + +void +LXVSTPluginUI::forward_key_event (GdkEventKey* ev) +{ + std::cerr << "LXVSTPluginUI : keypress forwarding to linuxVSTs unsupported" << std::endl; +} + + +void +LXVSTPluginUI::create_preset_store () +{ + VSTFX* vstfx = lxvst->vstfx(); + + int vst_version = vstfx->plugin->dispatcher (vstfx->plugin, effGetVstVersion, 0, 0, NULL, 0.0f); + + preset_model = ListStore::create (preset_columns); + + for (int i = 0; i < vstfx->plugin->numPrograms; ++i) { + char buf[100]; + TreeModel::Row row = *(preset_model->append()); + + snprintf (buf, 90, "preset %d", i); + + if (vst_version >= 2) { + vstfx->plugin->dispatcher (vstfx->plugin, 29, i, 0, buf, 0.0); + } + + row[preset_columns.name] = buf; + row[preset_columns.number] = i; + } + + if (vstfx->plugin->numPrograms > 0) { + vstfx->plugin->dispatcher( vstfx->plugin, effSetProgram, 0, 0, NULL, 0.0 ); + } + + lxvst_preset_combo.set_model (preset_model); + + CellRenderer* renderer = manage (new CellRendererText()); + lxvst_preset_combo.pack_start (*renderer, true); + lxvst_preset_combo.add_attribute (*renderer, "text", 0); + + if (lxvst->vstfx()->current_program != -1) { + lxvst_preset_combo.set_active (lxvst->vstfx()->current_program); + } else { + lxvst_preset_combo.set_active (0); + } +} + +typedef int (*error_handler_t)( Display *, XErrorEvent *); +static Display *the_gtk_display; +static error_handler_t vstfx_error_handler; +static error_handler_t gtk_error_handler; + +static int +gtk_xerror_handler( Display *disp, XErrorEvent *ev ) +{ + std::cerr << "** ERROR ** LXVSTPluginUI : Trapped an X Window System Error" << std::endl; + + return 0; +} + +void +gui_init (int *argc, char **argv[]) +{ + vstfx_error_handler = XSetErrorHandler (NULL); + gtk_init (argc, argv); + the_gtk_display = gdk_x11_display_get_xdisplay (gdk_display_get_default()); + gtk_error_handler = XSetErrorHandler( gtk_xerror_handler ); +} + diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 8fb14796e0..e6ffe1bd51 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -1547,12 +1547,16 @@ MidiRegionView::update_note (CanvasNote* ev, bool update_ghost_regions) { boost::shared_ptr<NoteType> note = ev->note(); + cerr << "Note " << *note << " @ region frames " << source_beats_to_region_frames (note->time()) << endl; + const double x = trackview.editor().frame_to_pixel (source_beats_to_region_frames (note->time())); const double y1 = midi_stream_view()->note_to_y(note->note()); ev->property_x1() = x; ev->property_y1() = y1; + cerr << "\t" << x << " ... "; + /* trim note display to not overlap the end of its region */ if (note->length() > 0) { @@ -1562,6 +1566,8 @@ MidiRegionView::update_note (CanvasNote* ev, bool update_ghost_regions) ev->property_x2() = trackview.editor().frame_to_pixel (_region->length()); } + cerr << ev->property_x2() << endl; + ev->property_y2() = y1 + floor(midi_stream_view()->note_height()); if (note->length() == 0) { diff --git a/gtk2_ardour/plugin_selector.cc b/gtk2_ardour/plugin_selector.cc index 07ab3fd9f5..1b00c56fd9 100644 --- a/gtk2_ardour/plugin_selector.cc +++ b/gtk2_ardour/plugin_selector.cc @@ -240,6 +240,9 @@ PluginSelector::show_this_plugin (const PluginInfoPtr& info, const std::string& case VST: compstr = X_("VST"); break; + case LXVST: + compstr = X_("LXVST"); + break; } } else if (mode == _("Author contains")) { @@ -285,6 +288,7 @@ PluginSelector::refill () ladspa_refiller (filterstr); lv2_refiller (filterstr); vst_refiller (filterstr); + lxvst_refiller (filterstr); au_refiller (filterstr); in_row_change = false; @@ -358,6 +362,18 @@ PluginSelector::vst_refiller (const std::string&) } void +#ifdef LXVST_SUPPORT +PluginSelector::lxvst_refiller (const std::string& filterstr) +#else +PluginSelector::lxvst_refiller (const std::string&) +#endif +{ +#ifdef LXVST_SUPPORT + refiller (manager->lxvst_plugin_info(), filterstr, "LXVST"); +#endif +} + +void #ifdef HAVE_AUDIOUNITS PluginSelector::au_refiller (const std::string& filterstr) #else @@ -585,6 +601,9 @@ PluginSelector::build_plugin_menu () #ifdef VST_SUPPORT all_plugs.insert (all_plugs.end(), manager->vst_plugin_info().begin(), manager->vst_plugin_info().end()); #endif +#ifdef LXVST_SUPPORT + all_plugs.insert (all_plugs.end(), manager->lxvst_plugin_info().begin(), manager->lxvst_plugin_info().end()); +#endif #ifdef HAVE_AUDIOUNITS all_plugs.insert (all_plugs.end(), manager->au_plugin_info().begin(), manager->au_plugin_info().end()); #endif diff --git a/gtk2_ardour/plugin_selector.h b/gtk2_ardour/plugin_selector.h index 0c7d9f4211..3635b71a76 100644 --- a/gtk2_ardour/plugin_selector.h +++ b/gtk2_ardour/plugin_selector.h @@ -112,6 +112,7 @@ class PluginSelector : public ArdourDialog void ladspa_refiller (const std::string&); void lv2_refiller (const std::string&); void vst_refiller (const std::string&); + void lxvst_refiller (const std::string&); void au_refiller (const std::string&); Gtk::Menu* _plugin_menu; diff --git a/gtk2_ardour/plugin_ui.cc b/gtk2_ardour/plugin_ui.cc index beb070c150..f6a97a1cf1 100644 --- a/gtk2_ardour/plugin_ui.cc +++ b/gtk2_ardour/plugin_ui.cc @@ -50,6 +50,10 @@ #include "ardour/vst_plugin.h" #include "vst_pluginui.h" #endif +#ifdef LXVST_SUPPORT +#include "ardour/lxvst_plugin.h" +#include "lxvst_plugin_ui.h" +#endif #ifdef LV2_SUPPORT #include "ardour/lv2_plugin.h" #include "lv2_plugin_ui.h" @@ -98,6 +102,10 @@ PluginUIWindow::PluginUIWindow ( case ARDOUR::VST: have_gui = create_vst_editor (insert); break; + + case ARDOUR::LXVST: + have_gui = create_lxvst_editor (insert); + break; case ARDOUR::AudioUnit: have_gui = create_audiounit_editor (insert); @@ -275,6 +283,36 @@ PluginUIWindow::create_vst_editor(boost::shared_ptr<PluginInsert>) } bool +#ifdef LXVST_SUPPORT +PluginUIWindow::create_lxvst_editor(boost::shared_ptr<PluginInsert> insert) +#else +PluginUIWindow::create_lxvst_editor(boost::shared_ptr<PluginInsert>) +#endif +{ +#ifndef LXVST_SUPPORT + return false; +#else + + boost::shared_ptr<LXVSTPlugin> lxvp; + + if ((lxvp = boost::dynamic_pointer_cast<LXVSTPlugin> (insert->plugin())) == 0) { + error << _("unknown type of editor-supplying plugin (note: no linuxVST support in this version of ardour)") + << endmsg; + throw failed_constructor (); + } else { + LXVSTPluginUI* lxvpu = new LXVSTPluginUI (insert, lxvp); + + _pluginui = lxvpu; + _pluginui->KeyboardFocused.connect (sigc::mem_fun (*this, &PluginUIWindow::keyboard_focused)); + add (*lxvpu); + lxvpu->package (*this); + } + + return true; +#endif +} + +bool #ifdef GTKOSX PluginUIWindow::create_audiounit_editor (boost::shared_ptr<PluginInsert> insert) #else diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h index 7c88b01bbd..e060907986 100644 --- a/gtk2_ardour/plugin_ui.h +++ b/gtk2_ardour/plugin_ui.h @@ -53,6 +53,7 @@ namespace ARDOUR { class PluginInsert; class Plugin; class VSTPlugin; + class LXVSTPlugin; class IOProcessor; class AUPlugin; } @@ -298,6 +299,7 @@ class PluginUIWindow : public Gtk::Window void plugin_going_away (); bool create_vst_editor (boost::shared_ptr<ARDOUR::PluginInsert>); + bool create_lxvst_editor(boost::shared_ptr<ARDOUR::PluginInsert>); bool create_audiounit_editor (boost::shared_ptr<ARDOUR::PluginInsert>); bool create_lv2_editor (boost::shared_ptr<ARDOUR::PluginInsert>); }; diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index fb30400017..dd7d2f544b 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -305,6 +305,7 @@ def build(bld): obj.includes = ['.'] obj.source = gtk2_ardour_sources obj.name = 'gtk2_ardour' + obj.linkflags = [] if bld.env['VST_SUPPORT']: obj.target = 'gtk2_ardour' obj.includes += ['../libs/fst'] @@ -343,6 +344,12 @@ def build(bld): if bld.env['VST_SUPPORT']: obj.source += [ 'vst_pluginui.cc' ] obj.defines += [ 'VST_SUPPORT' ] + bld.env.append ('LINKFLAGS', '-lX11') + + if bld.env['LXVST_SUPPORT']: + obj.source += [ 'lxvst_pluginui.cc' ] + obj.defines += [ 'LXVST_SUPPORT' ] + obj.linkflags += [ '-lX11' ] if bld.env['PHONE_HOME']: obj.defines += [ 'PHONE_HOME' ] @@ -365,7 +372,7 @@ def build(bld): ''' obj.includes = '../libs/fst' obj.target = 'ardour-3.0-vst' - obj.linkflags = ['-mwindows', '-Wl,--export-dynamic', '-lpthread'] + obj.linkflags += ['-mwindows', '-Wl,--export-dynamic', '-lpthread'] obj.defines = ['_POSIX_SOURCE', 'USE_WS_PREFIX'] obj.uselib = 'ALSA' obj.uselib_local = ['libpbd','libmidipp','libtaglib','libardour', |