Control Surface new-input
MIDI Control Surface library for Arduino
Notes.hpp
Go to the documentation of this file.
1 /* ✔ */
2 
3 #pragma once
4 
5 #include <Settings/NamespaceSettings.hpp>
6 #include <stdint.h>
7 
9 
12 
14 namespace MIDI_Notes {
15 
16 class Note {
17  private:
18  int8_t base;
19  constexpr Note(int8_t base) : base(base) {}
20 
21  public:
22  constexpr int8_t operator()(int8_t octave = -1) const {
23  return base + 12 * (octave + 1);
24  }
25 
26  constexpr static Note C() { return Note{0}; }
27  constexpr static Note Db() { return Note{1}; }
28  constexpr static Note D() { return Note{2}; }
29  constexpr static Note Eb() { return Note{3}; }
30  constexpr static Note E() { return Note{4}; }
31  constexpr static Note F_() { return Note{5}; }
32  constexpr static Note Gb() { return Note{6}; }
33  constexpr static Note G() { return Note{7}; }
34  constexpr static Note Ab() { return Note{8}; }
35  constexpr static Note A() { return Note{9}; }
36  constexpr static Note Bb() { return Note{10}; }
37  constexpr static Note B() { return Note{11}; }
38 };
39 
40 constexpr Note C = Note::C();
41 constexpr Note Db = Note::Db();
42 constexpr Note D = Note::D();
43 constexpr Note Eb = Note::Eb();
44 constexpr Note E = Note::E();
45 constexpr Note F_ = Note::F_();
46 constexpr Note Gb = Note::Gb();
47 constexpr Note G = Note::G();
48 constexpr Note Ab = Note::Ab();
49 constexpr Note A = Note::A();
50 constexpr Note Bb = Note::Bb();
51 constexpr Note B = Note::B();
52 
54 [[deprecated("Instead of `note(C, 4)`, use `MIDI_Notes::C(4)`")]] //
55 constexpr int8_t
56 note(Note note, int8_t numOctave) {
57  return note(numOctave);
58 }
59 
60 } // namespace MIDI_Notes
61 
63 
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
constexpr static Note Ab()
Definition: Notes.hpp:34
constexpr static Note E()
Definition: Notes.hpp:30
constexpr static Note Gb()
Definition: Notes.hpp:32
constexpr static Note Db()
Definition: Notes.hpp:27
int8_t base
Definition: Notes.hpp:18
constexpr static Note C()
Definition: Notes.hpp:26
constexpr static Note B()
Definition: Notes.hpp:37
constexpr static Note Eb()
Definition: Notes.hpp:29
constexpr static Note G()
Definition: Notes.hpp:33
constexpr Note(int8_t base)
Definition: Notes.hpp:19
constexpr static Note A()
Definition: Notes.hpp:35
constexpr static Note Bb()
Definition: Notes.hpp:36
constexpr int8_t operator()(int8_t octave=-1) const
Definition: Notes.hpp:22
constexpr static Note D()
Definition: Notes.hpp:28
constexpr static Note F_()
Definition: Notes.hpp:31
MIDI note names.
Definition: Notes.hpp:14
constexpr Note F_
F (Fa)
Definition: Notes.hpp:45
constexpr Note Bb
A♯, B♭ (La sharp, Si flat)
Definition: Notes.hpp:50
constexpr Note Db
C♯, D♭ (Do sharp, Re flat)
Definition: Notes.hpp:41
constexpr int8_t note(Note note, int8_t numOctave)
Get the MIDI note in the given octave.
Definition: Notes.hpp:56
constexpr Note Gb
F♯, G♭ (Fa sharp, Sol flat)
Definition: Notes.hpp:46
constexpr Note G
G (Sol)
Definition: Notes.hpp:47
constexpr Note Eb
D♯, E♭ (Re sharp, Mi flat)
Definition: Notes.hpp:43
constexpr Note Ab
G♯, A♭ (Sol sharp, La flat)
Definition: Notes.hpp:48
constexpr Note E
E (Mi)
Definition: Notes.hpp:44
constexpr Note B
B (Si)
Definition: Notes.hpp:51
constexpr Note A
A (La)
Definition: Notes.hpp:49
constexpr Note C
C (Do)
Definition: Notes.hpp:40
constexpr Note D
D (Re)
Definition: Notes.hpp:42