changeset 150:4b2ea82fd0ed

* Reorganising code base. This revision probably should compile once more.
author Chris Cannam
date Mon, 31 Jul 2006 14:05:22 +0000
parents 3e4c384f518e
children 3c1d5ef43baa
files base/AudioLevel.cpp base/ConfigFile.cpp base/FFTCache.cpp base/Model.cpp base/Model.h base/PlayParameterRepository.cpp base/Preferences.cpp base/Profiler.h base/RealTime.cpp base/RecentFiles.cpp base/RingBuffer.h base/Scavenger.h base/System.cpp base/System.h base/TempDirectory.cpp base/base.pro data/data.pro data/fft/FFTDataServer.cpp data/fft/FFTFileCache.cpp data/fft/FFTFileCache.h data/fileio/AudioFileReader.h data/fileio/CSVFileReader.cpp data/fileio/CSVFileWriter.cpp data/fileio/DataFileReaderFactory.cpp data/fileio/FileReadThread.h data/fileio/MIDIFileReader.cpp data/fileio/MP3FileReader.cpp data/fileio/MatrixFile.cpp data/fileio/OggVorbisFileReader.cpp data/model/DenseThreeDimensionalModel.h data/model/DenseTimeValueModel.cpp data/model/DenseTimeValueModel.h data/model/Model.cpp data/model/Model.h data/model/NoteModel.h data/model/SparseModel.h data/model/SparseOneDimensionalModel.h data/model/SparseTimeValueModel.h data/model/SparseValueModel.h data/model/WaveFileModel.cpp data/model/WaveFileModel.h plugin/DSSIPluginFactory.cpp plugin/DSSIPluginFactory.h plugin/FeatureExtractionPluginFactory.cpp plugin/LADSPAPluginFactory.cpp plugin/LADSPAPluginFactory.h plugin/plugin.pro system/Init.cpp system/Init.h system/System.cpp system/System.h system/system.pro
diffstat 52 files changed, 723 insertions(+), 420 deletions(-) [+]
line wrap: on
line diff
--- a/base/AudioLevel.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/base/AudioLevel.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -18,7 +18,7 @@
    This file copyright 2000-2006 Chris Cannam.
 */
 
-#include "base/AudioLevel.h"
+#include "AudioLevel.h"
 #include <cmath>
 #include <iostream>
 #include <map>
--- a/base/ConfigFile.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/base/ConfigFile.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -15,7 +15,7 @@
 
 #include "ConfigFile.h"
 
-#include "base/Exceptions.h"
+#include "Exceptions.h"
 
 #include <iostream>
 
--- a/base/FFTCache.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/base/FFTCache.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -14,7 +14,7 @@
 */
 
 #include "FFTCache.h"
-#include "System.h"
+#include "system/System.h"
 
 #include <iostream>
 
--- a/base/Model.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
-
-/*
-    Sonic Visualiser
-    An audio file viewer and annotation editor.
-    Centre for Digital Music, Queen Mary, University of London.
-    This file copyright 2006 Chris Cannam.
-    
-    This program is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License as
-    published by the Free Software Foundation; either version 2 of the
-    License, or (at your option) any later version.  See the file
-    COPYING included with this distribution for more information.
-*/
-
-#include "Model.h"
-#include "PlayParameterRepository.h"
-
-#include <QTextStream>
-
-#include <iostream>
-
-const int Model::COMPLETION_UNKNOWN = -1;
-
-Model::~Model()
-{
-//    std::cerr << "Model::~Model(" << this << ")" << std::endl;
-
-    // Subclasses have to handle adding themselves to the repository,
-    // if they want to be played.  We can't do it from here because
-    // the repository would be unable to tell whether we were playable
-    // or not (because dynamic_cast won't work from the base class ctor)
-    PlayParameterRepository::getInstance()->removeModel(this);
-}
-
-void
-Model::toXml(QTextStream &stream, QString indent,
-             QString extraAttributes) const
-{
-    stream << indent;
-    stream << QString("<model id=\"%1\" name=\"%2\" sampleRate=\"%3\" start=\"%4\" end=\"%5\" %6/>\n")
-	.arg(getObjectExportId(this))
-	.arg(encodeEntities(objectName()))
-	.arg(getSampleRate())
-	.arg(getStartFrame())
-	.arg(getEndFrame())
-	.arg(extraAttributes);
-}
-
-QString
-Model::toXmlString(QString indent, QString extraAttributes) const
-{
-    QString s;
-    
-    s += indent;
-
-    s += QString("<model id=\"%1\" name=\"%2\" sampleRate=\"%3\" start=\"%4\" end=\"%5\" %6/>\n")
-	.arg(getObjectExportId(this))
-	.arg(encodeEntities(objectName()))
-	.arg(getSampleRate())
-	.arg(getStartFrame())
-	.arg(getEndFrame())
-	.arg(extraAttributes);
-
-    return s;
-}
-
-#ifdef INCLUDE_MOCFILES
-#include "Model.moc.cpp"
-#endif
-
--- a/base/Model.h	Mon Jul 31 12:03:45 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
-
-/*
-    Sonic Visualiser
-    An audio file viewer and annotation editor.
-    Centre for Digital Music, Queen Mary, University of London.
-    This file copyright 2006 Chris Cannam.
-    
-    This program is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License as
-    published by the Free Software Foundation; either version 2 of the
-    License, or (at your option) any later version.  See the file
-    COPYING included with this distribution for more information.
-*/
-
-#ifndef _MODEL_H_
-#define _MODEL_H_
-
-#include <vector>
-#include <QObject>
-
-#include "XmlExportable.h"
-
-typedef std::vector<float> SampleBlock;
-
-/** 
- * Model is the base class for all data models that represent any sort
- * of data on a time scale based on an audio frame rate.
- */
-
-class Model : virtual public QObject,
-	      public XmlExportable
-{
-    Q_OBJECT
-
-public:
-    virtual ~Model();
-
-    /**
-     * Return true if the model was constructed successfully.  Classes
-     * that refer to the model should always test this before use.
-     */
-    virtual bool isOK() const = 0;
-
-    /**
-     * Return the first audio frame spanned by the model.
-     */
-    virtual size_t getStartFrame() const = 0;
-
-    /**
-     * Return the last audio frame spanned by the model.
-     */
-    virtual size_t getEndFrame() const = 0;
-
-    /**
-     * Return the frame rate in frames per second.
-     */
-    virtual size_t getSampleRate() const = 0;
-
-    /**
-     * Return a copy of this model.
-     *
-     * If the model is not editable, this may be effectively a shallow
-     * copy.  If the model is editable, however, this operation must
-     * properly copy all of the model's editable data.
-     *
-     * In general this operation is not useful for non-editable dense
-     * models such as waveforms, because there may be no efficient
-     * copy operation implemented -- for such models it is better not
-     * to copy at all.
-     *
-     * Caller owns the returned value.
-     */
-    virtual Model *clone() const = 0;
-    
-    /**
-     * Return true if the model has finished loading or calculating
-     * all its data, for a model that is capable of calculating in a
-     * background thread.  The default implementation is appropriate
-     * for a thread that does not background any work but carries out
-     * all its calculation from the constructor or accessors.
-     *
-     * If "completion" is non-NULL, this function should return
-     * through it an estimated percentage value showing how far
-     * through the background operation it thinks it is (for progress
-     * reporting).  If it has no way to calculate progress, it may
-     * return the special value COMPLETION_UNKNOWN.
-     */
-    virtual bool isReady(int *completion = 0) const {
-	bool ok = isOK();
-	if (completion) *completion = (ok ? 100 : 0);
-	return ok;
-    }
-    static const int COMPLETION_UNKNOWN;
-
-    virtual void toXml(QTextStream &stream,
-                       QString indent = "",
-                       QString extraAttributes = "") const;
-
-    virtual QString toXmlString(QString indent = "",
-				QString extraAttributes = "") const;
-
-    virtual QString toDelimitedDataString(QString) const { return ""; }
-
-signals:
-    /**
-     * Emitted when a model has been edited (or more data retrieved
-     * from cache, in the case of a cached model that generates slowly)
-     */
-    void modelChanged();
-
-    /**
-     * Emitted when a model has been edited (or more data retrieved
-     * from cache, in the case of a cached model that generates slowly)
-     */
-    void modelChanged(size_t startFrame, size_t endFrame);
-
-    /**
-     * Emitted when some internal processing has advanced a stage, but
-     * the model has not changed externally.  Views should respond by
-     * updating any progress meters or other monitoring, but not
-     * refreshing the actual view.
-     */
-    void completionChanged();
-
-protected:
-    Model() { }
-
-    // Not provided.
-    Model(const Model &);
-    Model &operator=(const Model &); 
-};
-
-#endif
--- a/base/PlayParameterRepository.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/base/PlayParameterRepository.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -19,7 +19,7 @@
 //!!! shouldn't be including this here -- restructure needed
 
 //!!! should the AudioGenerator actually implement all this stuff itself?  do we even want this class?
