move TimecodeFormat to libtimecode

provide a way to convert any TimecodeFormat to float frame-rate,
not only the currently active timecode_foramt.

git-svn-id: svn://localhost/ardour2/branches/3.0@13249 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Robin Gareus 2012-10-12 01:08:29 +00:00
parent 9116ea83dd
commit a9abe3b1e1
9 changed files with 133 additions and 111 deletions

View File

@ -26,6 +26,7 @@
using namespace std;
using namespace ARDOUR;
using namespace Timecode;
SessionOptionEditor::SessionOptionEditor (Session* s)
: OptionEditor (&(s->config), _("Session Properties"))

View File

@ -40,7 +40,7 @@ CONFIG_VARIABLE (bool, auto_input, "auto-input", true)
CONFIG_VARIABLE (bool, punch_in, "punch-in", false)
CONFIG_VARIABLE (bool, punch_out, "punch-out", false)
CONFIG_VARIABLE (uint32_t, subframes_per_frame, "subframes-per-frame", 100)
CONFIG_VARIABLE (TimecodeFormat, timecode_format, "timecode-format", timecode_30)
CONFIG_VARIABLE (Timecode::TimecodeFormat, timecode_format, "timecode-format", Timecode::timecode_30)
CONFIG_VARIABLE_SPECIAL(std::string, raid_path, "raid-path", "", path_expand)
CONFIG_VARIABLE_SPECIAL(std::string, audio_search_path, "audio-search-path", "", search_path_expand)
CONFIG_VARIABLE_SPECIAL(std::string, midi_search_path, "midi-search-path", "", search_path_expand)

View File

@ -252,7 +252,7 @@ class MTC_Slave : public Slave {
framepos_t window_end;
framepos_t first_mtc_timestamp;
bool did_reset_tc_format;
TimecodeFormat saved_tc_format;
Timecode::TimecodeFormat saved_tc_format;
Glib::Threads::Mutex reset_lock;
uint32_t reset_pending;
bool reset_position;
@ -260,8 +260,8 @@ class MTC_Slave : public Slave {
int busy_guard1;
int busy_guard2;
TimecodeFormat mtc_timecode;
TimecodeFormat a3e_timecode;
Timecode::TimecodeFormat mtc_timecode;
Timecode::TimecodeFormat a3e_timecode;
bool printed_timecode_warning;
/* DLL - chase MTC */

View File

@ -200,19 +200,6 @@ namespace ARDOUR {
TrackColor
};
enum TimecodeFormat {
timecode_23976,
timecode_24,
timecode_24976,
timecode_25,
timecode_2997,
timecode_2997drop,
timecode_30,
timecode_30drop,
timecode_5994,
timecode_60
};
class AnyTime {
public:
enum Type {
@ -589,7 +576,7 @@ std::istream& operator>>(std::istream& o, ARDOUR::CrossfadeChoice& sf);
std::istream& operator>>(std::istream& o, ARDOUR::SyncSource& sf);
std::istream& operator>>(std::istream& o, ARDOUR::ShuttleBehaviour& sf);
std::istream& operator>>(std::istream& o, ARDOUR::ShuttleUnits& sf);
std::istream& operator>>(std::istream& o, ARDOUR::TimecodeFormat& sf);
std::istream& operator>>(std::istream& o, Timecode::TimecodeFormat& sf);
std::istream& operator>>(std::istream& o, ARDOUR::DenormalModel& sf);
std::istream& operator>>(std::istream& o, ARDOUR::WaveformScale& sf);
std::istream& operator>>(std::istream& o, ARDOUR::WaveformShape& sf);
@ -610,7 +597,7 @@ std::ostream& operator<<(std::ostream& o, const ARDOUR::CrossfadeChoice& sf);
std::ostream& operator<<(std::ostream& o, const ARDOUR::SyncSource& sf);
std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleBehaviour& sf);
std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleUnits& sf);
std::ostream& operator<<(std::ostream& o, const ARDOUR::TimecodeFormat& sf);
std::ostream& operator<<(std::ostream& o, const Timecode::TimecodeFormat& sf);
std::ostream& operator<<(std::ostream& o, const ARDOUR::DenormalModel& sf);
std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformScale& sf);
std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformShape& sf);

View File

