changeset 687:06f13a3b9e9e debug-output

Convert many cerrs to DEBUGs
author Chris Cannam
date Mon, 16 May 2011 17:19:09 +0100
parents b4a8d8221eaf
children 573d45e9487b
files base/LogRange.cpp base/LogRange.h base/PlayParameterRepository.cpp base/PropertyContainer.cpp base/RangeMapper.cpp base/RealTime.cpp base/ResourceFinder.cpp base/StorageAdviser.cpp base/TempDirectory.cpp base/XmlExportable.cpp data/fft/FFTDataServer.cpp data/fft/FFTFileCacheReader.cpp data/fft/FFTFileCacheWriter.cpp data/fileio/AudioFileReaderFactory.cpp data/fileio/BZipFileDevice.cpp data/fileio/CSVFileReader.cpp data/fileio/CachedFile.cpp data/fileio/CodedAudioFileReader.cpp data/fileio/FileReadThread.cpp data/fileio/FileSource.cpp data/fileio/MIDIFileReader.cpp data/fileio/MP3FileReader.cpp data/fileio/MatchFileReader.cpp data/fileio/MatchFileReader.h data/fileio/MatrixFile.cpp data/fileio/OggVorbisFileReader.cpp data/fileio/QuickTimeFileReader.cpp data/fileio/ResamplingWavFileReader.cpp data/fileio/WavFileReader.cpp data/fileio/WavFileWriter.cpp data/midi/MIDIEvent.h data/midi/MIDIInput.cpp data/midi/rtmidi/RtMidi.cpp data/model/AggregateWaveModel.cpp data/model/AlignmentModel.cpp data/model/EditableDenseThreeDimensionalModel.cpp data/model/Model.cpp data/model/ModelDataTableModel.cpp data/model/PowerOfSqrtTwoZoomConstraint.cpp data/model/WaveFileModel.cpp data/model/WritableWaveFileModel.cpp data/osc/OSCQueue.cpp plugin/DSSIPluginFactory.cpp plugin/DSSIPluginInstance.cpp plugin/FeatureExtractionPluginFactory.cpp plugin/LADSPAPluginFactory.cpp plugin/LADSPAPluginInstance.cpp plugin/PluginXml.cpp plugin/RealTimePluginFactory.cpp plugin/RealTimePluginInstance.cpp plugin/plugins/SamplePlayer.cpp rdf/PluginRDFDescription.cpp rdf/PluginRDFIndexer.cpp rdf/RDFFeatureWriter.cpp rdf/RDFImporter.cpp rdf/RDFTransformFactory.cpp rdf/SimpleSPARQLQuery.cpp system/System.h transform/CSVFeatureWriter.cpp transform/FeatureExtractionModelTransformer.cpp transform/FileFeatureWriter.cpp transform/ModelTransformerFactory.cpp transform/RealTimeEffectModelTransformer.cpp transform/Transform.cpp transform/TransformFactory.cpp
diffstat 65 files changed, 485 insertions(+), 492 deletions(-) [+]
line wrap: on
line diff
--- a/base/LogRange.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/base/LogRange.cpp	Mon May 16 17:19:09 2011 +0100
@@ -26,7 +26,7 @@
     if (min > max) std::swap(min, max);
     if (max == min) max = min + 1;
 
-//    std::cerr << "LogRange::mapRange: min = " << min << ", max = " << max << std::endl;
+//    DEBUG << "LogRange::mapRange: min = " << min << ", max = " << max << endl;
 
     if (min >= 0.f) {
 
@@ -35,7 +35,7 @@
         if (min == 0.f) min = std::min(logthresh, max);
         else min = log10f(min);
 
-//        std::cerr << "LogRange::mapRange: positive: min = " << min << ", max = " << max << std::endl;
+//        DEBUG << "LogRange::mapRange: positive: min = " << min << ", max = " << max << endl;
 
     } else if (max <= 0.f) {
         
@@ -46,7 +46,7 @@
         
         std::swap(min, max);
         
-//        std::cerr << "LogRange::mapRange: negative: min = " << min << ", max = " << max << std::endl;
+//        DEBUG << "LogRange::mapRange: negative: min = " << min << ", max = " << max << endl;
 
     } else {
         
@@ -55,7 +55,7 @@
         max = log10f(std::max(max, -min));
         min = std::min(logthresh, max);
 
-//        std::cerr << "LogRange::mapRange: spanning: min = " << min << ", max = " << max << std::endl;
+//        DEBUG << "LogRange::mapRange: spanning: min = " << min << ", max = " << max << endl;
     }
 
     if (min == max) min = max - 1;
@@ -104,8 +104,8 @@
     float sd0 = sd(values, 0, mi);
     float sd1 = sd(values, mi, values.size() - mi);
 
-    std::cerr << "LogRange::useLogScale: sd0 = "
-              << sd0 << ", sd1 = " << sd1 << std::endl;
+    DEBUG << "LogRange::useLogScale: sd0 = "
+              << sd0 << ", sd1 = " << sd1 << endl;
 
     if (sd0 == 0 || sd1 == 0) return false;
 
--- a/base/LogRange.h	Thu May 12 17:31:24 2011 +0100
+++ b/base/LogRange.h	Mon May 16 17:19:09 2011 +0100
@@ -17,6 +17,7 @@
 #define _LOG_RANGE_H_
 
 #include <vector>
+#include "Debug.h"
 
 class LogRange
 {
--- a/base/PlayParameterRepository.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/base/PlayParameterRepository.cpp	Mon May 16 17:19:09 2011 +0100
@@ -124,7 +124,7 @@
 PlayParameterRepository::playPluginConfigurationChanged(QString config)
 {
     PlayParameters *params = dynamic_cast<PlayParameters *>(sender());
-//    std::cerr << "PlayParameterRepository::playPluginConfigurationChanged" << std::endl;
+//    DEBUG << "PlayParameterRepository::playPluginConfigurationChanged" << endl;
     for (PlayableParameterMap::iterator i = m_playParameters.begin();
          i != m_playParameters.end(); ++i) {
         if (i->second == params) {
--- a/base/PropertyContainer.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/base/PropertyContainer.cpp	Mon May 16 17:19:09 2011 +0100
@@ -192,7 +192,7 @@
         break;
 
     case InvalidProperty:
-        std::cerr << "PropertyContainer::convertPropertyStrings: Invalid property name \"" << name << "\"" << std::endl;
+        DEBUG << "PropertyContainer::convertPropertyStrings: Invalid property name \"" << name << "\"" << endl;
         return false;
     }
 
@@ -207,7 +207,7 @@
         std::cerr << "PropertyContainer::convertPropertyStrings: Unable to parse value string \"" << valueString << "\"" << std::endl;
         return false;
     } else if (i < min || i > max) {
-        std::cerr << "PropertyContainer::convertPropertyStrings: Property value \"" << i << "\" outside valid range " << min << " to " << max << std::endl;
+        DEBUG << "PropertyContainer::convertPropertyStrings: Property value \"" << i << "\" outside valid range " << min << " to " << max << endl;
         return false;
     }
 
--- a/base/RangeMapper.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/base/RangeMapper.cpp	Mon May 16 17:19:09 2011 +0100
@@ -43,8 +43,8 @@
                * (m_maxpos - m_minpos));
     if (position < m_minpos) position = m_minpos;
     if (position > m_maxpos) position = m_maxpos;
-//    std::cerr << "LinearRangeMapper::getPositionForValue: " << value << " -> "
-//              << position << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", minval " << m_minval << ", maxval " << m_maxval << ")" << std::endl;
+//    DEBUG << "LinearRangeMapper::getPositionForValue: " << value << " -> "
+//              << position << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", minval " << m_minval << ", maxval " << m_maxval << ")" << endl;
     if (m_inverted) return m_maxpos - position;
     else return position;
 }
@@ -58,8 +58,8 @@
          * (m_maxval - m_minval));
     if (value < m_minval) value = m_minval;
     if (value > m_maxval) value = m_maxval;
-//    std::cerr << "LinearRangeMapper::getValueForPosition: " << position << " -> "
-//              << value << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", minval " << m_minval << ", maxval " << m_maxval << ")" << std::endl;
+//    DEBUG << "LinearRangeMapper::getValueForPosition: " << position << " -> "
+//              << value << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", minval " << m_minval << ", maxval " << m_maxval << ")" << endl;
     return value;
 }
 
@@ -109,8 +109,8 @@
     int position = (log10(value) - m_minlog) * m_ratio + m_minpos;
     if (position < m_minpos) position = m_minpos;
     if (position > m_maxpos) position = m_maxpos;
-//    std::cerr << "LogRangeMapper::getPositionForValue: " << value << " -> "
-//              << position << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", ratio " << m_ratio << ", minlog " << m_minlog << ")" << std::endl;
+//    DEBUG << "LogRangeMapper::getPositionForValue: " << value << " -> "
+//              << position << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", ratio " << m_ratio << ", minlog " << m_minlog << ")" << endl;
     if (m_inverted) return m_maxpos - position;
     else return position;
 }
@@ -120,8 +120,8 @@
 {
     if (m_inverted) position = m_maxpos - position;
     float value = powf(10, (position - m_minpos) / m_ratio + m_minlog);
-//    std::cerr << "LogRangeMapper::getValueForPosition: " << position << " -> "
-//              << value << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", ratio " << m_ratio << ", minlog " << m_minlog << ")" << std::endl;
+//    DEBUG << "LogRangeMapper::getValueForPosition: " << position << " -> "
+//              << value << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", ratio " << m_ratio << ", minlog " << m_minlog << ")" << endl;
     return value;
 }
 
--- a/base/RealTime.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/base/RealTime.cpp	Mon May 16 17:19:09 2011 +0100
@@ -242,8 +242,8 @@
     int nsec = atoi(snsec.c_str());
     if (negative) sec = -sec;
 
-//    std::cerr << "RealTime::fromString: string " << s << " -> "
-//              << sec << " sec, " << nsec << " nsec" << std::endl;
+//    DEBUG << "RealTime::fromString: string " << s << " -> "
+//              << sec << " sec, " << nsec << " nsec" << endl;
 
     return RealTime(sec, nsec);
 }
--- a/base/ResourceFinder.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/base/ResourceFinder.cpp	Mon May 16 17:19:09 2011 +0100
@@ -152,7 +152,7 @@
         
         QString prefix = *i;
 
-        std::cerr << "ResourceFinder::getResourcePath: Looking up file \"" << fileName << "\" for category \"" << resourceCat << "\" in prefix \"" << prefix << "\"" << std::endl;
+        DEBUG << "ResourceFinder::getResourcePath: Looking up file \"" << fileName << "\" for category \"" << resourceCat << "\" in prefix \"" << prefix << "\"" << endl;
 
         QString path =
             QString("%1%2/%3").arg(prefix).arg(resourceCat).arg(fileName);
@@ -278,7 +278,7 @@
     // This is the lowest-priority alternative path for this
     // resource, so we know that there must be no installed copy.
     // Install one to the user location.