-#include "audioio/AudioGenerator.h"
+#include "sv/audioio/AudioGenerator.h"
 
 #include <iostream>
 
--- a/base/Preferences.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/base/Preferences.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -19,7 +19,7 @@
 
 #include "TempDirectory.h"
 
-#include "fileio/ConfigFile.h" //!!! reorg
+#include "ConfigFile.h" //!!! reorg
 
 #include <QDir>
 #include <QFileInfo>
--- a/base/Profiler.h	Mon Jul 31 12:03:45 2006 +0000
+++ b/base/Profiler.h	Mon Jul 31 14:05:22 2006 +0000
@@ -22,7 +22,7 @@
 #ifndef _PROFILER_H_
 #define _PROFILER_H_
 
-#include "System.h"
+#include "system/System.h"
 
 #include <ctime>
 #include <sys/time.h>
--- a/base/RealTime.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/base/RealTime.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -30,7 +30,7 @@
 using std::cerr;
 using std::endl;
 
-#include "base/RealTime.h"
+#include "RealTime.h"
 #include "sys/time.h"
 
 // A RealTime consists of two ints that must be at least 32 bits each.
--- a/base/RecentFiles.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/base/RecentFiles.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -16,7 +16,7 @@
 #include "RecentFiles.h"
 #include "ConfigFile.h"
 
-#include "base/Preferences.h"
+#include "Preferences.h"
 
 #include <QFileInfo>
 
--- a/base/RingBuffer.h	Mon Jul 31 12:03:45 2006 +0000
+++ b/base/RingBuffer.h	Mon Jul 31 14:05:22 2006 +0000
@@ -23,7 +23,7 @@
 
 #include <sys/types.h>
 
-#include "System.h"
+#include "system/System.h"
 #include "Scavenger.h"
 
 //#define DEBUG_RINGBUFFER 1
--- a/base/Scavenger.h	Mon Jul 31 12:03:45 2006 +0000
+++ b/base/Scavenger.h	Mon Jul 31 14:05:22 2006 +0000
@@ -22,7 +22,7 @@
 #ifndef _SCAVENGER_H_
 #define _SCAVENGER_H_
 
-#include "System.h"
+#include "system/System.h"
 
 #include <vector>
 #include <sys/time.h>
