Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
tuning.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <compare>
6#include <cstdint>
7#include <optional>
8
9namespace pulp::timeline {
10
14
19enum class TuningSystem : std::uint8_t {
30};
31
33inline constexpr std::uint32_t kDefaultReferencePitchMillihertz = 440'000;
35inline constexpr std::uint32_t kMinReferencePitchMillihertz = 20'000;
37inline constexpr std::uint32_t kMaxReferencePitchMillihertz = 20'000'000;
38
50 std::optional<ContentHash> scale_content;
53 std::optional<ContentHash> keyboard_map_content;
54
55 constexpr auto operator<=>(const TuningReference&) const = default;
56};
57
63constexpr bool valid_tuning_reference(const TuningReference& tuning) noexcept {
64 if (tuning.reference_pitch_millihertz < kMinReferencePitchMillihertz ||
65 tuning.reference_pitch_millihertz > kMaxReferencePitchMillihertz)
66 return false;
67 switch (tuning.system) {
70 return !tuning.scale_content && !tuning.keyboard_map_content;
72 return tuning.scale_content && tuning.scale_content->valid() &&
73 (!tuning.keyboard_map_content || tuning.keyboard_map_content->valid());
74 }
75 return false;
76}
77
79
80} // namespace pulp::timeline
constexpr std::uint32_t kMinReferencePitchMillihertz
Lowest reference pitch a document may state, in millihertz.
Definition tuning.hpp:35
constexpr std::uint32_t kDefaultReferencePitchMillihertz
Reference pitch for A4 that a document states when it states nothing else.
Definition tuning.hpp:33
constexpr bool valid_tuning_reference(const TuningReference &tuning) noexcept
Returns whether a tuning reference is internally consistent.
Definition tuning.hpp:63
constexpr std::uint32_t kMaxReferencePitchMillihertz
Highest reference pitch a document may state, in millihertz.
Definition tuning.hpp:37
TuningSystem
How a document states the mapping from note number to pitch.
Definition tuning.hpp:19
@ EqualTemperament
Twelve equal divisions of the octave against the stated reference pitch.
Definition tuning.hpp:21
@ Scala
A sealed Scala scale, and optionally a sealed keyboard mapping.
Definition tuning.hpp:29
@ MtsEsp
Defer to whichever MTS-ESP master is present when the document plays.
Definition tuning.hpp:27
Definition program_compiler.hpp:18
Durable statement of the tuning a project or one instrument plays in.
Definition tuning.hpp:46
TuningSystem system
Definition tuning.hpp:47
std::uint32_t reference_pitch_millihertz
Definition tuning.hpp:48
constexpr auto operator<=>(const TuningReference &) const =default
std::optional< ContentHash > scale_content
Sealed .scl payload. Required when system is Scala, absent otherwise.
Definition tuning.hpp:50
std::optional< ContentHash > keyboard_map_content
Sealed .kbm payload.
Definition tuning.hpp:53