LCOV - code coverage report
Current view: top level - src/MIDI_Constants - Notes.hpp (source / functions) Coverage Total Hit
Test: 73449d9b107c772cf65493691543348214e5d5eb Lines: 100.0 % 3 3
Test Date: 2026-06-06 17:44:35 Functions: 100.0 % 2 2
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* ✔ */
       2              : 
       3              : #pragma once
       4              : 
       5              : #include <Settings/NamespaceSettings.hpp>
       6              : #include <stdint.h>
       7              : 
       8              : BEGIN_CS_NAMESPACE
       9              : 
      10              : /// @addtogroup    MIDIConstants
      11              : /// @{
      12              : 
      13              : /// MIDI note names.
      14              : /// Uses the [Scientific Pitch Notation system](https://en.wikipedia.org/wiki/Scientific_pitch_notation),
      15              : /// where <b>A<sub>4</sub></b> is 440 Hz, and <b>C<sub>-1</sub></b> is 8.1758 Hz.
      16              : ///
      17              : /// |Octave| C |C♯/D♭| D |D♯/E♭| E | F  |F♯/G♭| G |G♯/A♭| A |A♯/B♭| B  |
      18              : /// |:-----|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|
      19              : /// |-1    |   0|   1|   2|   3|   4|   5|   6|   7|   8|   9|  10|  11|
      20              : /// |0     |  12|  13|  14|  15|  16|  17|  18|  19|  20|  21|  22|  23|
      21              : /// |1     |  24|  25|  26|  27|  28|  29|  30|  31|  32|  33|  34|  35|
      22              : /// |2     |  36|  37|  38|  39|  40|  41|  42|  43|  44|  45|  46|  47|
      23              : /// |3     |  48|  49|  50|  51|  52|  53|  54|  55|  56|  57|  58|  59|
      24              : /// |4     |  60|  61|  62|  63|  64|  65|  66|  67|  68|  69|  70|  71|
      25              : /// |5     |  72|  73|  74|  75|  76|  77|  78|  79|  80|  81|  82|  83|
      26              : /// |6     |  84|  85|  86|  87|  88|  89|  90|  91|  92|  93|  94|  95|
      27              : /// |7     |  96|  97|  98|  99| 100| 101| 102| 103| 104| 105| 106| 107|
      28              : /// |8     | 108| 109| 110| 111| 112| 113| 114| 115| 116| 117| 118| 119|
      29              : namespace MIDI_Notes {
      30              : 
      31              : class Note {
      32              :   private:
      33              :     int8_t base;
      34              :     constexpr Note(int8_t base) : base(base) {}
      35              : 
      36              :   public:
      37            4 :     constexpr int8_t operator()(int8_t octave = -1) const {
      38            4 :         return base + 12 * (octave + 1);
      39              :     }
      40            4 :     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              : 
      56              : constexpr Note C = (Note::C)();   ///< C (Do)
      57              : constexpr Note Db = (Note::Db)(); ///< C♯, D♭ (Do sharp, Re flat)
      58              : constexpr Note D = (Note::D)();   ///< D (Re)
      59              : constexpr Note Eb = (Note::Eb)(); ///< D♯, E♭ (Re sharp, Mi flat)
      60              : constexpr Note E = (Note::E)();   ///< E (Mi)
      61              : constexpr Note F = (Note::F)();   ///< F (Fa)
      62              : constexpr Note Gb = (Note::Gb)(); ///< F♯, G♭ (Fa sharp, Sol flat)
      63              : constexpr Note G = (Note::G)();   ///< G (Sol)
      64              : constexpr Note Ab = (Note::Ab)(); ///< G♯, A♭ (Sol sharp, La flat)
      65              : constexpr Note A = (Note::A)();   ///< A (La)
      66              : constexpr Note Bb = (Note::Bb)(); ///< A♯, B♭ (La sharp, Si flat)
      67              : constexpr Note B = (Note::B)();   ///< B (Si)
      68              : 
      69              : CS_DEPREC("Instead of `MIDI_Notes::F_(4)`, use `MIDI_Notes::F[4]`")
      70              : constexpr Note F_ = (Note::F)(); ///< F (Fa)
      71              : 
      72              : /// Get the MIDI note in the given octave.
      73              : CS_DEPREC("Instead of `note(C, 4)`, use `MIDI_Notes::C(4)`")
      74              : constexpr int8_t note(Note note, int8_t numOctave) { return note(numOctave); }
      75              : 
      76              : } // namespace MIDI_Notes
      77              : 
      78              : /// @}
      79              : 
      80              : END_CS_NAMESPACE
        

Generated by: LCOV version 2.4-beta