--- a/base/System.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
-
-/*
-    Sonic Visualiser
-    An audio file viewer and annotation editor.
-    Centre for Digital Music, Queen Mary, University of London.
-    This file copyright 2006 Chris Cannam.
-    
-    This program is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License as
-    published by the Free Software Foundation; either version 2 of the
-    License, or (at your option) any later version.  See the file
-    COPYING included with this distribution for more information.
-*/
-
-#include "System.h"
-
-#ifndef _WIN32
-#include <signal.h>
-#endif
-
-#include <iostream>
-
-#ifdef _WIN32
-
-extern "C" {
-
-void usleep(unsigned long usec)
-{
-    ::Sleep(usec / 1000);
-}
-
-void gettimeofday(struct timeval *tv, void *tz)
-{
-    union { 
-	long long ns100;  
-	FILETIME ft; 
-    } now; 
-    
-    ::GetSystemTimeAsFileTime(&now.ft); 
-    tv->tv_usec = (long)((now.ns100 / 10LL) % 1000000LL); 
-    tv->tv_sec = (long)((now.ns100 - 116444736000000000LL) / 10000000LL); 
-}
-
-}
-
-#endif
-
-ProcessStatus
-GetProcessStatus(int pid)
-{
-#ifdef _WIN32
-    HANDLE handle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
-    if (!handle) {
-        return ProcessNotRunning;
-    } else {
-        CloseHandle(handle);
-        return ProcessRunning;
-    }
-#else
-    if (kill(getpid(), 0) == 0) {
-        if (kill(pid, 0) == 0) {
-            return ProcessRunning;
-        } else {
-            return ProcessNotRunning;
-        }
-    } else {
-        return UnknownProcessStatus;
-    }
-#endif
-}
-
-double mod(double x, double y) { return x - (y * floor(x / y)); }
-float modf(float x, float y) { return x - (y * floorf(x / y)); }
-
-double princarg(double a) { return mod(a + M_PI, -2 * M_PI) + M_PI; }
-float princargf(float a) { return modf(a + M_PI, -2 * M_PI) + M_PI; }
-
--- a/base/System.h	Mon Jul 31 12:03:45 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
-
-/*
-    Sonic Visualiser
-    An audio file viewer and annotation editor.
-    Centre for Digital Music, Queen Mary, University of London.
-    This file copyright 2006 Chris Cannam.
-    
-    This program is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License as
-    published by the Free Software Foundation; either version 2 of the
-    License, or (at your option) any later version.  See the file
-    COPYING included with this distribution for more information.
-*/
-
-#ifndef _SYSTEM_H_
-#define _SYSTEM_H_
-
-#ifdef _WIN32
-
-#include <windows.h>
-#include <malloc.h>
-#include <process.h>
-
-#define MLOCK(a,b)   1
-#define MUNLOCK(a,b) 1
-#define MUNLOCK_SAMPLEBLOCK(a) 1
-
-#define DLOPEN(a,b)  LoadLibrary((a).toStdWString().c_str())
-#define DLSYM(a,b)   GetProcAddress((HINSTANCE)(a),(b))
-#define DLCLOSE(a)   FreeLibrary((HINSTANCE)(a))
-#define DLERROR()    ""
-
-#define PLUGIN_GLOB  "*.dll"
-#define PATH_SEPARATOR ';'
-#define DEFAULT_VAMP_PATH "%ProgramFiles%\\Vamp Plugins"
-
-#define getpid _getpid
-
-extern "C" {
-void usleep(unsigned long usec);
-void gettimeofday(struct timeval *p, void *tz);
-}
-
-#else
-
-#include <sys/mman.h>
-#include <dlfcn.h>
-
-#define MLOCK(a,b)   ::mlock((a),(b))
-#define MUNLOCK(a,b) (::munlock((a),(b)) ? (::perror("munlock failed"), 0) : 0)
-#define MUNLOCK_SAMPLEBLOCK(a) do { if (!(a).empty()) { const float &b = *(a).begin(); MUNLOCK(&b, (a).capacity() * sizeof(float)); } } while(0);
-
-#define DLOPEN(a,b)  dlopen((a).toStdString().c_str(),(b))
-#define DLSYM(a,b)   dlsym((a),(b))
-#define DLCLOSE(a)   dlclose((a))
-#define DLERROR()    dlerror()
-
-#define PATH_SEPARATOR ':'
-
-#ifdef __APPLE__
-
-#define PLUGIN_GLOB  "*.dylib"
-#define DEFAULT_VAMP_PATH "/Library/Audio/Plug-Ins/Vamp/:$HOME/Library/Audio/Plug-Ins/Vamp"
-
-#else 
-
-#define PLUGIN_GLOB  "*.so"
-#define DEFAULT_VAMP_PATH "/usr/local/lib/vamp:/usr/lib/vamp:$HOME/vamp:$HOME/.vamp"
-
-#endif /* __APPLE__ */
-
-#endif /* ! _WIN32 */
-
-enum ProcessStatus { ProcessRunning, ProcessNotRunning, UnknownProcessStatus };
-extern ProcessStatus GetProcessStatus(int pid);
-
-#include <cmath>
-
-extern double mod(double x, double y);
-extern float modf(float x, float y);
-
-extern double princarg(double a);
-extern float princargf(float a);
-
-#endif /* ! _SYSTEM_H_ */
-
-
--- a/base/TempDirectory.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/base/TempDirectory.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -14,7 +14,7 @@
 */
 
 #include "TempDirectory.h"
-#include "System.h"
+#include "system/System.h"
 #include "Exceptions.h"
 
 #include <QDir>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/base/base.pro	Mon Jul 31 14:05:22 2006 +0000
