changeset 78:c983dda79f72

* Replace crash with warning when a transform could not be automatically re-run * More sensible default paths for Vamp plugin lookup (at least on Linux and OS/X) * A start to making the y coords for time value layers etc align * Set sensible y coords for text labels in time instant and value layers
author Chris Cannam
date Thu, 13 Apr 2006 18:29:10 +0000
parents 2beca8ddcdc3
children 9e027aa5b5c3
files base/CommandHistory.cpp base/Layer.h base/System.h base/View.cpp base/View.h plugin/FeatureExtractionPluginFactory.cpp plugin/LADSPAPluginFactory.cpp plugin/LADSPAPluginInstance.cpp
diffstat 8 files changed, 79 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/base/CommandHistory.cpp	Wed Apr 12 09:59:40 2006 +0000
+++ b/base/CommandHistory.cpp	Thu Apr 13 18:29:10 2006 +0000
@@ -92,7 +92,7 @@
 void
 CommandHistory::clear()
 {
-    std::cerr << "CommandHistory::clear()" << std::endl;
+//    std::cerr << "CommandHistory::clear()" << std::endl;
     closeBundle();
     m_savedAt = -1;
     clearStack(m_undoStack);
@@ -131,10 +131,10 @@
 	closeBundle();
     }
 
-    std::cerr << "CommandHistory::addCommand: " << command->getName().toLocal8Bit().data() << " at " << command << std::endl;
+//    std::cerr << "CommandHistory::addCommand: " << command->getName().toLocal8Bit().data() << " at " << command << std::endl;
 
     // We can't redo after adding a command
-    std::cerr << "CommandHistory::clearing redo stack" << std::endl;
+//    std::cerr << "CommandHistory::clearing redo stack" << std::endl;
     clearStack(m_redoStack);
 
     // can we reach savedAt?
