Verovio
Source code documentation
customtuning.h
1 // Name: customtuning.h
3 // Author: Karim Ratib
4 // Created: 2025
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_CUSTOMTUNING_H__
9 #define __VRV_CUSTOMTUNING_H__
10 
11 #include "Tunings.h"
12 
13 //----------------------------------------------------------------------------
14 
15 #include <map>
16 
17 //----------------------------------------------------------------------------
18 
19 namespace vrv {
20 
21 class Doc;
22 class Note;
23 
24 //----------------------------------------------------------------------------
25 // CustomTuning
26 //----------------------------------------------------------------------------
27 
28 class CustomTuning {
29 public:
30  CustomTuning() {}
31  CustomTuning(const std::string &tuningDef, Doc *doc, bool useMusicXmlAccidentals);
32 
37  bool IsValid() const { return m_tuning.notationMapping.count > 0; }
38  Tunings::Tuning &GetTuning() { return m_tuning; }
39  const Tunings::Tuning &GetTuning() const { return m_tuning; }
40  std::map<std::string, std::string> &GetNoteMap() { return m_noteMap; }
41  const std::map<std::string, std::string> &GetNoteMap() const { return m_noteMap; }
43 
48  int GetMIDIPitch(const Note *note, const int shift, const int octaveShift) const;
50 
51  /*
52  * @name Helper functions for SMuFL glyphs
53  */
55  static char32_t GetGlyphCode(const std::string &glyphName, Doc *doc = NULL);
56  static std::string GetGlyphName(char32_t glyphCode, Doc *doc = NULL);
57  static char32_t GetAccidGlyph(const std::string &accid, bool useMusicXmlAccidentals);
59 
63  static void CopyCustomTunings(const Doc *src, Doc *dst);
64 
65 private:
70  static void CreateGlyphMapping(Doc *doc);
71  void CreateNoteMapping(bool useMusicXmlAccidentals);
73 
74 public:
75  //
76 
77 private:
78  Tunings::Tuning m_tuning;
79  std::map<std::string, std::string> m_noteMap;
80 
81  //----------------//
82  // Static members //
83  //----------------//
84 
85  static std::map<std::string, char32_t> s_glyphNames;
86  static std::map<char32_t, std::string> s_glyphCodes;
87 };
88 
89 } // namespace vrv
90 
91 #endif
Definition: customtuning.h:28
This class is a hold the data and corresponds to the model of a MVC design pattern.
Definition: doc.h:41
This class models the MEI <note> element.
Definition: note.h:69