Mercurial > hg > svcore
comparison base/NoteData.h @ 1615:24dc8cb42755 single-point
Rename a number of classes and methods (including Point -> Event); comments
| author | Chris Cannam |
|---|---|
| date | Thu, 07 Mar 2019 15:44:09 +0000 |
| parents | data/model/NoteData.h@6965c83c8fa7 |
| children | 7a23dfe65d66 |
comparison
equal
deleted
inserted
replaced
| 1614:2e14a7876945 | 1615:24dc8cb42755 |
|---|---|
| 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 SV_NOTE_DATA_H | |
| 16 #define SV_NOTE_DATA_H | |
| 17 | |
| 18 #include <vector> | |
| 19 | |
| 20 #include "Pitch.h" | |
| 21 | |
| 22 /** | |
| 23 * Note record used when constructing synthetic events for sonification. | |
| 24 */ | |
| 25 struct NoteData | |
| 26 { | |
| 27 NoteData(sv_frame_t _start, sv_frame_t _dur, int _mp, int _vel) : | |
| 28 start(_start), duration(_dur), midiPitch(_mp), frequency(0), | |
| 29 isMidiPitchQuantized(true), velocity(_vel), channel(0) { }; | |
| 30 | |
| 31 sv_frame_t start; // audio sample frame | |
| 32 sv_frame_t duration; // in audio sample frames | |
| 33 int midiPitch; // 0-127 | |
| 34 float frequency; // Hz, to be used if isMidiPitchQuantized false | |
| 35 bool isMidiPitchQuantized; | |
| 36 int velocity; // MIDI-style 0-127 | |
| 37 int channel; // MIDI 0-15 | |
| 38 | |
| 39 float getFrequency() const { | |
| 40 if (isMidiPitchQuantized) { | |
| 41 return float(Pitch::getFrequencyForPitch(midiPitch)); | |
| 42 } else { | |
| 43 return frequency; | |
| 44 } | |
| 45 } | |
| 46 }; | |
| 47 | |
| 48 typedef std::vector<NoteData> NoteList; | |
| 49 | |
| 50 class NoteExportable | |
| 51 { | |
| 52 public: | |
| 53 virtual NoteList getNotes() const = 0; | |
| 54 virtual NoteList getNotesWithin(sv_frame_t startFrame, sv_frame_t endFrame) const = 0; | |
| 55 }; | |
| 56 | |
| 57 #endif |
