Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
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
29namespace MIDI_Notes {
30
31class Note {
32 private:
33 int8_t base;
34 constexpr Note(int8_t base) : base(base) {}
35
36 public:
37 constexpr int8_t operator()(int8_t octave = -1) const {
38 return base + 12 * (octave + 1);
39 }
40 constexpr int8_t operator[](int8_t octave) const { return (*this)(octave); }
41
42 constexpr static Note(C)() { return Note {0}; }
43 constexpr static Note(Db)() { return Note {1}; }
44 constexpr static Note(D)() { return Note {2}; }
45 constexpr static Note(Eb)() { return Note {3}; }
46 constexpr static Note(E)() { return Note {4}; }
47 constexpr static Note(F)() { return Note {5}; }
48 constexpr static Note(Gb)() { return Note {6}; }
49 constexpr static Note(G)() { return Note {7}; }
50 constexpr static Note(Ab)() { return Note {8}; }
51 constexpr static Note(A)() { return Note {9}; }
52 constexpr static Note(Bb)() { return Note {10}; }
53 constexpr static Note(B)() { return Note {11}; }
54};
55
56constexpr Note C = (Note::C)();
57constexpr Note Db = (Note::Db)();
58constexpr Note D = (Note::D)();
59constexpr Note Eb = (Note::Eb)();
60constexpr Note E = (Note::E)();
61constexpr Note F = (Note::F)();
62constexpr Note Gb = (Note::Gb)();
63constexpr Note G = (Note::G)();
64constexpr Note Ab = (Note::Ab)();
65constexpr Note A = (Note::A)();
66constexpr Note Bb = (Note::Bb)();
67constexpr Note B = (Note::B)();
68
69CS_DEPREC("Instead of `MIDI_Notes::F_(4)`, use `MIDI_Notes::F[4]`")
70constexpr Note F_ = (Note::F)();
71
73CS_DEPREC("Instead of `note(C, 4)`, use `MIDI_Notes::C(4)`")
74constexpr int8_t note(Note note, int8_t numOctave) { return note(numOctave); }
75
76} // namespace MIDI_Notes
77
79
#define CS_DEPREC(...)
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
static constexpr Note F()
Definition Notes.hpp:47
static constexpr Note A()
Definition Notes.hpp:51
constexpr int8_t operator[](int8_t octave) const
Definition Notes.hpp:40
static constexpr Note Bb()
Definition Notes.hpp:52
static constexpr Note E()
Definition Notes.hpp:46
static constexpr Note D()
Definition Notes.hpp:44
static constexpr Note Db()
Definition Notes.hpp:43
constexpr Note(int8_t base)
Definition Notes.hpp:34
static constexpr Note C()
Definition Notes.hpp:42
static constexpr Note Eb()
Definition Notes.hpp:45
constexpr int8_t operator()(int8_t octave=-1) const
Definition Notes.hpp:37
static constexpr Note G()
Definition Notes.hpp:49
static constexpr Note Gb()
Definition Notes.hpp:48
static constexpr Note B()
Definition Notes.hpp:53
static constexpr Note Ab()
Definition Notes.hpp:50
MIDI note names.
Definition Notes.hpp:29
constexpr Note F_
F (Fa)
Definition Notes.hpp:70
constexpr int8_t note(Note note, int8_t numOctave)
Get the MIDI note in the given octave.
Definition Notes.hpp:74
constexpr Note Bb
A♯, B♭ (La sharp, Si flat)
Definition Notes.hpp:66
constexpr Note Db
C♯, D♭ (Do sharp, Re flat)
Definition Notes.hpp:57
constexpr Note F
F (Fa)
Definition Notes.hpp:61
constexpr Note Gb
F♯, G♭ (Fa sharp, Sol flat)
Definition Notes.hpp:62
constexpr Note G
G (Sol)
Definition Notes.hpp:63
constexpr Note Eb
D♯, E♭ (Re sharp, Mi flat)
Definition Notes.hpp:59
constexpr Note Ab
G♯, A♭ (Sol sharp, La flat)
Definition Notes.hpp:64
constexpr Note E
E (Mi)
Definition Notes.hpp:60
constexpr Note B
B (Si)
Definition Notes.hpp:67
constexpr Note A
A (La)
Definition Notes.hpp:65
constexpr Note C
C (Do)
Definition Notes.hpp:56
constexpr Note D
D (Re)
Definition Notes.hpp:58