# HG changeset patch # User Chris Cannam # Date 1154354722 0 # Node ID 4b2ea82fd0edeabb55d2d9724b141a85517300eb # Parent 3e4c384f518e1b174ea5d38091c4978ca75bfac7 * Reorganising code base. This revision probably should compile once more. diff -r 3e4c384f518e -r 4b2ea82fd0ed base/AudioLevel.cpp --- 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 #include #include diff -r 3e4c384f518e -r 4b2ea82fd0ed base/ConfigFile.cpp --- 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 diff -r 3e4c384f518e -r 4b2ea82fd0ed base/FFTCache.cpp --- 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 diff -r 3e4c384f518e -r 4b2ea82fd0ed base/Model.cpp --- 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 - -#include - -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("\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("\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 - diff -r 3e4c384f518e -r 4b2ea82fd0ed base/Model.h --- 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 -#include - -#include "XmlExportable.h" - -typedef std::vector 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 diff -r 3e4c384f518e -r 4b2ea82fd0ed base/PlayParameterRepository.cpp --- 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 diff -r 3e4c384f518e -r 4b2ea82fd0ed base/Preferences.cpp --- 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 #include diff -r 3e4c384f518e -r 4b2ea82fd0ed base/Profiler.h --- 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 #include diff -r 3e4c384f518e -r 4b2ea82fd0ed base/RealTime.cpp --- 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. diff -r 3e4c384f518e -r 4b2ea82fd0ed base/RecentFiles.cpp --- 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 diff -r 3e4c384f518e -r 4b2ea82fd0ed base/RingBuffer.h --- 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 -#include "System.h" +#include "system/System.h" #include "Scavenger.h" //#define DEBUG_RINGBUFFER 1 diff -r 3e4c384f518e -r 4b2ea82fd0ed base/Scavenger.h --- 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 #include diff -r 3e4c384f518e -r 4b2ea82fd0ed base/System.cpp --- 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 -#endif - -#include - -#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; } - diff -r 3e4c384f518e -r 4b2ea82fd0ed base/System.h --- 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 -#include -#include - -#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 -#include - -#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 - -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_ */ - - diff -r 3e4c384f518e -r 4b2ea82fd0ed base/TempDirectory.cpp --- 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 diff -r 3e4c384f518e -r 4b2ea82fd0ed base/base.pro --- /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 diff -r 3e4c384f518e -r 4b2ea82fd0ed data/data.pro --- /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 diff -r 3e4c384f518e -r 4b2ea82fd0ed data/fft/FFTDataServer.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 diff -r 3e4c384f518e -r 4b2ea82fd0ed data/fft/FFTFileCache.cpp --- 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" diff -r 3e4c384f518e -r 4b2ea82fd0ed data/fft/FFTFileCache.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 diff -r 3e4c384f518e -r 4b2ea82fd0ed data/fileio/AudioFileReader.h --- 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 -#include "base/Model.h" // for SampleBlock +#include "model/Model.h" // for SampleBlock class AudioFileReader { diff -r 3e4c384f518e -r 4b2ea82fd0ed data/fileio/CSVFileReader.cpp --- 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" diff -r 3e4c384f518e -r 4b2ea82fd0ed data/fileio/CSVFileWriter.cpp --- 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" diff -r 3e4c384f518e -r 4b2ea82fd0ed data/fileio/DataFileReaderFactory.cpp --- 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 diff -r 3e4c384f518e -r 4b2ea82fd0ed data/fileio/FileReadThread.h --- 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 #include diff -r 3e4c384f518e -r 4b2ea82fd0ed data/fileio/MIDIFileReader.cpp --- 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" diff -r 3e4c384f518e -r 4b2ea82fd0ed data/fileio/MP3FileReader.cpp --- 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 #include diff -r 3e4c384f518e -r 4b2ea82fd0ed data/fileio/MatrixFile.cpp --- 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" diff -r 3e4c384f518e -r 4b2ea82fd0ed data/fileio/OggVorbisFileReader.cpp --- 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 #include diff -r 3e4c384f518e -r 4b2ea82fd0ed data/model/DenseThreeDimensionalModel.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 diff -r 3e4c384f518e -r 4b2ea82fd0ed data/model/DenseTimeValueModel.cpp --- 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() { diff -r 3e4c384f518e -r 4b2ea82fd0ed data/model/DenseTimeValueModel.h --- 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 -#include "base/Model.h" +#include "Model.h" /** * Base class for models containing dense two-dimensional data (value diff -r 3e4c384f518e -r 4b2ea82fd0ed data/model/Model.cpp --- /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 + +#include + +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("\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("\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 + diff -r 3e4c384f518e -r 4b2ea82fd0ed data/model/Model.h --- /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 +#include + +#include "base/XmlExportable.h" + +typedef std::vector 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 diff -r 3e4c384f518e -r 4b2ea82fd0ed data/model/NoteModel.h --- 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" /** diff -r 3e4c384f518e -r 4b2ea82fd0ed data/model/SparseModel.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" diff -r 3e4c384f518e -r 4b2ea82fd0ed data/model/SparseOneDimensionalModel.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 diff -r 3e4c384f518e -r 4b2ea82fd0ed data/model/SparseTimeValueModel.h --- 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" /** diff -r 3e4c384f518e -r 4b2ea82fd0ed data/model/SparseValueModel.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 diff -r 3e4c384f518e -r 4b2ea82fd0ed data/model/WaveFileModel.cpp --- 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 #include diff -r 3e4c384f518e -r 4b2ea82fd0ed data/model/WaveFileModel.h --- 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 #include diff -r 3e4c384f518e -r 4b2ea82fd0ed plugin/DSSIPluginFactory.cpp --- 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 DSSIPluginFactory::getLRDFPath(QString &baseUri) { + std::vector lrdfPaths; + +#ifdef HAVE_LRDF std::vector pathList = getPluginPath(); - std::vector 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 diff -r 3e4c384f518e -r 4b2ea82fd0ed plugin/DSSIPluginFactory.h --- 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 getPluginPath(); -#ifdef HAVE_LRDF virtual std::vector getLRDFPath(QString &baseUri); -#endif virtual void discoverPlugins(QString soName); diff -r 3e4c384f518e -r 4b2ea82fd0ed plugin/FeatureExtractionPluginFactory.cpp --- 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 #include diff -r 3e4c384f518e -r 4b2ea82fd0ed plugin/LADSPAPluginFactory.cpp --- 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 LADSPAPluginFactory::getLRDFPath(QString &baseUri) { + std::vector lrdfPaths; + +#ifdef HAVE_LRDF std::vector pathList = getPluginPath(); - std::vector 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() diff -r 3e4c384f518e -r 4b2ea82fd0ed plugin/LADSPAPluginFactory.h --- 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 getPluginPath(); -#ifdef HAVE_LRDF virtual std::vector getLRDFPath(QString &baseUri); -#endif virtual void discoverPlugins(QString soName); virtual void generateTaxonomy(QString uri, QString base); diff -r 3e4c384f518e -r 4b2ea82fd0ed plugin/plugin.pro --- /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 diff -r 3e4c384f518e -r 4b2ea82fd0ed system/Init.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 +#include + +#include + +#ifdef Q_WS_X11 +#include +#include +#include +#include + +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 + +// 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 +} + diff -r 3e4c384f518e -r 4b2ea82fd0ed system/Init.h --- /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 diff -r 3e4c384f518e -r 4b2ea82fd0ed system/System.cpp --- /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 +#endif + +#include + +#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; } + diff -r 3e4c384f518e -r 4b2ea82fd0ed system/System.h --- /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 +#include +#include + +#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 +#include + +#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 + +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_ */ + + diff -r 3e4c384f518e -r 4b2ea82fd0ed system/system.pro --- /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