2 * Copyright (C) 2017 Paul Davis <paul@linuxaudiosystems.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "temporal/bbt_time.h"
24 using namespace Timecode;
26 /* This defines the smallest division of a "beat".
28 The number is intended to have as many integer factors as possible so that
29 1/Nth divisions are integer numbers of ticks.
31 1920 has many factors, though going up to 3840 gets a couple more.
33 This needs to match Temporal::Beats::PPQN
36 const double BBT_Time::ticks_per_beat = 1920.0;
38 BBT_Offset::BBT_Offset (double dbeats)
40 /* NOTE: this does not construct a BBT time in a canonical form,
41 in that beats may be a very large number, and bars will
42 always be zero. Hence ... it's a BBT_Offset
48 beats = lrint (floor (dbeats));
49 ticks = lrint (floor (BBT_Time::ticks_per_beat * fmod (dbeats, 1.0)));