@ -41,6 +41,7 @@ using namespace std;
using namespace PBD;
using namespace ARDOUR;
using namespace MIDI;
using namespace Timecode;
namespace ARDOUR {

View File

@ -38,6 +38,7 @@ using namespace std;
using namespace ARDOUR;
using namespace MIDI;
using namespace PBD;
using namespace Timecode;
/* length (in timecode frames) of the "window" that we consider legal given receipt of
a given timecode position. Ardour will try to chase within this window, and will
@ -280,7 +281,7 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full, framepos_t now)
*/
//DEBUG_TRACE (DEBUG::MTC, string_compose ("MTC::update_mtc_time - TID:%1\n", ::pthread_self()));
Timecode::Time timecode;
Time timecode;
TimecodeFormat tc_format;
bool reset_tc = true;

View File

@ -50,105 +50,19 @@ Session::bbt_time (framepos_t when, Timecode::BBT_Time& bbt)
}
/* Timecode TIME */
float
Session::timecode_frames_per_second() const
{
switch (config.get_timecode_format()) {
case timecode_23976:
return 23.976;
break;
case timecode_24:
return 24;
break;
case timecode_24976:
return 24.976;
break;
case timecode_25:
return 25;
break;
case timecode_2997:
return 29.97;
break;
case timecode_2997drop:
return 29.97;
break;
case timecode_30:
return 30;
break;
case timecode_30drop:
return 30;
break;
case timecode_5994:
return 59.94;
break;
case timecode_60:
return 60;
break;
default:
cerr << "Editor received unexpected timecode type" << endl;
}
return 30.0;
return Timecode::timecode_to_frames_per_second (config.get_timecode_format());
}
bool
Session::timecode_drop_frames() const
{
switch (config.get_timecode_format()) {
case timecode_23976:
return false;
break;
case timecode_24:
return false;
break;
case timecode_24976:
return false;
break;
case timecode_25:
return false;
break;
case timecode_2997:
return false;
break;
case timecode_2997drop:
return true;
break;
case timecode_30:
return false;
break;
case timecode_30drop:
return true;
break;
case timecode_5994:
return false;
break;
case timecode_60:
return false;
break;
default:
error << "Editor received unexpected timecode type" << endmsg;
}
return false;
return Timecode::timecode_has_drop_frames(config.get_timecode_format());
}
void
Session::sync_time_vars ()
{

View File

@ -423,6 +423,108 @@ hours_floor(Time& timecode)
}
}
float
timecode_to_frames_per_second(TimecodeFormat t)
{
switch (t) {
case timecode_23976:
return (24000.0/1001.0); //23.976;
break;
case timecode_24:
return 24;
break;
case timecode_24976:
return (25000.0/1001.0); //24.976;
break;
case timecode_25:
return 25;
break;
case timecode_2997:
return 29.97;
break;
case timecode_2997drop:
return (30000.0/1001.0); //29.97;
break;
case timecode_30:
return 30;
break;
case timecode_30drop:
return 30;
break;
case timecode_5994:
return (60000.0/1001.0); //59.94;
break;
case timecode_60:
return 60;
break;
default:
//std::cerr << "Editor received unexpected timecode type" << std::endl;
break;
}
return 30.0;
}
bool
timecode_has_drop_frames(TimecodeFormat t)
{
switch (t) {
case timecode_23976:
return false;
break;
case timecode_24:
return false;
break;
case timecode_24976:
return false;
break;
case timecode_25:
return false;
break;
case timecode_2997:
return false;
break;
case timecode_2997drop:
return true;
break;
case timecode_30:
return false;
break;
case timecode_30drop:
return true;
break;
case timecode_5994:
return false;
break;
case timecode_60:
return false;
break;
default:
//error << "Editor received unexpected timecode type" << endmsg;
break;
}
return false;
}
} // namespace Timecode

View File

@ -32,6 +32,19 @@ enum Wrap {
HOURS
};
enum TimecodeFormat {
timecode_23976,
timecode_24,
timecode_24976,
timecode_25,
timecode_2997,
timecode_2997drop,
timecode_30,
timecode_30drop,
timecode_5994,
timecode_60
};
struct Time {
bool negative;
uint32_t hours;
@ -84,6 +97,9 @@ void seconds_floor (Time& timecode);
void minutes_floor (Time& timecode);
void hours_floor (Time& timecode);
float timecode_to_frames_per_second(TimecodeFormat const t);
bool timecode_has_drop_frames(TimecodeFormat const t);
} // namespace Timecode
std::ostream& operator<< (std::ostream& ostr, const Timecode::Time& t);