A validated musical grid whose phase restarts at every authored bar. More...
#include <snap_grid.hpp>
Public Member Functions | |
| timebase::TickPosition | snap (const timebase::CompiledMeterMap &meter_map, timebase::TickPosition position, SnapDirection direction=SnapDirection::Nearest) const noexcept |
| Snap position without leaving the signed tick domain. | |
| timebase::TickDuration | interval () const noexcept |
| timebase::SwingRatio | swing () const noexcept |
Static Public Member Functions | |
| static runtime::Result< SnapGrid, SnapGridError > | create (timebase::TickDuration interval, timebase::SwingRatio swing=timebase::kStraightSwing) noexcept |
A validated musical grid whose phase restarts at every authored bar.
The interval is expressed in ticks so callers can offer straight, dotted, triplet or custom resolutions without a UI enum leaking into the kernel. Every bar boundary is also a grid boundary, including when the interval does not divide that bar. Swing warps interior boundaries in pairs and is restarted from the bar, so a meter change cannot inherit the previous signature's phase.
|
staticnoexcept |
|
inlinenoexcept |
|
noexcept |
Snap position without leaving the signed tick domain.
All directions include an exact boundary. Nearest resolves an exact midpoint toward the later tick so two input devices cannot disagree through incidental rounding. A directional request with no representable boundary on that side clamps to the signed endpoint; nearest still chooses a real representable boundary on the other side.
|
inlinenoexcept |