annotate transform/FileFeatureWriter.h @ 1311:90ac1df228aa 3.0-integration

Merge from branch mp3-gapless
author Chris Cannam
date Tue, 29 Nov 2016 16:45:53 +0000
parents d74ebd2d2c49
children c01cbe41aeb5
rev   line source
Chris@498 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@498 2
Chris@498 3 /*
Chris@498 4 Sonic Visualiser
Chris@498 5 An audio file viewer and annotation editor.
Chris@498 6
Chris@498 7 Sonic Annotator
Chris@498 8 A utility for batch feature extraction from audio files.
Chris@498 9
Chris@498 10 Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London.
Chris@498 11 Copyright 2007-2008 QMUL.
Chris@498 12
Chris@498 13 This program is free software; you can redistribute it and/or
Chris@498 14 modify it under the terms of the GNU General Public License as
Chris@498 15 published by the Free Software Foundation; either version 2 of the
Chris@498 16 License, or (at your option) any later version. See the file
Chris@498 17 COPYING included with this distribution for more information.
Chris@498 18 */
Chris@498 19
Chris@498 20 #ifndef _FILE_FEATURE_WRITER_H_
Chris@498 21 #define _FILE_FEATURE_WRITER_H_
Chris@498 22
Chris@498 23 #include <string>
Chris@498 24 #include <map>
Chris@498 25 #include <set>
Chris@498 26
Chris@498 27 #include "FeatureWriter.h"
Chris@498 28
Chris@498 29 using std::string;
Chris@498 30 using std::map;
Chris@498 31 using std::set;
Chris@498 32 using std::pair;
Chris@498 33
Chris@498 34 class QTextStream;
Chris@1035 35 class QTextCodec;
Chris@498 36 class QFile;
Chris@498 37
Chris@498 38 class FileFeatureWriter : public FeatureWriter
Chris@498 39 {
Chris@498 40 public:
Chris@498 41 virtual ~FileFeatureWriter();
Chris@498 42
Chris@498 43 virtual ParameterList getSupportedParameters() const;
Chris@498 44 virtual void setParameters(map<string, string> &params);
Chris@498 45
Chris@625 46 virtual void testOutputFile(QString trackId, TransformId transformId);
Chris@515 47 virtual void flush();
Chris@531 48 virtual void finish();
Chris@515 49
Chris@498 50 protected:
Chris@498 51 enum FileWriteSupport {
Chris@498 52 SupportOneFilePerTrackTransform = 1,
Chris@498 53 SupportOneFilePerTrack = 2,
Chris@997 54 SupportOneFileTotal = 4,
Chris@997 55 SupportStdOut = 8
Chris@498 56 };
Chris@498 57
Chris@498 58 FileFeatureWriter(int support, QString extension);
Chris@1035 59 QTextStream *getOutputStream(QString, TransformId, QTextCodec *);
Chris@498 60
Chris@498 61 typedef pair<QString, TransformId> TrackTransformPair;
Chris@999 62 typedef map<TrackTransformPair, QString> FileNameMap;
Chris@498 63 typedef map<TrackTransformPair, QFile *> FileMap;
Chris@498 64 typedef map<QFile *, QTextStream *> FileStreamMap;
Chris@498 65 FileMap m_files;
Chris@999 66 FileNameMap m_filenames;
Chris@498 67 FileStreamMap m_streams;
Chris@512 68 QTextStream *m_prevstream;
Chris@498 69
Chris@999 70 TrackTransformPair getFilenameKey(QString, TransformId);
Chris@999 71
Chris@999 72 // Come up with a suitable output filename for the given track ID -
Chris@999 73 // transform ID combo. Fail if it already exists, etc.
Chris@999 74 QString createOutputFilename(QString, TransformId);
Chris@999 75
Chris@999 76 // Look up and return the output filename for the given track ID -
Chris@999 77 // transform ID combo.
Chris@498 78 QString getOutputFilename(QString, TransformId);
Chris@999 79
Chris@999 80 // Look up and return the output file handle for the given track
Chris@999 81 // ID - transform ID combo. Return 0 if it could not be opened.
Chris@498 82 QFile *getOutputFile(QString, TransformId);
Chris@591 83
Chris@591 84 // subclass can implement this to be called before file is opened for append
Chris@930 85 virtual void reviewFileForAppending(QString) { }
Chris@498 86
Chris@498 87 int m_support;
Chris@498 88 QString m_extension;
Chris@498 89 QString m_baseDir;
Chris@498 90 bool m_manyFiles;
Chris@498 91 QString m_singleFileName;
Chris@498 92 bool m_stdout;
Chris@498 93 bool m_append;
Chris@498 94 bool m_force;
Chris@498 95 };
Chris@498 96
Chris@498 97 #endif