remove empty sigc++2 directory

git-svn-id: svn://localhost/ardour2/branches/3.0@3432 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Doug McLain
2008-06-02 05:02:28 +00:00
parent 2f3f697bb8
commit 9c0d7d72d7
2797 changed files with 0 additions and 992363 deletions

View File

@@ -1,58 +0,0 @@
# -*- python -*-
import os
import os.path
import glob
Import('env final_prefix install_prefix final_config_prefix libraries i18n')
cp = env.Copy()
#
# this defines the version number of libardour_cp
#
domain = 'ardour_cp'
cp.Append(DOMAIN = domain, MAJOR = 1, MINOR = 0, MICRO = 0)
cp.Append(CXXFLAGS = "-DPACKAGE=\\\"" + domain + "\\\"")
cp.Append(CXXFLAGS="-DLIBSIGC_DISABLE_DEPRECATED")
cp.Append(PACKAGE = domain)
cp.Append(POTFILE = domain + '.pot')
cp_files=Split("""
basic_ui.cc
control_protocol.cc
smpte.cc
""")
cp.Append(CCFLAGS="-D_REENTRANT -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE")
cp.Append(CXXFLAGS="-DDATA_DIR=\\\""+final_prefix+"/share\\\"")
cp.Append(CXXFLAGS="-DCONFIG_DIR=\\\""+final_config_prefix+"\\\"")
cp.Append(CXXFLAGS="-DLOCALEDIR=\\\""+final_prefix+"/share/locale\\\"")
cp.Merge ([
libraries['ardour'],
libraries['sndfile-ardour'],
libraries['sigc2'],
libraries['pbd'],
libraries['midi++2'],
libraries['xml'],
libraries['usb'],
libraries['glib2'],
libraries['glibmm2']
])
libardour_cp = cp.SharedLibrary('ardour_cp', cp_files)
Default(libardour_cp)
if env['NLS']:
i18n (cp, cp_files, env)
env.Alias('install', env.Install(os.path.join(install_prefix, env['LIBDIR'], 'ardour3'), libardour_cp))
env.Alias('tarball', env.Distribute (env['DISTTREE'],
[ 'SConscript' ] +
cp_files +
glob.glob('po/*.po') + glob.glob('*.h') + glob.glob('control_protocol/*.h')))

View File

