comparison runner/BinaryFeatureWriter.h @ 60:da84d2efd7a3

Added NumPy compatible binary feature writer for track-level outputs
author gyorgyf
date Sun, 12 Feb 2012 19:55:06 +0000
parents
children 0ef80ae6493c
comparison
equal deleted inserted replaced
59:52b9d58edb78 60:da84d2efd7a3
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Annotator
5 A utility for batch feature extraction from audio files.
6 Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London.
7 Copyright 2007-2008 QMUL.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #ifndef _BINARY_FEATURE_WRITER_H_
17 #define _BINARY_FEATURE_WRITER_H_
18
19 #include <string>
20 #include <map>
21 #include <fstream>
22
23 using std::string;
24 using std::map;
25
26 #include "transform/FeatureWriter.h"
27
28 class BinaryFeatureWriter : public FeatureWriter
29 {
30 public:
31 BinaryFeatureWriter();
32 virtual ~BinaryFeatureWriter();
33
34 virtual ParameterList getSupportedParameters() const;
35 virtual void setParameters(map<string, string> &params);
36
37 virtual void setOutputFile(const string &);
38
39 virtual void write(QString trackid,
40 const Transform &transform,
41 const Vamp::Plugin::OutputDescriptor &output,
42 const Vamp::Plugin::FeatureList &features,
43 std::string summaryType = "");
44
45 virtual void finish();
46
47 virtual QString getWriterTag() const { return "binary"; }
48
49 private:
50 // Parameters
51 string outputFile;
52
53 // Parameter names (class vars)
54 static string outputFileParam;
55
56 struct OutputStream;
57 /*
58 struct BinaryFeatureWriter::TrackStream
59 {
60 QString trackid;
61 ofstream* ofs;
62 };
63 */
64 typedef std::map<QString, float> ParameterMap;
65
66 OutputStream *binary;
67
68 bool openBinaryFile();
69 long feature_count;
70 long data_size_pos;
71 long output_binCount;
72 };
73
74 #endif