@@ -0,0 +1,61 @@
+TEMPLATE = lib
+
+SV_UNIT_PACKAGES =
+load(../sv.prf)
+
+CONFIG += sv staticlib qt thread warn_on stl rtti exceptions
+
+TARGET = svbase
+
+DEPENDPATH += .
+INCLUDEPATH += . ..
+OBJECTS_DIR = tmp_obj
+MOC_DIR = tmp_moc
+
+# Input
+HEADERS += AudioLevel.h \
+           AudioPlaySource.h \
+           Clipboard.h \
+           Command.h \
+           CommandHistory.h \
+           ConfigFile.h \
+           Exceptions.h \
+           FFTCache.h \
+           Pitch.h \
+           PlayParameterRepository.h \
+           PlayParameters.h \
+           Preferences.h \
+           Profiler.h \
+           PropertyContainer.h \
+           RealTime.h \
+           RecentFiles.h \
+           ResizeableBitset.h \
+           RingBuffer.h \
+           Scavenger.h \
+           Selection.h \
+           TempDirectory.h \
+           Thread.h \
+           UnitDatabase.h \
+           Window.h \
+           XmlExportable.h \
+           ZoomConstraint.h
+SOURCES += AudioLevel.cpp \
+           Clipboard.cpp \
+           Command.cpp \
+           CommandHistory.cpp \
+           ConfigFile.cpp \
+           Exceptions.cpp \
+           FFTCache.cpp \
+           Pitch.cpp \
+           PlayParameterRepository.cpp \
+           PlayParameters.cpp \
+           Preferences.cpp \
+           Profiler.cpp \
+           PropertyContainer.cpp \
+           RealTime.cpp \
+           RecentFiles.cpp \
+           Selection.cpp \
+           TempDirectory.cpp \
+           Thread.cpp \
+           UnitDatabase.cpp \
+           XmlExportable.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/data.pro	Mon Jul 31 14:05:22 2006 +0000
@@ -0,0 +1,70 @@
+TEMPLATE = lib
+
+SV_UNIT_PACKAGES = fftw3f sndfile mad oggz fishsound
+load(../sv.prf)
+
+CONFIG += sv staticlib qt thread warn_on stl rtti exceptions
+
+TARGET = svdata
+
+DEPENDPATH += fft fileio model ..
+INCLUDEPATH += . fft model fileio ..
+OBJECTS_DIR = tmp_obj
+MOC_DIR = tmp_moc
+
+# Input
+HEADERS += fft/FFTDataServer.h \
+           fft/FFTFileCache.h \
+           fft/FFTFuzzyAdapter.h \
+           fileio/AudioFileReader.h \
+           fileio/AudioFileReaderFactory.h \
+           fileio/BZipFileDevice.h \
+           fileio/CodedAudioFileReader.h \
+           fileio/CSVFileReader.h \
+           fileio/CSVFileWriter.h \
+           fileio/DataFileReader.h \
+           fileio/DataFileReaderFactory.h \
+           fileio/FileReadThread.h \
+           fileio/MatrixFile.h \
+           fileio/MIDIFileReader.h \
+           fileio/MP3FileReader.h \
+           fileio/OggVorbisFileReader.h \
+           fileio/WavFileReader.h \
+           fileio/WavFileWriter.h \
+           model/DenseThreeDimensionalModel.h \
+           model/DenseTimeValueModel.h \
+           model/Model.h \
+           model/NoteModel.h \
+           model/PowerOfSqrtTwoZoomConstraint.h \
+           model/PowerOfTwoZoomConstraint.h \
+           model/RangeSummarisableTimeValueModel.h \
+           model/SparseModel.h \
+           model/SparseOneDimensionalModel.h \
+           model/SparseTimeValueModel.h \
+           model/SparseValueModel.h \
+           model/TextModel.h \
+           model/WaveFileModel.h
+SOURCES += fft/FFTDataServer.cpp \
+           fft/FFTFileCache.cpp \
+           fft/FFTFuzzyAdapter.cpp \
+           fileio/AudioFileReaderFactory.cpp \
+           fileio/BZipFileDevice.cpp \
+           fileio/CodedAudioFileReader.cpp \
+           fileio/CSVFileReader.cpp \
+           fileio/CSVFileWriter.cpp \
+           fileio/DataFileReaderFactory.cpp \
+           fileio/FileReadThread.cpp \
+           fileio/MatrixFile.cpp \
+           fileio/MIDIFileReader.cpp \
+           fileio/MP3FileReader.cpp \
+           fileio/OggVorbisFileReader.cpp \
+           fileio/WavFileReader.cpp \
+           fileio/WavFileWriter.cpp \
+           model/DenseThreeDimensionalModel.cpp \
+           model/DenseTimeValueModel.cpp \
+           model/Model.cpp \
+           model/NoteModel.cpp \
+           model/PowerOfSqrtTwoZoomConstraint.cpp \
+           model/PowerOfTwoZoomConstraint.cpp \
+           model/RangeSummarisableTimeValueModel.cpp \
+           model/WaveFileModel.cpp
--- a/data/fft/FFTDataServer.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/fft/FFTDataServer.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -19,7 +19,7 @@
 
 #include "model/DenseTimeValueModel.h"
 
-#include "base/System.h"
+#include "system/System.h"
 
 //#define DEBUG_FFT_SERVER 1
 //#define DEBUG_FFT_SERVER_FILL 1
--- a/data/fft/FFTFileCache.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/fft/FFTFileCache.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -15,7 +15,7 @@
 
 #include "FFTFileCache.h"
 
-#include "MatrixFile.h"
+#include "fileio/MatrixFile.h"
 
 #include "base/Profiler.h"
 
--- a/data/fft/FFTFileCache.h	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/fft/FFTFileCache.h	Mon Jul 31 14:05:22 2006 +0000
@@ -16,8 +16,8 @@
 #ifndef _FFT_FILE_CACHE_H_
 #define _FFT_FILE_CACHE_H_
 
-#include "FFTCache.h"
-#include "MatrixFile.h"
+#include "base/FFTCache.h"
+#include "fileio/MatrixFile.h"
 
 #include <QMutex>
 
--- a/data/fileio/AudioFileReader.h	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/fileio/AudioFileReader.h	Mon Jul 31 14:05:22 2006 +0000
@@ -17,7 +17,7 @@
 #define _AUDIO_FILE_READER_H_
 
 #include <QString>
