libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
midinotenames.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <promeki/core/array.h>
11#include <promeki/core/string.h>
13
15
28 public:
29 static constexpr int NumNotes = 128;
30
32 MidiNoteNames() = default;
33
41 if(!note.isValid()) return String();
42 const String &n = _names[note.rawValue()];
43 if(!n.isEmpty()) return n;
44 return note.name();
45 }
46
49 if(note.isValid()) _names[note.rawValue()] = name;
50 }
51
54 if(note.isValid()) _names[note.rawValue()] = String();
55 }
56
58 bool hasName(MidiNote note) const {
59 if(!note.isValid()) return false;
60 return !_names[note.rawValue()].isEmpty();
61 }
62
65
66 private:
68};
69
Dynamic array container wrapping std::vector.
Definition list.h:40
bool isEmpty() const noexcept
Returns true if the list has no elements.
Definition list.h:296
Provides a customizable name overlay for MIDI notes.
Definition midinotenames.h:27
String name(MidiNote note) const
Returns the name for a MIDI note.
Definition midinotenames.h:40
void clearName(MidiNote note)
Clears the custom name for a MIDI note (reverts to default).
Definition midinotenames.h:53
bool hasName(MidiNote note) const
Returns true if a custom name is set for the given note.
Definition midinotenames.h:58
static MidiNoteNames gmPercussion()
Creates a name set with General MIDI percussion names.
void setName(MidiNote note, const String &name)
Sets a custom name for a MIDI note.
Definition midinotenames.h:48
MidiNoteNames()=default
Constructs an empty name set (all notes fall back to MidiNote::name()).
Represents a MIDI note number (0–127) with utility methods.
Definition midinote.h:26
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19