Loading...
Searching...
No Matches
score::note_values Namespace Reference

Detailed Description

The note values a time or grid chooser's knob steps through: straight, dotted and triplet, from 1/64th to four whole notes.

Classes

struct  NoteValue
 

Enumerations

enum class  Feel : uint8_t { Straight , Dotted , Triplet }
 

Functions

constexpr Feel feelOf (int index) noexcept
 
constexpr double position (int index) noexcept
 The knob position, 0..1, of a note value.
 
int indexAt (double v01) noexcept
 The note value at a knob position.
 
double snapPosition (double v01, Feel feel, bool fullTable) noexcept
 
int nearest (float frac) noexcept
 The note value nearest to a fraction of a whole note.
 
int nearest (float frac, Feel feel) noexcept
 The note value of that feel nearest to a fraction of a whole note.
 
float straightLength (int index) noexcept
 How long the note is, straight: a dotted note is 3/2 of it, a triplet 2/3.
 
float withFeel (float straight, Feel feel) noexcept
 

Variables

constexpr NoteValue table []
 
constexpr int count = std::ssize(table)
 
constexpr int eighth = 8
 

Function Documentation

◆ snapPosition()

double score::note_values::snapPosition ( double  v01,
Feel  feel,
bool  fullTable 
)
inlinenoexcept

Snap a 0..1 knob position onto a note value of that feel (any with fullTable), so that the knob angle, the emitted value and the execution feedback all land on the exact same positions.

Variable Documentation

◆ table

constexpr NoteValue score::note_values::table[]
inlineconstexpr
Initial value:
= {
{1.f / 64.f, "1/64"}, {1.f / 48.f, "1/32T"}, {1.f / 32.f, "1/32"},
{1.f / 24.f, "1/16T"}, {3.f / 64.f, "1/32."}, {1.f / 16.f, "1/16"},
{1.f / 12.f, "1/8T"}, {3.f / 32.f, "1/16."}, {1.f / 8.f, "1/8"},
{1.f / 6.f, "1/4T"}, {3.f / 16.f, "1/8."}, {1.f / 4.f, "1/4"},
{1.f / 3.f, "1/2T"}, {3.f / 8.f, "1/4."}, {1.f / 2.f, "1/2"},
{2.f / 3.f, "1/1T"}, {3.f / 4.f, "1/2."}, {1.f, "1/1"},
{3.f / 2.f, "1/1."}, {2.f, "2/1"}, {3.f, "2/1."},
{4.f, "4/1"},
}