-#include "base/Model.h" // for SampleBlock
+#include "model/Model.h" // for SampleBlock
 
 class AudioFileReader
 {
--- a/data/fileio/CSVFileReader.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/fileio/CSVFileReader.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -15,7 +15,7 @@
 
 #include "CSVFileReader.h"
 
-#include "base/Model.h"
+#include "model/Model.h"
 #include "base/RealTime.h"
 #include "model/SparseOneDimensionalModel.h"
 #include "model/SparseTimeValueModel.h"
--- a/data/fileio/CSVFileWriter.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/fileio/CSVFileWriter.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -15,7 +15,7 @@
 
 #include "CSVFileWriter.h"
 
-#include "base/Model.h"
+#include "model/Model.h"
 #include "model/SparseOneDimensionalModel.h"
 #include "model/SparseTimeValueModel.h"
 #include "model/NoteModel.h"
--- a/data/fileio/DataFileReaderFactory.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/fileio/DataFileReaderFactory.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -17,7 +17,7 @@
 #include "MIDIFileReader.h"
 #include "CSVFileReader.h"
 
-#include "base/Model.h"
+#include "model/Model.h"
 
 #include <QString>
 
--- a/data/fileio/FileReadThread.h	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/fileio/FileReadThread.h	Mon Jul 31 14:05:22 2006 +0000
@@ -16,7 +16,7 @@
 #ifndef _FILE_READ_THREAD_H_
 #define _FILE_READ_THREAD_H_
 
-#include "Thread.h"
+#include "base/Thread.h"
 
 #include <QMutex>
 #include <QWaitCondition>
--- a/data/fileio/MIDIFileReader.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/fileio/MIDIFileReader.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -28,7 +28,7 @@
 
 #include "MIDIFileReader.h"
 
-#include "base/Model.h"
+#include "model/Model.h"
 #include "base/Pitch.h"
 #include "base/RealTime.h"
 #include "model/NoteModel.h"
--- a/data/fileio/MP3FileReader.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/fileio/MP3FileReader.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -17,7 +17,7 @@
 #ifdef HAVE_MAD
 
 #include "MP3FileReader.h"
-#include "base/System.h"
+#include "system/System.h"
 
 #include <sys/types.h>
 #include <sys/stat.h>
--- a/data/fileio/MatrixFile.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/fileio/MatrixFile.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -15,7 +15,7 @@
 
 #include "MatrixFile.h"
 #include "base/TempDirectory.h"
-#include "base/System.h"
+#include "system/System.h"
 #include "base/Profiler.h"
 #include "base/Exceptions.h"
 
--- a/data/fileio/OggVorbisFileReader.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/fileio/OggVorbisFileReader.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -18,7 +18,7 @@
 
 #include "OggVorbisFileReader.h"
 #include "base/Profiler.h"
-#include "base/System.h"
+#include "system/System.h"
 
 #include <sys/types.h>
 #include <sys/stat.h>
--- a/data/model/DenseThreeDimensionalModel.h	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/model/DenseThreeDimensionalModel.h	Mon Jul 31 14:05:22 2006 +0000
@@ -16,7 +16,7 @@
 #ifndef _DENSE_THREE_DIMENSIONAL_MODEL_H_
 #define _DENSE_THREE_DIMENSIONAL_MODEL_H_
 
-#include "base/Model.h"
+#include "Model.h"
 #include "base/ZoomConstraint.h"
 
 #include <QMutex>
--- a/data/model/DenseTimeValueModel.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/model/DenseTimeValueModel.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -14,7 +14,7 @@
 */
 
 #include "DenseTimeValueModel.h"
-#include "PlayParameterRepository.h"
+#include "base/PlayParameterRepository.h"
 
 DenseTimeValueModel::DenseTimeValueModel()
 {
--- a/data/model/DenseTimeValueModel.h	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/model/DenseTimeValueModel.h	Mon Jul 31 14:05:22 2006 +0000
@@ -18,7 +18,7 @@
 
 #include <QObject>
 
-#include "base/Model.h"
+#include "Model.h"
 
 /**
  * Base class for models containing dense two-dimensional data (value
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/model/Model.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -0,0 +1,71 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Sonic Visualiser
+    An audio file viewer and annotation editor.
+    Centre for Digital Music, Queen Mary, University of London.
+    This file copyright 2006 Chris Cannam.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#include "Model.h"
+#include "base/PlayParameterRepository.h"
+
+#include <QTextStream>
+
+#include <iostream>
+
+const int Model::COMPLETION_UNKNOWN = -1;
+
+Model::~Model()
+{
+//    std::cerr << "Model::~Model(" << this << ")" << std::endl;
+
+    // Subclasses have to handle adding themselves to the repository,
+    // if they want to be played.  We can't do it from here because
+    // the repository would be unable to tell whether we were playable
+    // or not (because dynamic_cast won't work from the base class ctor)
+    PlayParameterRepository::getInstance()->removeModel(this);
+}
+
+void
+Model::toXml(QTextStream &stream, QString indent,
+             QString extraAttributes) const
+{
+    stream << indent;
+    stream << QString("<model id=\"%1\" name=\"%2\" sampleRate=\"%3\" start=\"%4\" end=\"%5\" %6/>\n")
+	.arg(getObjectExportId(this))
+	.arg(encodeEntities(objectName()))
+	.arg(getSampleRate())
+	.arg(getStartFrame())
+	.arg(getEndFrame())
+	.arg(extraAttributes);
+}
+
+QString
+Model::toXmlString(QString indent, QString extraAttributes) const
+{
+    QString s;
+    
+    s += indent;
+
+    s += QString("<model id=\"%1\" name=\"%2\" sampleRate=\"%3\" start=\"%4\" end=\"%5\" %6/>\n")
+	.arg(getObjectExportId(this))
+	.arg(encodeEntities(objectName()))
+	.arg(getSampleRate())
+	.arg(getStartFrame())
+	.arg(getEndFrame())
+	.arg(extraAttributes);
+
+    return s;
+}
+
+#ifdef INCLUDE_MOCFILES
+#include "Model.moc.cpp"
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/model/Model.h	Mon Jul 31 14:05:22 2006 +0000
@@ -0,0 +1,134 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Sonic Visualiser
+    An audio file viewer and annotation editor.
+    Centre for Digital Music, Queen Mary, University of London.
+    This file copyright 2006 Chris Cannam.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#ifndef _MODEL_H_
+#define _MODEL_H_
+
+#include <vector>
+#include <QObject>
+
+#include "base/XmlExportable.h"
+
+typedef std::vector<float> SampleBlock;
+
+/** 
+ * Model is the base class for all data models that represent any sort
+ * of data on a time scale based on an audio frame rate.
+ */
+
+class Model : virtual public QObject,
+	      public XmlExportable
+{
+    Q_OBJECT
+
+public:
+    virtual ~Model();
+
+    /**
+     * Return true if the model was constructed successfully.  Classes
+     * that refer to the model should always test this before use.
+     */
+    virtual bool isOK() const = 0;
+
+    /**
+     * Return the first audio frame spanned by the model.
+     */
+    virtual size_t getStartFrame() const = 0;
+
+    /**
+     * Return the last audio frame spanned by the model.
+     */
+    virtual size_t getEndFrame() const = 0;
+
+    /**
+     * Return the frame rate in frames per second.
+     */
+    virtual size_t getSampleRate() const = 0;
+
+    /**
+     * Return a copy of this model.
+     *
+     * If the model is not editable, this may be effectively a shallow
+     * copy.  If the model is editable, however, this operation must
+     * properly copy all of the model's editable data.
+     *
+     * In general this operation is not useful for non-editable dense
+     * models such as waveforms, because there may be no efficient
+     * copy operation implemented -- for such models it is better not
+     * to copy at all.
+     *
+     * Caller owns the returned value.
+     */
+    virtual Model *clone() const = 0;
+    
+    /**
+     * Return true if the model has finished loading or calculating
+     * all its data, for a model that is capable of calculating in a
+     * background thread.  The default implementation is appropriate
+     * for a thread that does not background any work but carries out
+     * all its calculation from the constructor or accessors.
+     *
+     * If "completion" is non-NULL, this function should return
+     * through it an estimated percentage value showing how far
+     * through the background operation it thinks it is (for progress
+     * reporting).  If it has no way to calculate progress, it may
+     * return the special value COMPLETION_UNKNOWN.
+     */
+    virtual bool isReady(int *completion = 0) const {
+	bool ok = isOK();
+	if (completion) *completion = (ok ? 100 : 0);
+	return ok;
+    }
+    static const int COMPLETION_UNKNOWN;
+
+    virtual void toXml(QTextStream &stream,
+                       QString indent = "",
+                       QString extraAttributes = "") const;
+
+    virtual QString toXmlString(QString indent = "",
+				QString extraAttributes = "") const;
+
+    virtual QString toDelimitedDataString(QString) const { return ""; }
+
+signals:
+    /**
+     * Emitted when a model has been edited (or more data retrieved
+     * from cache, in the case of a cached model that generates slowly)
+     */
+    void modelChanged();
+
+    /**
+     * Emitted when a model has been edited (or more data retrieved
+     * from cache, in the case of a cached model that generates slowly)
+     */
+    void modelChanged(size_t startFrame, size_t endFrame);
+
+    /**
+     * Emitted when some internal processing has advanced a stage, but
+     * the model has not changed externally.  Views should respond by
+     * updating any progress meters or other monitoring, but not
+     * refreshing the actual view.
+     */
+    void completionChanged();
+
+protected:
+    Model() { }
+
+    // Not provided.
+    Model(const Model &);
+    Model &operator=(const Model &); 
+};
+
+#endif
--- a/data/model/NoteModel.h	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/model/NoteModel.h	Mon Jul 31 14:05:22 2006 +0000
@@ -17,7 +17,7 @@
 #define _NOTE_MODEL_H_
 
 #include "SparseValueModel.h"
-#include "PlayParameterRepository.h"
+#include "base/PlayParameterRepository.h"
 #include "base/RealTime.h"
 
 /**
--- a/data/model/SparseModel.h	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/model/SparseModel.h	Mon Jul 31 14:05:22 2006 +0000
@@ -16,7 +16,7 @@
 #ifndef _SPARSE_MODEL_H_
 #define _SPARSE_MODEL_H_
 
-#include "base/Model.h"
+#include "Model.h"
 #include "base/Command.h"
 #include "base/CommandHistory.h"
 
--- a/data/model/SparseOneDimensionalModel.h	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/model/SparseOneDimensionalModel.h	Mon Jul 31 14:05:22 2006 +0000
@@ -17,7 +17,7 @@
 #define _SPARSE_ONE_DIMENSIONAL_MODEL_H_
 
 #include "SparseModel.h"
-#include "PlayParameterRepository.h"
+#include "base/PlayParameterRepository.h"
 #include "base/RealTime.h"
 
 struct OneDimensionalPoint
--- a/data/model/SparseTimeValueModel.h	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/model/SparseTimeValueModel.h	Mon Jul 31 14:05:22 2006 +0000
@@ -17,7 +17,7 @@
 #define _SPARSE_TIME_VALUE_MODEL_H_
 
 #include "SparseValueModel.h"
-#include "PlayParameterRepository.h"
+#include "base/PlayParameterRepository.h"
 #include "base/RealTime.h"
 
 /**
--- a/data/model/SparseValueModel.h	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/model/SparseValueModel.h	Mon Jul 31 14:05:22 2006 +0000
@@ -17,7 +17,7 @@
 #define _SPARSE_VALUE_MODEL_H_
 
 #include "SparseModel.h"
-#include "UnitDatabase.h"
+#include "base/UnitDatabase.h"
 
 /**
  * Model containing sparse data (points with some properties) of which
--- a/data/model/WaveFileModel.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/model/WaveFileModel.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -13,12 +13,12 @@
     COPYING included with this distribution for more information.
 */
 
-#include "model/WaveFileModel.h"
+#include "WaveFileModel.h"
 
 #include "fileio/AudioFileReader.h"
 #include "fileio/AudioFileReaderFactory.h"
 
-#include "base/System.h"
+#include "system/System.h"
 
 #include <QMessageBox>
 #include <QFileInfo>
--- a/data/model/WaveFileModel.h	Mon Jul 31 12:03:45 2006 +0000
+++ b/data/model/WaveFileModel.h	Mon Jul 31 14:05:22 2006 +0000
@@ -16,7 +16,7 @@
 #ifndef _WAVE_FILE_MODEL_H_
 #define _WAVE_FILE_MODEL_H_
 
-#include "Thread.h"
+#include "base/Thread.h"
 #include <QMutex>
 #include <QTimer>
 
--- a/plugin/DSSIPluginFactory.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/plugin/DSSIPluginFactory.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -27,9 +27,9 @@
 #include "PluginIdentifier.h"
 
 //!!!
-#include "plugins/SamplePlayer.h"
+#include "plugin/plugins/SamplePlayer.h"
 
-#include "base/System.h"
+#include "system/System.h"
 
 #ifdef HAVE_LRDF
 #include "lrdf.h"
@@ -225,12 +225,13 @@
 }
 
 
-#ifdef HAVE_LRDF
 std::vector<QString>
 DSSIPluginFactory::getLRDFPath(QString &baseUri)
 {
+    std::vector<QString> lrdfPaths;
+
+#ifdef HAVE_LRDF
     std::vector<QString> pathList = getPluginPath();
-    std::vector<QString> lrdfPaths;
 
     lrdfPaths.push_back("/usr/local/share/dssi/rdf");
     lrdfPaths.push_back("/usr/share/dssi/rdf");
@@ -248,10 +249,10 @@
 #else
     baseUri = "http://dssi.sourceforge.net/ontology#";
 #endif
+#endif
 
     return lrdfPaths;
 }    
-#endif
 
 
 void
--- a/plugin/DSSIPluginFactory.h	Mon Jul 31 12:03:45 2006 +0000
+++ b/plugin/DSSIPluginFactory.h	Mon Jul 31 14:05:22 2006 +0000
@@ -50,9 +50,7 @@
 
     virtual std::vector<QString> getPluginPath();
 
-#ifdef HAVE_LRDF
     virtual std::vector<QString> getLRDFPath(QString &baseUri);
-#endif
 
     virtual void discoverPlugins(QString soName);
 
--- a/plugin/FeatureExtractionPluginFactory.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/plugin/FeatureExtractionPluginFactory.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -19,7 +19,7 @@
 #include "vamp/vamp.h"
 #include "vamp-sdk/PluginHostAdapter.h"
 
-#include "base/System.h"
+#include "system/System.h"
 
 #include <QDir>
 #include <QFile>
--- a/plugin/LADSPAPluginFactory.cpp	Mon Jul 31 12:03:45 2006 +0000
+++ b/plugin/LADSPAPluginFactory.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -30,7 +30,7 @@
 #include "LADSPAPluginInstance.h"
 #include "PluginIdentifier.h"
 
-#include "base/System.h"
+#include "system/System.h"
 #include "base/Preferences.h"
 
 #ifdef HAVE_LRDF
@@ -541,12 +541,13 @@
 }
 
 
