libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
midinotenames.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_MUSIC
13#include <promeki/array.h>
14#include <promeki/string.h>
15#include <promeki/midinote.h>
16
17PROMEKI_NAMESPACE_BEGIN
18
30class MidiNoteNames {
31 public:
32 static constexpr int NumNotes = 128;
33
35 MidiNoteNames() = default;
36
43 String name(MidiNote note) const {
44 if (!note.isValid()) return String();
45 const String &n = _names[note.rawValue()];
46 if (!n.isEmpty()) return n;
47 return note.name();
48 }
49
51 void setName(MidiNote note, const String &name) {
52 if (note.isValid()) _names[note.rawValue()] = name;
53 }
54
56 void clearName(MidiNote note) {
57 if (note.isValid()) _names[note.rawValue()] = String();
58 }
59
61 bool hasName(MidiNote note) const {
62 if (!note.isValid()) return false;
63 return !_names[note.rawValue()].isEmpty();
64 }
65
67 static MidiNoteNames gmPercussion();
68
69 private:
70 Array<String, NumNotes> _names;
71};
72
73PROMEKI_NAMESPACE_END
74
75#endif // PROMEKI_ENABLE_MUSIC