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@1495
|
15 #ifndef SV_NOTE_DATA_H
|
Chris@1495
|
16 #define SV_NOTE_DATA_H
|
Chris@852
|
17
|
Chris@852
|
18 #include <vector>
|
Chris@852
|
19
|
Chris@1615
|
20 #include "Pitch.h"
|
Chris@865
|
21
|
Chris@1615
|
22 /**
|
Chris@1615
|
23 * Note record used when constructing synthetic events for sonification.
|
Chris@1615
|
24 */
|
Chris@852
|
25 struct NoteData
|
Chris@852
|
26 {
|
Chris@1038
|
27 NoteData(sv_frame_t _start, sv_frame_t _dur, int _mp, int _vel) :
|
Chris@1429
|
28 start(_start), duration(_dur), midiPitch(_mp), frequency(0),
|
Chris@1429
|
29 isMidiPitchQuantized(true), velocity(_vel), channel(0) { };
|
Chris@852
|
30
|
Chris@1038
|
31 sv_frame_t start; // audio sample frame
|
Chris@1038
|
32 sv_frame_t duration; // in audio sample frames
|
Chris@996
|
33 int midiPitch; // 0-127
|
Chris@865
|
34 float frequency; // Hz, to be used if isMidiPitchQuantized false
|
Chris@852
|
35 bool isMidiPitchQuantized;
|
Chris@996
|
36 int velocity; // MIDI-style 0-127
|
Chris@996
|
37 int channel; // MIDI 0-15
|
Chris@865
|
38
|
Chris@865
|
39 float getFrequency() const {
|
Chris@865
|
40 if (isMidiPitchQuantized) {
|
Chris@1038
|
41 return float(Pitch::getFrequencyForPitch(midiPitch));
|
Chris@865
|
42 } else {
|
Chris@865
|
43 return frequency;
|
Chris@865
|
44 }
|
Chris@865
|
45 }
|
Chris@852
|
46 };
|
Chris@852
|
47
|
Chris@852
|
48 typedef std::vector<NoteData> NoteList;
|
Chris@852
|
49
|
Chris@852
|
50 class NoteExportable
|
Chris@852
|
51 {
|
Chris@852
|
52 public:
|
Chris@852
|
53 virtual NoteList getNotes() const = 0;
|
Chris@1038
|
54 virtual NoteList getNotesWithin(sv_frame_t startFrame, sv_frame_t endFrame) const = 0;
|
Chris@852
|
55 };
|
Chris@852
|
56
|
Chris@852
|
57 #endif
|