Mercurial > hg > svcore
comparison data/model/NoteData.h @ 874:862fe7b20df7 tony_integration
Merge from tonioni branch
author | Chris Cannam |
---|---|
date | Tue, 28 Jan 2014 15:01:54 +0000 |
parents | 9196cff56abe |
children | 59e7fe1b1003 |
comparison
equal
deleted
inserted
replaced
862:786ee8d1f30e | 874:862fe7b20df7 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 | |
8 This program is free software; you can redistribute it and/or | |
9 modify it under the terms of the GNU General Public License as | |
10 published by the Free Software Foundation; either version 2 of the | |
11 License, or (at your option) any later version. See the file | |
12 COPYING included with this distribution for more information. | |
13 */ | |
14 | |
15 #ifndef NOTE_DATA_H | |
16 #define NOTE_DATA_H | |
17 | |
18 #include <vector> | |
19 | |
20 #include "base/Pitch.h" | |
21 | |
22 struct NoteData | |
23 { | |
24 NoteData(size_t _start, size_t _dur, int _mp, int _vel) : | |
25 start(_start), duration(_dur), midiPitch(_mp), frequency(0), | |
26 isMidiPitchQuantized(true), velocity(_vel) { }; | |
27 | |
28 size_t start; // audio sample frame | |
29 size_t duration; // in audio sample frames | |
30 int midiPitch; // 0-127 | |
31 float frequency; // Hz, to be used if isMidiPitchQuantized false | |
32 bool isMidiPitchQuantized; | |
33 int velocity; // MIDI-style 0-127 | |
34 | |
35 float getFrequency() const { | |
36 if (isMidiPitchQuantized) { | |
37 return Pitch::getFrequencyForPitch(midiPitch); | |
38 } else { | |
39 return frequency; | |
40 } | |
41 } | |
42 }; | |
43 | |
44 typedef std::vector<NoteData> NoteList; | |
45 | |
46 class NoteExportable | |
47 { | |
48 public: | |
49 virtual NoteList getNotes() const = 0; | |
50 virtual NoteList getNotes(size_t startFrame, size_t endFrame) const = 0; | |
51 }; | |
52 | |
53 #endif |