-#ifdef HAVE_LRDF
 std::vector<QString>
 LADSPAPluginFactory::getLRDFPath(QString &baseUri)
 {
+    std::vector<QString> lrdfPaths;
+
+#ifdef HAVE_LRDF
     std::vector<QString> pathList = getPluginPath();
-    std::vector<QString> lrdfPaths;
 
     lrdfPaths.push_back("/usr/local/share/ladspa/rdf");
     lrdfPaths.push_back("/usr/share/ladspa/rdf");
@@ -557,9 +558,10 @@
     }
 
     baseUri = LADSPA_BASE;
+#endif
+
     return lrdfPaths;
 }    
-#endif
 
 void
 LADSPAPluginFactory::discoverPlugins()
--- a/plugin/LADSPAPluginFactory.h	Mon Jul 31 12:03:45 2006 +0000
+++ b/plugin/LADSPAPluginFactory.h	Mon Jul 31 14:05:22 2006 +0000
@@ -63,9 +63,7 @@
 
     virtual std::vector<QString> getPluginPath();
 
-#ifdef HAVE_LRDF
     virtual std::vector<QString> getLRDFPath(QString &baseUri);
-#endif
 
     virtual void discoverPlugins(QString soName);
     virtual void generateTaxonomy(QString uri, QString base);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugin/plugin.pro	Mon Jul 31 14:05:22 2006 +0000