@@ -200,7 +200,7 @@
 void
 CommandHistory::addToCompound(Command *command)
 {
-    std::cerr << "CommandHistory::addToCompound: " << command->getName().toLocal8Bit().data() << std::endl;
+//    std::cerr << "CommandHistory::addToCompound: " << command->getName().toLocal8Bit().data() << std::endl;
 
     if (m_executeCompound) command->execute();
     m_currentCompound->addCommand(command);
@@ -353,7 +353,7 @@
 
 	for (i = 0; i < limit; ++i) {
 	    Command *command = stack.top();
-	    std::cerr << "CommandHistory::clipStack: Saving recent command: " << command->getName().toLocal8Bit().data() << " at " << command << std::endl;
+//	    std::cerr << "CommandHistory::clipStack: Saving recent command: " << command->getName().toLocal8Bit().data() << " at " << command << std::endl;
 	    tempStack.push(stack.top());
 	    stack.pop();
 	}
--- a/base/Layer.h	Wed Apr 12 09:59:40 2006 +0000
+++ b/base/Layer.h	Thu Apr 13 18:29:10 2006 +0000
@@ -230,6 +230,10 @@
 
     virtual PlayParameters *getPlayParameters();
 
+    virtual bool needsTextLabelHeight() const { return false; }
+
+    virtual bool getValueExtents(float &min, float &max, QString &unit) const = 0;
+
 public slots:
     void showLayer(View *, bool show);
 
--- a/base/System.h	Wed Apr 12 09:59:40 2006 +0000
+++ b/base/System.h	Thu Apr 13 18:29:10 2006 +0000
@@ -31,6 +31,8 @@
 #define DLERROR()    ""
 
 #define PLUGIN_GLOB  "*.dll"
+#define PATH_SEPARATOR ';'
+#define DEFAULT_VAMP_PATH ""
 
 extern "C" {
 void gettimeofday(struct timeval *p, void *tz);
@@ -50,13 +52,17 @@
 #define DLCLOSE(a)   dlclose((a))
 #define DLERROR()    dlerror()
 
+#define PATH_SEPARATOR ':'
+
 #ifdef __APPLE__
 
 #define PLUGIN_GLOB  "*.dylib"
+#define DEFAULT_VAMP_PATH "/Library/Audio/Plug-Ins/VAMP/:$HOME/Library/Audio/Plug-Ins/VAMP"
 
 #else 
 
 #define PLUGIN_GLOB  "*.so"
+#define DEFAULT_VAMP_PATH "/usr/local/lib/vamp:/usr/lib/vamp:$HOME/vamp:$HOME/.vamp"
 
 #endif /* __APPLE__ */
 
--- a/base/View.cpp	Wed Apr 12 09:59:40 2006 +0000
+++ b/base/View.cpp	Thu Apr 13 18:29:10 2006 +0000
@@ -152,6 +152,47 @@
     return m_layers[i-1];
 }
 
+bool
+View::getValueExtents(QString unit, float &min, float &max) const
+{
+    bool have = false;
+
+    for (LayerList::const_iterator i = m_layers.begin();
+         i != m_layers.end(); ++i) { 
+
+        QString layerUnit;
+        float layerMin, layerMax;
+
+        if ((*i)->getValueExtents(layerMin, layerMax, layerUnit) &&
+            layerUnit.toLower() == unit.toLower()) {
+
+            if (!have || layerMin < min) min = layerMin;
+            if (!have || layerMax > max) max = layerMax;
+            have = true;
+        }
+    }
+
+    return have;
+}
+
+int
+View::getTextLabelHeight(const Layer *layer, QPainter &paint) const
+{
+    int y = 15 + paint.fontMetrics().ascent();
+
+    for (LayerList::const_iterator i = m_layers.begin();
+         i != m_layers.end(); ++i) { 
+
+        if (*i == layer) return y;
+
+        if ((*i)->needsTextLabelHeight()) {
+            y += paint.fontMetrics().height();
+        }
+    }
+
+    return y;
+}
+
 void
 View::propertyContainerSelected(View *client, PropertyContainer *pc)
 {
--- a/base/View.h	Wed Apr 12 09:59:40 2006 +0000
+++ b/base/View.h	Thu Apr 13 18:29:10 2006 +0000
@@ -220,6 +220,10 @@
     virtual const PropertyContainer *getPropertyContainer(size_t i) const;
     virtual PropertyContainer *getPropertyContainer(size_t i);
 
+    virtual int getTextLabelHeight(const Layer *layer, QPainter &) const;
+
+    virtual bool getValueExtents(QString unit, float &min, float &max) const;
+
     virtual QString toXmlString(QString indent = "",
 				QString extraAttributes = "") const;
 
--- a/plugin/FeatureExtractionPluginFactory.cpp	Wed Apr 12 09:59:40 2006 +0000
+++ b/plugin/FeatureExtractionPluginFactory.cpp	Thu Apr 13 18:29:10 2006 +0000
@@ -58,22 +58,26 @@
     std::vector<QString> path;
     std::string envPath;
 
-    char *cpath = getenv("Vamp_PATH");
+    char *cpath = getenv("VAMP_PATH");
     if (cpath) envPath = cpath;
 
     if (envPath == "") {
-        //!!! system dependent
-        envPath = "/usr/local/lib/vamp:/usr/lib/vamp";
+        envPath = DEFAULT_VAMP_PATH;
         char *chome = getenv("HOME");
         if (chome) {
-            envPath = std::string(chome) + "/vamp:" +
-                std::string(chome) + "/.vamp:" + envPath;
+            std::string home(chome);
+            int f;
+            while ((f = envPath.find("$HOME")) >= 0 && f < envPath.length()) {
+                envPath.replace(f, 5, home);
+            }
         }
     }
 
+    std::cerr << "VAMP path is: \"" << envPath << "\"" << std::endl;
+
     std::string::size_type index = 0, newindex = 0;
 
-    while ((newindex = envPath.find(':', index)) < envPath.size()) {
+    while ((newindex = envPath.find(PATH_SEPARATOR, index)) < envPath.size()) {
 	path.push_back(envPath.substr(index, newindex - index).c_str());
 	index = newindex + 1;
     }
--- a/plugin/LADSPAPluginFactory.cpp	Wed Apr 12 09:59:40 2006 +0000
+++ b/plugin/LADSPAPluginFactory.cpp	Thu Apr 13 18:29:10 2006 +0000
@@ -323,6 +323,9 @@
 
 	m_instances.insert(instance);
 
+        std::cerr << "LADSPAPluginFactory::instantiatePlugin("
+                  << identifier.toStdString() << ": now have " << m_instances.size() << " instances" << std::endl;
+
 	return instance;
     }
 
@@ -351,16 +354,19 @@
 	QString itype, isoname, ilabel;
 	PluginIdentifier::parseIdentifier((*ii)->getIdentifier(), itype, isoname, ilabel);
 	if (isoname == soname) {
-//	    std::cerr << "LADSPAPluginFactory::releasePlugin: dll " << soname.toStdString() << " is still in use for plugin " << ilabel << std::endl;
+	    std::cerr << "LADSPAPluginFactory::releasePlugin: dll " << soname.toStdString() << " is still in use for plugin " << ilabel.toStdString() << std::endl;
 	    stillInUse = true;
 	    break;
 	}
     }
     
     if (!stillInUse) {
-//	std::cerr << "LADSPAPluginFactory::releasePlugin: dll " << soname.toStdString() << " no longer in use, unloading" << std::endl;
+	std::cerr << "LADSPAPluginFactory::releasePlugin: dll " << soname.toStdString() << " no longer in use, unloading" << std::endl;
 	unloadLibrary(soname);
     }
+
+    std::cerr << "LADSPAPluginFactory::releasePlugin("
+                  << identifier.toStdString() << ": now have " << m_instances.size() << " instances" << std::endl;
 }
 
 const LADSPA_Descriptor *
--- a/plugin/LADSPAPluginInstance.cpp	Wed Apr 12 09:59:40 2006 +0000
+++ b/plugin/LADSPAPluginInstance.cpp	Thu Apr 13 18:29:10 2006 +0000
@@ -24,7 +24,7 @@
 #include "LADSPAPluginInstance.h"
 #include "LADSPAPluginFactory.h"
 
-//#define DEBUG_LADSPA 1
+#define DEBUG_LADSPA 1
 
 
 LADSPAPluginInstance::LADSPAPluginInstance(RealTimePluginFactory *factory,