annotate data/model/NoteData.h @ 852:d6bd5751b8f6 tonioni_multi_transform

Add NoteExportable base class, use it in MIDI export (and also elsewhere in playback)
author Chris Cannam
date Mon, 02 Dec 2013 17:11:20 +0000
parents
children 1f98e28f70c6
rev   line source
Chris@852 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@852 2
Chris@852 3 /*
Chris@852 4 Sonic Visualiser
Chris@852 5 An audio file viewer and annotation editor.
Chris@852 6 Centre for Digital Music, Queen Mary, University of London.
Chris@852 7
Chris@852 8 This program is free software; you can redistribute it and/or
Chris@852 9 modify it under the terms of the GNU General Public License as
Chris@852 10 published by the Free Software Foundation; either version 2 of the
Chris@852 11 License, or (at your option) any later version. See the file
Chris@852 12 COPYING included with this distribution for more information.
Chris@852 13 */
Chris@852 14
Chris@852 15 #ifndef NOTE_DATA_H
Chris@852 16 #define NOTE_DATA_H
Chris@852 17
Chris@852 18 #include <vector>
Chris@852 19
Chris@852 20 struct NoteData
Chris@852 21 {
Chris@852 22 NoteData(size_t _start, size_t _dur, int _mp, int _vel) :
Chris@852 23 start(_start), duration(_dur), midiPitch(_mp), frequency(0),
Chris@852 24 isMidiPitchQuantized(true), velocity(_vel) { };
Chris@852 25
Chris@852 26 size_t start; // audio sample frame
Chris@852 27 size_t duration; // in audio sample frames
Chris@852 28 int midiPitch; // 0-127
Chris@852 29 int frequency; // Hz, to be used if isMidiPitchQuantized false
Chris@852 30 bool isMidiPitchQuantized;
Chris@852 31 int velocity; // MIDI-style 0-127
Chris@852 32 };
Chris@852 33
Chris@852 34 typedef std::vector<NoteData> NoteList;
Chris@852 35
Chris@852 36 class NoteExportable
Chris@852 37 {
Chris@852 38 public:
Chris@852 39 virtual NoteList getNotes() const = 0;
Chris@852 40 virtual NoteList getNotes(size_t startFrame, size_t endFrame) const = 0;
Chris@852 41 };
Chris@852 42
Chris@852 43 #endif