ardour
windows_vst_plugin.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2004 Paul Davis
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 
18 */
19 
20 #include "fst.h"
21 
23 #include "ardour/session.h"
24 
25 #include "i18n.h"
26 
27 using namespace std;
28 using namespace ARDOUR;
29 using namespace PBD;
30 
31 WindowsVSTPlugin::WindowsVSTPlugin (AudioEngine& e, Session& session, VSTHandle* h, int unique_id)
32  : VSTPlugin (e, session, h)
33 {
35  if ((_state = fst_instantiate (_handle, Session::vst_callback, this)) == 0) {
36  throw failed_constructor();
37  }
39 
41 }
42 
44  : VSTPlugin (other)
45 {
46  _handle = other._handle;
47 
49  if ((_state = fst_instantiate (_handle, Session::vst_callback, this)) == 0) {
50  throw failed_constructor();
51  }
53 
55 }
56 
58 {
59  deactivate ();
60  fst_close (_state);
61 }
62 
65 {
66  try {
67  PluginPtr plugin;
68 
69  if (Config->get_use_windows_vst ()) {
70  VSTHandle* handle;
71 
72  handle = fst_load(path.c_str());
73 
74  if (!handle) {
75  error << string_compose(_("VST: cannot load module from \"%1\""), path) << endmsg;
76  } else {
77  plugin.reset (new WindowsVSTPlugin (session.engine(), session, handle, PBD::atoi(unique_id)));
78  }
79  } else {
80  error << _("You asked ardour to not use any VST plugins") << endmsg;
81  return PluginPtr ((Plugin*) 0);
82  }
83 
84  plugin->set_info(PluginInfoPtr(new WindowsVSTPluginInfo(*this)));
85  return plugin;
86  }
87 
88  catch (failed_constructor &err) {
89  return PluginPtr ((Plugin*) 0);
90  }
91 }
92 
94 {
96 }
97 
int atoi(const string &s)
Definition: convert.cc:140
VSTState * _state
Definition: vst_plugin.h:96
std::string path
Definition: plugin.h:62
Definition: Beats.hpp:239
LIBPBD_API Transmitter error
std::ostream & endmsg(std::ostream &ostr)
Definition: transmitter.h:71
#define _(Text)
Definition: i18n.h:11
boost::shared_ptr< Plugin > PluginPtr
Definition: plugin.h:50
LIBARDOUR_API RCConfiguration * Config
Definition: globals.cc:119
static intptr_t vst_callback(AEffect *effect, int32_t opcode, int32_t index, intptr_t value, void *ptr, float opt)
Definition: session_vst.cc:64
Definition: amp.h:29
AEffect * _plugin
Definition: vst_plugin.h:97
void set_plugin(AEffect *)
Definition: vst_plugin.cc:57
VSTHandle * _handle
Definition: vst_plugin.h:95
std::string unique_id
Definition: plugin.h:67
static int vst_current_loading_id
Definition: session.h:837
AEffect * plugin
Definition: vst_types.h:76
std::string unique_id() const
Definition: vst_plugin.cc:604
PluginPtr load(Session &session)
Definition: debug.h:30
boost::shared_ptr< PluginInfo > PluginInfoPtr
Definition: plugin.h:89
ARDOUR::PluginType type
Definition: plugin.h:65
AudioEngine & engine()
Definition: session.h:546
WindowsVSTPlugin(AudioEngine &, Session &, VSTHandle *, int unique_id)
std::string string_compose(const std::string &fmt, const T1 &o1)
Definition: compose.h:208