17inline double grid_rate(
double seconds,
double tempo,
bool note_value)
noexcept
19 if(!(seconds > 0.) || !(tempo > 0.))
21 double whole_notes = seconds * tempo / 240.;
24 constexpr double unit = 256. * 9. * 5. * 7.;
25 whole_notes = std::max(1., std::round(whole_notes * unit)) / unit;
27 return 1. / whole_notes;
39void for_each_pulse_point(
40 double start,
double end,
double origin,
double unit,
double quarters_in_bar,
43 if(!(end > start) || !(unit > 0.) || !(quarters_in_bar > 0.))
45 const auto point = [&](int64_t k) {
return origin + double(k) * unit; };
46 auto k = int64_t(std::ceil((start - origin) / unit));
47 while(point(k - 1) >= start)
49 while(point(k) < start)
54 constexpr double tolerance = 1e-4;
55 for(
int count = 0; count < 1024; count++, k++)
57 const double p = point(k);
62 + std::floor((p - origin) / quarters_in_bar + tolerance) * quarters_in_bar;
63 const auto first_in_bar = int64_t(std::ceil((bar - origin) / unit - tolerance));
64 f(p, k - first_in_bar);