-    std::cerr << "ResourceFinder::unbundleResource: File " << fileName << " is bundled, un-bundling it" << std::endl;
+    DEBUG << "ResourceFinder::unbundleResource: File " << fileName << " is bundled, un-bundling it" << endl;
     QString target = getResourceSavePath(resourceCat, fileName);
     QFile file(path);
     if (!file.copy(target)) {
--- a/base/StorageAdviser.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/base/StorageAdviser.cpp	Mon May 16 17:19:09 2011 +0100
@@ -36,9 +36,9 @@
 			  int maximumSize)
 {
 #ifdef DEBUG_STORAGE_ADVISER
-    std::cerr << "StorageAdviser::recommend: Criteria " << criteria 
+    DEBUG << "StorageAdviser::recommend: Criteria " << criteria 
               << ", minimumSize " << minimumSize
-              << ", maximumSize " << maximumSize << std::endl;
+              << ", maximumSize " << maximumSize << endl;
 #endif
 
     if (m_baseRecommendation != NoRecommendation) {
--- a/base/TempDirectory.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/base/TempDirectory.cpp	Mon May 16 17:19:09 2011 +0100
@@ -44,7 +44,7 @@
 
 TempDirectory::~TempDirectory()
 {
-    std::cerr << "TempDirectory::~TempDirectory" << std::endl;
+    DEBUG << "TempDirectory::~TempDirectory" << endl;
 
     cleanup();
 }
--- a/base/XmlExportable.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/base/XmlExportable.cpp	Mon May 16 17:19:09 2011 +0100
@@ -25,7 +25,7 @@
 XmlExportable::toXmlString(QString indent,
                            QString extraAttributes) const
 {
-//    std::cerr << "XmlExportable::toXmlString" << std::endl;
+//    DEBUG << "XmlExportable::toXmlString" << endl;
 
     QString s;
 
--- a/data/fft/FFTDataServer.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fft/FFTDataServer.cpp	Mon May 16 17:19:09 2011 +0100
@@ -191,7 +191,7 @@
                 if (server->getFillCompletion() < 50) distance += 100;
 
 #ifdef DEBUG_FFT_SERVER
-                std::cerr << "FFTDataServer::getFuzzyInstance: Distance for server " << server << " is " << distance << ", best is " << bestdist << std::endl;
+                DEBUG << "FFTDataServer::getFuzzyInstance: Distance for server " << server << " is " << distance << ", best is " << bestdist << endl;
 #endif
                 
                 if (bestdist == -1 || distance < bestdist) {
@@ -204,7 +204,7 @@
         if (bestdist >= 0) {
             FFTDataServer *server = best->second.first;
 #ifdef DEBUG_FFT_SERVER
-            std::cerr << "FFTDataServer::getFuzzyInstance: We like server " << server << " (with distance " << bestdist << ")" << std::endl;
+            DEBUG << "FFTDataServer::getFuzzyInstance: We like server " << server << " (with distance " << bestdist << ")" << endl;
 #endif
             claimInstance(server, false);
             return server;
@@ -228,7 +228,7 @@
 FFTDataServer::findServer(QString n)
 {    
 #ifdef DEBUG_FFT_SERVER
-    std::cerr << "FFTDataServer::findServer(\"" << n << "\")" << std::endl;
+    DEBUG << "FFTDataServer::findServer(\"" << n << "\")" << endl;
 #endif
 
     if (m_servers.find(n) != m_servers.end()) {
@@ -236,7 +236,7 @@
         FFTDataServer *server = m_servers[n].first;
 
 #ifdef DEBUG_FFT_SERVER
-        std::cerr << "FFTDataServer::findServer(\"" << n << "\"): found " << server << std::endl;
+        DEBUG << "FFTDataServer::findServer(\"" << n << "\"): found " << server << endl;
 #endif
 
         claimInstance(server, false);
@@ -245,7 +245,7 @@
     }
 
 #ifdef DEBUG_FFT_SERVER
-        std::cerr << "FFTDataServer::findServer(\"" << n << "\"): not found" << std::endl;
+        DEBUG << "FFTDataServer::findServer(\"" << n << "\"): not found" << endl;
 #endif
 
     return 0;
@@ -264,7 +264,7 @@
                        "FFTDataServer::claimInstance::m_serverMapMutex");
 
 #ifdef DEBUG_FFT_SERVER
-    std::cerr << "FFTDataServer::claimInstance(" << server << ")" << std::endl;
+    DEBUG << "FFTDataServer::claimInstance(" << server << ")" << endl;
 #endif
 
     for (ServerMap::iterator i = m_servers.begin(); i != m_servers.end(); ++i) {
@@ -275,7 +275,7 @@
 
                 if (*j == server) {
 #ifdef DEBUG_FFT_SERVER
-    std::cerr << "FFTDataServer::claimInstance: found in released server list, removing from it" << std::endl;
+    DEBUG << "FFTDataServer::claimInstance: found in released server list, removing from it" << endl;
 #endif
                     m_releasedServers.erase(j);
                     break;
@@ -285,7 +285,7 @@
             ++i->second.second;
 
 #ifdef DEBUG_FFT_SERVER
-            std::cerr << "FFTDataServer::claimInstance: new refcount is " << i->second.second << std::endl;
+            DEBUG << "FFTDataServer::claimInstance: new refcount is " << i->second.second << endl;
 #endif
 
             return;
@@ -309,7 +309,7 @@
                        "FFTDataServer::releaseInstance::m_serverMapMutex");
 
 #ifdef DEBUG_FFT_SERVER
-    std::cerr << "FFTDataServer::releaseInstance(" << server << ")" << std::endl;
+    DEBUG << "FFTDataServer::releaseInstance(" << server << ")" << endl;
 #endif
 
     // -- if ref count > 0, decrement and return
@@ -332,18 +332,18 @@
 /*!!!
                 if (server->m_lastUsedCache == -1) { // never used
 #ifdef DEBUG_FFT_SERVER
-                    std::cerr << "FFTDataServer::releaseInstance: instance "
+                    DEBUG << "FFTDataServer::releaseInstance: instance "
                               << server << " has never been used, erasing"
-                              << std::endl;
+                              << endl;
 #endif
                     delete server;
                     m_servers.erase(i);
                 } else {
 */
 #ifdef DEBUG_FFT_SERVER
-                    std::cerr << "FFTDataServer::releaseInstance: instance "
+                    DEBUG << "FFTDataServer::releaseInstance: instance "
                               << server << " no longer in use, marking for possible collection"
-                              << std::endl;
+                              << endl;
 #endif
                     bool found = false;
                     for (ServerQueue::iterator j = m_releasedServers.begin();
@@ -361,9 +361,9 @@
 //!!!                }
             } else {
 #ifdef DEBUG_FFT_SERVER
-                    std::cerr << "FFTDataServer::releaseInstance: instance "
+                    DEBUG << "FFTDataServer::releaseInstance: instance "
                               << server << " now has refcount " << i->second.second
-                              << std::endl;
+                              << endl;
 #endif
             }
             return;
@@ -378,8 +378,8 @@
 FFTDataServer::purgeLimbo(int maxSize)
 {
 #ifdef DEBUG_FFT_SERVER
-    std::cerr << "FFTDataServer::purgeLimbo(" << maxSize << "): "
-              << m_releasedServers.size() << " candidates" << std::endl;
+    DEBUG << "FFTDataServer::purgeLimbo(" << maxSize << "): "
+              << m_releasedServers.size() << " candidates" << endl;
 #endif
 
     while (int(m_releasedServers.size()) > maxSize) {
@@ -389,8 +389,8 @@
         bool found = false;
 
 #ifdef DEBUG_FFT_SERVER
-        std::cerr << "FFTDataServer::purgeLimbo: considering candidate "
-                  << server << std::endl;
+        DEBUG << "FFTDataServer::purgeLimbo: considering candidate "
+                  << server << endl;
 #endif
 
         for (ServerMap::iterator i = m_servers.begin(); i != m_servers.end(); ++i) {
@@ -405,8 +405,8 @@
                     break;
                 }
 #ifdef DEBUG_FFT_SERVER
-                std::cerr << "FFTDataServer::purgeLimbo: looks OK, erasing it"
-                          << std::endl;
+                DEBUG << "FFTDataServer::purgeLimbo: looks OK, erasing it"
+                          << endl;
 #endif
 
                 m_servers.erase(i);
@@ -426,8 +426,8 @@
     }
 
 #ifdef DEBUG_FFT_SERVER
-    std::cerr << "FFTDataServer::purgeLimbo(" << maxSize << "): "
-              << m_releasedServers.size() << " remain" << std::endl;
+    DEBUG << "FFTDataServer::purgeLimbo(" << maxSize << "): "
+              << m_releasedServers.size() << " remain" << endl;
 #endif
 
 }
@@ -439,8 +439,8 @@
                        "FFTDataServer::modelAboutToBeDeleted::m_serverMapMutex");
 
 #ifdef DEBUG_FFT_SERVER
-    std::cerr << "FFTDataServer::modelAboutToBeDeleted(" << model << ")"
-              << std::endl;
+    DEBUG << "FFTDataServer::modelAboutToBeDeleted(" << model << ")"
+              << endl;
 #endif
 
     for (ServerMap::iterator i = m_servers.begin(); i != m_servers.end(); ++i) {
@@ -450,8 +450,8 @@
         if (server->getModel() == model) {
 
 #ifdef DEBUG_FFT_SERVER
-            std::cerr << "FFTDataServer::modelAboutToBeDeleted: server is "
-                      << server << std::endl;
+            DEBUG << "FFTDataServer::modelAboutToBeDeleted: server is "
+                      << server << endl;
 #endif
 
             if (i->second.second > 0) {
@@ -463,14 +463,14 @@
                  j != m_releasedServers.end(); ++j) {
                 if (*j == server) {
 #ifdef DEBUG_FFT_SERVER
-                    std::cerr << "FFTDataServer::modelAboutToBeDeleted: erasing from released servers" << std::endl;
+                    DEBUG << "FFTDataServer::modelAboutToBeDeleted: erasing from released servers" << endl;
 #endif
                     m_releasedServers.erase(j);
                     break;
                 }
             }
 #ifdef DEBUG_FFT_SERVER
-            std::cerr << "FFTDataServer::modelAboutToBeDeleted: erasing server" << std::endl;
+            DEBUG << "FFTDataServer::modelAboutToBeDeleted: erasing server" << endl;
 #endif
             m_servers.erase(i);
             delete server;
@@ -841,7 +841,7 @@
     // preconditions: m_caches[c] exists and contains a file writer;
     // m_cacheVectorLock is not locked by this thread
 #ifdef DEBUG_FFT_SERVER
-    std::cerr << "FFTDataServer::makeCacheReader(" << c << ")" << std::endl;
+    DEBUG << "FFTDataServer::makeCacheReader(" << c << ")" << endl;
 #endif
 
     QThread *me = QThread::currentThread();
@@ -875,7 +875,7 @@
     cb = m_caches.at(deleteCandidate);
     if (cb && cb->fileCacheReader.find(me) != cb->fileCacheReader.end()) {
 #ifdef DEBUG_FFT_SERVER
-        std::cerr << "FFTDataServer::makeCacheReader: Deleting probably unpopular reader " << deleteCandidate << " for this thread (as I create reader " << c << ")" << std::endl;
+        DEBUG << "FFTDataServer::makeCacheReader: Deleting probably unpopular reader " << deleteCandidate << " for this thread (as I create reader " << c << ")" << endl;
 #endif
         delete cb->fileCacheReader[me];
         cb->fileCacheReader.erase(me);
@@ -901,8 +901,8 @@
         if (!cache->haveSetColumnAt(col)) {
             Profiler profiler("FFTDataServer::getMagnitudeAt: filling");
 #ifdef DEBUG_FFT_SERVER
-            std::cerr << "FFTDataServer::getMagnitudeAt: calling fillColumn(" 
-                  << x << ")" << std::endl;
+            DEBUG << "FFTDataServer::getMagnitudeAt: calling fillColumn(" 
+                  << x << ")" << endl;
 #endif
             fillColumn(x);
         }
@@ -1130,7 +1130,7 @@
         if (!cache->haveSetColumnAt(col)) {
             Profiler profiler("FFTDataServer::getValuesAt: filling");
 #ifdef DEBUG_FFT_SERVER
-            std::cerr << "FFTDataServer::getValuesAt(" << x << ", " << y << "): filling" << std::endl;
+            DEBUG << "FFTDataServer::getValuesAt(" << x << ", " << y << "): filling" << endl;
 #endif
             fillColumn(x);
         }        
@@ -1189,7 +1189,7 @@
 /*!!!
         if (m_lastUsedCache == -1) {
             if (m_suspended) {
-                std::cerr << "FFTDataServer::isColumnReady(" << x << "): no cache, calling resume" << std::endl;
+                DEBUG << "FFTDataServer::isColumnReady(" << x << "): no cache, calling resume" << endl;
                 resume();
             }
             m_fillThread->start();
@@ -1258,12 +1258,12 @@
     endFrame   -= winsize / 2;
 
 #ifdef DEBUG_FFT_SERVER_FILL
-    std::cerr << "FFTDataServer::fillColumn: requesting frames "
+    DEBUG << "FFTDataServer::fillColumn: requesting frames "
               << startFrame + pfx << " -> " << endFrame << " ( = "
               << endFrame - (startFrame + pfx) << ") at index "
               << off + pfx << " in buffer of size " << m_fftSize
               << " with window size " << m_windowSize 
-              << " from channel " << m_channel << std::endl;
+              << " from channel " << m_channel << endl;
 #endif
 
     QMutexLocker locker(&m_fftBuffersLock);
@@ -1370,7 +1370,7 @@
     }
 
     if (m_suspended) {
-//        std::cerr << "FFTDataServer::fillColumn(" << x << "): calling resume" << std::endl;
+//        DEBUG << "FFTDataServer::fillColumn(" << x << "): calling resume" << endl;
 //        resume();
     }
 }    
@@ -1446,7 +1446,7 @@
 FFTDataServer::FillThread::run()
 {
 #ifdef DEBUG_FFT_SERVER_FILL
-    std::cerr << "FFTDataServer::FillThread::run()" << std::endl;
+    DEBUG << "FFTDataServer::FillThread::run()" << endl;
 #endif
     
     m_extent = 0;
@@ -1454,7 +1454,7 @@
     
     while (!m_server.m_model->isReady() && !m_server.m_exiting) {
 #ifdef DEBUG_FFT_SERVER_FILL
-        std::cerr << "FFTDataServer::FillThread::run(): waiting for model " << m_server.m_model << " to be ready" << std::endl;
+        DEBUG << "FFTDataServer::FillThread::run(): waiting for model " << m_server.m_model << " to be ready" << endl;
 #endif
         sleep(1);
     }
@@ -1476,7 +1476,7 @@
             try {
                 m_server.fillColumn(int((f - start) / m_server.m_windowIncrement));
             } catch (std::exception &e) {
-                std::cerr << "FFTDataServer::FillThread::run: exception: " << e.what() << std::endl;
+                DEBUG << "FFTDataServer::FillThread::run: exception: " << e.what() << endl;
                 m_error = e.what();
                 m_server.fillComplete();
                 m_completion = 100;
@@ -1525,7 +1525,7 @@
         try {
             m_server.fillColumn(int((f - start) / m_server.m_windowIncrement));
         } catch (std::exception &e) {
-            std::cerr << "FFTDataServer::FillThread::run: exception: " << e.what() << std::endl;
+            DEBUG << "FFTDataServer::FillThread::run: exception: " << e.what() << endl;
             m_error = e.what();
             m_server.fillComplete();
             m_completion = 100;
@@ -1567,7 +1567,7 @@
     m_extent = end;
 
 #ifdef DEBUG_FFT_SERVER
-    std::cerr << "FFTDataServer::FillThread::run exiting" << std::endl;
+    DEBUG << "FFTDataServer::FillThread::run exiting" << endl;
 #endif
 }
 
--- a/data/fft/FFTFileCacheReader.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fft/FFTFileCacheReader.cpp	Mon May 16 17:19:09 2011 +0100
@@ -157,7 +157,7 @@
 void
 FFTFileCacheReader::getValuesAt(size_t x, size_t y, float &real, float &imag) const
 {
-//    std::cerr << "FFTFileCacheReader::getValuesAt(" << x << "," << y << ")" << std::endl;
+//    DEBUG << "FFTFileCacheReader::getValuesAt(" << x << "," << y << ")" << endl;
 
     switch (m_storageType) {
 
@@ -216,7 +216,7 @@
 {
     if (m_readbuf && m_readbufGood &&
         (m_readbufCol == x || (m_readbufWidth > 1 && m_readbufCol+1 == x))) {
-//        std::cerr << "FFTFileCacheReader::haveSetColumnAt: short-circuiting; we know about this one" << std::endl;
+//        DEBUG << "FFTFileCacheReader::haveSetColumnAt: short-circuiting; we know about this one" << endl;
         return true;
     }
     return m_mfc->haveSetColumnAt(x);
@@ -236,7 +236,7 @@
 {
     Profiler profiler("FFTFileCacheReader::populateReadBuf", false);
 
-//    std::cerr << "FFTFileCacheReader::populateReadBuf(" << x << ")" << std::endl;
+//    DEBUG << "FFTFileCacheReader::populateReadBuf(" << x << ")" << endl;
 
     if (!m_readbuf) {
         m_readbuf = new char[m_mfc->getHeight() * 2 * m_mfc->getCellSize()];
--- a/data/fft/FFTFileCacheWriter.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fft/FFTFileCacheWriter.cpp	Mon May 16 17:19:09 2011 +0100
@@ -188,7 +188,7 @@
 FFTFileCacheWriter::allColumnsWritten()
 {
 #ifdef DEBUG_FFT_FILE_CACHE_WRITER
-    std::cerr << "FFTFileCacheWriter::allColumnsWritten" << std::endl;
+    DEBUG << "FFTFileCacheWriter::allColumnsWritten" << endl;
 #endif
     m_mfc->close();
 }
--- a/data/fileio/AudioFileReaderFactory.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/AudioFileReaderFactory.cpp	Mon May 16 17:19:09 2011 +0100
@@ -73,7 +73,7 @@
 {
     QString err;
 
-//    std::cerr << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\"): Requested rate: " << targetRate << std::endl;
+//    DEBUG << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\"): Requested rate: " << targetRate << endl;
 
     if (!source.isOK()) {
         std::cerr << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Failed to retrieve source (transmission error?): " << source.getErrorString() << std::endl;
@@ -81,7 +81,7 @@
     }
 
     if (!source.isAvailable()) {
-        std::cerr << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Source not found" << std::endl;
+        DEBUG << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Source not found" << endl;
         return 0;
     }
 
@@ -98,7 +98,7 @@
             reader->isOK() &&
             reader->getSampleRate() != targetRate) {
 
-            std::cerr << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", creating resampling reader" << std::endl;
+            DEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", creating resampling reader" << endl;
 
             delete reader;
             reader = new ResamplingWavFileReader
@@ -189,7 +189,7 @@
             reader->isOK() &&
             reader->getSampleRate() != targetRate) {
 
-            std::cerr << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", creating resampling reader" << std::endl;
+            DEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", creating resampling reader" << endl;
 
             delete reader;
             reader = new ResamplingWavFileReader
--- a/data/fileio/BZipFileDevice.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/BZipFileDevice.cpp	Mon May 16 17:19:09 2011 +0100
@@ -30,7 +30,7 @@
 
 BZipFileDevice::~BZipFileDevice()
 {
-//    std::cerr << "BZipFileDevice::~BZipFileDevice(" << m_fileName << ")" << std::endl;
+//    DEBUG << "BZipFileDevice::~BZipFileDevice(" << m_fileName << ")" << endl;
     if (m_bzFile) close();
 }
 
@@ -178,7 +178,7 @@
     int bzError = BZ_OK;
     int read = BZ2_bzRead(&bzError, m_bzFile, data, maxSize);
 
-//    std::cerr << "BZipFileDevice::readData: requested " << maxSize << ", read " << read << std::endl;
+//    DEBUG << "BZipFileDevice::readData: requested " << maxSize << ", read " << read << endl;
 
     if (bzError != BZ_OK) {
         if (bzError != BZ_STREAM_END) {
@@ -187,7 +187,7 @@
             m_ok = false;
             return -1;
         } else {
-//            std::cerr << "BZipFileDevice::readData: reached end of file" << std::endl;
+//            DEBUG << "BZipFileDevice::readData: reached end of file" << endl;
             m_atEnd = true;
         }            
     }
@@ -201,7 +201,7 @@
     int bzError = BZ_OK;
     BZ2_bzWrite(&bzError, m_bzFile, (void *)data, maxSize);
 
-//    std::cerr << "BZipFileDevice::writeData: " << maxSize << " to write" << std::endl;
+//    DEBUG << "BZipFileDevice::writeData: " << maxSize << " to write" << endl;
 
     if (bzError != BZ_OK) {
         std::cerr << "BZipFileDevice::writeData: error condition" << std::endl;
@@ -210,7 +210,7 @@
         return -1;
     }
 
-//    std::cerr << "BZipFileDevice::writeData: wrote " << maxSize << std::endl;
+//    DEBUG << "BZipFileDevice::writeData: wrote " << maxSize << endl;
 
     return maxSize;
 }
--- a/data/fileio/CSVFileReader.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/CSVFileReader.cpp	Mon May 16 17:19:09 2011 +0100
@@ -59,10 +59,10 @@
 
 CSVFileReader::~CSVFileReader()
 {
-    std::cerr << "CSVFileReader::~CSVFileReader: file is " << m_file << std::endl;
+    DEBUG << "CSVFileReader::~CSVFileReader: file is " << m_file << endl;
 
     if (m_file) {
-        std::cerr << "CSVFileReader::CSVFileReader: Closing file" << std::endl;
+        DEBUG << "CSVFileReader::CSVFileReader: Closing file" << endl;
         m_file->close();
     }
     delete m_file;
@@ -345,8 +345,8 @@
                     }
                 }
 	
-//                std::cerr << "Setting bin values for count " << lineno << ", frame "
-//                          << frameNo << ", time " << RealTime::frame2RealTime(frameNo, sampleRate) << std::endl;
+//                DEBUG << "Setting bin values for count " << lineno << ", frame "
+//                          << frameNo << ", time " << RealTime::frame2RealTime(frameNo, sampleRate) << endl;
 
                 model3->setColumn(lineno, values);
             }
--- a/data/fileio/CachedFile.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/CachedFile.cpp	Mon May 16 17:19:09 2011 +0100
@@ -78,8 +78,8 @@
 {
     Profiler p("CachedFile::CachedFile[1]");
 
-    std::cerr << "CachedFile::CachedFile: origin is \""
-              << origin << "\"" << std::endl;
+    DEBUG << "CachedFile::CachedFile: origin is \""
+              << origin << "\"" << endl;
     check();
 }
 
@@ -93,8 +93,8 @@
 {
     Profiler p("CachedFile::CachedFile[2]");
 
-    std::cerr << "CachedFile::CachedFile: url is \""
-              << url.toString() << "\"" << std::endl;
+    DEBUG << "CachedFile::CachedFile: url is \""
+              << url.toString() << "\"" << endl;
     check();
 }
 
@@ -132,20 +132,20 @@
     m_localFilename = getLocalFilenameFor(m_origin);
 
     if (!QFileInfo(m_localFilename).exists()) {
-        std::cerr << "CachedFile::check: Local file does not exist, making a note that it hasn't been retrieved" << std::endl;
+        DEBUG << "CachedFile::check: Local file does not exist, making a note that it hasn't been retrieved" << endl;
         updateLastRetrieval(false); // empirically!
     }
 
     QDateTime lastRetrieval = getLastRetrieval();
 
     if (lastRetrieval.isValid()) {
-        std::cerr << "CachedFile::check: Valid last retrieval at "
-                  << lastRetrieval.toString() << std::endl;
+        DEBUG << "CachedFile::check: Valid last retrieval at "
+                  << lastRetrieval.toString() << endl;
         // this will not be the case if the file is missing, after
         // updateLastRetrieval(false) was called above
         m_ok = true;
         if (lastRetrieval.addDays(2) < QDateTime::currentDateTime()) { //!!!
-            std::cerr << "CachedFile::check: Out of date; trying to retrieve again" << std::endl;
+            DEBUG << "CachedFile::check: Out of date; trying to retrieve again" << endl;
             // doesn't matter if retrieval fails -- we just don't
             // update the last retrieval time
 
@@ -154,17 +154,17 @@
             // retrieval every single time if it isn't working
 
             if (retrieve()) {
-                std::cerr << "CachedFile::check: Retrieval succeeded" << std::endl;
+                DEBUG << "CachedFile::check: Retrieval succeeded" << endl;
                 updateLastRetrieval(true);
             } else {
                 std::cerr << "CachedFile::check: Retrieval failed, will try again later (using existing file for now)" << std::endl;
             }                
         }
     } else {
-        std::cerr << "CachedFile::check: No valid last retrieval" << std::endl;
+        DEBUG << "CachedFile::check: No valid last retrieval" << endl;
         // there is no acceptable file
         if (retrieve()) {
-            std::cerr << "CachedFile::check: Retrieval succeeded" << std::endl;
+            DEBUG << "CachedFile::check: Retrieval succeeded" << endl;
             m_ok = true;
             updateLastRetrieval(true);
         } else {
@@ -191,21 +191,21 @@
     FileSource fs(m_origin, m_reporter, m_preferredContentType);
 
     if (!fs.isOK() || !fs.isAvailable()) {
-        std::cerr << "CachedFile::retrieve: ERROR: FileSource reported unavailable or failure" << std::endl;
+        DEBUG << "CachedFile::retrieve: ERROR: FileSource reported unavailable or failure" << endl;
         return false;
     }
 
     fs.waitForData();
 
     if (!fs.isOK()) {
-        std::cerr << "CachedFile::retrieve: ERROR: FileSource reported failure during receive" << std::endl;
+        DEBUG << "CachedFile::retrieve: ERROR: FileSource reported failure during receive" << endl;
         return false;
     }
 
     QString tempName = fs.getLocalFilename();
     QFile tempFile(tempName);
     if (!tempFile.exists()) {
-        std::cerr << "CachedFile::retrieve: ERROR: FileSource reported success, but local temporary file \"" << tempName << "\" does not exist" << std::endl;
+        DEBUG << "CachedFile::retrieve: ERROR: FileSource reported success, but local temporary file \"" << tempName << "\" does not exist" << endl;
         return false;
     }
 
@@ -226,7 +226,7 @@
         return false;
     }
 
-    std::cerr << "CachedFile::retrieve: Successfully copied newly retrieved file \"" << tempName << "\" to its home at \"" << m_localFilename << "\"" << std::endl;
+    DEBUG << "CachedFile::retrieve: Successfully copied newly retrieved file \"" << tempName << "\" to its home at \"" << m_localFilename << "\"" << endl;
 
     return true;
 }
--- a/data/fileio/CodedAudioFileReader.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/CodedAudioFileReader.cpp	Mon May 16 17:19:09 2011 +0100
@@ -40,7 +40,7 @@
     m_resampler(0),
     m_resampleBuffer(0)
 {
-//    std::cerr << "CodedAudioFileReader::CodedAudioFileReader: rate " << targetRate << std::endl;
+//    DEBUG << "CodedAudioFileReader::CodedAudioFileReader: rate " << targetRate << endl;
 
     m_frameCount = 0;
     m_sampleRate = targetRate;
@@ -54,7 +54,7 @@
 
     if (m_cacheFileWritePtr) sf_close(m_cacheFileWritePtr);
 
-//    std::cerr << "CodedAudioFileReader::~CodedAudioFileReader: deleting cache file reader" << std::endl;
+//    DEBUG << "CodedAudioFileReader::~CodedAudioFileReader: deleting cache file reader" << endl;
 
     delete m_cacheFileReader;
     delete[] m_cacheWriteBuffer;
@@ -72,7 +72,7 @@
 void
 CodedAudioFileReader::startSerialised(QString id)
 {
-//    std::cerr << "CodedAudioFileReader::startSerialised(" << id << ")" << std::endl;
+//    DEBUG << "CodedAudioFileReader::startSerialised(" << id << ")" << endl;
 
     delete m_serialiser;
     m_serialiser = new Serialiser(id);
@@ -92,15 +92,15 @@
 {
     QMutexLocker locker(&m_cacheMutex);
 
-//    std::cerr << "CodedAudioFileReader::initialiseDecodeCache: file rate = " << m_fileRate << std::endl;
+//    DEBUG << "CodedAudioFileReader::initialiseDecodeCache: file rate = " << m_fileRate << endl;
 
     if (m_fileRate == 0) {
-        std::cerr << "CodedAudioFileReader::initialiseDecodeCache: ERROR: File sample rate unknown (bug in subclass implementation?)" << std::endl;
+        DEBUG << "CodedAudioFileReader::initialiseDecodeCache: ERROR: File sample rate unknown (bug in subclass implementation?)" << endl;
         m_fileRate = 48000; // got to have something
     }
     if (m_sampleRate == 0) {
         m_sampleRate = m_fileRate;
-        std::cerr << "CodedAudioFileReader::initialiseDecodeCache: rate (from file) = " << m_fileRate << std::endl;
+        DEBUG << "CodedAudioFileReader::initialiseDecodeCache: rate (from file) = " << m_fileRate << endl;
     }
     if (m_fileRate != m_sampleRate) {
         std::cerr << "CodedAudioFileReader: resampling " << m_fileRate << " -> " <<  m_sampleRate << std::endl;
@@ -354,7 +354,7 @@
     // locking)
 
     if (!m_initialised) {
-        std::cerr << "CodedAudioFileReader::getInterleavedFrames: not initialised" << std::endl;
+        DEBUG << "CodedAudioFileReader::getInterleavedFrames: not initialised" << endl;
         return;
     }
 
--- a/data/fileio/FileReadThread.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/FileReadThread.cpp	Mon May 16 17:19:09 2011 +0100
@@ -47,7 +47,7 @@
     notifyCancelled();
 
 #ifdef DEBUG_FILE_READ_THREAD
-    std::cerr << "FileReadThread::run() exiting" << std::endl;
+    DEBUG << "FileReadThread::run() exiting" << endl;
 #endif
 }
 
@@ -55,7 +55,7 @@
 FileReadThread::finish()
 {
 #ifdef DEBUG_FILE_READ_THREAD
-    std::cerr << "FileReadThread::finish()" << std::endl;
+    DEBUG << "FileReadThread::finish()" << endl;
 #endif
 
     {
@@ -73,7 +73,7 @@
     m_condition.wakeAll();
 
 #ifdef DEBUG_FILE_READ_THREAD
-    std::cerr << "FileReadThread::finish() exiting" << std::endl;
+    DEBUG << "FileReadThread::finish() exiting" << endl;
 #endif
 }
 
@@ -113,7 +113,7 @@
     }
 
 #ifdef DEBUG_FILE_READ_THREAD
-    std::cerr << "FileReadThread::cancel(" << token << ") waking condition" << std::endl;
+    DEBUG << "FileReadThread::cancel(" << token << ") waking condition" << endl;
 #endif
 
     m_condition.wakeAll();
@@ -216,7 +216,7 @@
     m_mutex.unlock();
 
 #ifdef DEBUG_FILE_READ_THREAD
-    std::cerr << "FileReadThread::process: reading " << request.start << ", " << request.size << " on " << request.fd << std::endl;
+    DEBUG << "FileReadThread::process: reading " << request.start << ", " << request.size << " on " << request.fd << endl;
 #endif
 
     bool successful = false;
@@ -289,14 +289,14 @@
         m_queue.erase(token);
         m_readyRequests[token] = request;
 #ifdef DEBUG_FILE_READ_THREAD
-        std::cerr << "FileReadThread::process: done, marking as ready (success = " << m_readyRequests[token].successful << ")" << std::endl;
+        DEBUG << "FileReadThread::process: done, marking as ready (success = " << m_readyRequests[token].successful << ")" << endl;
 #endif
     } else {
 #ifdef DEBUG_FILE_READ_THREAD
         if (m_exiting) {
-            std::cerr << "FileReadThread::process: exiting" << std::endl;
+            DEBUG << "FileReadThread::process: exiting" << endl;
         } else {
-            std::cerr << "FileReadThread::process: request disappeared" << std::endl;
+            DEBUG << "FileReadThread::process: request disappeared" << endl;
         }
 #endif
     }
@@ -312,7 +312,7 @@
         int token = *m_newlyCancelled.begin();
 
 #ifdef DEBUG_FILE_READ_THREAD
-        std::cerr << "FileReadThread::notifyCancelled: token " << token << std::endl;
+        DEBUG << "FileReadThread::notifyCancelled: token " << token << endl;
 #endif
 
         m_newlyCancelled.erase(token);
--- a/data/fileio/FileSource.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/FileSource.cpp	Mon May 16 17:19:09 2011 +0100
@@ -88,12 +88,12 @@
     }
  
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::FileSource(" << fileOrUrl << "): url <" << m_url.toString() << ">" << std::endl;
+    DEBUG << "FileSource::FileSource(" << fileOrUrl << "): url <" << m_url.toString() << ">" << endl;
     incCount(m_url.toString());
 #endif
 
     if (!canHandleScheme(m_url)) {
-        std::cerr << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString() << "\"" << std::endl;
+        DEBUG << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString() << "\"" << endl;
         m_errorString = tr("Unsupported scheme in URL");
         return;
     }
@@ -148,7 +148,7 @@
     }
 
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::FileSource(string) exiting" << std::endl;
+    DEBUG << "FileSource::FileSource(string) exiting" << endl;
 #endif
 }
 
@@ -166,12 +166,12 @@
     m_refCounted(false)
 {
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::FileSource(" << url.toString() << ") [as url]" << std::endl;
+    DEBUG << "FileSource::FileSource(" << url.toString() << ") [as url]" << endl;
     incCount(m_url.toString());
 #endif
 
     if (!canHandleScheme(m_url)) {
-        std::cerr << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString() << "\"" << std::endl;
+        DEBUG << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString() << "\"" << endl;
         m_errorString = tr("Unsupported scheme in URL");
         return;
     }
@@ -179,7 +179,7 @@
     init();
 
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::FileSource(url) exiting" << std::endl;
+    DEBUG << "FileSource::FileSource(url) exiting" << endl;
 #endif
 }
 
@@ -198,12 +198,12 @@
     m_refCounted(false)
 {
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::FileSource(" << m_url.toString() << ") [copy ctor]" << std::endl;
+    DEBUG << "FileSource::FileSource(" << m_url.toString() << ") [copy ctor]" << endl;
     incCount(m_url.toString());
 #endif
 
     if (!canHandleScheme(m_url)) {
-        std::cerr << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString() << "\"" << std::endl;
+        DEBUG << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString() << "\"" << endl;
         m_errorString = tr("Unsupported scheme in URL");
         return;
     }
@@ -213,8 +213,8 @@
     } else {
         QMutexLocker locker(&m_mapMutex);
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::FileSource(copy ctor): ref count is "
-                  << m_refCountMap[m_url] << std::endl;
+        DEBUG << "FileSource::FileSource(copy ctor): ref count is "
+                  << m_refCountMap[m_url] << endl;
 #endif
         if (m_refCountMap[m_url] > 0) {
             m_refCountMap[m_url]++;
@@ -232,11 +232,11 @@
     m_done = true;
 
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::FileSource(" << m_url.toString() << ") [copy ctor]: note: local filename is \"" << m_localFilename << "\"" << std::endl;
+    DEBUG << "FileSource::FileSource(" << m_url.toString() << ") [copy ctor]: note: local filename is \"" << m_localFilename << "\"" << endl;
 #endif
 
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::FileSource(copy ctor) exiting" << std::endl;
+    DEBUG << "FileSource::FileSource(copy ctor) exiting" << endl;
 #endif
 }
 
@@ -257,7 +257,7 @@
 {
     if (!isRemote()) {
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::init: Not a remote URL" << std::endl;
+        DEBUG << "FileSource::init: Not a remote URL" << endl;
 #endif
         bool literal = false;
         m_localFilename = m_url.toLocalFile();
@@ -269,8 +269,8 @@
         m_localFilename = QFileInfo(m_localFilename).absoluteFilePath();
 
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::init: URL translates to local filename \""
-                  << m_localFilename << "\" (with literal=" << literal << ")" << std::endl;
+        DEBUG << "FileSource::init: URL translates to local filename \""
+                  << m_localFilename << "\" (with literal=" << literal << ")" << endl;
 #endif
         m_ok = true;
         m_lastStatus = 200;
@@ -280,7 +280,7 @@
                 m_lastStatus = 404;
             } else {
 #ifdef DEBUG_FILE_SOURCE
-                std::cerr << "FileSource::init: Local file of this name does not exist, trying URL as a literal filename" << std::endl;
+                DEBUG << "FileSource::init: Local file of this name does not exist, trying URL as a literal filename" << endl;
 #endif
                 // Again, QUrl may have been mistreating us --
                 // e.g. dropping a part that looks like query data
@@ -298,7 +298,7 @@
 
     if (createCacheFile()) {
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::init: Already have this one" << std::endl;
+        DEBUG << "FileSource::init: Already have this one" << endl;
 #endif
         m_ok = true;
         if (!QFileInfo(m_localFilename).exists()) {
@@ -317,8 +317,8 @@
     QString scheme = m_url.scheme().toLower();
 
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::init: Don't have local copy of \""
-              << m_url.toString() << "\", retrieving" << std::endl;
+    DEBUG << "FileSource::init: Don't have local copy of \""
+              << m_url.toString() << "\", retrieving" << endl;
 #endif
 
     if (scheme == "http") {
@@ -343,7 +343,7 @@
             cleanup();
             m_refCountMap[m_url]++;
 #ifdef DEBUG_FILE_SOURCE
-            std::cerr << "FileSource::init: Another FileSource has got there first, abandoning our download and using theirs" << std::endl;
+            DEBUG << "FileSource::init: Another FileSource has got there first, abandoning our download and using theirs" << endl;
 #endif
             m_localFilename = m_remoteLocalMap[m_url];
             m_refCounted = true;
@@ -426,8 +426,8 @@
     QString path = "/" + QString(m_url.toEncoded()).section('/', 3);
 
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource: path is \""
-              << path << "\"" << std::endl;
+    DEBUG << "FileSource: path is \""
+              << path << "\"" << endl;
 #endif
         
     if (m_preferredContentType == "") {
@@ -528,8 +528,8 @@
     if (!m_ok) available = false;
     else available = (m_lastStatus / 100 == 2);
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::isAvailable: " << (available ? "yes" : "no")
-              << std::endl;
+    DEBUG << "FileSource::isAvailable: " << (available ? "yes" : "no")
+              << endl;
 #endif
     return available;
 }
@@ -547,7 +547,7 @@
 FileSource::waitForData()
 {
     while (m_ok && !m_done) {
-//        std::cerr << "FileSource::waitForData: calling QApplication::processEvents" << std::endl;
+//        DEBUG << "FileSource::waitForData: calling QApplication::processEvents" << endl;
         QCoreApplication::processEvents();
         usleep(10000);
     }
@@ -627,14 +627,14 @@
 FileSource::httpResponseHeaderReceived(const QHttpResponseHeader &resp)
 {
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::httpResponseHeaderReceived" << std::endl;
+    DEBUG << "FileSource::httpResponseHeaderReceived" << endl;
 #endif
 
     if (resp.statusCode() / 100 == 3) {
         QString location = resp.value("Location");
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::responseHeaderReceived: redirect to \""
-                  << location << "\" received" << std::endl;
+        DEBUG << "FileSource::responseHeaderReceived: redirect to \""
+                  << location << "\" received" << endl;
 #endif
         if (location != "") {
             QUrl newUrl(location);
@@ -661,13 +661,13 @@
         m_errorString = QString("%1 %2")
             .arg(resp.statusCode()).arg(resp.reasonPhrase());
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::responseHeaderReceived: "
-                  << m_errorString << std::endl;
+        DEBUG << "FileSource::responseHeaderReceived: "
+                  << m_errorString << endl;
 #endif
     } else {
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::responseHeaderReceived: "
-                  << m_lastStatus << std::endl;
+        DEBUG << "FileSource::responseHeaderReceived: "
+                  << m_lastStatus << endl;
 #endif
         if (resp.hasContentType()) m_contentType = resp.contentType();
     }
@@ -687,8 +687,8 @@
 
     if (!error) {
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::ftpCommandFinished: success for command "
-                  << command << std::endl;
+        DEBUG << "FileSource::ftpCommandFinished: success for command "
+                  << command << endl;
 #endif
         return;
     }
@@ -776,7 +776,7 @@
 FileSource::deleteCacheFile()
 {
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::deleteCacheFile(\"" << m_localFilename << "\")" << std::endl;
+    DEBUG << "FileSource::deleteCacheFile(\"" << m_localFilename << "\")" << endl;
 #endif
 
     cleanup();
@@ -817,7 +817,7 @@
 #endif
     } else {
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::deleteCacheFile: Deleted cache file \"" << m_localFilename << "\"" << std::endl;
+        DEBUG << "FileSource::deleteCacheFile: Deleted cache file \"" << m_localFilename << "\"" << endl;
 #endif
         m_localFilename = "";
     }
@@ -834,7 +834,7 @@
         QMutexLocker locker(&m_mapMutex);
 
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::createCacheFile: refcount is " << m_refCountMap[m_url] << std::endl;
+        DEBUG << "FileSource::createCacheFile: refcount is " << m_refCountMap[m_url] << endl;
 #endif
 
         if (m_refCountMap[m_url] > 0) {
@@ -881,7 +881,7 @@
     QString filepath(dir.filePath(filename));
 
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::createCacheFile: URL is \"" << m_url.toString() << "\", dir is \"" << dir.path() << "\", base \"" << base << "\", extension \"" << extension << "\", filebase \"" << filename << "\", filename \"" << filepath << "\"" << std::endl;
+    DEBUG << "FileSource::createCacheFile: URL is \"" << m_url.toString() << "\", dir is \"" << dir.path() << "\", base \"" << base << "\", extension \"" << extension << "\", filebase \"" << filename << "\", filename \"" << filepath << "\"" << endl;
 #endif
 
     QMutexLocker fcLocker(&m_fileCreationMutex);
@@ -918,9 +918,9 @@
     }
 
 #ifdef DEBUG_FILE_SOURCE
-    std::cerr << "FileSource::createCacheFile: url "
+    DEBUG << "FileSource::createCacheFile: url "
               << m_url.toString() << " -> local filename "
-              << filepath << std::endl;
+              << filepath << endl;
 #endif
     
     m_localFilename = filepath;
--- a/data/fileio/MIDIFileReader.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/MIDIFileReader.cpp	Mon May 16 17:19:09 2011 +0100
@@ -278,7 +278,7 @@
     m_error = "";
 
 #ifdef MIDI_DEBUG
-    cerr << "MIDIFileReader::open() : fileName = " << m_fileName.c_str() << endl;
+    DEBUG << "MIDIFileReader::open() : fileName = " << m_fileName.c_str() << endl;
 #endif
 
     // Open the file
@@ -315,7 +315,7 @@
 	for (unsigned int j = 0; j < m_numberOfTracks; ++j) {
 
 #ifdef MIDI_DEBUG
-	    cerr << "Parsing Track " << j << endl;
+	    DEBUG << "Parsing Track " << j << endl;
 #endif
 
 	    if (!skipToNextTrack()) {
@@ -350,7 +350,7 @@
 
     } catch (MIDIException e) {
 
-        cerr << "MIDIFileReader::open() - caught exception - " << e.what() << endl;
+        DEBUG << "MIDIFileReader::open() - caught exception - " << e.what() << endl;
 	m_error = e.what();
     }
     
@@ -392,14 +392,14 @@
 {
     if (midiHeader.size() < 14) {
 #ifdef MIDI_DEBUG
-        cerr << "MIDIFileReader::parseHeader() - file header undersized" << endl;
+        DEBUG << "MIDIFileReader::parseHeader() - file header undersized" << endl;
 #endif
         return false;
     }
 
     if (midiHeader.compare(0, 4, MIDI_FILE_HEADER) != 0) {
 #ifdef MIDI_DEBUG
-	cerr << "MIDIFileReader::parseHeader()"
+	DEBUG << "MIDIFileReader::parseHeader()"
 	     << "- file header not found or malformed"
 	     << endl;
 #endif
@@ -408,7 +408,7 @@
 
     if (midiBytesToLong(midiHeader.substr(4,4)) != 6L) {
 #ifdef MIDI_DEBUG
-        cerr << "MIDIFileReader::parseHeader()"
+        DEBUG << "MIDIFileReader::parseHeader()"
 	     << " - header length incorrect"
 	     << endl;
 #endif
@@ -498,7 +498,7 @@
 	    data1 = midiByte;
 
 #ifdef MIDI_DEBUG
-	    cerr << "using running status (byte " << int(midiByte) << " found)" << endl;
+	    DEBUG << "using running status (byte " << int(midiByte) << " found)" << endl;
 #endif
         } else {
 #ifdef MIDI_DEBUG
@@ -611,7 +611,7 @@
                         MIDI_END_OF_EXCLUSIVE)
                 {
 #ifdef MIDI_DEBUG
-                    cerr << "MIDIFileReader::parseTrack() - "
+                    DEBUG << "MIDIFileReader::parseTrack() - "
                               << "malformed or unsupported SysEx type"
                               << endl;
 #endif
@@ -631,14 +631,14 @@
 
             case MIDI_END_OF_EXCLUSIVE:
 #ifdef MIDI_DEBUG
-                cerr << "MIDIFileReader::parseTrack() - "
+                DEBUG << "MIDIFileReader::parseTrack() - "
                           << "Found a stray MIDI_END_OF_EXCLUSIVE" << endl;
 #endif
                 break;
 
             default:
 #ifdef MIDI_DEBUG
-                cerr << "MIDIFileReader::parseTrack()" 
+                DEBUG << "MIDIFileReader::parseTrack()" 
                           << " - Unsupported MIDI Event Code:  "
                           << (int)eventCode << endl;
 #endif
@@ -787,15 +787,15 @@
     double seconds = (60.0 * quarters) / tempo;
 
 /*
-    std::cerr << "MIDIFileReader::getTimeForMIDITime(" << midiTime << ")"
-	      << std::endl;
-    std::cerr << "timing division = " << td << std::endl;
+    DEBUG << "MIDIFileReader::getTimeForMIDITime(" << midiTime << ")"
+	      << endl;
+    DEBUG << "timing division = " << td << endl;
     std::cerr << "nearest tempo event (of " << m_tempoMap.size() << ") is at " << tempoMIDITime << " ("
 	      << tempoRealTime << ")" << std::endl;
     std::cerr << "quarters since then = " << quarters << std::endl;
     std::cerr << "tempo = " << tempo << " quarters per minute" << std::endl;
     std::cerr << "seconds since then = " << seconds << std::endl;
-    std::cerr << "resulting time = " << (tempoRealTime + RealTime::fromSeconds(seconds)) << std::endl;
+    DEBUG << "resulting time = " << (tempoRealTime + RealTime::fromSeconds(seconds)) << endl;
 */
 
     return tempoRealTime + RealTime::fromSeconds(seconds);
@@ -1033,7 +1033,7 @@
 		    Note note(startFrame, (*i)->getPitch(),
 			      endFrame - startFrame, level, noteLabel);
 
-//		    std::cerr << "Adding note " << startFrame << "," << (endFrame-startFrame) << " : " << int((*i)->getPitch()) << std::endl;
+//		    DEBUG << "Adding note " << startFrame << "," << (endFrame-startFrame) << " : " << int((*i)->getPitch()) << endl;
 
 		    model->addPoint(note);
 		    break;
--- a/data/fileio/MP3FileReader.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/MP3FileReader.cpp	Mon May 16 17:19:09 2011 +0100
@@ -177,7 +177,7 @@
     id3_tag *tag = id3_file_tag(file);
     if (!tag) {
 #ifdef DEBUG_ID3TAG
-        std::cerr << "MP3FileReader::loadTags: No ID3 tag found" << std::endl;
+        DEBUG << "MP3FileReader::loadTags: No ID3 tag found" << endl;
 #endif
         id3_file_close(file);
         return;
@@ -200,8 +200,8 @@
 
 #else
 #ifdef DEBUG_ID3TAG
-    std::cerr << "MP3FileReader::loadTags: ID3 tag support not compiled in"
-              << std::endl;
+    DEBUG << "MP3FileReader::loadTags: ID3 tag support not compiled in"
+              << endl;
 #endif
 #endif
 }
@@ -215,20 +215,20 @@
     id3_frame *frame = id3_tag_findframe(tag, name, 0);
     if (!frame) {
 #ifdef DEBUG_ID3TAG
-        std::cerr << "MP3FileReader::loadTags: No \"" << name << "\" in ID3 tag" << std::endl;
+        DEBUG << "MP3FileReader::loadTags: No \"" << name << "\" in ID3 tag" << endl;
 #endif
         return "";
     }
         
     if (frame->nfields < 2) {
-        std::cerr << "MP3FileReader::loadTags: WARNING: Not enough fields (" << frame->nfields << ") for \"" << name << "\" in ID3 tag" << std::endl;
+        DEBUG << "MP3FileReader::loadTags: WARNING: Not enough fields (" << frame->nfields << ") for \"" << name << "\" in ID3 tag" << endl;
         return "";
     }
 
     unsigned int nstrings = id3_field_getnstrings(&frame->fields[1]);
     if (nstrings == 0) {
 #ifdef DEBUG_ID3TAG
-        std::cerr << "MP3FileReader::loadTags: No strings for \"" << name << "\" in ID3 tag" << std::endl;
+        DEBUG << "MP3FileReader::loadTags: No strings for \"" << name << "\" in ID3 tag" << endl;
 #endif
         return "";
     }
@@ -236,7 +236,7 @@
     id3_ucs4_t const *ustr = id3_field_getstrings(&frame->fields[1], 0);
     if (!ustr) {
 #ifdef DEBUG_ID3TAG
-        std::cerr << "MP3FileReader::loadTags: Invalid or absent data for \"" << name << "\" in ID3 tag" << std::endl;
+        DEBUG << "MP3FileReader::loadTags: Invalid or absent data for \"" << name << "\" in ID3 tag" << endl;
 #endif
         return "";
     }
@@ -251,8 +251,8 @@
     free(u8str);
 
 #ifdef DEBUG_ID3TAG
-	std::cerr << "MP3FileReader::loadTags: tag \"" << name << "\" -> \""
-	<< rv << "\"" << std::endl;
+	DEBUG << "MP3FileReader::loadTags: tag \"" << name << "\" -> \""
+	<< rv << "\"" << endl;
 #endif
 
 
@@ -365,7 +365,7 @@
         initialiseDecodeCache();
 
         if (m_cacheMode == CacheInTemporaryFile) {
-//            std::cerr << "MP3FileReader::accept: channel count " << m_channelCount << ", file rate " << m_fileRate << ", about to start serialised section" << std::endl;
+//            DEBUG << "MP3FileReader::accept: channel count " << m_channelCount << ", file rate " << m_fileRate << ", about to start serialised section" << endl;
             startSerialised("MP3FileReader::Decode");
         }
     }
--- a/data/fileio/MatchFileReader.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/MatchFileReader.cpp	Mon May 16 17:19:09 2011 +0100
@@ -86,7 +86,7 @@
 MatchFileReader::~MatchFileReader()
 {
     if (m_file) {
-        std::cerr << "MatchFileReader::MatchFileReader: Closing file" << std::endl;
+        DEBUG << "MatchFileReader::MatchFileReader: Closing file" << endl;
         m_file->close();
     }
     delete m_file;
--- a/data/fileio/MatchFileReader.h	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/MatchFileReader.h	Mon May 16 17:19:09 2011 +0100
@@ -18,6 +18,7 @@
 
 #include <vector>
 #include <QString>
+#include "base/Debug.h"
 
 class QFile;
 class Model;
--- a/data/fileio/MatrixFile.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/MatrixFile.cpp	Mon May 16 17:19:09 2011 +0100
@@ -68,7 +68,7 @@
     Profiler profiler("MatrixFile::MatrixFile", true);
 
 #ifdef DEBUG_MATRIX_FILE
-    std::cerr << "MatrixFile::MatrixFile(" << fileBase << ", " << int(mode) << ", " << cellSize << ", " << width << ", " << height << ")" << std::endl;
+    DEBUG << "MatrixFile::MatrixFile(" << fileBase << ", " << int(mode) << ", " << cellSize << ", " << width << ", " << height << ")" << endl;
 #endif
 
     m_createMutex.lock();
@@ -248,7 +248,7 @@
 MatrixFile::close()
 {
 #ifdef DEBUG_MATRIX_FILE
-    std::cerr << "MatrixFile::close()" << std::endl;
+    DEBUG << "MatrixFile::close()" << endl;
 #endif
     if (m_fd >= 0) {
         if (::close(m_fd) < 0) {
--- a/data/fileio/OggVorbisFileReader.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/OggVorbisFileReader.cpp	Mon May 16 17:19:09 2011 +0100
@@ -50,7 +50,7 @@
     m_channelCount = 0;
     m_fileRate = 0;
 
-//    std::cerr << "OggVorbisFileReader::OggVorbisFileReader(" << m_path.toLocal8Bit().data() << "): now have " << (++instances) << " instances" << std::endl;
+//    DEBUG << "OggVorbisFileReader::OggVorbisFileReader(" << m_path.toLocal8Bit().data() << "): now have " << (++instances) << " instances" << endl;
 
     Profiler profiler("OggVorbisFileReader::OggVorbisFileReader", true);
 
@@ -102,7 +102,7 @@
 
 OggVorbisFileReader::~OggVorbisFileReader()
 {
-//    std::cerr << "OggVorbisFileReader::~OggVorbisFileReader(" << m_path.toLocal8Bit().data() << "): now have " << (--instances) << " instances" << std::endl;
+//    DEBUG << "OggVorbisFileReader::~OggVorbisFileReader(" << m_path.toLocal8Bit().data() << "): now have " << (--instances) << " instances" << endl;
     if (m_decodeThread) {
         m_cancelled = true;
         m_decodeThread->wait();
--- a/data/fileio/QuickTimeFileReader.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/QuickTimeFileReader.cpp	Mon May 16 17:19:09 2011 +0100
@@ -66,7 +66,7 @@
 
     Profiler profiler("QuickTimeFileReader::QuickTimeFileReader", true);
 
-std::cerr << "QuickTimeFileReader: path is \"" << m_path << "\"" << std::endl;
+DEBUG << "QuickTimeFileReader: path is \"" << m_path << "\"" << endl;
 
     long QTversion;
 
@@ -270,7 +270,7 @@
 
 QuickTimeFileReader::~QuickTimeFileReader()
 {
-    std::cerr << "QuickTimeFileReader::~QuickTimeFileReader" << std::endl;
+    DEBUG << "QuickTimeFileReader::~QuickTimeFileReader" << endl;
 
     if (m_decodeThread) {
         m_cancelled = true;
--- a/data/fileio/ResamplingWavFileReader.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/ResamplingWavFileReader.cpp	Mon May 16 17:19:09 2011 +0100
@@ -39,8 +39,8 @@
     m_channelCount = 0;
     m_fileRate = 0;
 
-    std::cerr << "ResamplingWavFileReader::ResamplingWavFileReader(\""
-              << m_path << "\"): rate " << targetRate << std::endl;
+    DEBUG << "ResamplingWavFileReader::ResamplingWavFileReader(\""
+              << m_path << "\"): rate " << targetRate << endl;
 
     Profiler profiler("ResamplingWavFileReader::ResamplingWavFileReader", true);
 
--- a/data/fileio/WavFileReader.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/WavFileReader.cpp	Mon May 16 17:19:09 2011 +0100
@@ -85,7 +85,7 @@
         }
     }
 
-//    std::cerr << "WavFileReader::updateFrameCount: now " << m_fileInfo.frames << std::endl;
+//    DEBUG << "WavFileReader::updateFrameCount: now " << m_fileInfo.frames << endl;
 
     m_frameCount = m_fileInfo.frames;
 
@@ -122,8 +122,8 @@
     }
 
     if ((long)start >= m_fileInfo.frames) {
-//        std::cerr << "WavFileReader::getInterleavedFrames: " << start
-//                  << " > " << m_fileInfo.frames << std::endl;
+//        DEBUG << "WavFileReader::getInterleavedFrames: " << start
+//                  << " > " << m_fileInfo.frames << endl;
 	return;
     }
 
--- a/data/fileio/WavFileWriter.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/fileio/WavFileWriter.cpp	Mon May 16 17:19:09 2011 +0100
@@ -82,9 +82,9 @@
     }
 
     if (source->getChannelCount() != m_channels) {
-        std::cerr << "WavFileWriter::writeModel: Wrong number of channels ("
+        DEBUG << "WavFileWriter::writeModel: Wrong number of channels ("
                   << source->getChannelCount()  << " != " << m_channels << ")"
-                  << std::endl;
+                  << endl;
         m_error = QString("Failed to write model to audio file '%1'")
             .arg(m_temp->getTemporaryFilename());
         return false;
--- a/data/midi/MIDIEvent.h	Thu May 12 17:31:24 2011 +0100
+++ b/data/midi/MIDIEvent.h	Mon May 16 17:19:09 2011 +0100
@@ -25,6 +25,7 @@
 #include <QString>
 #include <string>
 #include <iostream>
+#include "base/Debug.h"
 
 typedef unsigned char MIDIByte;
 
--- a/data/midi/MIDIInput.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/midi/MIDIInput.cpp	Mon May 16 17:19:09 2011 +0100
@@ -50,7 +50,7 @@
 void
 MIDIInput::callback(double timestamp, std::vector<unsigned char> *message)
 {
-    std::cerr << "MIDIInput::callback(" << timestamp << ")" << std::endl;
+    DEBUG << "MIDIInput::callback(" << timestamp << ")" << endl;
     // In my experience so far, the timings passed to this function
     // are not reliable enough to use.  We request instead an audio
     // frame time from whatever FrameTimer we have been given, and use
@@ -84,7 +84,7 @@
             return;
         }
         std::cerr << "WARNING: MIDIInput::postEvent: MIDI event queue (capacity " << m_buffer.getSize() << " is full!" << std::endl;
-        std::cerr << "Waiting for something to be processed" << std::endl;
+        DEBUG << "Waiting for something to be processed" << endl;
 #ifdef _WIN32
         Sleep(1);
 #else
--- a/data/midi/rtmidi/RtMidi.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/midi/rtmidi/RtMidi.cpp	Mon May 16 17:19:09 2011 +0100
@@ -761,12 +761,12 @@
 
 		case SND_SEQ_EVENT_PORT_UNSUBSCRIBED:
 #if defined(__RTMIDI_DEBUG__)
-      std::cerr << "RtMidiIn::alsaMidiHandler: port connection has closed!\n";
+      DEBUG << "RtMidiIn::alsaMidiHandler: port connection has closed!\n";
       // FIXME: this is called for all unsubscribe events, even ones
       //not related to this particular connection.  As it stands, I
       //see no data provided in the "source" and "dest" fields so
       //there is nothing we can do about this at this time.
-      // std::cout << "sender = " << ev->source.client << ", dest = " << ev->dest.port << std::endl;
+      // std::cout << "sender = " << ev->source.client << ", dest = " << ev->dest.port << endl;
 #endif
       //data->doInput = false;
       break;
--- a/data/model/AggregateWaveModel.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/model/AggregateWaveModel.cpp	Mon May 16 17:19:09 2011 +0100
@@ -29,7 +29,7 @@
          i != channelSpecs.end(); ++i) {
         if (i->model->getSampleRate() !=
             channelSpecs.begin()->model->getSampleRate()) {
-            std::cerr << "AggregateWaveModel::AggregateWaveModel: WARNING: Component models do not all have the same sample rate" << std::endl;
+            DEBUG << "AggregateWaveModel::AggregateWaveModel: WARNING: Component models do not all have the same sample rate" << endl;
             break;
         }
     }
--- a/data/model/AlignmentModel.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/model/AlignmentModel.cpp	Mon May 16 17:19:09 2011 +0100
@@ -141,7 +141,7 @@
 AlignmentModel::toReference(size_t frame) const
 {
 #ifdef DEBUG_ALIGNMENT_MODEL
-    std::cerr << "AlignmentModel::toReference(" << frame << ")" << std::endl;
+    DEBUG << "AlignmentModel::toReference(" << frame << ")" << endl;
 #endif
     if (!m_path) {
         if (!m_rawPath) return frame;
@@ -154,7 +154,7 @@
 AlignmentModel::fromReference(size_t frame) const
 {
 #ifdef DEBUG_ALIGNMENT_MODEL
-    std::cerr << "AlignmentModel::fromReference(" << frame << ")" << std::endl;
+    DEBUG << "AlignmentModel::fromReference(" << frame << ")" << endl;
 #endif
     if (!m_reversePath) {
         if (!m_rawPath) return frame;
@@ -194,8 +194,8 @@
         m_rawPath->isReady(&completion);
 
 #ifdef DEBUG_ALIGNMENT_MODEL
-        std::cerr << "AlignmentModel::pathCompletionChanged: completion = "
-                  << completion << std::endl;
+        DEBUG << "AlignmentModel::pathCompletionChanged: completion = "
+                  << completion << endl;
 #endif
 
         m_pathComplete = (completion == 100);
@@ -242,7 +242,7 @@
     }
 
 #ifdef DEBUG_ALIGNMENT_MODEL
-    std::cerr << "AlignmentModel::constructPath: " << m_path->getPointCount() << " points, at least " << (2 * m_path->getPointCount() * (3 * sizeof(void *) + sizeof(int) + sizeof(PathPoint))) << " bytes" << std::endl;
+    DEBUG << "AlignmentModel::constructPath: " << m_path->getPointCount() << " points, at least " << (2 * m_path->getPointCount() * (3 * sizeof(void *) + sizeof(int) + sizeof(PathPoint))) << " bytes" << endl;
 #endif
 }
 
@@ -273,7 +273,7 @@
     }
 
 #ifdef DEBUG_ALIGNMENT_MODEL
-    std::cerr << "AlignmentModel::constructReversePath: " << m_reversePath->getPointCount() << " points, at least " << (2 * m_reversePath->getPointCount() * (3 * sizeof(void *) + sizeof(int) + sizeof(PathPoint))) << " bytes" << std::endl;
+    DEBUG << "AlignmentModel::constructReversePath: " << m_reversePath->getPointCount() << " points, at least " << (2 * m_reversePath->getPointCount() * (3 * sizeof(void *) + sizeof(int) + sizeof(PathPoint))) << " bytes" << endl;
 #endif
 }
 
@@ -291,13 +291,13 @@
 
     if (points.empty()) {
 #ifdef DEBUG_ALIGNMENT_MODEL
-        std::cerr << "AlignmentModel::align: No points" << std::endl;
+        DEBUG << "AlignmentModel::align: No points" << endl;
 #endif
         return frame;
     }        
 
 #ifdef DEBUG_ALIGNMENT_MODEL
-    std::cerr << "AlignmentModel::align: frame " << frame << " requested" << std::endl;
+    DEBUG << "AlignmentModel::align: frame " << frame << " requested" << endl;
 #endif
 
     PathModel::Point point(frame);
@@ -340,7 +340,7 @@
     }
 
 #ifdef DEBUG_ALIGNMENT_MODEL
-    std::cerr << "AlignmentModel::align: resultFrame = " << resultFrame << std::endl;
+    DEBUG << "AlignmentModel::align: resultFrame = " << resultFrame << endl;
 #endif
 
     return resultFrame;
@@ -353,12 +353,12 @@
     delete m_path;
     m_path = path;
 #ifdef DEBUG_ALIGNMENT_MODEL
-    std::cerr << "AlignmentModel::setPath: path = " << m_path << std::endl;
+    DEBUG << "AlignmentModel::setPath: path = " << m_path << endl;
 #endif
     constructReversePath();
 #ifdef DEBUG_ALIGNMENT_MODEL
-    std::cerr << "AlignmentModel::setPath: after construction path = "
-              << m_path << ", rpath = " << m_reversePath << std::endl;
+    DEBUG << "AlignmentModel::setPath: after construction path = "
+              << m_path << ", rpath = " << m_reversePath << endl;
 #endif
 }
     
@@ -368,7 +368,7 @@
                       QString extraAttributes) const
 {
     if (!m_path) {
-        std::cerr << "AlignmentModel::toXml: no path" << std::endl;
+        DEBUG << "AlignmentModel::toXml: no path" << endl;
         return;
     }
 
--- a/data/model/EditableDenseThreeDimensionalModel.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/model/EditableDenseThreeDimensionalModel.cpp	Mon May 16 17:19:09 2011 +0100
@@ -492,7 +492,7 @@
 
     // For historical reasons we read and write "resolution" as "windowSize"
 
-    std::cerr << "EditableDenseThreeDimensionalModel::toXml" << std::endl;
+    DEBUG << "EditableDenseThreeDimensionalModel::toXml" << endl;
 
     Model::toXml
 	(out, indent,
--- a/data/model/Model.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/model/Model.cpp	Mon May 16 17:19:09 2011 +0100
@@ -24,12 +24,12 @@
 
 Model::~Model()
 {
-//    std::cerr << "Model::~Model(" << this << ")" << std::endl;
+//    DEBUG << "Model::~Model(" << this << ")" << endl;
 
     if (!m_aboutToDelete) {
-        std::cerr << "NOTE: Model::~Model(" << this << ", \""
+        DEBUG << "NOTE: Model::~Model(" << this << ", \""
                   << objectName() << "\"): Model deleted "
-                  << "with no aboutToDelete notification" << std::endl;
+                  << "with no aboutToDelete notification" << endl;
     }
 
     if (m_alignment) {
@@ -134,7 +134,7 @@
 int
 Model::getAlignmentCompletion() const
 {
-//    std::cerr << "Model::getAlignmentCompletion" << std::endl;
+//    DEBUG << "Model::getAlignmentCompletion" << endl;
     if (!m_alignment) {
         if (m_sourceModel) return m_sourceModel->getAlignmentCompletion();
         else return 100;
--- a/data/model/ModelDataTableModel.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/model/ModelDataTableModel.cpp	Mon May 16 17:19:09 2011 +0100
@@ -195,8 +195,8 @@
 void
 ModelDataTableModel::sort(int column, Qt::SortOrder sortOrder)
 {
-//    std::cerr << "ModelDataTableModel::sort(" << column << ", " << sortOrder
-//              << ")" << std::endl;
+//    DEBUG << "ModelDataTableModel::sort(" << column << ", " << sortOrder
+//              << ")" << endl;
     int prevCurrent = getCurrentRow();
     if (m_sortColumn != column) {
         clearSort();
--- a/data/model/PowerOfSqrtTwoZoomConstraint.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/model/PowerOfSqrtTwoZoomConstraint.cpp	Mon May 16 17:19:09 2011 +0100
@@ -51,7 +51,7 @@
 	else if (dir == RoundDown) rval = size_t(prevVal + 0.01);
 	else if (val - blockSize < blockSize - prevVal) rval = size_t(val + 0.01);
 	else rval = size_t(prevVal + 0.01);
-//	std::cerr << "returning " << rval << std::endl;
+//	DEBUG << "returning " << rval << endl;
 	return rval;
     }
 
@@ -74,7 +74,7 @@
 		    << (power - minCachePower));
 	}
 
-//	std::cerr << "Testing base " << base << std::endl;
+//	DEBUG << "Testing base " << base << endl;
 
         if (base == blockSize) {
             result = base;
--- a/data/model/WaveFileModel.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/model/WaveFileModel.cpp	Mon May 16 17:19:09 2011 +0100
@@ -53,8 +53,8 @@
         m_reader = AudioFileReaderFactory::createThreadingReader
             (m_source, targetRate);
         if (m_reader) {
-            std::cerr << "WaveFileModel::WaveFileModel: reader rate: "
-                      << m_reader->getSampleRate() << std::endl;
+            DEBUG << "WaveFileModel::WaveFileModel: reader rate: "
+                      << m_reader->getSampleRate() << endl;
         }
     }
     if (m_reader) setObjectName(m_reader->getTitle());
@@ -115,7 +115,7 @@
         prevCompletion = *completion;
     }
 #ifdef DEBUG_WAVE_FILE_MODEL
-    std::cerr << "WaveFileModel::isReady(): ready = " << ready << ", completion = " << (completion ? *completion : -1) << std::endl;
+    DEBUG << "WaveFileModel::isReady(): ready = " << ready << ", completion = " << (completion ? *completion : -1) << endl;
 #endif
     return ready;
 }
@@ -210,8 +210,8 @@
     }
 
 #ifdef DEBUG_WAVE_FILE_MODEL
-//    std::cerr << "WaveFileModel::getValues(" << channel << ", "
-//              << start << ", " << end << "): calling reader" << std::endl;
+//    DEBUG << "WaveFileModel::getValues(" << channel << ", "
+//              << start << ", " << end << "): calling reader" << endl;
 #endif
 
     int channels = getChannelCount();
@@ -534,7 +534,7 @@
     }
 
 #ifdef DEBUG_WAVE_FILE_MODEL
-    cerr << "returning " << ranges.size() << " ranges" << endl;
+    DEBUG << "returning " << ranges.size() << " ranges" << endl;
 #endif
     return;
 }
@@ -607,7 +607,7 @@
     m_fillThread->start();
 
 #ifdef DEBUG_WAVE_FILE_MODEL
-    std::cerr << "WaveFileModel::fillCache: started fill thread" << std::endl;
+    DEBUG << "WaveFileModel::fillCache: started fill thread" << endl;
 #endif
 }   
 
@@ -617,7 +617,7 @@
     if (m_fillThread) {
 	size_t fillExtent = m_fillThread->getFillExtent();
 #ifdef DEBUG_WAVE_FILE_MODEL
-        cerr << "WaveFileModel::fillTimerTimedOut: extent = " << fillExtent << endl;
+        DEBUG << "WaveFileModel::fillTimerTimedOut: extent = " << fillExtent << endl;
 #endif
 	if (fillExtent > m_lastFillExtent) {
 	    emit modelChanged(m_lastFillExtent, fillExtent);
@@ -625,7 +625,7 @@
 	}
     } else {
 #ifdef DEBUG_WAVE_FILE_MODEL
-        cerr << "WaveFileModel::fillTimerTimedOut: no thread" << std::endl;
+        DEBUG << "WaveFileModel::fillTimerTimedOut: no thread" << endl;
 #endif
 	emit modelChanged();
     }
@@ -646,7 +646,7 @@
     emit modelChanged();
     emit ready();
 #ifdef DEBUG_WAVE_FILE_MODEL
-    cerr << "WaveFileModel::cacheFilled" << endl;
+    DEBUG << "WaveFileModel::cacheFilled" << endl;
 #endif
 }
 
@@ -669,7 +669,7 @@
 
     if (updating) {
         while (channels == 0 && !m_model.m_exiting) {
-//            std::cerr << "WaveFileModel::fill: Waiting for channels..." << std::endl;
+//            DEBUG << "WaveFileModel::fill: Waiting for channels..." << endl;
             sleep(1);
             channels = m_model.getChannelCount();
         }
@@ -690,11 +690,11 @@
         updating = m_model.m_reader->isUpdating();
         m_frameCount = m_model.getFrameCount();
 
-//        std::cerr << "WaveFileModel::fill: frame = " << frame << ", count = " << m_frameCount << std::endl;
+//        DEBUG << "WaveFileModel::fill: frame = " << frame << ", count = " << m_frameCount << endl;
 
         while (frame < m_frameCount) {
 
-//            std::cerr << "WaveFileModel::fill inner loop: frame = " << frame << ", count = " << m_frameCount << ", blocksize " << readBlockSize << std::endl;
+//            DEBUG << "WaveFileModel::fill inner loop: frame = " << frame << ", count = " << m_frameCount << ", blocksize " << readBlockSize << endl;
 
             if (updating && (frame + readBlockSize > m_frameCount)) break;
 
--- a/data/model/WritableWaveFileModel.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/model/WritableWaveFileModel.cpp	Mon May 16 17:19:09 2011 +0100
@@ -106,7 +106,7 @@
     if (!m_writer) return false;
 
 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL
-//    std::cerr << "WritableWaveFileModel::addSamples(" << count << ")" << std::endl;
+//    DEBUG << "WritableWaveFileModel::addSamples(" << count << ")" << endl;
 #endif
 
     if (!m_writer->writeSamples(samples, count)) {
@@ -120,12 +120,12 @@
 
     if (m_reader && m_reader->getChannelCount() == 0) {
 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL
-        std::cerr << "WritableWaveFileModel::addSamples(" << count << "): calling updateFrameCount (initial)" << std::endl;
+        DEBUG << "WritableWaveFileModel::addSamples(" << count << "): calling updateFrameCount (initial)" << endl;
 #endif
         m_reader->updateFrameCount();
     } else if (++updateCounter == 100) {
 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL
-        std::cerr << "WritableWaveFileModel::addSamples(" << count << "): calling updateFrameCount (periodic)" << std::endl;
+        DEBUG << "WritableWaveFileModel::addSamples(" << count << "): calling updateFrameCount (periodic)" << endl;
 #endif
         if (m_reader) m_reader->updateFrameCount();
         updateCounter = 0;
@@ -138,7 +138,7 @@
 WritableWaveFileModel::isOK() const
 {
     bool ok = (m_writer && m_writer->isOK());
-//    std::cerr << "WritableWaveFileModel::isOK(): ok = " << ok << std::endl;
+//    DEBUG << "WritableWaveFileModel::isOK(): ok = " << ok << endl;
     return ok;
 }
 
@@ -161,7 +161,7 @@
 size_t
 WritableWaveFileModel::getFrameCount() const
 {
-//    std::cerr << "WritableWaveFileModel::getFrameCount: count = " << m_frameCount << std::endl;
+//    DEBUG << "WritableWaveFileModel::getFrameCount: count = " << m_frameCount << endl;
     return m_frameCount;
 }
 
--- a/data/osc/OSCQueue.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/data/osc/OSCQueue.cpp	Mon May 16 17:19:09 2011 +0100
@@ -167,7 +167,7 @@
             return;
         }
         std::cerr << "WARNING: OSCQueue::postMessage: OSC message queue (capacity " << m_buffer.getSize() << " is full!" << std::endl;
-        std::cerr << "Waiting for something to be processed" << std::endl;
+        DEBUG << "Waiting for something to be processed" << endl;
 #ifdef _WIN32
         Sleep(1);
 #else
@@ -178,9 +178,9 @@
 
     OSCMessage *mp = new OSCMessage(message);
     m_buffer.write(&mp, 1);
-    std::cerr << "OSCQueue::postMessage: Posted OSC message: target "
+    DEBUG << "OSCQueue::postMessage: Posted OSC message: target "
               << message.getTarget() << ", target data " << message.getTargetData()
-              << ", method " << message.getMethod() << std::endl;
+              << ", method " << message.getMethod() << endl;
     emit messagesAvailable();
 }
 
@@ -219,8 +219,7 @@
         return false;
     }
 
-    std::cerr << "OSCQueue::parseOSCPath: good path \"" << path.toStdString()
-              << "\"" << std::endl;
+    DEBUG << "OSCQueue::parseOSCPath: good path \"" << path              << "\"" << endl;
 
     return true;
 }
--- a/plugin/DSSIPluginFactory.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/plugin/DSSIPluginFactory.cpp	Mon May 16 17:19:09 2011 +0100
@@ -69,7 +69,7 @@
 	const LADSPA_Descriptor *descriptor = ddesc->LADSPA_Plugin;
 	if (!descriptor) continue;
 	
-//	std::cerr << "DSSIPluginFactory::enumeratePlugins: Name " << (descriptor->Name ? descriptor->Name : "NONE" ) << std::endl;
+//	DEBUG << "DSSIPluginFactory::enumeratePlugins: Name " << (descriptor->Name ? descriptor->Name : "NONE" ) << endl;
 
 	list.push_back(*i);
 	list.push_back(descriptor->Name);
--- a/plugin/DSSIPluginInstance.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/plugin/DSSIPluginInstance.cpp	Mon May 16 17:19:09 2011 +0100
@@ -77,8 +77,8 @@
     m_haveLastEventSendTime(false)
 {
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::DSSIPluginInstance(" << identifier << ")"
-	      << std::endl;
+    DEBUG << "DSSIPluginInstance::DSSIPluginInstance(" << identifier << ")"
+	      << endl;
 #endif
 
     init();
@@ -177,7 +177,7 @@
 DSSIPluginInstance::getParameter(std::string id) const
 {
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::getParameter(" << id << ")" << std::endl;
+    DEBUG << "DSSIPluginInstance::getParameter(" << id << ")" << endl;
 #endif
     for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) {
         if (id == m_descriptor->LADSPA_Plugin->PortNames[m_controlPortsIn[i].first]) {
@@ -186,7 +186,7 @@
 #endif
             float v = getParameterValue(i);
 #ifdef DEBUG_DSSI
-            std::cerr << "Returning " << v << std::endl;
+            DEBUG << "Returning " << v << endl;
 #endif
             return v;
         }
@@ -199,7 +199,7 @@
 DSSIPluginInstance::setParameter(std::string id, float value)
 {
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::setParameter(" << id << ", " << value << ")" << std::endl;
+    DEBUG << "DSSIPluginInstance::setParameter(" << id << ", " << value << ")" << endl;
 #endif
 
     for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) {
@@ -214,7 +214,7 @@
 DSSIPluginInstance::init()
 {
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::init" << std::endl;
+    DEBUG << "DSSIPluginInstance::init" << endl;
 #endif
 
     // Discover ports numbers and identities
@@ -258,8 +258,8 @@
         }
 #ifdef DEBUG_DSSI
         else
-            std::cerr << "DSSIPluginInstance::DSSIPluginInstance - "
-                      << "unrecognised port type" << std::endl;
+            DEBUG << "DSSIPluginInstance::DSSIPluginInstance - "
+                      << "unrecognised port type" << endl;
 #endif
     }
 
@@ -272,7 +272,7 @@
     size_t latency = 0;
 
 #ifdef DEBUG_DSSI_PROCESS
-    std::cerr << "DSSIPluginInstance::getLatency(): m_latencyPort " << m_latencyPort << ", m_run " << m_run << std::endl;
+    DEBUG << "DSSIPluginInstance::getLatency(): m_latencyPort " << m_latencyPort << ", m_run " << m_run << endl;
 #endif
 
     if (m_latencyPort) {
@@ -288,7 +288,7 @@
     }
     
 #ifdef DEBUG_DSSI_PROCESS
-    std::cerr << "DSSIPluginInstance::getLatency(): latency is " << latency << std::endl;
+    DEBUG << "DSSIPluginInstance::getLatency(): latency is " << latency << endl;
 #endif
 
     return latency;
@@ -313,8 +313,8 @@
 DSSIPluginInstance::setIdealChannelCount(size_t channels)
 {
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::setIdealChannelCount: channel count "
-	      << channels << " (was " << m_idealChannelCount << ")" << std::endl;
+    DEBUG << "DSSIPluginInstance::setIdealChannelCount: channel count "
+	      << channels << " (was " << m_idealChannelCount << ")" << endl;
 #endif
 
     if (channels == m_idealChannelCount) {
@@ -401,7 +401,7 @@
 DSSIPluginInstance::~DSSIPluginInstance()
 {
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::~DSSIPluginInstance" << std::endl;
+    DEBUG << "DSSIPluginInstance::~DSSIPluginInstance" << endl;
 #endif
 
     if (m_threads.find(m_instanceHandle) != m_threads.end()) {
@@ -502,7 +502,7 @@
     m_cachedPrograms.clear();
 
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::checkProgramCache" << std::endl;
+    DEBUG << "DSSIPluginInstance::checkProgramCache" << endl;
 #endif
 
     if (!m_descriptor || !m_descriptor->get_program) {
@@ -522,7 +522,7 @@
     }
 
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::checkProgramCache: have " << m_cachedPrograms.size() << " programs" << std::endl;
+    DEBUG << "DSSIPluginInstance::checkProgramCache: have " << m_cachedPrograms.size() << " programs" << endl;
 #endif
 
     m_programCacheValid = true;
@@ -532,7 +532,7 @@
 DSSIPluginInstance::getPrograms() const
 {
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::getPrograms" << std::endl;
+    DEBUG << "DSSIPluginInstance::getPrograms" << endl;
 #endif
 
     if (!m_descriptor) return ProgramList();
@@ -553,7 +553,7 @@
 DSSIPluginInstance::getProgram(int bank, int program) const
 {
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::getProgram(" << bank << "," << program << ")" << std::endl;
+    DEBUG << "DSSIPluginInstance::getProgram(" << bank << "," << program << ")" << endl;
 #endif
 
     if (!m_descriptor) return std::string();
@@ -572,7 +572,7 @@
 DSSIPluginInstance::getProgram(std::string name) const
 {
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::getProgram(" << name << ")" << std::endl;
+    DEBUG << "DSSIPluginInstance::getProgram(" << name << ")" << endl;
 #endif
 
     if (!m_descriptor) return 0;
@@ -609,7 +609,7 @@
 DSSIPluginInstance::selectProgramAux(std::string program, bool backupPortValues)
 {
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::selectProgram(" << program << ")" << std::endl;
+    DEBUG << "DSSIPluginInstance::selectProgram(" << program << ")" << endl;
 #endif
 
     if (!m_descriptor) return;
@@ -631,7 +631,7 @@
 	    found = true;
 
 #ifdef DEBUG_DSSI
-	    std::cerr << "DSSIPluginInstance::selectProgram(" << program << "): found at bank " << bankNo << ", program " << programNo << std::endl;
+	    DEBUG << "DSSIPluginInstance::selectProgram(" << program << "): found at bank " << bankNo << ", program " << programNo << endl;
 #endif
 
 	    break;
@@ -647,7 +647,7 @@
     m_processLock.unlock();
 
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::selectProgram(" << program << "): made select_program(" << bankNo << "," << programNo << ") call" << std::endl;
+    DEBUG << "DSSIPluginInstance::selectProgram(" << program << "): made select_program(" << bankNo << "," << programNo << ") call" << endl;
 #endif
 
     if (backupPortValues) {
@@ -661,7 +661,7 @@
 DSSIPluginInstance::activate()
 {
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::activate" << std::endl;
+    DEBUG << "DSSIPluginInstance::activate" << endl;
 #endif
 
     if (!m_descriptor || !m_descriptor->LADSPA_Plugin->activate) return;
@@ -669,14 +669,14 @@
 
     if (m_program != "") {
 #ifdef DEBUG_DSSI
-	std::cerr << "DSSIPluginInstance::activate: restoring program " << m_program << std::endl;
+	DEBUG << "DSSIPluginInstance::activate: restoring program " << m_program << endl;
 #endif
 	selectProgramAux(m_program, false);
     }
 
     for (size_t i = 0; i < m_backupControlPortsIn.size(); ++i) {
 #ifdef DEBUG_DSSI
-	std::cerr << "DSSIPluginInstance::activate: setting port " << m_controlPortsIn[i].first << " to " << m_backupControlPortsIn[i] << std::endl;
+	DEBUG << "DSSIPluginInstance::activate: setting port " << m_controlPortsIn[i].first << " to " << m_backupControlPortsIn[i] << endl;
 #endif
 	*m_controlPortsIn[i].second = m_backupControlPortsIn[i];
     }
@@ -687,9 +687,9 @@
 {
     if (!m_descriptor || !m_descriptor->LADSPA_Plugin->connect_port) return;
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::connectPorts: " << m_audioPortsIn.size() 
+    DEBUG << "DSSIPluginInstance::connectPorts: " << m_audioPortsIn.size() 
 	      << " audio ports in, " << m_audioPortsOut.size() << " out, "
-	      << m_outputBufferCount << " output buffers" << std::endl;
+	      << m_outputBufferCount << " output buffers" << endl;
 #endif
 
     assert(sizeof(LADSPA_Data) == sizeof(float));
@@ -726,7 +726,7 @@
             *m_controlPortsIn[i].second = defaultValue;
             m_backupControlPortsIn[i] = defaultValue;
 #ifdef DEBUG_DSSI
-            std::cerr << "DSSIPluginInstance::connectPorts: set control port " << i << " to default value " << defaultValue << std::endl;
+            DEBUG << "DSSIPluginInstance::connectPorts: set control port " << i << " to default value " << defaultValue << endl;
 #endif
         }
     }
@@ -749,7 +749,7 @@
 DSSIPluginInstance::setParameterValue(unsigned int parameter, float value)
 {
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::setParameterValue(" << parameter << ") to " << value << std::endl;
+    DEBUG << "DSSIPluginInstance::setParameterValue(" << parameter << ") to " << value << endl;
 #endif
     if (parameter >= m_controlPortsIn.size()) return;
 
@@ -773,7 +773,7 @@
 DSSIPluginInstance::setPortValueFromController(unsigned int port, int cv)
 {
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::setPortValueFromController(" << port << ") to " << cv << std::endl;
+    DEBUG << "DSSIPluginInstance::setPortValueFromController(" << port << ") to " << cv << endl;
 #endif
 
     const LADSPA_Descriptor *p = m_descriptor->LADSPA_Plugin;
@@ -819,7 +819,7 @@
 DSSIPluginInstance::getParameterValue(unsigned int parameter) const
 {
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::getParameterValue(" << parameter << ")" << std::endl;
+    DEBUG << "DSSIPluginInstance::getParameterValue(" << parameter << ")" << endl;
 #endif
     if (parameter >= m_controlPortsIn.size()) return 0.0;
     return (*m_controlPortsIn[parameter].second);
@@ -869,7 +869,7 @@
 	
     
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::configure(" << key << "," << value << ")" << std::endl;
+    DEBUG << "DSSIPluginInstance::configure(" << key << "," << value << ")" << endl;
 #endif
 
     char *message = m_descriptor->configure(m_instanceHandle,
@@ -908,7 +908,7 @@
 			      const void *e)
 {
 #ifdef DEBUG_DSSI_PROCESS
-    std::cerr << "DSSIPluginInstance::sendEvent: last was " << m_lastEventSendTime << " (valid " << m_haveLastEventSendTime << "), this is " << eventTime << std::endl;
+    DEBUG << "DSSIPluginInstance::sendEvent: last was " << m_lastEventSendTime << " (valid " << m_haveLastEventSendTime << "), this is " << eventTime << endl;
 #endif
 
     // The process mechanism only works correctly if the events are
@@ -926,7 +926,7 @@
 
     snd_seq_event_t *event = (snd_seq_event_t *)e;
 #ifdef DEBUG_DSSI_PROCESS
-    std::cerr << "DSSIPluginInstance::sendEvent at " << eventTime << std::endl;
+    DEBUG << "DSSIPluginInstance::sendEvent at " << eventTime << endl;
 #endif
     snd_seq_event_t ev(*event);
 
@@ -955,7 +955,7 @@
     int controller = ev->data.control.param;
 
 #ifdef DEBUG_DSSI_PROCESS
-    std::cerr << "DSSIPluginInstance::handleController " << controller << std::endl;
+    DEBUG << "DSSIPluginInstance::handleController " << controller << endl;
 #endif
 
     if (controller == 0) { // bank select MSB
@@ -1020,13 +1020,13 @@
     }
 
 #ifdef DEBUG_DSSI_PROCESS
-    std::cerr << "DSSIPluginInstance::run(" << blockTime << ")" << std::endl;
+    DEBUG << "DSSIPluginInstance::run(" << blockTime << ")" << endl;
 #endif
 
 #ifdef DEBUG_DSSI_PROCESS
     if (m_eventBuffer.getReadSpace() > 0) {
-	std::cerr << "DSSIPluginInstance::run: event buffer has "
-		  << m_eventBuffer.getReadSpace() << " event(s) in it" << std::endl;
+	DEBUG << "DSSIPluginInstance::run: event buffer has "
+		  << m_eventBuffer.getReadSpace() << " event(s) in it" << endl;
     }
 #endif
 
@@ -1044,8 +1044,8 @@
 	}
 
 #ifdef DEBUG_DSSI_PROCESS
-	std::cerr << "DSSIPluginInstance::run: evTime " << evTime << ", blockTime " << blockTime << ", frameOffset " << frameOffset
-		  << ", blockSize " << m_blockSize << std::endl;
+	DEBUG << "DSSIPluginInstance::run: evTime " << evTime << ", blockTime " << blockTime << ", frameOffset " << frameOffset
+		  << ", blockSize " << m_blockSize << endl;
 	std::cerr << "Type: " << int(ev->type) << ", pitch: " << int(ev->data.note.note) << ", velocity: " << int(ev->data.note.velocity) << std::endl;
 #endif
 
@@ -1079,20 +1079,20 @@
 	int bank = m_pending.lsb + 128 * m_pending.msb;
 
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::run: making select_program(" << bank << "," << program << ") call" << std::endl;
+    DEBUG << "DSSIPluginInstance::run: making select_program(" << bank << "," << program << ") call" << endl;
 #endif
 
 	m_pending.lsb = m_pending.msb = m_pending.program = -1;
 	m_descriptor->select_program(m_instanceHandle, bank, program);
 
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::run: made select_program(" << bank << "," << program << ") call" << std::endl;
+    DEBUG << "DSSIPluginInstance::run: made select_program(" << bank << "," << program << ") call" << endl;
 #endif
     }
 
 #ifdef DEBUG_DSSI_PROCESS
-    std::cerr << "DSSIPluginInstance::run: running with " << evCount << " events"
-	      << std::endl;
+    DEBUG << "DSSIPluginInstance::run: running with " << evCount << " events"
+	      << endl;
 #endif
 
     m_descriptor->run_synth(m_instanceHandle, count,
@@ -1153,7 +1153,7 @@
     PluginSet &s = m_groupMap[m_identifier];
 
 #ifdef DEBUG_DSSI_PROCESS
-    std::cerr << "DSSIPluginInstance::runGrouped(" << blockTime << "): this is " << this << "; " << s.size() << " elements in m_groupMap[" << m_identifier << "]" << std::endl;
+    DEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): this is " << this << "; " << s.size() << " elements in m_groupMap[" << m_identifier << "]" << endl;
 #endif
 
     if (m_lastRunTime != blockTime) {
@@ -1161,7 +1161,7 @@
 	    DSSIPluginInstance *instance = *i;
 	    if (instance != this && instance->m_lastRunTime == blockTime) {
 #ifdef DEBUG_DSSI_PROCESS
-		std::cerr << "DSSIPluginInstance::runGrouped(" << blockTime << "): plugin " << instance << " has already been run" << std::endl;
+		DEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): plugin " << instance << " has already been run" << endl;
 #endif
 		needRun = false;
 	    }
@@ -1170,13 +1170,13 @@
 
     if (!needRun) {
 #ifdef DEBUG_DSSI_PROCESS
-	std::cerr << "DSSIPluginInstance::runGrouped(" << blockTime << "): already run, returning" << std::endl;
+	DEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): already run, returning" << endl;
 #endif
 	return;
     }
 
 #ifdef DEBUG_DSSI_PROCESS
-    std::cerr << "DSSIPluginInstance::runGrouped(" << blockTime << "): I'm the first, running" << std::endl;
+    DEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): I'm the first, running" << endl;
 #endif
 
     size_t index = 0;
@@ -1194,7 +1194,7 @@
 	instances[index] = instance->m_instanceHandle;
 
 #ifdef DEBUG_DSSI_PROCESS
-	std::cerr << "DSSIPluginInstance::runGrouped(" << blockTime << "): running " << instance << std::endl;
+	DEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): running " << instance << endl;
 #endif
 
 	if (instance->m_pending.program >= 0 &&
@@ -1220,8 +1220,8 @@
 	    }
 
 #ifdef DEBUG_DSSI_PROCESS
-	    std::cerr << "DSSIPluginInstance::runGrouped: evTime " << evTime << ", frameOffset " << frameOffset
-		      << ", block size " << m_blockSize << std::endl;
+	    DEBUG << "DSSIPluginInstance::runGrouped: evTime " << evTime << ", frameOffset " << frameOffset
+		      << ", block size " << m_blockSize << endl;
 #endif
 
 	    if (frameOffset >= int(m_blockSize)) break;
@@ -1259,7 +1259,7 @@
 {
     // This is called from a non-RT context (during instantiate)
 
-    std::cerr << "DSSIPluginInstance::requestMidiSend" << std::endl;
+    DEBUG << "DSSIPluginInstance::requestMidiSend" << endl;
     return 1;
 }
 
@@ -1270,7 +1270,7 @@
 {
     // This is likely to be called from an RT context
 
-    std::cerr << "DSSIPluginInstance::midiSend" << std::endl;
+    DEBUG << "DSSIPluginInstance::midiSend" << endl;
 }
 
 void
@@ -1296,7 +1296,7 @@
 DSSIPluginInstance::deactivate()
 {
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::deactivate " << m_identifier << std::endl;
+    DEBUG << "DSSIPluginInstance::deactivate " << m_identifier << endl;
 #endif
     if (!m_descriptor || !m_descriptor->LADSPA_Plugin->deactivate) return;
 
@@ -1306,7 +1306,7 @@
 
     m_descriptor->LADSPA_Plugin->deactivate(m_instanceHandle);
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::deactivate " << m_identifier << " done" << std::endl;
+    DEBUG << "DSSIPluginInstance::deactivate " << m_identifier << " done" << endl;
 #endif
 
     m_bufferScavenger.scavenge();
@@ -1316,7 +1316,7 @@
 DSSIPluginInstance::cleanup()
 {
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::cleanup " << m_identifier << std::endl;
+    DEBUG << "DSSIPluginInstance::cleanup " << m_identifier << endl;
 #endif
     if (!m_descriptor) return;
 
@@ -1331,7 +1331,7 @@
     m_descriptor->LADSPA_Plugin->cleanup(m_instanceHandle);
     m_instanceHandle = 0;
 #ifdef DEBUG_DSSI
-    std::cerr << "DSSIPluginInstance::cleanup " << m_identifier << " done" << std::endl;
+    DEBUG << "DSSIPluginInstance::cleanup " << m_identifier << " done" << endl;
 #endif
 }
 
--- a/plugin/FeatureExtractionPluginFactory.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/plugin/FeatureExtractionPluginFactory.cpp	Mon May 16 17:19:09 2011 +0100
@@ -58,8 +58,7 @@
 {
     if (pluginType == "vamp") {
 	if (!_nativeInstance) {
-//	    std::cerr << "FeatureExtractionPluginFactory::instance(" << pluginType.toStdString()
-//		      << "): creating new FeatureExtractionPluginFactory" << std::endl;
+//	    DEBUG << "FeatureExtractionPluginFactory::instance(" << pluginType//		      << "): creating new FeatureExtractionPluginFactory" << endl;
 	    _nativeInstance = new FeatureExtractionPluginFactory();
 	}
 	return _nativeInstance;
@@ -118,7 +117,7 @@
     for (std::vector<QString>::iterator i = path.begin(); i != path.end(); ++i) {
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-        std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << i->toStdString() << std::endl;
+        DEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << i-<< endl;
 #endif
 
 	QDir pluginDir(*i, PLUGIN_GLOB,
@@ -130,7 +129,7 @@
             QString soname = pluginDir.filePath(pluginDir[j]);
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-            std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: trying potential library " << soname << std::endl;
+            DEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: trying potential library " << soname << endl;
 #endif
 
             void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL);
@@ -141,7 +140,7 @@
             }
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-            std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: It's a library all right, checking for descriptor" << std::endl;
+            DEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: It's a library all right, checking for descriptor" << endl;
 #endif
 
             VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction)
@@ -156,7 +155,7 @@
             }
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-            std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Vamp descriptor found" << std::endl;
+            DEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: Vamp descriptor found" << endl;
 #endif
 
             const VampPluginDescriptor *descriptor = 0;
@@ -174,7 +173,7 @@
                               << descriptor->identifier << "\" at indices "
                               << known[descriptor->identifier] << " and "
                               << index << std::endl;
-                    std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << std::endl;
+                    DEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl;
                     ok = false;
                     break;
                 } else {
@@ -194,7 +193,7 @@
                         ("vamp", soname, descriptor->identifier);
                     rv.push_back(id);
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-                    std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Found plugin id " << id << " at index " << index << std::endl;
+                    DEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: Found plugin id " << id << " at index " << index << endl;
 #endif
                     ++index;
                 }
@@ -217,9 +216,9 @@
     QString file = "";
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-    std::cerr << "FeatureExtractionPluginFactory::findPluginFile(\""
+    DEBUG << "FeatureExtractionPluginFactory::findPluginFile(\""
               << soname << "\", \"" << inDir << "\")"
-              << std::endl;
+              << endl;
 #endif
 
     if (inDir != "") {
@@ -234,8 +233,8 @@
         if (QFileInfo(file).exists() && QFileInfo(file).isFile()) {
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-            std::cerr << "FeatureExtractionPluginFactory::findPluginFile: "
-                      << "found trivially at " << file << std::endl;
+            DEBUG << "FeatureExtractionPluginFactory::findPluginFile: "
+                      << "found trivially at " << file << endl;
 #endif
 
             return file;
@@ -246,8 +245,8 @@
             if (QFileInfo(file).baseName() == QFileInfo(soname).baseName()) {
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-                std::cerr << "FeatureExtractionPluginFactory::findPluginFile: "
-                          << "found \"" << soname << "\" at " << file << std::endl;
+                DEBUG << "FeatureExtractionPluginFactory::findPluginFile: "
+                          << "found \"" << soname << "\" at " << file << endl;
 #endif
 
                 return file;
@@ -255,8 +254,8 @@
         }
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-        std::cerr << "FeatureExtractionPluginFactory::findPluginFile (with dir): "
-                  << "not found" << std::endl;
+        DEBUG << "FeatureExtractionPluginFactory::findPluginFile (with dir): "
+                  << "not found" << endl;
 #endif
 
         return "";
@@ -267,8 +266,8 @@
 
         if (fi.isAbsolute() && fi.exists() && fi.isFile()) {
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-            std::cerr << "FeatureExtractionPluginFactory::findPluginFile: "
-                      << "found trivially at " << soname << std::endl;
+            DEBUG << "FeatureExtractionPluginFactory::findPluginFile: "
+                      << "found trivially at " << soname << endl;
 #endif
             return soname;
         }
@@ -288,8 +287,8 @@
         }
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-        std::cerr << "FeatureExtractionPluginFactory::findPluginFile: "
-                  << "not found" << std::endl;
+        DEBUG << "FeatureExtractionPluginFactory::findPluginFile: "
+                  << "not found" << endl;
 #endif
 
         return "";
@@ -311,7 +310,7 @@
     QString type, soname, label;
     PluginIdentifier::parseIdentifier(identifier, type, soname, label);
     if (type != "vamp") {
-	std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Wrong factory for plugin type " << type << std::endl;
+	DEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Wrong factory for plugin type " << type << endl;
 	return 0;
     }
 
@@ -323,7 +322,7 @@
     } else if (found != soname) {
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-        std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Given library name was " << soname << ", found at " << found << std::endl;
+        DEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Given library name was " << soname << ", found at " << found << endl;
         std::cerr << soname << " -> " << found << std::endl;
 #endif
 
@@ -342,7 +341,7 @@
         DLSYM(libraryHandle, "vampGetPluginDescriptor");
     
     if (!fn) {
-        std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: No descriptor function in " << soname << std::endl;
+        DEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: No descriptor function in " << soname << endl;
         goto done;
     }
 
@@ -363,7 +362,7 @@
         rv = new PluginDeletionNotifyAdapter(plugin, this);
     }
 
-//    std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Constructed Vamp plugin, rv is " << rv << std::endl;
+//    DEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Constructed Vamp plugin, rv is " << rv << endl;
 
     //!!! need to dlclose() when plugins from a given library are unloaded
 
@@ -374,7 +373,7 @@
         }
     }
 
-//    std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Instantiated plugin " << label << " from library " << soname << ": descriptor " << descriptor << ", rv "<< rv << ", label " << rv->getName() << ", outputs " << rv->getOutputDescriptors().size() << std::endl;
+//    DEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Instantiated plugin " << label << " from library " << soname << ": descriptor " << descriptor << ", rv "<< rv << ", label " << rv->getName() << ", outputs " << rv->getOutputDescriptors().size() << endl;
     
     return rv;
 }
@@ -384,7 +383,7 @@
 {
     void *handle = m_handleMap[plugin];
     if (handle) {
-//        std::cerr << "unloading library " << handle << " for plugin " << plugin << std::endl;
+//        DEBUG << "unloading library " << handle << " for plugin " << plugin << endl;
         DLCLOSE(handle);
     }
     m_handleMap.erase(plugin);
@@ -416,12 +415,12 @@
 
 	QDir dir(path[i], "*.cat");
 
-//	std::cerr << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i] << " has " << dir.count() << " .cat files" << std::endl;
+//	DEBUG << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i] << " has " << dir.count() << " .cat files" << endl;
 	for (unsigned int j = 0; j < dir.count(); ++j) {
 
 	    QFile file(path[i] + "/" + dir[j]);
 
-//	    std::cerr << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i].toStdString() + "/" + dir[j].toStdString()) << std::endl;
+//	    DEBUG << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i]+ "/" + dir[j]) << endl;
 
 	    if (file.open(QIODevice::ReadOnly)) {
 //		    std::cerr << "...opened" << std::endl;
--- a/plugin/LADSPAPluginFactory.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/plugin/LADSPAPluginFactory.cpp	Mon May 16 17:19:09 2011 +0100
@@ -227,7 +227,7 @@
         else logmax = log10f(maximum);
     }
 
-//    std::cerr << "LADSPAPluginFactory::getPortDefault: hint = " << d << std::endl;
+//    DEBUG << "LADSPAPluginFactory::getPortDefault: hint = " << d << endl;
 
     if (!LADSPA_IS_HINT_HAS_DEFAULT(d)) {
 	
@@ -349,8 +349,8 @@
 	m_instances.insert(instance);
 
 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
-        std::cerr << "LADSPAPluginFactory::instantiatePlugin("
-                  << identifier << ": now have " << m_instances.size() << " instances" << std::endl;
+        DEBUG << "LADSPAPluginFactory::instantiatePlugin("
+                  << identifier << ": now have " << m_instances.size() << " instances" << endl;
 #endif
 
 	return instance;
@@ -384,7 +384,7 @@
 	PluginIdentifier::parseIdentifier((*ii)->getPluginIdentifier(), itype, isoname, ilabel);
 	if (isoname == soname) {
 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
-	    std::cerr << "LADSPAPluginFactory::releasePlugin: dll " << soname << " is still in use for plugin " << ilabel << std::endl;
+	    DEBUG << "LADSPAPluginFactory::releasePlugin: dll " << soname << " is still in use for plugin " << ilabel << endl;
 #endif
 	    stillInUse = true;
 	    break;
@@ -394,15 +394,15 @@
     if (!stillInUse) {
         if (soname != PluginIdentifier::BUILTIN_PLUGIN_SONAME) {
 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
-            std::cerr << "LADSPAPluginFactory::releasePlugin: dll " << soname << " no longer in use, unloading" << std::endl;
+            DEBUG << "LADSPAPluginFactory::releasePlugin: dll " << soname << " no longer in use, unloading" << endl;
 #endif
             unloadLibrary(soname);
         }
     }
 
 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
-    std::cerr << "LADSPAPluginFactory::releasePlugin("
-                  << identifier << ": now have " << m_instances.size() << " instances" << std::endl;
+    DEBUG << "LADSPAPluginFactory::releasePlugin("
+                  << identifier << ": now have " << m_instances.size() << " instances" << endl;
 #endif
 }
 
@@ -449,7 +449,7 @@
     void *libraryHandle = DLOPEN(soName, RTLD_NOW);
     if (libraryHandle) {
         m_libraryHandles[soName] = libraryHandle;
-        std::cerr << "LADSPAPluginFactory::loadLibrary: Loaded library \"" << soName << "\"" << std::endl;
+        DEBUG << "LADSPAPluginFactory::loadLibrary: Loaded library \"" << soName << "\"" << endl;
         return;
     }
 
@@ -468,7 +468,7 @@
 	 i != pathList.end(); ++i) {
         
 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
-        std::cerr << "Looking at: " << (*i) << std::endl;
+        DEBUG << "Looking at: " << (*i) << endl;
 #endif
 
         QDir dir(*i, PLUGIN_GLOB,
@@ -509,7 +509,7 @@
 {
     LibraryHandleMap::iterator li = m_libraryHandles.find(soName);
     if (li != m_libraryHandles.end()) {
-//	std::cerr << "unloading " << soname << std::endl;
+//	DEBUG << "unloading " << soname << endl;
 	DLCLOSE(m_libraryHandles[soName]);
 	m_libraryHandles.erase(li);
     }
@@ -633,13 +633,13 @@
 
     std::vector<QString> pathList = getPluginPath();
 
-//    std::cerr << "LADSPAPluginFactory::discoverPlugins - "
+//    DEBUG << "LADSPAPluginFactory::discoverPlugins - "
 //	      << "discovering plugins; path is ";
 //    for (std::vector<QString>::iterator i = pathList.begin();
 //	 i != pathList.end(); ++i) {
-//	std::cerr << "[" << i->toStdString() << "] ";
+//	DEBUG << "[" << i-<< "] ";
 //    }
-//    std::cerr << std::endl;
+//    DEBUG << endl;
 
 #ifdef HAVE_LRDF
     // read the description files 
@@ -818,22 +818,22 @@
             path.push_back(p);
 	    p.replace("/lib/", "/share/");
 	    path.push_back(p);
-//	    std::cerr << "LADSPAPluginFactory::generateFallbackCategories: path element " << p << std::endl;
+//	    DEBUG << "LADSPAPluginFactory::generateFallbackCategories: path element " << p << endl;
 	}
 	path.push_back(pluginPath[i]);
-//	std::cerr << "LADSPAPluginFactory::generateFallbackCategories: path element " << pluginPath[i] << std::endl;
+//	DEBUG << "LADSPAPluginFactory::generateFallbackCategories: path element " << pluginPath[i] << endl;
     }
 
     for (size_t i = 0; i < path.size(); ++i) {
 
 	QDir dir(path[i], "*.cat");
 
-//	std::cerr << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i] << " has " << dir.count() << " .cat files" << std::endl;
+//	DEBUG << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i] << " has " << dir.count() << " .cat files" << endl;
 	for (unsigned int j = 0; j < dir.count(); ++j) {
 
 	    QFile file(path[i] + "/" + dir[j]);
 
-//	    std::cerr << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i].toStdString() + "/" + dir[j].toStdString()) << std::endl;
+//	    DEBUG << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i]+ "/" + dir[j]) << endl;
 
 	    if (file.open(QIODevice::ReadOnly)) {
 //		    std::cerr << "...opened" << std::endl;
--- a/plugin/LADSPAPluginInstance.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/plugin/LADSPAPluginInstance.cpp	Mon May 16 17:19:09 2011 +0100
@@ -207,8 +207,8 @@
     for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) {
         if (id == m_descriptor->PortNames[m_controlPortsIn[i].first]) {
 #ifdef DEBUG_LADSPA
-            std::cerr << "LADSPAPluginInstance::setParameter: Found id "
-                      << id << " at control port " << i << std::endl;
+            DEBUG << "LADSPAPluginInstance::setParameter: Found id "
+                      << id << " at control port " << i << endl;
 #endif
             setParameterValue(i, value);
             break;
@@ -220,8 +220,8 @@
 LADSPAPluginInstance::init(int idealChannelCount)
 {
 #ifdef DEBUG_LADSPA
-    std::cerr << "LADSPAPluginInstance::init(" << idealChannelCount << "): plugin has "
-	      << m_descriptor->PortCount << " ports" << std::endl;
+    DEBUG << "LADSPAPluginInstance::init(" << idealChannelCount << "): plugin has "
+	      << m_descriptor->PortCount << " ports" << endl;
 #endif
 
     // Discover ports numbers and identities
@@ -232,12 +232,12 @@
 
             if (LADSPA_IS_PORT_INPUT(m_descriptor->PortDescriptors[i])) {
 #ifdef DEBUG_LADSPA
-		std::cerr << "LADSPAPluginInstance::init: port " << i << " is audio in" << std::endl;
+		DEBUG << "LADSPAPluginInstance::init: port " << i << " is audio in" << endl;
 #endif
                 m_audioPortsIn.push_back(i);
 	    } else {
 #ifdef DEBUG_LADSPA
-		std::cerr << "LADSPAPluginInstance::init: port " << i << " is audio out" << std::endl;
+		DEBUG << "LADSPAPluginInstance::init: port " << i << " is audio out" << endl;
 #endif
                 m_audioPortsOut.push_back(i);
 	    }
@@ -247,7 +247,7 @@
 	    if (LADSPA_IS_PORT_INPUT(m_descriptor->PortDescriptors[i])) {
 
 #ifdef DEBUG_LADSPA
-		std::cerr << "LADSPAPluginInstance::init: port " << i << " is control in" << std::endl;
+		DEBUG << "LADSPAPluginInstance::init: port " << i << " is control in" << endl;
 #endif
 		LADSPA_Data *data = new LADSPA_Data(0.0);
 		m_controlPortsIn.push_back(
@@ -256,7 +256,7 @@
 	    } else {
 
 #ifdef DEBUG_LADSPA
-		std::cerr << "LADSPAPluginInstance::init: port " << i << " is control out" << std::endl;
+		DEBUG << "LADSPAPluginInstance::init: port " << i << " is control out" << endl;
 #endif
 		LADSPA_Data *data = new LADSPA_Data(0.0);
 		m_controlPortsOut.push_back(
@@ -273,8 +273,8 @@
         }
 #ifdef DEBUG_LADSPA
         else
-            std::cerr << "LADSPAPluginInstance::init - "
-                      << "unrecognised port type" << std::endl;
+            DEBUG << "LADSPAPluginInstance::init - "
+                      << "unrecognised port type" << endl;
 #endif
     }
 
@@ -341,7 +341,7 @@
 LADSPAPluginInstance::~LADSPAPluginInstance()
 {
 #ifdef DEBUG_LADSPA
-    std::cerr << "LADSPAPluginInstance::~LADSPAPluginInstance" << std::endl;
+    DEBUG << "LADSPAPluginInstance::~LADSPAPluginInstance" << endl;
 #endif
 
     if (m_instanceHandles.size() != 0) { // "isOK()"
--- a/plugin/PluginXml.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/plugin/PluginXml.cpp	Mon May 16 17:19:09 2011 +0100
@@ -81,9 +81,9 @@
     for (Vamp::PluginBase::ParameterList::const_iterator i = parameters.begin();
          i != parameters.end(); ++i) {
 
-//        std::cerr << "PluginXml::toXml: parameter name \""
+//        DEBUG << "PluginXml::toXml: parameter name \""
 //                  << i->name.c_str() << "\" has value "
-//                  << m_plugin->getParameter(i->name) << std::endl;
+//                  << m_plugin->getParameter(i->name) << endl;
 
         stream << QString("param-%1=\"%2\" ")
             .arg(stripInvalidParameterNameCharacters(QString(i->identifier.c_str())))
@@ -174,15 +174,15 @@
                  (QString(i->identifier.c_str())));
 
         if (attrs.value(pname) == "") {
-//            std::cerr << "PluginXml::setParameters: no parameter \"" << i->name << "\" (attribute \"" << name << "\")" << std::endl;
+//            DEBUG << "PluginXml::setParameters: no parameter \"" << i->name << "\" (attribute \"" << name << "\")" << endl;
             continue;
         }
 
         bool ok;
         float value = attrs.value(pname).trimmed().toFloat(&ok);
         if (ok) {
-//            std::cerr << "PluginXml::setParameters: setting parameter \""
-//                      << i->identifier << "\" to value " << value << std::endl;
+//            DEBUG << "PluginXml::setParameters: setting parameter \""
+//                      << i->identifier << "\" to value " << value << endl;
             m_plugin->setParameter(i->identifier, value);
         } else {
             std::cerr << "WARNING: PluginXml::setParameters: Invalid value \"" << attrs.value(pname) << "\" for parameter \"" << i->identifier << "\" (attribute \"" << pname << "\")" << std::endl;
@@ -199,8 +199,8 @@
     int errorLine;
     int errorColumn;
 
-//    std::cerr << "PluginXml::setParametersFromXml: XML is \""
-//              << xml.toLocal8Bit().data() << "\"" << std::endl;
+//    DEBUG << "PluginXml::setParametersFromXml: XML is \""
+//              << xml.toLocal8Bit().data() << "\"" << endl;
 
     if (!doc.setContent(xml, false, &error, &errorLine, &errorColumn)) {
         std::cerr << "PluginXml::setParametersFromXml: Error in parsing XML: " << error << " at line " << errorLine << ", column " << errorColumn << std::endl;
@@ -217,8 +217,7 @@
     for (unsigned int i = 0; i < attrNodes.length(); ++i) {
         QDomAttr attr = attrNodes.item(i).toAttr();
         if (attr.isNull()) continue;
-//        std::cerr << "PluginXml::setParametersFromXml: Adding attribute \"" << attr.name().toStdString()
-//                  << "\" with value \"" << attr.value() << "\"" << std::endl;
+//        DEBUG << "PluginXml::setParametersFromXml: Adding attribute \"" << attr.name()//                  << "\" with value \"" << attr.value() << "\"" << endl;
         attrs.append(attr.name(), "", "", attr.value());
     }
 
--- a/plugin/RealTimePluginFactory.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/plugin/RealTimePluginFactory.cpp	Mon May 16 17:19:09 2011 +0100
@@ -44,16 +44,14 @@
 {
     if (pluginType == "ladspa") {
 	if (!_ladspaInstance) {
-//	    std::cerr << "RealTimePluginFactory::instance(" << pluginType.toStdString()
-//		      << "): creating new LADSPAPluginFactory" << std::endl;
+//	    DEBUG << "RealTimePluginFactory::instance(" << pluginType//		      << "): creating new LADSPAPluginFactory" << endl;
 	    _ladspaInstance = new LADSPAPluginFactory();
 	    _ladspaInstance->discoverPlugins();
 	}
 	return _ladspaInstance;
     } else if (pluginType == "dssi") {
 	if (!_dssiInstance) {
-//	    std::cerr << "RealTimePluginFactory::instance(" << pluginType.toStdString()
-//		      << "): creating new DSSIPluginFactory" << std::endl;
+//	    DEBUG << "RealTimePluginFactory::instance(" << pluginType//		      << "): creating new DSSIPluginFactory" << endl;
 	    _dssiInstance = new DSSIPluginFactory();
 	    _dssiInstance->discoverPlugins();
 	}
--- a/plugin/RealTimePluginInstance.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/plugin/RealTimePluginInstance.cpp	Mon May 16 17:19:09 2011 +0100
@@ -28,10 +28,10 @@
 
 RealTimePluginInstance::~RealTimePluginInstance()
 {
-//    std::cerr << "RealTimePluginInstance::~RealTimePluginInstance" << std::endl;
+//    DEBUG << "RealTimePluginInstance::~RealTimePluginInstance" << endl;
 
     if (m_factory) {
-//	std::cerr << "Asking factory to release " << m_identifier << std::endl;
+//	DEBUG << "Asking factory to release " << m_identifier << endl;
 
 	m_factory->releasePlugin(this, m_identifier);
     }
--- a/plugin/plugins/SamplePlayer.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/plugin/plugins/SamplePlayer.cpp	Mon May 16 17:19:09 2011 +0100
@@ -152,14 +152,14 @@
 SamplePlayer::instantiate(const LADSPA_Descriptor *, unsigned long rate)
 {
     if (!hostDescriptor || !hostDescriptor->request_non_rt_thread) {
-	std::cerr << "SamplePlayer::instantiate: Host does not provide request_non_rt_thread, not instantiating" << std::endl;
+	DEBUG << "SamplePlayer::instantiate: Host does not provide request_non_rt_thread, not instantiating" << endl;
 	return 0;
     }
 
     SamplePlayer *player = new SamplePlayer(rate);
 
     if (hostDescriptor->request_non_rt_thread(player, workThreadCallback)) {
-	std::cerr << "SamplePlayer::instantiate: Host rejected request_non_rt_thread call, not instantiating" << std::endl;
+	DEBUG << "SamplePlayer::instantiate: Host rejected request_non_rt_thread call, not instantiating" << endl;
 	delete player;
 	return 0;
     }
@@ -321,7 +321,7 @@
     if (player->m_pendingProgramChange >= 0) {
 
 #ifdef DEBUG_SAMPLE_PLAYER
-	std::cerr << "SamplePlayer::workThreadCallback: pending program change " << player->m_pendingProgramChange << std::endl;
+	DEBUG << "SamplePlayer::workThreadCallback: pending program change " << player->m_pendingProgramChange << endl;
 #endif
 
 	player->m_mutex.lock();
@@ -364,8 +364,8 @@
     m_samples.clear();
 
 #ifdef DEBUG_SAMPLE_PLAYER
-    std::cerr << "SamplePlayer::searchSamples: Directory is \""
-	      << m_sampleDir.toLocal8Bit().data() << "\"" << std::endl;
+    DEBUG << "SamplePlayer::searchSamples: Directory is \""
+	      << m_sampleDir.toLocal8Bit().data() << "\"" << endl;
 #endif
 
     QDir dir(m_sampleDir, "*.wav");
--- a/rdf/PluginRDFDescription.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/rdf/PluginRDFDescription.cpp	Mon May 16 17:19:09 2011 +0100
@@ -305,7 +305,7 @@
     }
 
     if (results.empty()) {
-        cerr << "ERROR: PluginRDFDescription::indexURL: NOTE: No outputs defined for <"
+        DEBUG << "ERROR: PluginRDFDescription::indexURL: NOTE: No outputs defined for <"
              << m_pluginUri << ">" << endl;
         return false;
     }
--- a/rdf/PluginRDFIndexer.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/rdf/PluginRDFIndexer.cpp	Mon May 16 17:19:09 2011 +0100
@@ -117,7 +117,7 @@
 bool
 PluginRDFIndexer::indexConfiguredURLs()
 {
-    std::cerr << "PluginRDFIndexer::indexConfiguredURLs" << std::endl;
+    DEBUG << "PluginRDFIndexer::indexConfiguredURLs" << endl;
 
     QSettings settings;
     settings.beginGroup("RDF");
@@ -129,8 +129,8 @@
 
         QString index = indices[i];
 
-        std::cerr << "PluginRDFIndexer::indexConfiguredURLs: index url is "
-                  << index << std::endl;
+        DEBUG << "PluginRDFIndexer::indexConfiguredURLs: index url is "
+                  << index << endl;
 
         CachedFile cf(index);
         if (!cf.isOK()) continue;
@@ -143,8 +143,8 @@
         PlaylistFileReader::Playlist list = reader.load();
         for (PlaylistFileReader::Playlist::const_iterator j = list.begin();
              j != list.end(); ++j) {
-            std::cerr << "PluginRDFIndexer::indexConfiguredURLs: url is "
-                      << j->toStdString() << std::endl;
+            DEBUG << "PluginRDFIndexer::indexConfiguredURLs: url is "
+                  << j->toStdString() << endl;
             pullURL(*j);
         }
     }
@@ -241,7 +241,7 @@
 
     loadPrefixes();
 
-//    std::cerr << "PluginRDFIndexer::indexURL(" << urlString << ")" << std::endl;
+//    DEBUG << "PluginRDFIndexer::indexURL(" << urlString << ")" << endl;
 
     QMutexLocker locker(&m_mutex);
 
@@ -293,7 +293,7 @@
     }
 
     if (results.empty()) {
-        cerr << "PluginRDFIndexer::reindex: NOTE: no vamp:Plugin resources found in indexed documents" << endl;
+        DEBUG << "PluginRDFIndexer::reindex: NOTE: no vamp:Plugin resources found in indexed documents" << endl;
         return false;
     }
 
@@ -308,13 +308,13 @@
         QString identifier = (*i)["plugin_id"].value;
 
         if (identifier == "") {
-            cerr << "PluginRDFIndexer::reindex: NOTE: No vamp:identifier for plugin <"
+            DEBUG << "PluginRDFIndexer::reindex: NOTE: No vamp:identifier for plugin <"
                  << pluginUri << ">"
                  << endl;
             continue;
         }
         if (soUri == "") {
-            cerr << "PluginRDFIndexer::reindex: NOTE: No implementation library for plugin <"
+            DEBUG << "PluginRDFIndexer::reindex: NOTE: No implementation library for plugin <"
                  << pluginUri << ">"
                  << endl;
             continue;
@@ -334,7 +334,7 @@
             SimpleSPARQLQuery::singleResultQuery(m, sonameQuery, "library_id");
         QString soname = sonameValue.value;
         if (soname == "") {
-            cerr << "PluginRDFIndexer::reindex: NOTE: No identifier for library <"
+            DEBUG << "PluginRDFIndexer::reindex: NOTE: No identifier for library <"
                  << soUri << ">"
                  << endl;
             continue;
@@ -355,7 +355,7 @@
 
         if (pluginUri != "") {
             if (m_uriToIdMap.find(pluginUri) != m_uriToIdMap.end()) {
-                cerr << "PluginRDFIndexer::reindex: WARNING: Found multiple plugins with the same URI:" << endl;
+                DEBUG << "PluginRDFIndexer::reindex: WARNING: Found multiple plugins with the same URI:" << endl;
                 cerr << "  1. Plugin id \"" << m_uriToIdMap[pluginUri] << "\"" << endl;
                 cerr << "  2. Plugin id \"" << pluginId << "\"" << endl;
                 cerr << "both claim URI <" << pluginUri << ">" << endl;
@@ -366,7 +366,7 @@
     }
 
     if (!foundSomething) {
-        cerr << "PluginRDFIndexer::reindex: NOTE: Plugins found, but none sufficiently described" << endl;
+        DEBUG << "PluginRDFIndexer::reindex: NOTE: Plugins found, but none sufficiently described" << endl;
     }
     
     return addedSomething;
--- a/rdf/RDFFeatureWriter.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/rdf/RDFFeatureWriter.cpp	Mon May 16 17:19:09 2011 +0100
@@ -141,10 +141,10 @@
         m_rdfDescriptions[pluginId] = PluginRDFDescription(pluginId);
 
         if (m_rdfDescriptions[pluginId].haveDescription()) {
-            cerr << "NOTE: Have RDF description for plugin ID \""
+            DEBUG << "NOTE: Have RDF description for plugin ID \""
                  << pluginId << "\"" << endl;
         } else {
-            cerr << "NOTE: No RDF description for plugin ID \""
+            DEBUG << "NOTE: No RDF description for plugin ID \""
                  << pluginId << "\"" << endl;
             if (!m_network) {
                 cerr << "      Consider using the --rdf-network option to retrieve plugin descriptions"  << endl;
@@ -292,7 +292,7 @@
 RDFFeatureWriter::writeSignalDescription(QTextStream *sptr,
                                          QString trackId)
 {
-//    std::cerr << "RDFFeatureWriter::writeSignalDescription" << std::endl;
+//    DEBUG << "RDFFeatureWriter::writeSignalDescription" << endl;
 
     QTextStream &stream = *sptr;
 
@@ -520,7 +520,7 @@
                                  PluginRDFDescription &desc,
                                  QString timelineURI)
 {
-//    std::cerr << "RDFFeatureWriter::writeSparseRDF: have " << featureList.size() << " features" << std::endl;
+//    DEBUG << "RDFFeatureWriter::writeSparseRDF: have " << featureList.size() << " features" << endl;
 
     if (featureList.empty()) return;
     QTextStream &stream = *sptr;
@@ -621,7 +621,7 @@
     QString featureUri = desc.getOutputFeatureAttributeURI(outputId);
 
     if (featureUri == "") {
-        cerr << "RDFFeatureWriter::writeTrackLevelRDF: ERROR: No feature URI available -- this function should not have been called!" << endl;
+        DEBUG << "RDFFeatureWriter::writeTrackLevelRDF: ERROR: No feature URI available -- this function should not have been called!" << endl;
         return;
     }
 
@@ -765,14 +765,14 @@
 
 void RDFFeatureWriter::finish()
 {
-//    cerr << "RDFFeatureWriter::finish()" << endl;
+//    DEBUG << "RDFFeatureWriter::finish()" << endl;
 
     // close any open dense feature literals
 
     for (map<StringTransformPair, StreamBuffer>::iterator i =
              m_openDenseFeatures.begin();
          i != m_openDenseFeatures.end(); ++i) {
-//        cerr << "closing a stream" << endl;
+//        DEBUG << "closing a stream" << endl;
         StreamBuffer &b = i->second;
         *(b.first) << b.second << "\" ." << endl;
     }
--- a/rdf/RDFImporter.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/rdf/RDFImporter.cpp	Mon May 16 17:19:09 2011 +0100
@@ -219,14 +219,12 @@
         QString signal = results[i]["signal"].value;
         QString source = results[i]["source"].value;
 
-        std::cerr << "NOTE: Seeking signal source \"" << source.toStdString()
-                  << "\"..." << std::endl;
+        DEBUG << "NOTE: Seeking signal source \"" << source                  << "\"..." << endl;
 
         FileSource *fs = new FileSource(source, reporter);
         if (fs->isAvailable()) {
-            std::cerr << "NOTE: Source is available: Local filename is \""
-                      << fs->getLocalFilename().toStdString()
-                      << "\"..." << std::endl;
+            DEBUG << "NOTE: Source is available: Local filename is \""
+                      << fs->getLocalFilename()                      << "\"..." << endl;
         }
             
 #ifdef NO_SV_GUI
@@ -237,8 +235,7 @@
         }
 #else
         if (!fs->isAvailable()) {
-            std::cerr << "NOTE: Signal source \"" << source.toStdString()
-                      << "\" is not available, using file finder..." << std::endl;
+            DEBUG << "NOTE: Signal source \"" << source                      << "\" is not available, using file finder..." << endl;
             FileFinder *ff = FileFinder::getInstance();
             if (ff) {
                 QString path = ff->find(FileFinder::AudioFile,
@@ -428,7 +425,7 @@
          "title");
 
     if (v.value != "") {
-        std::cerr << "RDFImporterImpl::getDenseModelTitle: Title (from signal) \"" << v.value << "\"" << std::endl;
+        DEBUG << "RDFImporterImpl::getDenseModelTitle: Title (from signal) \"" << v.value << "\"" << endl;
         m->setObjectName(v.value);
         return;
     }
@@ -439,12 +436,12 @@
          "title");
     
     if (v.value != "") {
-        std::cerr << "RDFImporterImpl::getDenseModelTitle: Title (from signal type) \"" << v.value << "\"" << std::endl;
+        DEBUG << "RDFImporterImpl::getDenseModelTitle: Title (from signal type) \"" << v.value << "\"" << endl;
         m->setObjectName(v.value);
         return;
     }
 
-    std::cerr << "RDFImporterImpl::getDenseModelTitle: No title available for feature <" << featureUri << ">" << std::endl;
+    DEBUG << "RDFImporterImpl::getDenseModelTitle: No title available for feature <" << featureUri << ">" << endl;
 }
 
 void
@@ -744,7 +741,7 @@
         } else {
             QString timestring = SimpleSPARQLQuery::singleResultQuery
                 (s, timeQueryString.arg(thinguri), "time").value;
-//            std::cerr << "timestring = " << timestring << std::endl;
+//            DEBUG << "timestring = " << timestring << endl;
             if (timestring != "") {
                 time = RealTime::fromXsdDuration(timestring.toStdString());
                 haveTime = true;
@@ -773,11 +770,10 @@
             modelMap[timeline][type][dimensions].end()) {
 
 /*
-            std::cerr << "Creating new model: source = " << source.toStdString()
-                      << ", type = " << type << ", dimensions = "
+            DEBUG << "Creating new model: source = " << source                      << ", type = " << type << ", dimensions = "
                       << dimensions << ", haveDuration = " << haveDuration
                       << ", time = " << time << ", duration = " << duration
-                      << std::endl;
+                      << endl;
 */
             
             if (!haveDuration) {
@@ -878,7 +874,7 @@
                            std::vector<float> &values,
                            QString label)
 {
-//    std::cerr << "RDFImporterImpl::fillModel: adding point at frame " << ftime << std::endl;
+//    DEBUG << "RDFImporterImpl::fillModel: adding point at frame " << ftime << endl;
 
     SparseOneDimensionalModel *sodm =
         dynamic_cast<SparseOneDimensionalModel *>(model);
@@ -1030,8 +1026,8 @@
         }
     }
 
-    std::cerr << "NOTE: RDFImporter::identifyDocumentType: haveAudio = "
-              << haveAudio << std::endl;
+    DEBUG << "NOTE: RDFImporter::identifyDocumentType: haveAudio = "
+              << haveAudio << endl;
 
     value =
         SimpleSPARQLQuery::singleResultQuery
@@ -1064,8 +1060,8 @@
         }
     }
 
-    std::cerr << "NOTE: RDFImporter::identifyDocumentType: haveAnnotations = "
-              << haveAnnotations << std::endl;
+    DEBUG << "NOTE: RDFImporter::identifyDocumentType: haveAnnotations = "
+              << haveAnnotations << endl;
 
     SimpleSPARQLQuery::closeSingleSource(url);
 
--- a/rdf/RDFTransformFactory.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/rdf/RDFTransformFactory.cpp	Mon May 16 17:19:09 2011 +0100
@@ -168,7 +168,7 @@
     m_isRDF = true;
 
     if (transformResults.empty()) {
-        cerr << "RDFTransformFactory: NOTE: No RDF/TTL transform descriptions found in document at <" << m_urlString << ">" << endl;
+        DEBUG << "RDFTransformFactory: NOTE: No RDF/TTL transform descriptions found in document at <" << m_urlString << ">" << endl;
         return transforms;
     }
 
@@ -272,7 +272,7 @@
                     } else if (optional == "block_size") {
                         transform.setBlockSize(v.value.toUInt());
                     } else if (optional == "window_type") {
-                        cerr << "NOTE: can't handle window type yet (value is \""
+                        DEBUG << "NOTE: can't handle window type yet (value is \""
                              << v.value << "\")" << endl;
                     } else if (optional == "sample_rate") {
                         transform.setSampleRate(v.value.toFloat());
@@ -289,7 +289,7 @@
             }
         }
 
-        cerr << "RDFTransformFactory: NOTE: Transform is: " << endl;
+        DEBUG << "RDFTransformFactory: NOTE: Transform is: " << endl;
         cerr << transform.toXmlString() << endl;
 
         transforms.push_back(transform);
--- a/rdf/SimpleSPARQLQuery.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/rdf/SimpleSPARQLQuery.cpp	Mon May 16 17:19:09 2011 +0100
@@ -178,17 +178,17 @@
 WredlandWorldWrapper::freeModel(QString forUri)
 {
 #ifdef DEBUG_SIMPLE_SPARQL_QUERY
-    std::cerr << "SimpleSPARQLQuery::freeModel: Model uri = \"" << forUri << "\"" << std::endl;
+    DEBUG << "SimpleSPARQLQuery::freeModel: Model uri = \"" << forUri << "\"" << endl;
 #endif
 
     QMutexLocker locker(&m_mutex);
     if (forUri == "") {
-        std::cerr << "SimpleSPARQLQuery::freeModel: ERROR: Can't free default model" << std::endl;
+        DEBUG << "SimpleSPARQLQuery::freeModel: ERROR: Can't free default model" << endl;
         return;
     }
     if (m_ownModelUris.find(forUri) == m_ownModelUris.end()) {
 #ifdef DEBUG_SIMPLE_SPARQL_QUERY
-        std::cerr << "SimpleSPARQLQuery::freeModel: NOTE: Unknown or already-freed model (uri = \"" << forUri << "\")" << std::endl;
+        DEBUG << "SimpleSPARQLQuery::freeModel: NOTE: Unknown or already-freed model (uri = \"" << forUri << "\")" << endl;
 #endif
         return;
     }
@@ -388,7 +388,7 @@
 SimpleSPARQLQuery::Impl::executeDirectParser()
 {
 #ifdef DEBUG_SIMPLE_SPARQL_QUERY
-    std::cerr << "SimpleSPARQLQuery::executeDirectParser: Query is: \"" << m_query << "\"" << std::endl;
+    DEBUG << "SimpleSPARQLQuery::executeDirectParser: Query is: \"" << m_query << "\"" << endl;
 #endif
 
     ResultList list;
@@ -399,13 +399,13 @@
     QString fromUri;
 
     if (fromRE.indexIn(m_query) < 0) {
-        std::cerr << "SimpleSPARQLQuery::executeDirectParser: Query contains no FROM clause, nothing to parse from" << std::endl;
+        DEBUG << "SimpleSPARQLQuery::executeDirectParser: Query contains no FROM clause, nothing to parse from" << endl;
         return list;
     } else {
         fromUri = fromRE.cap(1);
 #ifdef DEBUG_SIMPLE_SPARQL_QUERY
-        std::cerr << "SimpleSPARQLQuery::executeDirectParser: FROM URI is <"
-                  << fromUri << ">" << std::endl;
+        DEBUG << "SimpleSPARQLQuery::executeDirectParser: FROM URI is <"
+                  << fromUri << ">" << endl;
 #endif
     }
 
@@ -416,7 +416,7 @@
 SimpleSPARQLQuery::Impl::executeDatastore()
 {
 #ifdef DEBUG_SIMPLE_SPARQL_QUERY
-    std::cerr << "SimpleSPARQLQuery::executeDatastore: Query is: \"" << m_query << "\"" << std::endl;
+    DEBUG << "SimpleSPARQLQuery::executeDatastore: Query is: \"" << m_query << "\"" << endl;
 #endif
 
     ResultList list;
@@ -576,7 +576,7 @@
     librdf_free_query(query);
 
 #ifdef DEBUG_SIMPLE_SPARQL_QUERY
-    cerr << "SimpleSPARQLQuery::executeDatastore: All results retrieved (" << resultCount << " of them)" << endl;
+    DEBUG << "SimpleSPARQLQuery::executeDatastore: All results retrieved (" << resultCount << " of them)" << endl;
 #endif
 
     return list;
@@ -620,7 +620,7 @@
     SimpleSPARQLQuery q(type, query);
     ResultList results = q.execute();
     if (!q.isOK()) {
-        cerr << "SimpleSPARQLQuery::singleResultQuery: ERROR: "
+        DEBUG << "SimpleSPARQLQuery::singleResultQuery: ERROR: "
              << q.getErrorString() << endl;
         return Value();
     }
--- a/system/System.h	Thu May 12 17:31:24 2011 +0100
+++ b/system/System.h	Mon May 16 17:19:09 2011 +0100
@@ -16,6 +16,8 @@
 #ifndef _SYSTEM_H_
 #define _SYSTEM_H_
 
+#include "base/Debug.h"
+
 #ifdef _WIN32
 
 #include <windows.h>
--- a/transform/CSVFeatureWriter.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/transform/CSVFeatureWriter.cpp	Mon May 16 17:19:09 2011 +0100
@@ -64,7 +64,7 @@
 {
     FileFeatureWriter::setParameters(params);
 
-    cerr << "CSVFeatureWriter::setParameters" << endl;
+    DEBUG << "CSVFeatureWriter::setParameters" << endl;
     for (map<string, string>::iterator i = params.begin();
          i != params.end(); ++i) {
         cerr << i->first << " -> " << i->second << endl;
--- a/transform/FeatureExtractionModelTransformer.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/transform/FeatureExtractionModelTransformer.cpp	Mon May 16 17:19:09 2011 +0100
@@ -43,7 +43,7 @@
     m_descriptor(0),
     m_outputFeatureNo(0)
 {
-//    std::cerr << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: plugin " << pluginId << ", outputName " << m_transform.getOutput() << std::endl;
+//    DEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: plugin " << pluginId << ", outputName " << m_transform.getOutput() << endl;
 
     QString pluginId = transform.getPluginIdentifier();
 
@@ -86,9 +86,9 @@
 	return;
     }
 
-    std::cerr << "Initialising feature extraction plugin with channels = "
+    DEBUG << "Initialising feature extraction plugin with channels = "
               << channelCount << ", step = " << m_transform.getStepSize()
-              << ", block = " << m_transform.getBlockSize() << std::endl;
+              << ", block = " << m_transform.getBlockSize() << endl;
 
     if (!m_plugin->initialise(channelCount,
                               m_transform.getStepSize(),
@@ -152,7 +152,7 @@
     }
     
     for (size_t i = 0; i < outputs.size(); ++i) {
-//        std::cerr << "comparing output " << i << " name \"" << outputs[i].identifier << "\" with expected \"" << m_transform.getOutput() << "\"" << std::endl;
+//        DEBUG << "comparing output " << i << " name \"" << outputs[i].identifier << "\" with expected \"" << m_transform.getOutput() << "\"" << endl;
 	if (m_transform.getOutput() == "" ||
             outputs[i].identifier == m_transform.getOutput().toStdString()) {
 	    m_outputFeatureNo = i;
@@ -378,7 +378,7 @@
 
 FeatureExtractionModelTransformer::~FeatureExtractionModelTransformer()
 {
-//    std::cerr << "FeatureExtractionModelTransformer::~FeatureExtractionModelTransformer()" << std::endl;
+//    DEBUG << "FeatureExtractionModelTransformer::~FeatureExtractionModelTransformer()" << endl;
     delete m_plugin;
     delete m_descriptor;
 }
@@ -386,12 +386,12 @@
 DenseTimeValueModel *
 FeatureExtractionModelTransformer::getConformingInput()
 {
-//    std::cerr << "FeatureExtractionModelTransformer::getConformingInput: input model is " << getInputModel() << std::endl;
+//    DEBUG << "FeatureExtractionModelTransformer::getConformingInput: input model is " << getInputModel() << endl;
 
     DenseTimeValueModel *dtvm =
 	dynamic_cast<DenseTimeValueModel *>(getInputModel());
     if (!dtvm) {
-	std::cerr << "FeatureExtractionModelTransformer::getConformingInput: WARNING: Input model is not conformable to DenseTimeValueModel" << std::endl;
+	DEBUG << "FeatureExtractionModelTransformer::getConformingInput: WARNING: Input model is not conformable to DenseTimeValueModel" << endl;
     }
     return dtvm;
 }
@@ -405,7 +405,7 @@
     if (!m_output) return;
 
     while (!input->isReady() && !m_abandoned) {
-        std::cerr << "FeatureExtractionModelTransformer::run: Waiting for input model to be ready..." << std::endl;
+        DEBUG << "FeatureExtractionModelTransformer::run: Waiting for input model to be ready..." << endl;
         usleep(500000);
     }
     if (m_abandoned) return;
@@ -499,9 +499,9 @@
                 contextStart + contextDuration) break;
         }
 
-//	std::cerr << "FeatureExtractionModelTransformer::run: blockFrame "
+//	DEBUG << "FeatureExtractionModelTransformer::run: blockFrame "
 //		  << blockFrame << ", endFrame " << endFrame << ", blockSize "
-//                  << blockSize << std::endl;
+//                  << blockSize << endl;
 
 	long completion =
 	    (((blockFrame - contextStart) / stepSize) * 99) /
@@ -636,8 +636,8 @@
 {
     size_t inputRate = m_input.getModel()->getSampleRate();
 
-//    std::cerr << "FeatureExtractionModelTransformer::addFeature("
-//	      << blockFrame << ")" << std::endl;
+//    DEBUG << "FeatureExtractionModelTransformer::addFeature("
+//	      << blockFrame << ")" << endl;
 
     int binCount = 1;
     if (m_descriptor->hasFixedBinCount) {
@@ -777,7 +777,7 @@
 	model->setColumn(frame / model->getResolution(), values);
 
     } else {
-        std::cerr << "FeatureExtractionModelTransformer::addFeature: Unknown output model type!" << std::endl;
+        DEBUG << "FeatureExtractionModelTransformer::addFeature: Unknown output model type!" << endl;
     }
 }
 
@@ -789,8 +789,8 @@
 	binCount = m_descriptor->binCount;
     }
 
-//    std::cerr << "FeatureExtractionModelTransformer::setCompletion("
-//              << completion << ")" << std::endl;
+//    DEBUG << "FeatureExtractionModelTransformer::setCompletion("
+//              << completion << ")" << endl;
 
     if (isOutput<SparseOneDimensionalModel>()) {
 
--- a/transform/FileFeatureWriter.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/transform/FileFeatureWriter.cpp	Mon May 16 17:19:09 2011 +0100
@@ -46,7 +46,7 @@
         } else if (m_support & SupportOneFileTotal) {
             m_singleFileName = QString("output.%1").arg(m_extension);
         } else {
-            cerr << "FileFeatureWriter::FileFeatureWriter: ERROR: Invalid support specification " << support << endl;
+            DEBUG << "FileFeatureWriter::FileFeatureWriter: ERROR: Invalid support specification " << support << endl;
         }
     }
 }
@@ -60,7 +60,7 @@
     }
     while (!m_files.empty()) {
         if (m_files.begin()->second) {
-            cerr << "FileFeatureWriter::~FileFeatureWriter: NOTE: Closing feature file \""
+            DEBUG << "FileFeatureWriter::~FileFeatureWriter: NOTE: Closing feature file \""
                  << m_files.begin()->second->fileName() << "\"" << endl;
             delete m_files.begin()->second;
         }
@@ -128,7 +128,7 @@
             if (m_support & SupportOneFilePerTrackTransform &&
                 m_support & SupportOneFilePerTrack) {
                 if (m_singleFileName != "") {
-                    cerr << "FileFeatureWriter::setParameters: WARNING: Both one-file and many-files parameters provided, ignoring many-files" << endl;
+                    DEBUG << "FileFeatureWriter::setParameters: WARNING: Both one-file and many-files parameters provided, ignoring many-files" << endl;
                 } else {
                     m_manyFiles = true;
                 }
@@ -142,7 +142,7 @@
                     // OneFilePerTrack), so we need to be able to
                     // override it
 //                    if (m_manyFiles) {
-//                        cerr << "FileFeatureWriter::setParameters: WARNING: Both many-files and one-file parameters provided, ignoring one-file" << endl;
+//                        DEBUG << "FileFeatureWriter::setParameters: WARNING: Both many-files and one-file parameters provided, ignoring one-file" << endl;
 //                    } else {
                         m_singleFileName = i->second.c_str();
 //                    }
@@ -151,7 +151,7 @@
         } else if (i->first == "stdout") {
             if (m_support & SupportOneFileTotal) {
                 if (m_singleFileName != "") {
-                    cerr << "FileFeatureWriter::setParameters: WARNING: Both stdout and one-file provided, ignoring stdout" << endl;
+                    DEBUG << "FileFeatureWriter::setParameters: WARNING: Both stdout and one-file provided, ignoring stdout" << endl;
                 } else {
                     m_stdout = true;
                 }
@@ -171,7 +171,7 @@
     if (m_singleFileName != "") {
         if (QFileInfo(m_singleFileName).exists() && !(m_force || m_append)) {
             cerr << endl << "FileFeatureWriter: ERROR: Specified output file \"" << m_singleFileName << "\" exists and neither --" << getWriterTag() << "-force nor --" << getWriterTag() << "-append flag is specified -- not overwriting" << endl;
-            cerr << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl;
+            DEBUG << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl;
             return "";
         }
         return m_singleFileName;
@@ -216,7 +216,7 @@
 
     if (QFileInfo(filename).exists() && !(m_force || m_append)) {
         cerr << endl << "FileFeatureWriter: ERROR: Output file \"" << filename << "\" exists (for input file or URL \"" << trackId << "\" and transform \"" << transformId << "\") and neither --" << getWriterTag() << "-force nor --" << getWriterTag() << "-append is specified -- not overwriting" << endl;
-        cerr << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl;
+        DEBUG << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl;
         return "";
     }
     
@@ -263,11 +263,11 @@
             return 0;
         }
 
-        cerr << "FileFeatureWriter: NOTE: Using output filename \""
+        DEBUG << "FileFeatureWriter: NOTE: Using output filename \""
              << filename << "\"" << endl;
 
         if (m_append) {
-            cerr << "FileFeatureWriter: NOTE: Calling reviewFileForAppending" << endl;
+            DEBUG << "FileFeatureWriter: NOTE: Calling reviewFileForAppending" << endl;
             reviewFileForAppending(filename);
         }
         
@@ -329,7 +329,7 @@
 void
 FileFeatureWriter::finish()
 {
-//    cerr << "FileFeatureWriter::finish()" << endl;
+//    DEBUG << "FileFeatureWriter::finish()" << endl;
 
     if (m_singleFileName != "" || m_stdout) return;
 
@@ -340,7 +340,7 @@
     }
     while (!m_files.empty()) {
         if (m_files.begin()->second) {
-            cerr << "FileFeatureWriter::finish: NOTE: Closing feature file \""
+            DEBUG << "FileFeatureWriter::finish: NOTE: Closing feature file \""
                  << m_files.begin()->second->fileName() << "\"" << endl;
             delete m_files.begin()->second;
         }
--- a/transform/ModelTransformerFactory.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/transform/ModelTransformerFactory.cpp	Mon May 16 17:19:09 2011 +0100
@@ -181,8 +181,8 @@
             new RealTimeEffectModelTransformer(input, transform);
 
     } else {
-        std::cerr << "ModelTransformerFactory::createTransformer: Unknown transform \""
-                  << transform.getIdentifier() << "\"" << std::endl;
+        DEBUG << "ModelTransformerFactory::createTransformer: Unknown transform \""
+                  << transform.getIdentifier() << "\"" << endl;
         return transformer;
     }
 
@@ -195,7 +195,7 @@
                                    const ModelTransformer::Input &input,
                                    QString &message)
 {
-    std::cerr << "ModelTransformerFactory::transform: Constructing transformer with input model " << input.getModel() << std::endl;
+    DEBUG << "ModelTransformerFactory::transform: Constructing transformer with input model " << input.getModel() << endl;
 
     ModelTransformer *t = createTransformer(transform, input);
     if (!t) return 0;
@@ -236,7 +236,7 @@
     QObject *s = sender();
     ModelTransformer *transformer = dynamic_cast<ModelTransformer *>(s);
     
-//    std::cerr << "ModelTransformerFactory::transformerFinished(" << transformer << ")" << std::endl;
+//    DEBUG << "ModelTransformerFactory::transformerFinished(" << transformer << ")" << endl;
 
     if (!transformer) {
 	std::cerr << "WARNING: ModelTransformerFactory::transformerFinished: sender is not a transformer" << std::endl;
--- a/transform/RealTimeEffectModelTransformer.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/transform/RealTimeEffectModelTransformer.cpp	Mon May 16 17:19:09 2011 +0100
@@ -43,7 +43,7 @@
 
     if (!m_transform.getBlockSize()) m_transform.setBlockSize(1024);
 
-//    std::cerr << "RealTimeEffectModelTransformer::RealTimeEffectModelTransformer: plugin " << pluginId << ", output " << output << std::endl;
+//    DEBUG << "RealTimeEffectModelTransformer::RealTimeEffectModelTransformer: plugin " << pluginId << ", output " << output << endl;
 
     RealTimePluginFactory *factory =
 	RealTimePluginFactory::instanceFor(pluginId);
@@ -110,7 +110,7 @@
     DenseTimeValueModel *dtvm =
 	dynamic_cast<DenseTimeValueModel *>(getInputModel());
     if (!dtvm) {
-	std::cerr << "RealTimeEffectModelTransformer::getConformingInput: WARNING: Input model is not conformable to DenseTimeValueModel" << std::endl;
+	DEBUG << "RealTimeEffectModelTransformer::getConformingInput: WARNING: Input model is not conformable to DenseTimeValueModel" << endl;
     }
     return dtvm;
 }
@@ -122,7 +122,7 @@
     if (!input) return;
 
     while (!input->isReady() && !m_abandoned) {
-        std::cerr << "RealTimeEffectModelTransformer::run: Waiting for input model to be ready..." << std::endl;
+        DEBUG << "RealTimeEffectModelTransformer::run: Waiting for input model to be ready..." << endl;
         usleep(500000);
     }
     if (m_abandoned) return;
--- a/transform/Transform.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/transform/Transform.cpp	Mon May 16 17:19:09 2011 +0100
@@ -124,7 +124,7 @@
         m_duration == t.m_duration &&
         m_sampleRate == t.m_sampleRate;
 /*
-    std::cerr << "Transform::operator==: identical = " << identical << std::endl;
+    DEBUG << "Transform::operator==: identical = " << identical << endl;
     std::cerr << "A = " << std::endl;
     std::cerr << toXmlString() << std::endl;
     std::cerr << "B = " << std::endl;
@@ -260,8 +260,7 @@
 void
 Transform::setParameter(QString name, float value)
 {
-//    std::cerr << "Transform::setParameter(" << name.toStdString()
-//              << ") -> " << value << std::endl;
+//    DEBUG << "Transform::setParameter(" << name//              << ") -> " << value << endl;
     m_parameters[name] = value;
 }
 
@@ -280,8 +279,7 @@
 void
 Transform::setConfigurationValue(QString name, QString value)
 {
-    std::cerr << "Transform::setConfigurationValue(" << name.toStdString()
-              << ") -> " << value << std::endl;
+    DEBUG << "Transform::setConfigurationValue(" << name              << ") -> " << value << endl;
     m_configuration[name] = value;
 }
 
@@ -463,8 +461,8 @@
         str == "standard deviation" || str == "sd") return StandardDeviation;
     if (str == "count") return Count;
     if (str == "") return NoSummary;
-    std::cerr << "Transform::stringToSummaryType: unknown summary type \""
-              << str << "\"" << std::endl;
+    DEBUG << "Transform::stringToSummaryType: unknown summary type \""
+              << str << "\"" << endl;
     return NoSummary;
 }
 
@@ -483,8 +481,8 @@
     case Count: return "count";
     case NoSummary: return "";
     default:
-        std::cerr << "Transform::summaryTypeToString: unexpected summary type "
-                  << int(type) << std::endl;
+        DEBUG << "Transform::summaryTypeToString: unexpected summary type "
+                  << int(type) << endl;
         return "";
     }
 }
--- a/transform/TransformFactory.cpp	Thu May 12 17:31:24 2011 +0100
+++ b/transform/TransformFactory.cpp	Mon May 16 17:19:09 2011 +0100
@@ -52,7 +52,7 @@
 void
 TransformFactory::deleteInstance()
 {
-    std::cerr << "TransformFactory::deleteInstance called" << std::endl;
+    DEBUG << "TransformFactory::deleteInstance called" << endl;
     delete m_instance;
     m_instance = 0;
 }
@@ -70,12 +70,12 @@
     m_exiting = true;
     if (m_thread) {
 #ifdef DEBUG_TRANSFORM_FACTORY
-        std::cerr << "TransformFactory::~TransformFactory: waiting on thread" << std::endl;
+        DEBUG << "TransformFactory::~TransformFactory: waiting on thread" << endl;
 #endif
         m_thread->wait();
         delete m_thread;
 #ifdef DEBUG_TRANSFORM_FACTORY
-        std::cerr << "TransformFactory::~TransformFactory: waited and done" << std::endl;
+        DEBUG << "TransformFactory::~TransformFactory: waited and done" << endl;
 #endif
     }
 }
@@ -113,7 +113,7 @@
     for (TransformDescriptionMap::const_iterator i = m_transforms.begin();
 	 i != m_transforms.end(); ++i) {
 #ifdef DEBUG_TRANSFORM_FACTORY
-        cerr << "inserting transform into set: id = " << i->second.identifier << endl;
+        DEBUG << "inserting transform into set: id = " << i->second.identifier << endl;
 #endif
 	dset.insert(i->second);
     }
@@ -122,7 +122,7 @@
     for (std::set<TransformDescription>::const_iterator i = dset.begin();
 	 i != dset.end(); ++i) {
 #ifdef DEBUG_TRANSFORM_FACTORY
-        cerr << "inserting transform into list: id = " << i->identifier << endl;
+        DEBUG << "inserting transform into list: id = " << i->identifier << endl;
 #endif
 	list.push_back(*i);
     }
@@ -159,7 +159,7 @@
     for (TransformDescriptionMap::const_iterator i = m_uninstalledTransforms.begin();
 	 i != m_uninstalledTransforms.end(); ++i) {
 #ifdef DEBUG_TRANSFORM_FACTORY
-        cerr << "inserting transform into set: id = " << i->second.identifier << endl;
+        DEBUG << "inserting transform into set: id = " << i->second.identifier << endl;
 #endif
 	dset.insert(i->second);
     }
@@ -168,7 +168,7 @@
     for (std::set<TransformDescription>::const_iterator i = dset.begin();
 	 i != dset.end(); ++i) {
 #ifdef DEBUG_TRANSFORM_FACTORY
-        cerr << "inserting transform into uninstalled list: id = " << i->identifier << endl;
+        DEBUG << "inserting transform into uninstalled list: id = " << i->identifier << endl;
 #endif
 	list.push_back(*i);
     }
@@ -659,9 +659,8 @@
         QString name = desc.getPluginName();
 #ifdef DEBUG_TRANSFORM_FACTORY
         if (name == "") {
-            std::cerr << "TransformFactory::populateUninstalledTransforms: "
-                      << "No name available for plugin " << i->toStdString()
-                      << ", skipping" << std::endl;
+            DEBUG << "TransformFactory::populateUninstalledTransforms: "
+                      << "No name available for plugin " << i-                      << ", skipping" << endl;
             continue;
         }
 #endif
@@ -678,8 +677,8 @@
             
             if (m_transforms.find(tid) != m_transforms.end()) {
 #ifdef DEBUG_TRANSFORM_FACTORY
-                std::cerr << "TransformFactory::populateUninstalledTransforms: "
-                          << tid << " is installed; adding info url if appropriate, skipping rest" << std::endl;
+                DEBUG << "TransformFactory::populateUninstalledTransforms: "
+                          << tid << " is installed; adding info url if appropriate, skipping rest" << endl;
 #endif
                 if (infoUrl != "") {
                     if (m_transforms[tid].infoUrl == "") {
@@ -690,8 +689,8 @@
             }
 
 #ifdef DEBUG_TRANSFORM_FACTORY
-            std::cerr << "TransformFactory::populateUninstalledTransforms: "
-                      << "adding " << tid << std::endl;
+            DEBUG << "TransformFactory::populateUninstalledTransforms: "
+                      << "adding " << tid << endl;
 #endif
 
             QString oname = desc.getOutputName(*j);
@@ -953,9 +952,9 @@
     for (Vamp::PluginBase::ParameterList::const_iterator i = parameters.begin();
          i != parameters.end(); ++i) {
         pmap[i->identifier.c_str()] = plugin->getParameter(i->identifier);
-//        std::cerr << "TransformFactory::setParametersFromPlugin: parameter "
+//        DEBUG << "TransformFactory::setParametersFromPlugin: parameter "
 //                  << i->identifier << " -> value " <<
-//            pmap[i->identifier.c_str()] << std::endl;
+//            pmap[i->identifier.c_str()] << endl;
     }
 
     transform.setParameters(pmap);
@@ -1068,7 +1067,7 @@
     Vamp::PluginBase *plugin = instantiateDefaultPluginFor
         (t.getIdentifier(), 0);
     if (!plugin) {
-        cerr << "TransformFactory::getPluginConfigurationXml: "
+        DEBUG << "TransformFactory::getPluginConfigurationXml: "
                   << "Unable to instantiate plugin for transform \""
                   << t.getIdentifier() << "\"" << endl;
         return xml;
@@ -1090,7 +1089,7 @@
     Vamp::PluginBase *plugin = instantiateDefaultPluginFor
         (t.getIdentifier(), 0);
     if (!plugin) {
-        cerr << "TransformFactory::setParametersFromPluginConfigurationXml: "
+        DEBUG << "TransformFactory::setParametersFromPluginConfigurationXml: "
                   << "Unable to instantiate plugin for transform \""
                   << t.getIdentifier() << "\"" << endl;
         return;
@@ -1146,7 +1145,7 @@
     if (!m_uninstalledTransformsMutex.tryLock()) {
         // uninstalled transforms are being populated; this may take some time,
         // and they aren't critical, but we will speed them up if necessary
-        std::cerr << "TransformFactory::search: Uninstalled transforms mutex is held, skipping" << std::endl;
+        DEBUG << "TransformFactory::search: Uninstalled transforms mutex is held, skipping" << endl;
         m_populatingSlowly = false;
         return results;
     }