Control Surface master
MIDI Control Surface library for Arduino
Frequency.hpp
Go to the documentation of this file.
1#pragma once
2
4AH_DIAGNOSTIC_WERROR() // Enable errors on warnings
5
6#include <AH/Settings/NamespaceSettings.hpp>
7
9
11class Frequency {
12 public:
13 explicit constexpr Frequency(unsigned long hertz) : hertz(hertz) {}
14 constexpr operator unsigned long() const { return hertz; }
15
16 private:
17 unsigned long hertz;
18};
19constexpr Frequency operator"" _Hz(unsigned long long hz) {
20 return Frequency{(unsigned long)hz};
21}
22constexpr Frequency operator"" _kHz(long double khz) {
23 return Frequency{(unsigned long)(khz * 1E3l)};
24}
25constexpr Frequency operator"" _kHz(unsigned long long khz) {
26 return Frequency{(unsigned long)(khz * 1E3)};
27}
28constexpr Frequency operator"" _MHz(long double mhz) {
29 return Frequency{(unsigned long)(mhz * 1E6l)};
30}
31constexpr Frequency operator"" _MHz(unsigned long long mhz) {
32 return Frequency{(unsigned long)(mhz * 1E6)};
33}
34
36
#define END_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
#define AH_DIAGNOSTIC_POP()
Definition: Warnings.hpp:36
#define AH_DIAGNOSTIC_WERROR()
Definition: Warnings.hpp:35
Type-safe class for frequency values.
Definition: Frequency.hpp:11
unsigned long hertz
Definition: Frequency.hpp:17
constexpr Frequency(unsigned long hertz)
Definition: Frequency.hpp:13