mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 15:25:01 +01:00
first pass at integrating nutempo v1 with new 64 bit superclock/ticks representation
This compiles libtemporal, but nothing more
This commit is contained in:
parent
e0b5b12129
commit
a80960468d
7 changed files with 1227 additions and 155 deletions
|
|
@ -1,39 +1,27 @@
|
|||
/*
|
||||
* Copyright (C) 2017 Paul Davis <paul@linuxaudiosystems.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
Copyright (C) 2002-2010 Paul Davis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
|
||||
#include "temporal/bbt_time.h"
|
||||
|
||||
using namespace Timecode;
|
||||
|
||||
/* This defines the smallest division of a "beat".
|
||||
|
||||
The number is intended to have as many integer factors as possible so that
|
||||
1/Nth divisions are integer numbers of ticks.
|
||||
|
||||
1920 has many factors, though going up to 3840 gets a couple more.
|
||||
|
||||
This needs to match Temporal::Beats::PPQN
|
||||
*/
|
||||
|
||||
const double BBT_Time::ticks_per_beat = 1920.0;
|
||||
using namespace Temporal;
|
||||
|
||||
BBT_Offset::BBT_Offset (double dbeats)
|
||||
{
|
||||
|
|
@ -46,5 +34,53 @@ BBT_Offset::BBT_Offset (double dbeats)
|
|||
|
||||
bars = 0;
|
||||
beats = lrint (floor (dbeats));
|
||||
ticks = lrint (floor (BBT_Time::ticks_per_beat * fmod (dbeats, 1.0)));
|
||||
ticks = lrint (floor (Temporal::ticks_per_beat * fmod (dbeats, 1.0)));
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
std::operator<< (std::ostream& o, Temporal::BBT_Time const & bbt)
|
||||
{
|
||||
o << bbt.bars << '|' << bbt.beats << '|' << bbt.ticks;
|
||||
return o;
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
std::operator<< (std::ostream& o, const Temporal::BBT_Offset& bbt)
|
||||
{
|
||||
o << bbt.bars << '|' << bbt.beats << '|' << bbt.ticks;
|
||||
return o;
|
||||
}
|
||||
|
||||
std::istream&
|
||||
std::operator>>(std::istream& i, Temporal::BBT_Offset& bbt)
|
||||
{
|
||||
int32_t B, b, t;
|
||||
char skip_pipe_char;
|
||||
|
||||
i >> B;
|
||||
i >> skip_pipe_char;
|
||||
i >> b;
|
||||
i >> skip_pipe_char;
|
||||
i >> t;
|
||||
|
||||
bbt = Temporal::BBT_Time (B, b, t);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
std::istream&
|
||||
std::operator>>(std::istream& i, Temporal::BBT_Time& bbt)
|
||||
{
|
||||
int32_t B, b, t;
|
||||
char skip_pipe_char;
|
||||
|
||||
i >> B;
|
||||
i >> skip_pipe_char;
|
||||
i >> b;
|
||||
i >> skip_pipe_char;
|
||||
i >> t;
|
||||
|
||||
bbt = Temporal::BBT_Time (B, b, t);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue