comparison data/model/SparseOneDimensionalModel.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 e22b6e89a7f7
children 6d07bcc844a1
comparison
equal deleted inserted replaced
850:dba8a02b0413 852:d6bd5751b8f6
15 15
16 #ifndef _SPARSE_ONE_DIMENSIONAL_MODEL_H_ 16 #ifndef _SPARSE_ONE_DIMENSIONAL_MODEL_H_
17 #define _SPARSE_ONE_DIMENSIONAL_MODEL_H_ 17 #define _SPARSE_ONE_DIMENSIONAL_MODEL_H_
18 18
19 #include "SparseModel.h" 19 #include "SparseModel.h"
20 #include "NoteData.h"
20 #include "base/PlayParameterRepository.h" 21 #include "base/PlayParameterRepository.h"
21 #include "base/RealTime.h" 22 #include "base/RealTime.h"
22 23
23 #include <QStringList> 24 #include <QStringList>
24 25
67 } 68 }
68 }; 69 };
69 }; 70 };
70 71
71 72
72 class SparseOneDimensionalModel : public SparseModel<OneDimensionalPoint> 73 class SparseOneDimensionalModel : public SparseModel<OneDimensionalPoint>,
74 public NoteExportable
73 { 75 {
74 Q_OBJECT 76 Q_OBJECT
75 77
76 public: 78 public:
77 SparseOneDimensionalModel(size_t sampleRate, size_t resolution, 79 SparseOneDimensionalModel(size_t sampleRate, size_t resolution,
179 virtual SortType getSortType(int column) const 181 virtual SortType getSortType(int column) const
180 { 182 {
181 if (column == 2) return SortAlphabetical; 183 if (column == 2) return SortAlphabetical;
182 return SortNumeric; 184 return SortNumeric;
183 } 185 }
186
187 /**
188 * NoteExportable methods.
189 */
190
191 NoteList getNotes() const {
192 return getNotes(getStartFrame(), getEndFrame());
193 }
194
195 NoteList getNotes(size_t startFrame, size_t endFrame) const {
196
197 PointList points = getPoints(startFrame, endFrame);
198 NoteList notes;
199
200 for (PointList::iterator pli =
201 points.begin(); pli != points.end(); ++pli) {
202
203 notes.push_back
204 (NoteData(pli->frame,
205 getSampleRate() / 6, // arbitrary short duration
206 64, // default pitch
207 100)); // default velocity
208 }
209
210 return notes;
211 }
184 }; 212 };
185 213
186 #endif 214 #endif
187 215
188 216