@@ -1,282 +0,0 @@
/*
Copyright (C) 2006 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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <pbd/pthread_utils.h>
#include <ardour/session.h>
#include <ardour/location.h>
#include <control_protocol/basic_ui.h>
#include "i18n.h"
using namespace ARDOUR;
using ARDOUR::nframes_t;
BasicUI::BasicUI (Session& s)
: session (&s)
{
}
BasicUI::BasicUI ()
: session (0)
{
}
BasicUI::~BasicUI ()
{
}
void
BasicUI::register_thread (std::string name)
{
PBD::ThreadCreated (pthread_self(), name);
}
void
BasicUI::loop_toggle ()
{
if (session->get_play_loop()) {
session->request_play_loop (false);
} else {
session->request_play_loop (true);
if (!session->transport_rolling()) {
session->request_transport_speed (1.0);
}
}
}
void
BasicUI::goto_start ()
{
session->goto_start ();
}
void
BasicUI::goto_end ()
{
session->goto_end ();
}
void
BasicUI::add_marker ()
{
nframes_t when = session->audible_frame();
session->locations()->add (new Location (when, when, _("unnamed"), Location::IsMark));
}
void
BasicUI::rewind ()
{
session->request_transport_speed (-2.0f);
}
void
BasicUI::ffwd ()
{
session->request_transport_speed (2.0f);
}
void
BasicUI::transport_stop ()
{
session->request_transport_speed (0.0);
}
void
BasicUI::transport_play (bool from_last_start)
{
bool rolling = session->transport_rolling ();
if (session->get_play_loop()) {
session->request_play_loop (false);
}
if (session->get_play_range ()) {
session->request_play_range (false);
}
if (from_last_start && rolling) {
session->request_locate (session->last_transport_start(), true);
}
session->request_transport_speed (1.0f);
}
void
BasicUI::rec_enable_toggle ()
{
switch (session->record_status()) {
case Session::Disabled:
if (session->ntracks() == 0) {
// string txt = _("Please create 1 or more track\nbefore trying to record.\nCheck the Session menu.");
// MessageDialog msg (*editor, txt);
// msg.run ();
return;
}
session->maybe_enable_record ();
break;
case Session::Recording:
case Session::Enabled:
session->disable_record (true);
}
}
void
BasicUI::save_state ()
{
session->save_state ("");
}
void
BasicUI::prev_marker ()
{
Location *location = session->locations()->first_location_before (session->transport_frame());
if (location) {
session->request_locate (location->start(), session->transport_rolling());
} else {
session->goto_start ();
}
}
void
BasicUI::next_marker ()
{
Location *location = session->locations()->first_location_after (session->transport_frame());
if (location) {
session->request_locate (location->start(), session->transport_rolling());
} else {
session->request_locate (session->current_end_frame());
}
}
void
BasicUI::set_transport_speed (float speed)
{
session->request_transport_speed (speed);
}
float
BasicUI::get_transport_speed ()
{
return session->transport_speed ();
}
void
BasicUI::undo ()
{
session->undo (1);
}
void
BasicUI::redo ()
{
session->redo (1);
}
void
BasicUI::toggle_all_rec_enables ()
{
if (session->get_record_enabled()) {
session->record_disenable_all ();
} else {
session->record_enable_all ();
}
}
void
BasicUI::toggle_punch_in ()
{
Config->set_punch_in (!Config->get_punch_in());
}
void
BasicUI::toggle_punch_out ()
{
Config->set_punch_out (!Config->get_punch_out());
}
bool
BasicUI::get_record_enabled ()
{
return session->get_record_enabled();
}
void
BasicUI::set_record_enable (bool yn)
{
if (yn) {
session->maybe_enable_record ();
} else {
session->disable_record (false, true);
}
}
nframes_t
BasicUI::transport_frame ()
{
return session->transport_frame();
}
void
BasicUI::locate (nframes_t where, bool roll_after_locate)
{
session->request_locate (where, roll_after_locate);
}
bool
BasicUI::locating ()
{
return session->locate_pending();
}
bool
BasicUI::locked ()
{
return session->transport_locked ();
}
nframes_t
BasicUI::smpte_frames_per_hour ()
{
return session->smpte_frames_per_hour ();
}
void
BasicUI::smpte_time (nframes_t where, SMPTE::Time& smpte)
{
session->smpte_time (where, *((SMPTE::Time *) &smpte));
}
void
BasicUI::smpte_to_sample (SMPTE::Time& smpte, nframes_t& sample, bool use_offset, bool use_subframes) const
{
session->smpte_to_sample (*((SMPTE::Time*)&smpte), sample, use_offset, use_subframes);
}
void
BasicUI::sample_to_smpte (nframes_t sample, SMPTE::Time& smpte, bool use_offset, bool use_subframes) const
{
session->sample_to_smpte (sample, *((SMPTE::Time*)&smpte), use_offset, use_subframes);
}

View File

@@ -1,342 +0,0 @@
/*
Copyright (C) 2006 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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <ardour/session.h>
#include <ardour/route.h>
#include <ardour/audio_track.h>
#include <ardour/meter.h>
#include <control_protocol/control_protocol.h>
using namespace ARDOUR;
using namespace std;
sigc::signal<void> ControlProtocol::ZoomToSession;
sigc::signal<void> ControlProtocol::ZoomOut;
sigc::signal<void> ControlProtocol::ZoomIn;
sigc::signal<void> ControlProtocol::Enter;
sigc::signal<void,float> ControlProtocol::ScrollTimeline;
ControlProtocol::ControlProtocol (Session& s, string str)
: BasicUI (s),
_name (str)
{
_active = false;
session->RouteAdded.connect (mem_fun(*this, &ControlProtocol::add_strip));
}
ControlProtocol::~ControlProtocol ()
{
}
void
ControlProtocol::add_strip (std::list<boost::shared_ptr<ARDOUR::Route> >)
{
route_list_changed();
}
void
ControlProtocol::next_track (uint32_t initial_id)
{
uint32_t limit = session->nroutes();
boost::shared_ptr<Route> cr = route_table[0];
uint32_t id;
if (cr) {
id = cr->remote_control_id ();
} else {
id = 0;
}
if (id == limit) {
id = 0;
} else {
id++;
}
while (id < limit) {
if ((cr = session->route_by_remote_id (id)) != 0) {
break;
}
id++;
}
if (id == limit) {
id = 0;
while (id != initial_id) {
if ((cr = session->route_by_remote_id (id)) != 0) {
break;
}
id++;
}
}
route_table[0] = cr;
}
void
ControlProtocol::prev_track (uint32_t initial_id)
{
uint32_t limit = session->nroutes() - 1;
boost::shared_ptr<Route> cr = route_table[0];
uint32_t id;
if (cr) {
id = cr->remote_control_id ();
} else {
id = 0;
}
if (id == 0) {
id = session->nroutes() - 1;
} else {
id--;
}
while (id >= 0) {
if ((cr = session->route_by_remote_id (id)) != 0) {
break;
}
id--;
}
if (id < 0) {
id = limit;
while (id > initial_id) {
if ((cr = session->route_by_remote_id (id)) != 0) {
break;
}
id--;
}
}
route_table[0] = cr;
}
void
ControlProtocol::set_route_table_size (uint32_t size)
{
while (route_table.size() < size) {
route_table.push_back (boost::shared_ptr<Route> ((Route*) 0));
}
}
void
ControlProtocol::set_route_table (uint32_t table_index, boost::shared_ptr<ARDOUR::Route> r)
{
if (table_index >= route_table.size()) {
return;
}
route_table[table_index] = r;
// XXX SHAREDPTR need to handle r->GoingAway
}
bool
ControlProtocol::set_route_table (uint32_t table_index, uint32_t remote_control_id)
{
boost::shared_ptr<Route> r = session->route_by_remote_id (remote_control_id);
if (!r) {
return false;
}
set_route_table (table_index, r);
return true;
}
void
ControlProtocol::route_set_rec_enable (uint32_t table_index, bool yn)
{
if (table_index > route_table.size()) {
return;
}
boost::shared_ptr<Route> r = route_table[table_index];
boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r);
if (at) {
at->set_record_enable (yn, this);
}
}
bool
ControlProtocol::route_get_rec_enable (uint32_t table_index)
{
if (table_index > route_table.size()) {
return false;
}
boost::shared_ptr<Route> r = route_table[table_index];
boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r);
if (at) {
return at->record_enabled ();
}
return false;
}
float
ControlProtocol::route_get_gain (uint32_t table_index)
{
if (table_index > route_table.size()) {
return 0.0f;
}
boost::shared_ptr<Route> r = route_table[table_index];
if (r == 0) {
return 0.0f;
}
return r->gain ();
}
void
ControlProtocol::route_set_gain (uint32_t table_index, float gain)
{
if (table_index > route_table.size()) {
return;
}
boost::shared_ptr<Route> r = route_table[table_index];
if (r != 0) {
r->set_gain (gain, this);
}
}
float
ControlProtocol::route_get_effective_gain (uint32_t table_index)
{
if (table_index > route_table.size()) {
return 0.0f;
}
boost::shared_ptr<Route> r = route_table[table_index];
if (r == 0) {
return 0.0f;
}
return r->effective_gain ();
}
float
ControlProtocol::route_get_peak_input_power (uint32_t table_index, uint32_t which_input)
{
if (table_index > route_table.size()) {
return 0.0f;
}
boost::shared_ptr<Route> r = route_table[table_index];
if (r == 0) {
return 0.0f;
}
return r->peak_meter().peak_power (which_input);
}
bool
ControlProtocol::route_get_muted (uint32_t table_index)
{
if (table_index > route_table.size()) {
return false;
}
boost::shared_ptr<Route> r = route_table[table_index];
if (r == 0) {
return false;
}
return r->muted ();
}
void
ControlProtocol::route_set_muted (uint32_t table_index, bool yn)
{
if (table_index > route_table.size()) {
return;
}
boost::shared_ptr<Route> r = route_table[table_index];
if (r != 0) {
r->set_mute (yn, this);
}
}
bool
ControlProtocol::route_get_soloed (uint32_t table_index)
{
if (table_index > route_table.size()) {
return false;
}
boost::shared_ptr<Route> r = route_table[table_index];
if (r == 0) {
return false;
}
return r->soloed ();
}
void
ControlProtocol::route_set_soloed (uint32_t table_index, bool yn)
{
if (table_index > route_table.size()) {
return;
}
boost::shared_ptr<Route> r = route_table[table_index];
if (r != 0) {
r->set_solo (yn, this);
}
}
string
ControlProtocol:: route_get_name (uint32_t table_index)
{
if (table_index > route_table.size()) {
return "";
}
boost::shared_ptr<Route> r = route_table[table_index];
if (r == 0) {
return "";
}
return r->name();
}

View File

@@ -1,84 +0,0 @@
/*
Copyright (C) 2006 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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __ardour_basic_ui_h__
#define __ardour_basic_ui_h__
#include <string>
#include <jack/types.h>
#include <control_protocol/smpte.h>
namespace ARDOUR {
class Session;
}
class BasicUI {
public:
BasicUI (ARDOUR::Session&);
virtual ~BasicUI ();
void add_marker ();
void register_thread (std::string name);
/* transport control */
void loop_toggle ();
void goto_start ();
void goto_end ();
void rewind ();
void ffwd ();
void transport_stop ();
void transport_play (bool jump_back = true);
void set_transport_speed (float speed);
float get_transport_speed ();
jack_nframes_t transport_frame ();
void locate (jack_nframes_t frame, bool play = false);
bool locating ();
bool locked ();
void save_state ();
void prev_marker ();
void next_marker ();
void undo ();
void redo ();
void toggle_punch_in ();
void toggle_punch_out ();
void set_record_enable (bool yn);
bool get_record_enabled ();
void rec_enable_toggle ();
void toggle_all_rec_enables ();
jack_nframes_t smpte_frames_per_hour ();
void smpte_time (jack_nframes_t where, SMPTE::Time&);
void smpte_to_sample (SMPTE::Time& smpte, jack_nframes_t& sample, bool use_offset, bool use_subframes) const;
void sample_to_smpte (jack_nframes_t sample, SMPTE::Time& smpte, bool use_offset, bool use_subframes) const;
protected:
BasicUI ();
ARDOUR::Session* session;
};
#endif /* __ardour_basic_ui_h__ */

