Verovio
Source code documentation
timemap.h
1 // Name: timemap.h
3 // Author: Laurent Pugin
4 // Created: 29/01/2022
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_TIMEMAP_H__
9 #define __VRV_TIMEMAP_H__
10 
11 #include <cassert>
12 #include <map>
13 #include <string>
14 #include <vector>
15 
16 //----------------------------------------------------------------------------
17 
18 #include "horizontalaligner.h"
19 
20 //----------------------------------------------------------------------------
21 
22 #include "jsonxx.h"
23 
24 namespace vrv {
25 
26 class Object;
27 
28 //----------------------------------------------------------------------------
29 // TimemapEntry
30 //----------------------------------------------------------------------------
31 
35 struct TimemapEntry {
36  double tempo = -1000.0;
37  double tstamp;
38  std::vector<std::string> notesOn;
39  std::vector<std::string> notesOff;
40  std::vector<std::string> restsOn;
41  std::vector<std::string> restsOff;
42  std::string measureOn;
43 };
44 
45 //----------------------------------------------------------------------------
46 // Timemap
47 //----------------------------------------------------------------------------
48 
52 class Timemap {
53 public:
57  Timemap();
59  virtual ~Timemap();
61 
63  void Reset();
64 
68  TimemapEntry &GetEntry(const Fraction &time) { return m_map[time]; }
69 
73  void ToJson(std::string &output, bool includeRests, bool includeMeasures, bool useFractions);
74 
75  static jsonxx::Array ToArray(const Fraction &fraction);
76 
77 private:
78  //
79 public:
80  //
81 private:
83  std::map<Fraction, TimemapEntry> m_map;
84 
85 }; // class Timemap
86 
87 } // namespace vrv
88 
89 #endif // __VRV_TIMEMAP_H__
vrv::Timemap
This class holds a timemap for exporting onset / offset values.
Definition: timemap.h:52
vrv::Fraction
Definition: fraction.h:19
vrv::TimemapEntry
Helper struct to store timemap entries.
Definition: timemap.h:35
vrv::Timemap::Reset
void Reset()
Resets the timemap.
vrv::Timemap::GetEntry
TimemapEntry & GetEntry(const Fraction &time)
Return (and possibly add) an entry for the given time.
Definition: timemap.h:68
vrv::Timemap::ToJson
void ToJson(std::string &output, bool includeRests, bool includeMeasures, bool useFractions)
Write the current timemap to a JSON string.