Chris@498: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@498: Chris@498: /* Chris@498: Sonic Visualiser Chris@498: An audio file viewer and annotation editor. Chris@498: Chris@498: Sonic Annotator Chris@498: A utility for batch feature extraction from audio files. Chris@498: Chris@498: Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London. Chris@498: Copyright 2007-2008 QMUL. Chris@498: Chris@498: This program is free software; you can redistribute it and/or Chris@498: modify it under the terms of the GNU General Public License as Chris@498: published by the Free Software Foundation; either version 2 of the Chris@498: License, or (at your option) any later version. See the file Chris@498: COPYING included with this distribution for more information. Chris@498: */ Chris@498: Chris@498: #ifndef _FEATURE_WRITER_H_ Chris@498: #define _FEATURE_WRITER_H_ Chris@498: Chris@498: #include Chris@498: #include Chris@498: #include Chris@498: Chris@498: #include Chris@498: Chris@498: #include "Transform.h" Chris@498: Chris@498: #include Chris@498: Chris@498: using std::string; Chris@498: using std::map; Chris@498: using std::vector; Chris@498: Chris@498: class FeatureWriter Chris@498: { Chris@498: public: Chris@498: virtual ~FeatureWriter() { } Chris@498: Chris@498: struct Parameter { // parameter of the writer, not the plugin Chris@498: string name; Chris@498: string description; Chris@498: bool hasArg; Chris@498: }; Chris@498: typedef vector ParameterList; Chris@498: virtual ParameterList getSupportedParameters() const { Chris@498: return ParameterList(); Chris@498: } Chris@498: Chris@498: virtual void setParameters(map ¶ms) { Chris@498: return; Chris@498: } Chris@498: Chris@504: struct TrackMetadata { Chris@504: QString title; Chris@504: QString maker; Chris@504: }; Chris@504: virtual void setTrackMetadata(QString trackid, TrackMetadata metadata) { } Chris@504: Chris@604: class FailedToOpenOutputStream : virtual public std::exception Chris@604: { Chris@604: public: Chris@604: FailedToOpenOutputStream(QString trackId, QString transformId) throw() : Chris@604: m_trackId(trackId), Chris@604: m_transformId(transformId) Chris@604: { } Chris@604: virtual ~FailedToOpenOutputStream() throw() { } Chris@604: virtual const char *what() const throw() { Chris@604: return QString("Failed to open output stream for track id \"%1\", transform id \"%2\"") Chris@604: .arg(m_trackId).arg(m_transformId).toLocal8Bit().data(); Chris@604: } Chris@604: Chris@604: protected: Chris@604: QString m_trackId; Chris@604: QString m_transformId; Chris@604: }; Chris@604: Chris@498: // may throw FailedToOpenFile or other exceptions Chris@498: Chris@498: virtual void write(QString trackid, Chris@498: const Transform &transform, Chris@498: const Vamp::Plugin::OutputDescriptor &output, Chris@498: const Vamp::Plugin::FeatureList &features, Chris@498: std::string summaryType = "") = 0; Chris@498: Chris@515: virtual void flush() { } // whatever the last stream was Chris@515: Chris@498: virtual void finish() = 0; Chris@604: Chris@604: virtual QString getWriterTag() const = 0; Chris@498: }; Chris@498: Chris@498: #endif