editor: remove a couple of unnecessary uses of Beats::from_double() and uses ::ticks() method instead

This commit is contained in:
Paul Davis 2022-06-22 13:14:47 -06:00
parent 22e77130e2
commit 1de542120a

View File

@ -4317,7 +4317,8 @@ Editor::get_grid_type_as_beats (bool& success, timepos_t const & position)
int32_t const divisions = get_grid_beat_divisions (_grid_type); int32_t const divisions = get_grid_beat_divisions (_grid_type);
/* Beat (+1), and Bar (-1) are handled below */ /* Beat (+1), and Bar (-1) are handled below */
if (divisions > 1) { if (divisions > 1) {
return Temporal::Beats::from_double (1.0 / (double) divisions); /* grid divisions are divisions of a 1/4 note */
return Temporal::Beats::ticks(Temporal::Beats::PPQN / divisions);
} }
TempoMap::SharedPtr tmap (TempoMap::use()); TempoMap::SharedPtr tmap (TempoMap::use());
@ -4389,11 +4390,11 @@ Temporal::Beats
Editor::get_draw_length_as_beats (bool& success, timepos_t const & position) Editor::get_draw_length_as_beats (bool& success, timepos_t const & position)
{ {
success = true; success = true;
GridType grid_to_use = draw_length() == DRAW_LEN_AUTO ? grid_type() : draw_length(); GridType grid_to_use = draw_length() == DRAW_LEN_AUTO ? grid_type() : draw_length();
int32_t const divisions = get_grid_beat_divisions (grid_to_use); int32_t const divisions = get_grid_beat_divisions (grid_to_use);
if (divisions != 0) { if (divisions != 0) {
return Temporal::Beats::from_double (1.0 / fabs (divisions)); return Temporal::Beats::ticks (Temporal::Beats::PPQN / divisions);
} }
success = false; success = false;