View File

@@ -1,129 +0,0 @@
/*
Copyright (C) 2006 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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef ardour_control_protocols_h
#define ardour_control_protocols_h
#include <string>
#include <vector>
#include <list>
#include <boost/shared_ptr.hpp>
#include <sigc++/sigc++.h>
#include <pbd/stateful.h>
#include <control_protocol/basic_ui.h>
namespace ARDOUR {
class Route;
class Session;
class ControlProtocol : public sigc::trackable, public PBD::Stateful, public BasicUI {
public:
ControlProtocol (Session&, std::string name);
virtual ~ControlProtocol();
std::string name() const { return _name; }
virtual int set_active (bool yn) = 0;
bool get_active() const { return _active; }
virtual int set_feedback (bool yn) { return 0; }
virtual bool get_feedback () const { return false; }
virtual void route_list_changed () {}
sigc::signal<void> ActiveChanged;
/* signals that a control protocol can emit and other (presumably graphical)
user interfaces can respond to
*/
static sigc::signal<void> ZoomToSession;
static sigc::signal<void> ZoomIn;
static sigc::signal<void> ZoomOut;
static sigc::signal<void> Enter;
static sigc::signal<void,float> ScrollTimeline;
/* the model here is as follows:
we imagine most control surfaces being able to control
from 1 to N tracks at a time, with a session that may
contain 1 to M tracks, where M may be smaller, larger or
equal to N.
the control surface has a fixed set of physical controllers
which can potentially be mapped onto different tracks/busses
via some mechanism.
therefore, the control protocol object maintains
a table that reflects the current mapping between
the controls and route object.
*/
void set_route_table_size (uint32_t size);
void set_route_table (uint32_t table_index, boost::shared_ptr<ARDOUR::Route>);
bool set_route_table (uint32_t table_index, uint32_t remote_control_id);
void route_set_rec_enable (uint32_t table_index, bool yn);
bool route_get_rec_enable (uint32_t table_index);
float route_get_gain (uint32_t table_index);
void route_set_gain (uint32_t table_index, float);
float route_get_effective_gain (uint32_t table_index);
float route_get_peak_input_power (uint32_t table_index, uint32_t which_input);
bool route_get_muted (uint32_t table_index);
void route_set_muted (uint32_t table_index, bool);
bool route_get_soloed (uint32_t table_index);
void route_set_soloed (uint32_t table_index, bool);
std::string route_get_name (uint32_t table_index);
protected:
std::vector<boost::shared_ptr<ARDOUR::Route> > route_table;
std::string _name;
bool _active;
void add_strip (std::list<boost::shared_ptr<ARDOUR::Route> >);
void next_track (uint32_t initial_id);
void prev_track (uint32_t initial_id);
};
extern "C" {
struct ControlProtocolDescriptor {
const char* name; /* descriptive */
const char* id; /* unique and version-specific */
void* ptr; /* protocol can store a value here */
void* module; /* not for public access */
int mandatory; /* if non-zero, always load and do not make optional */
bool supports_feedback; /* if true, protocol has toggleable feedback mechanism */
bool (*probe)(ControlProtocolDescriptor*);
ControlProtocol* (*initialize)(ControlProtocolDescriptor*,Session*);
void (*destroy)(ControlProtocolDescriptor*,ControlProtocol*);
};
}
}
#endif // ardour_control_protocols_h

