Make import GUI report if you are importing a file of a name that
[ardour.git] / libs / ardour / vst_plugin.cc
index dbb75470525c6cbe29b447498fe840237d74553b..2211b028a7d81cce63e938f6c4e41a6a2016838b 100644 (file)
@@ -15,7 +15,6 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id$
 */
 
 #include <algorithm>
@@ -103,23 +102,13 @@ VSTPlugin::~VSTPlugin ()
 }
 
 void
-VSTPlugin::set_block_size (jack_nframes_t nframes)
+VSTPlugin::set_block_size (nframes_t nframes)
 {
        deactivate ();
        _plugin->dispatcher (_plugin, effSetBlockSize, 0, nframes, NULL, 0.0f);
        activate ();
 }
 
-void
-VSTPlugin::store_state (PluginState& state)
-{
-}
-
-void
-VSTPlugin::restore_state (PluginState& state)
-{
-}
-
 float
 VSTPlugin::default_value (uint32_t port)
 {
@@ -152,7 +141,7 @@ VSTPlugin::get_state()
 {
        XMLNode *root = new XMLNode (state_node_name());
        LocaleGuard lg (X_("POSIX"));
-       
+
        if (_plugin->flags & effFlagsProgramChunks) {
 
                /* fetch the current chunk */
@@ -169,23 +158,22 @@ VSTPlugin::get_state()
                string path;
                struct stat sbuf;
 
-               path = getenv ("HOME");
-               path += "/.ardour/vst";
+               path = get_user_ardour_path ();
+               path += "vst";
 
                if (stat (path.c_str(), &sbuf)) {
                        if (errno == ENOENT) {
-                               if (mkdir (path.c_str(), 0600)) {
+                               if (g_mkdir_with_parents (path.c_str(), 0600)) {
                                        error << string_compose (_("cannot create VST chunk directory: %1"),
-                                                         strerror (errno))
+                                                                strerror (errno))
                                              << endmsg;
                                        return *root;
                                }
 
                        } else {
 
-                               error << string_compose (_("cannot check VST chunk directory: %1"),
-                                                 strerror (errno))
-                                     << endmsg;
+                               warning << string_compose (_("cannot check VST chunk directory: %1"), strerror (errno))
+                                       << endmsg;
                                return *root;
                        }
 
@@ -212,7 +200,7 @@ VSTPlugin::get_state()
                        char index[64];
                        char val[32];
                        snprintf (index, sizeof (index), "param_%ld", n);
-                       snprintf (val, sizeof (val), "%f", _plugin->getParameter (_plugin, n));
+                       snprintf (val, sizeof (val), "%.12g", _plugin->getParameter (_plugin, n));
                        parameters->add_property (index, val);
                }
 
@@ -245,6 +233,7 @@ VSTPlugin::set_state(const XMLNode& node)
                for (i = child->properties().begin(); i != child->properties().end(); ++i) {
                        long param;
                        float val;
+
                        sscanf ((*i)->name().c_str(), "param_%ld", &param);
                        sscanf ((*i)->value().c_str(), "%f", &val);
 
@@ -357,7 +346,7 @@ VSTPlugin::describe_parameter (uint32_t param)
        return name;
 }
 
-jack_nframes_t
+nframes_t
 VSTPlugin::latency () const
 {
        return _plugin->initialDelay;
@@ -376,7 +365,7 @@ VSTPlugin::automatable () const
 }
 
 int
-VSTPlugin::connect_and_run (vector<Sample*>& bufs, uint32_t maxbuf, int32_t& in_index, int32_t& out_index, jack_nframes_t nframes, jack_nframes_t offset)
+VSTPlugin::connect_and_run (vector<Sample*>& bufs, uint32_t maxbuf, int32_t& in_index, int32_t& out_index, nframes_t nframes, nframes_t offset)
 {
        float *ins[_plugin->numInputs];
        float *outs[_plugin->numOutputs];
@@ -419,10 +408,12 @@ VSTPlugin::activate ()
        _plugin->dispatcher (_plugin, effMainsChanged, 0, 1, NULL, 0.0f);
 }
 
-uint32_t 
+string
 VSTPlugin::unique_id() const
 {
-       return _plugin->uniqueID;
+       char buf[32];
+       snprintf (buf, sizeof (buf), "%d", _plugin->uniqueID);
+       return string (buf);
 }