@@ -0,0 +1,45 @@
+TEMPLATE = lib
+
+SV_UNIT_PACKAGES = lrdf raptor
+load(../sv.prf)
+
+CONFIG += sv staticlib qt thread warn_on stl rtti exceptions
+QT += xml
+
+TARGET = svplugin
+
+DEPENDPATH += . .. api plugins api/alsa api/alsa/sound
+INCLUDEPATH += . .. api api/alsa plugins api/alsa/sound
+OBJECTS_DIR = tmp_obj
+MOC_DIR = tmp_moc
+
+# Input
+HEADERS += DSSIPluginFactory.h \
+           DSSIPluginInstance.h \
+           FeatureExtractionPluginFactory.h \
+           LADSPAPluginFactory.h \
+           LADSPAPluginInstance.h \
+           PluginIdentifier.h \
+           PluginXml.h \
+           RealTimePluginFactory.h \
+           RealTimePluginInstance.h \
+           api/dssi.h \
+           api/ladspa.h \
+           plugins/SamplePlayer.h \
+           api/alsa/asoundef.h \
+           api/alsa/asoundlib.h \
+           api/alsa/seq.h \
+           api/alsa/seq_event.h \
+           api/alsa/seq_midi_event.h \
+           api/alsa/sound/asequencer.h
+SOURCES += DSSIPluginFactory.cpp \
+           DSSIPluginInstance.cpp \
+           FeatureExtractionPluginFactory.cpp \
+           LADSPAPluginFactory.cpp \
+           LADSPAPluginInstance.cpp \
+           PluginIdentifier.cpp \
+           PluginXml.cpp \
+           RealTimePluginFactory.cpp \
+           RealTimePluginInstance.cpp \
+           api/dssi_alsa_compat.c \
+           plugins/SamplePlayer.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/system/Init.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -0,0 +1,92 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Sonic Visualiser
+    An audio file viewer and annotation editor.
+    Centre for Digital Music, Queen Mary, University of London.
+    This file copyright 2006 Chris Cannam.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#include <QApplication>
+#include <QFont>
+
+#include <iostream>
+
+#ifdef Q_WS_X11
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/SM/SMlib.h>
+
+static int handle_x11_error(Display *dpy, XErrorEvent *err)
+{
+    char errstr[256];
+    XGetErrorText(dpy, err->error_code, errstr, 256);
+    if (err->error_code != BadWindow) {
+	std::cerr << "waveform: X Error: "
+		  << errstr << " " << int(err->error_code)
+		  << "\nin major opcode:  "
+		  << int(err->request_code) << std::endl;
+    }
+    return 0;
+}
+#endif
+
+#ifdef Q_WS_WIN32
+
+#include <fcntl.h>
+
+// Set default file open mode to binary
+#undef _fmode
+int _fmode = _O_BINARY;
+
+void redirectStderr()
+{
+    HANDLE stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
+    if (!stderrHandle) return;
+
+    AllocConsole();
+
+    CONSOLE_SCREEN_BUFFER_INFO info;
+    GetConsoleScreenBufferInfo(stderrHandle, &info);
+    info.dwSize.Y = 1000;
+    SetConsoleScreenBufferSize(stderrHandle, info.dwSize);
+
+    int h = _open_osfhandle((long)stderrHandle, _O_TEXT);
+    if (h) {
+        FILE *fd = _fdopen(h, "w");
+        if (fd) {
+            *stderr = *fd;
+            setvbuf(stderr, NULL, _IONBF, 0);
+        }
+    }
+}
+
+#endif
+
+extern void svSystemSpecificInitialisation()
+{
+#ifdef Q_WS_X11
+    XSetErrorHandler(handle_x11_error);
+#endif
+
+#ifdef Q_WS_WIN32
+    redirectStderr();
+    QFont fn = qApp->font();
+    fn.setFamily("Tahoma");
+    qApp->setFont(fn);
+#else
+#ifdef Q_WS_X11
+    QFont fn = qApp->font();
+    fn.setPointSize(fn.pointSize() + 2);
+    qApp->setFont(fn);
+#endif
+#endif
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/system/Init.h	Mon Jul 31 14:05:22 2006 +0000
@@ -0,0 +1,21 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Sonic Visualiser
+    An audio file viewer and annotation editor.
+    Centre for Digital Music, Queen Mary, University of London.
+    This file copyright 2006 Chris Cannam.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#ifndef _SV_SYSTEM_INIT_H_
+#define _SV_SYSTEM_INIT_H_
+
+extern void svSystemSpecificInitialisation();
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/system/System.cpp	Mon Jul 31 14:05:22 2006 +0000
@@ -0,0 +1,78 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Sonic Visualiser
+    An audio file viewer and annotation editor.
+    Centre for Digital Music, Queen Mary, University of London.
+    This file copyright 2006 Chris Cannam.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#include "System.h"
+
+#ifndef _WIN32
+#include <signal.h>
+#endif
+
+#include <iostream>
+
+#ifdef _WIN32
+
+extern "C" {
+
+void usleep(unsigned long usec)
+{
+    ::Sleep(usec / 1000);
+}
+
+void gettimeofday(struct timeval *tv, void *tz)
+{
+    union { 
+	long long ns100;  
+	FILETIME ft; 
+    } now; 
+    
+    ::GetSystemTimeAsFileTime(&now.ft); 
+    tv->tv_usec = (long)((now.ns100 / 10LL) % 1000000LL); 
+    tv->tv_sec = (long)((now.ns100 - 116444736000000000LL) / 10000000LL); 
+}
+
+}
+
+#endif
+
+ProcessStatus
+GetProcessStatus(int pid)
+{
+#ifdef _WIN32
+    HANDLE handle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
+    if (!handle) {
+        return ProcessNotRunning;
+    } else {
+        CloseHandle(handle);
+        return ProcessRunning;
+    }
+#else
+    if (kill(getpid(), 0) == 0) {
+        if (kill(pid, 0) == 0) {
+            return ProcessRunning;
+        } else {
+            return ProcessNotRunning;
+        }
+    } else {
+        return UnknownProcessStatus;
+    }
+#endif
+}
+
+double mod(double x, double y) { return x - (y * floor(x / y)); }
+float modf(float x, float y) { return x - (y * floorf(x / y)); }
+
+double princarg(double a) { return mod(a + M_PI, -2 * M_PI) + M_PI; }
+float princargf(float a) { return modf(a + M_PI, -2 * M_PI) + M_PI; }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/system/System.h	Mon Jul 31 14:05:22 2006 +0000
@@ -0,0 +1,88 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Sonic Visualiser
+    An audio file viewer and annotation editor.
+    Centre for Digital Music, Queen Mary, University of London.
+    This file copyright 2006 Chris Cannam.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#ifndef _SYSTEM_H_
+#define _SYSTEM_H_
+
+#ifdef _WIN32
+
+#include <windows.h>
+#include <malloc.h>
+#include <process.h>
+
+#define MLOCK(a,b)   1
+#define MUNLOCK(a,b) 1
+#define MUNLOCK_SAMPLEBLOCK(a) 1
+
+#define DLOPEN(a,b)  LoadLibrary((a).toStdWString().c_str())
+#define DLSYM(a,b)   GetProcAddress((HINSTANCE)(a),(b))
+#define DLCLOSE(a)   FreeLibrary((HINSTANCE)(a))
+#define DLERROR()    ""
+
+#define PLUGIN_GLOB  "*.dll"
+#define PATH_SEPARATOR ';'
+#define DEFAULT_VAMP_PATH "%ProgramFiles%\\Vamp Plugins"
+
+#define getpid _getpid
+
+extern "C" {
+void usleep(unsigned long usec);
+void gettimeofday(struct timeval *p, void *tz);
+}
+
+#else
+
+#include <sys/mman.h>
+#include <dlfcn.h>
+
+#define MLOCK(a,b)   ::mlock((a),(b))
+#define MUNLOCK(a,b) (::munlock((a),(b)) ? (::perror("munlock failed"), 0) : 0)
+#define MUNLOCK_SAMPLEBLOCK(a) do { if (!(a).empty()) { const float &b = *(a).begin(); MUNLOCK(&b, (a).capacity() * sizeof(float)); } } while(0);
+
+#define DLOPEN(a,b)  dlopen((a).toStdString().c_str(),(b))
+#define DLSYM(a,b)   dlsym((a),(b))
+#define DLCLOSE(a)   dlclose((a))
+#define DLERROR()    dlerror()
+
+#define PATH_SEPARATOR ':'
+
+#ifdef __APPLE__
+
+#define PLUGIN_GLOB  "*.dylib"
+#define DEFAULT_VAMP_PATH "/Library/Audio/Plug-Ins/Vamp/:$HOME/Library/Audio/Plug-Ins/Vamp"
+
+#else 
+
+#define PLUGIN_GLOB  "*.so"
+#define DEFAULT_VAMP_PATH "/usr/local/lib/vamp:/usr/lib/vamp:$HOME/vamp:$HOME/.vamp"
+
+#endif /* __APPLE__ */
+
+#endif /* ! _WIN32 */
+
+enum ProcessStatus { ProcessRunning, ProcessNotRunning, UnknownProcessStatus };
+extern ProcessStatus GetProcessStatus(int pid);
+
+#include <cmath>
+
+extern double mod(double x, double y);
+extern float modf(float x, float y);
+
+extern double princarg(double a);
+extern float princargf(float a);
+
+#endif /* ! _SYSTEM_H_ */
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/system/system.pro	Mon Jul 31 14:05:22 2006 +0000
@@ -0,0 +1,15 @@
+TEMPLATE = lib
+
+SV_UNIT_PACKAGES =
+load(../sv.prf)
+
+CONFIG += sv staticlib qt thread warn_on stl rtti exceptions
+
+TARGET = svsystem
+
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+HEADERS += Init.h System.h
+SOURCES += Init.cpp System.cpp