View File

@@ -1,70 +0,0 @@
/*
Copyright (C) 2006 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 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.,
675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __ardour_smpte_h__
#define __ardour_smpte_h__
#include <inttypes.h>
namespace SMPTE {
enum Wrap {
NONE = 0,
FRAMES,
SECONDS,
MINUTES,
HOURS
};
struct Time {
bool negative;
uint32_t hours;
uint32_t minutes;
uint32_t seconds;
uint32_t frames; ///< SMPTE frames (not audio samples)
uint32_t subframes; ///< Typically unused
float rate; ///< Frame rate of this Time
static float default_rate;///< Rate to use for default constructor
bool drop; ///< Whether this Time uses dropframe SMPTE
Time(float a_rate = default_rate) {
negative = false;
hours = 0;
minutes = 0;
seconds = 0;
frames = 0;
subframes = 0;
rate = a_rate;
}
};
Wrap increment( Time& smpte );
Wrap decrement( Time& smpte );
Wrap increment_subframes( Time& smpte );
Wrap decrement_subframes( Time& smpte );
Wrap increment_seconds( Time& smpte );
Wrap increment_minutes( Time& smpte );
Wrap increment_hours( Time& smpte );
void frames_floor( Time& smpte );
void seconds_floor( Time& smpte );
void minutes_floor( Time& smpte );
void hours_floor( Time& smpte );
} // namespace SMPTE
#endif // __ardour_smpte_h__

View File

@@ -1,428 +0,0 @@
/*
Copyright (C) 2006 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 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.,
675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define SMPTE_IS_AROUND_ZERO( sm ) (!(sm).frames && !(sm).seconds && !(sm).minutes && !(sm).hours)
#define SMPTE_IS_ZERO( sm ) (!(sm).frames && !(sm).seconds && !(sm).minutes && !(sm).hours && !(sm.subframes))
#include <control_protocol/smpte.h>
#include <ardour/configuration.h>
namespace SMPTE {
float Time::default_rate = 30.0;
/** Increment @a smpte by exactly one frame (keep subframes value).
* Realtime safe.
* @return true if seconds wrap.
*/
Wrap
increment( Time& smpte )
{
Wrap wrap = NONE;
if (smpte.negative) {
if (SMPTE_IS_AROUND_ZERO(smpte) && smpte.subframes) {
// We have a zero transition involving only subframes
smpte.subframes = ARDOUR::Config->get_subframes_per_frame() - smpte.subframes;
smpte.negative = false;
return SECONDS;
}
smpte.negative = false;
wrap = decrement( smpte );
if (!SMPTE_IS_ZERO( smpte )) {
smpte.negative = true;
}
return wrap;
}
switch ((int)ceil(smpte.rate)) {
case 24:
if (smpte.frames == 23) {
smpte.frames = 0;
wrap = SECONDS;
}
break;
case 25:
if (smpte.frames == 24) {
smpte.frames = 0;
wrap = SECONDS;
}
break;
case 30:
if (smpte.drop) {
if (smpte.frames == 29) {
if ( ((smpte.minutes + 1) % 10) && (smpte.seconds == 59) ) {
smpte.frames = 2;
}
else {
smpte.frames = 0;
}
wrap = SECONDS;
}
} else {
if (smpte.frames == 29) {
smpte.frames = 0;
wrap = SECONDS;
}
}
break;
case 60:
if (smpte.frames == 59) {
smpte.frames = 0;
wrap = SECONDS;
}
break;
}
if (wrap == SECONDS) {
if (smpte.seconds == 59) {
smpte.seconds = 0;
wrap = MINUTES;
if (smpte.minutes == 59) {
smpte.minutes = 0;
wrap = HOURS;
smpte.hours++;
} else {
smpte.minutes++;
}
} else {
smpte.seconds++;
}
} else {
smpte.frames++;
}
return wrap;
}
/** Decrement @a smpte by exactly one frame (keep subframes value)
* Realtime safe.
* @return true if seconds wrap. */
Wrap
decrement( Time& smpte )
{
Wrap wrap = NONE;
if (smpte.negative || SMPTE_IS_ZERO(smpte)) {
smpte.negative = false;
wrap = increment( smpte );
smpte.negative = true;
return wrap;
} else if (SMPTE_IS_AROUND_ZERO(smpte) && smpte.subframes) {
// We have a zero transition involving only subframes
smpte.subframes = ARDOUR::Config->get_subframes_per_frame() - smpte.subframes;
smpte.negative = true;
return SECONDS;
}
switch ((int)ceil(smpte.rate)) {
case 24:
if (smpte.frames == 0) {
smpte.frames = 23;
wrap = SECONDS;
}
break;
case 25:
if (smpte.frames == 0) {
smpte.frames = 24;
wrap = SECONDS;
}
break;
case 30:
if (smpte.drop) {
if ((smpte.minutes % 10) && (smpte.seconds == 0)) {
if (smpte.frames <= 2) {
smpte.frames = 29;
wrap = SECONDS;
}
} else if (smpte.frames == 0) {
smpte.frames = 29;
wrap = SECONDS;
}
} else {
if (smpte.frames == 0) {
smpte.frames = 29;
wrap = SECONDS;
}
}
break;
case 60:
if (smpte.frames == 0) {
smpte.frames = 59;
wrap = SECONDS;
}
break;
}
if (wrap == SECONDS) {
if (smpte.seconds == 0) {
smpte.seconds = 59;
wrap = MINUTES;
if (smpte.minutes == 0) {
smpte.minutes = 59;
wrap = HOURS;
smpte.hours--;
}
else {
smpte.minutes--;
}
} else {
smpte.seconds--;
}
} else {
smpte.frames--;
}
if (SMPTE_IS_ZERO( smpte )) {
smpte.negative = false;
}
return wrap;
}
/** Go to lowest absolute subframe value in this frame (set to 0 :-) ) */
void
frames_floor( Time& smpte )
{
smpte.subframes = 0;
if (SMPTE_IS_ZERO(smpte)) {
smpte.negative = false;
}
}
/** Increment @a smpte by one subframe */
Wrap
increment_subframes( Time& smpte )
{
Wrap wrap = NONE;
if (smpte.negative) {
smpte.negative = false;
wrap = decrement_subframes( smpte );
if (!SMPTE_IS_ZERO(smpte)) {
smpte.negative = true;
}
return wrap;
}
smpte.subframes++;
if (smpte.subframes >= ARDOUR::Config->get_subframes_per_frame()) {
smpte.subframes = 0;
increment( smpte );
return FRAMES;
}
return NONE;
}
/** Decrement @a smpte by one subframe */
Wrap
decrement_subframes( Time& smpte )
{
Wrap wrap = NONE;
if (smpte.negative) {
smpte.negative = false;
wrap = increment_subframes( smpte );
smpte.negative = true;
return wrap;
}
if (smpte.subframes <= 0) {
smpte.subframes = 0;
if (SMPTE_IS_ZERO(smpte)) {
smpte.negative = true;
smpte.subframes = 1;
return FRAMES;
} else {
decrement( smpte );
smpte.subframes = 79;
return FRAMES;
}
} else {
smpte.subframes--;
if (SMPTE_IS_ZERO(smpte)) {
smpte.negative = false;
}
return NONE;
}
}
/** Go to next whole second (frames == 0 or frames == 2) */
Wrap
increment_seconds( Time& smpte )
{
Wrap wrap = NONE;
// Clear subframes
frames_floor( smpte );
if (smpte.negative) {
// Wrap second if on second boundary
wrap = increment(smpte);
// Go to lowest absolute frame value
seconds_floor( smpte );
if (SMPTE_IS_ZERO(smpte)) {
smpte.negative = false;
}
} else {
// Go to highest possible frame in this second
switch ((int)ceil(smpte.rate)) {
case 24:
smpte.frames = 23;
break;
case 25:
smpte.frames = 24;
break;
case 30:
smpte.frames = 29;
break;
case 60:
smpte.frames = 59;
break;
}
// Increment by one frame
wrap = increment( smpte );
}
return wrap;
}
/** Go to lowest (absolute) frame value in this second
* Doesn't care about positive/negative */
void
seconds_floor( Time& smpte )
{
// Clear subframes
frames_floor( smpte );
// Go to lowest possible frame in this second
switch ((int)ceil(smpte.rate)) {
case 24:
case 25:
case 30:
case 60:
if (!(smpte.drop)) {
smpte.frames = 0;
} else {
if ((smpte.minutes % 10) && (smpte.seconds == 0)) {
smpte.frames = 2;
} else {
smpte.frames = 0;
}
}
break;
}
if (SMPTE_IS_ZERO(smpte)) {
smpte.negative = false;
}
}
/** Go to next whole minute (seconds == 0, frames == 0 or frames == 2) */
Wrap
increment_minutes( Time& smpte )
{
Wrap wrap = NONE;
// Clear subframes
frames_floor( smpte );
if (smpte.negative) {
// Wrap if on minute boundary
wrap = increment_seconds( smpte );
// Go to lowest possible value in this minute
minutes_floor( smpte );
} else {
// Go to highest possible second
smpte.seconds = 59;
// Wrap minute by incrementing second
wrap = increment_seconds( smpte );
}
return wrap;
}
/** Go to lowest absolute value in this minute */
void
minutes_floor( Time& smpte )
{
// Go to lowest possible second
smpte.seconds = 0;
// Go to lowest possible frame
seconds_floor( smpte );
if (SMPTE_IS_ZERO(smpte)) {
smpte.negative = false;
}
}
/** Go to next whole hour (minute = 0, second = 0, frame = 0) */
Wrap
increment_hours( Time& smpte )
{
Wrap wrap = NONE;
// Clear subframes
frames_floor(smpte);
if (smpte.negative) {
// Wrap if on hour boundary
wrap = increment_minutes( smpte );
// Go to lowest possible value in this hour
hours_floor( smpte );
} else {
smpte.minutes = 59;
wrap = increment_minutes( smpte );
}
return wrap;
}
/** Go to lowest absolute value in this hour */
void
hours_floor( Time& smpte )
{
smpte.minutes = 0;
smpte.seconds = 0;
smpte.frames = 0;
smpte.subframes = 0;
if (SMPTE_IS_ZERO(smpte)) {
smpte.negative = false;
}
}
} // namespace SMPTE