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@1581: #ifndef SV_FILE_FEATURE_WRITER_H Chris@1581: #define SV_FILE_FEATURE_WRITER_H Chris@498: Chris@498: #include Chris@498: #include Chris@498: #include Chris@498: Chris@498: #include "FeatureWriter.h" Chris@498: Chris@498: using std::string; Chris@498: using std::map; Chris@498: using std::set; Chris@498: using std::pair; Chris@498: Chris@498: class QTextStream; Chris@1035: class QTextCodec; Chris@498: class QFile; Chris@498: Chris@498: class FileFeatureWriter : public FeatureWriter Chris@498: { Chris@498: public: Chris@498: virtual ~FileFeatureWriter(); Chris@498: Chris@1580: ParameterList getSupportedParameters() const override; Chris@1580: void setParameters(map ¶ms) override; Chris@498: Chris@1580: void testOutputFile(QString trackId, TransformId transformId) override; Chris@1580: void flush() override; Chris@1580: void finish() override; Chris@515: Chris@498: protected: Chris@498: enum FileWriteSupport { Chris@498: SupportOneFilePerTrackTransform = 1, Chris@498: SupportOneFilePerTrack = 2, Chris@997: SupportOneFileTotal = 4, Chris@997: SupportStdOut = 8 Chris@498: }; Chris@498: Chris@498: FileFeatureWriter(int support, QString extension); Chris@1035: QTextStream *getOutputStream(QString, TransformId, QTextCodec *); Chris@498: Chris@498: typedef pair TrackTransformPair; Chris@999: typedef map FileNameMap; Chris@498: typedef map FileMap; Chris@498: typedef map FileStreamMap; Chris@498: FileMap m_files; Chris@999: FileNameMap m_filenames; Chris@498: FileStreamMap m_streams; Chris@512: QTextStream *m_prevstream; Chris@498: Chris@999: TrackTransformPair getFilenameKey(QString, TransformId); Chris@999: Chris@999: // Come up with a suitable output filename for the given track ID - Chris@999: // transform ID combo. Fail if it already exists, etc. Chris@999: QString createOutputFilename(QString, TransformId); Chris@999: Chris@999: // Look up and return the output filename for the given track ID - Chris@999: // transform ID combo. Chris@498: QString getOutputFilename(QString, TransformId); Chris@999: Chris@999: // Look up and return the output file handle for the given track Chris@999: // ID - transform ID combo. Return 0 if it could not be opened. Chris@498: QFile *getOutputFile(QString, TransformId); Chris@591: Chris@591: // subclass can implement this to be called before file is opened for append Chris@930: virtual void reviewFileForAppending(QString) { } Chris@498: Chris@498: int m_support; Chris@498: QString m_extension; Chris@498: QString m_baseDir; Chris@498: bool m_manyFiles; Chris@498: QString m_singleFileName; Chris@498: bool m_stdout; Chris@498: bool m_append; Chris@498: bool m_force; Chris@498: }; Chris@498: Chris@498: #endif