annotate runner/MIDIFeatureWriter.h @ 310:99d361aa7ad7

Code block formatting
author Chris Cannam
date Tue, 11 Jul 2017 18:35:21 +0100
parents 3f7c65f26559
children e39307a8d22d
rev   line source
Chris@137 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@137 2
Chris@137 3 /*
Chris@137 4 Sonic Annotator
Chris@137 5 A utility for batch feature extraction from audio files.
Chris@137 6
Chris@137 7 Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London.
Chris@137 8 Copyright 2007-2014 QMUL.
Chris@137 9
Chris@137 10 This program is free software; you can redistribute it and/or
Chris@137 11 modify it under the terms of the GNU General Public License as
Chris@137 12 published by the Free Software Foundation; either version 2 of the
Chris@137 13 License, or (at your option) any later version. See the file
Chris@137 14 COPYING included with this distribution for more information.
Chris@137 15 */
Chris@137 16
Chris@137 17 #ifndef _MIDI_FEATURE_WRITER_H_
Chris@137 18 #define _MIDI_FEATURE_WRITER_H_
Chris@137 19
Chris@137 20 #include "transform/FileFeatureWriter.h"
Chris@137 21 #include "data/model/NoteData.h"
Chris@137 22
Chris@137 23 class MIDIFileWriter;
Chris@137 24
Chris@137 25 class MIDIFeatureWriter : public FileFeatureWriter
Chris@137 26 {
Chris@137 27 public:
Chris@137 28 MIDIFeatureWriter();
Chris@137 29 virtual ~MIDIFeatureWriter();
Chris@137 30
Chris@144 31 string getDescription() const;
Chris@144 32
Chris@137 33 virtual ParameterList getSupportedParameters() const;
Chris@137 34 virtual void setParameters(map<string, string> &params);
Chris@137 35
Chris@137 36 virtual void setTrackMetadata(QString trackid, TrackMetadata metadata);
Chris@137 37
Chris@137 38 virtual void write(QString trackid,
Chris@137 39 const Transform &transform,
Chris@137 40 const Vamp::Plugin::OutputDescriptor &output,
Chris@137 41 const Vamp::Plugin::FeatureList &features,
Chris@137 42 std::string summaryType = "");
Chris@137 43
Chris@137 44 virtual void finish();
Chris@137 45
Chris@137 46 virtual QString getWriterTag() const { return "midi"; }
Chris@137 47
Chris@137 48 private:
Chris@137 49 class TrivialNoteExportable : public NoteExportable {
Chris@137 50 public:
Chris@137 51 TrivialNoteExportable(NoteList notes) : m_notes(notes) { }
Chris@137 52 virtual NoteList getNotes() const {
Chris@137 53 return m_notes;
Chris@137 54 }
Chris@195 55 virtual NoteList getNotesWithin(sv_frame_t, sv_frame_t) const {
Chris@137 56 // Not required by MIDIFileWriter, not supported
Chris@137 57 return NoteList();
Chris@137 58 }
Chris@137 59 private:
Chris@137 60 NoteList m_notes;
Chris@137 61 };
Chris@137 62
Chris@137 63 typedef map<QString, NoteList> NoteMap; // output filename -> notes
Chris@137 64 NoteMap m_notes;
Chris@140 65
Chris@175 66 typedef map<QString, set<Transform> > FileTransformMap;
Chris@140 67 FileTransformMap m_fileTransforms;
Chris@137 68
Chris@137 69 typedef map<QString, float> SampleRateMap; // NoteData uses sample timing
Chris@137 70 SampleRateMap m_rates;
Chris@137 71
Chris@175 72 typedef map<Transform, int> ChannelMap;
Chris@137 73 ChannelMap m_channels;
Chris@137 74
Chris@140 75 typedef map<QString, int> NextChannelMap;
Chris@140 76 NextChannelMap m_nextChannels;
Chris@137 77 };
Chris@137 78
Chris@137 79 #endif
Chris@137 80