summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorNick Mainsbridge <beatroute@iprimus.com.au>2007-01-02 13:57:06 +0000
committerNick Mainsbridge <beatroute@iprimus.com.au>2007-01-02 13:57:06 +0000
commit1bddf1bc884feedb5deb5c35f08c7b9730936dae (patch)
treebb8ef1d1fb866027a671ce3f641ee9475804c361 /libs/ardour
parenta3a1e4b413776cf6f0d72be831a33d8a8e6048ae (diff)
General SMPTE fixes mostly relating to non-integer frame rates. Please Test. Fix for sometimes entering an invalid SMPTE format by CHANGING THE SESSION FILE. ****Warning. the SMPTE frame rate will be reset to 30 NDF if you load an old sessionardour2_broken/***. Calculate the HMS verbose canvas cursor properly. Fix incorrect SMPTE display in clocks/VCC. Standardise size of SMPTE display in editor clocks. Make the zoom controls smaller (anyone with some smaller icons?).
git-svn-id: svn://localhost/ardour2/trunk@1257 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/configuration_vars.h3
-rw-r--r--libs/ardour/ardour/session.h23
-rw-r--r--libs/ardour/ardour/types.h13
-rw-r--r--libs/ardour/enums.cc22
-rw-r--r--libs/ardour/globals.cc1
-rw-r--r--libs/ardour/session_midi.cc2
-rw-r--r--libs/ardour/session_state.cc3
-rw-r--r--libs/ardour/session_time.cc159
-rw-r--r--libs/ardour/tempo.cc8
9 files changed, 175 insertions, 59 deletions
diff --git a/libs/ardour/ardour/configuration_vars.h b/libs/ardour/ardour/configuration_vars.h
index 67f4362095..ad7e44d332 100644
--- a/libs/ardour/ardour/configuration_vars.h
+++ b/libs/ardour/ardour/configuration_vars.h
@@ -95,11 +95,10 @@ CONFIG_VARIABLE (bool, quieten_at_speed, "quieten-at-speed", true)
/* timecode and sync */
CONFIG_VARIABLE (bool, jack_time_master, "jack-time-master", true)
+CONFIG_VARIABLE (SmpteFormat, smpte_format, "smpte-format", smpte_30)
CONFIG_VARIABLE (bool, use_video_sync, "use-video-sync", false)
CONFIG_VARIABLE (bool, timecode_source_is_synced, "timecode-source-is-synced", true)
-CONFIG_VARIABLE (float, smpte_frames_per_second, "smpte-frames-per-second", 30.0f)
CONFIG_VARIABLE (float, video_pullup, "video-pullup", 0.0f)
-CONFIG_VARIABLE (bool, smpte_drop_frames, "smpte-drop-frames", false)
/* metering */
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index a10cbfff95..c71403e125 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -378,6 +378,9 @@ class Session : public PBD::StatefulDestructible
double frames_per_smpte_frame() const { return _frames_per_smpte_frame; }
nframes_t smpte_frames_per_hour() const { return _smpte_frames_per_hour; }
+ float smpte_frames_per_second() const;
+ bool smpte_drop_frames() const;
+
/* Locations */
Locations *locations() { return &_locations; }
@@ -480,19 +483,6 @@ class Session : public PBD::StatefulDestructible
nframes_t transport_frame () const {return _transport_frame; }
nframes_t audible_frame () const;
- enum SmpteFormat {
- smpte_23976,
- smpte_24,
- smpte_24976,
- smpte_25,
- smpte_2997,
- smpte_2997drop,
- smpte_30,
- smpte_30drop,
- smpte_5994,
- smpte_60,
- };
-
enum PullupFormat {
pullup_Plus4Plus1,
pullup_Plus4,
@@ -502,11 +492,10 @@ class Session : public PBD::StatefulDestructible
pullup_Minus1,
pullup_Minus4Plus1,
pullup_Minus4,
- pullup_Minus4Minus1,
+ pullup_Minus4Minus1
};
- int set_smpte_type (float fps, bool drop_frames);
-
+ int set_smpte_format (SmpteFormat);
void sync_time_vars();
void bbt_time (nframes_t when, BBT_Time&);
@@ -1300,7 +1289,7 @@ class Session : public PBD::StatefulDestructible
nframes_t _smpte_frames_per_hour;
nframes_t _smpte_offset;
bool _smpte_offset_negative;
-
+
/* cache the most-recently requested time conversions.
this helps when we have multiple clocks showing the
same time (e.g. the transport frame)
diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h
index 27ff8e93da..4fe8a54f71 100644
--- a/libs/ardour/ardour/types.h
+++ b/libs/ardour/ardour/types.h
@@ -145,6 +145,18 @@ namespace ARDOUR {
}
};
+ enum SmpteFormat {
+ smpte_23976,
+ smpte_24,
+ smpte_24976,
+ smpte_25,
+ smpte_2997,
+ smpte_2997drop,
+ smpte_30,
+ smpte_30drop,
+ smpte_5994,
+ smpte_60
+ };
struct AnyTime {
enum Type {
@@ -343,6 +355,7 @@ std::istream& operator>>(std::istream& o, ARDOUR::CrossfadeModel& sf);
std::istream& operator>>(std::istream& o, ARDOUR::SlaveSource& 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::SmpteFormat& sf);
static inline nframes_t
session_frame_to_track_frame (nframes_t session_frame, double speed)
diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc
index 293fface5a..32f195e2ac 100644
--- a/libs/ardour/enums.cc
+++ b/libs/ardour/enums.cc
@@ -43,7 +43,7 @@ setup_enum_writer ()
mute_type _mute_type;
Session::RecordState _Session_RecordState;
Session::Event::Type _Session_Event_Type;
- Session::SmpteFormat _Session_SmpteFormat;
+ SmpteFormat _Session_SmpteFormat;
Session::PullupFormat _Session_PullupFormat;
AudioRegion::FadeShape _AudioRegion_FadeShape;
Panner::LinkDirection _Panner_LinkDirection;
@@ -222,16 +222,16 @@ setup_enum_writer ()
REGISTER_CLASS_ENUM (Session, InCleanup);
REGISTER_BITS (_Session_StateOfTheState);
- REGISTER_CLASS_ENUM (Session, smpte_23976);
- REGISTER_CLASS_ENUM (Session, smpte_24);
- REGISTER_CLASS_ENUM (Session, smpte_24976);
- REGISTER_CLASS_ENUM (Session, smpte_25);
- REGISTER_CLASS_ENUM (Session, smpte_2997);
- REGISTER_CLASS_ENUM (Session, smpte_2997drop);
- REGISTER_CLASS_ENUM (Session, smpte_30);
- REGISTER_CLASS_ENUM (Session, smpte_30drop);
- REGISTER_CLASS_ENUM (Session, smpte_5994);
- REGISTER_CLASS_ENUM (Session, smpte_60);
+ REGISTER_ENUM (smpte_23976);
+ REGISTER_ENUM (smpte_24);
+ REGISTER_ENUM (smpte_24976);
+ REGISTER_ENUM (smpte_25);
+ REGISTER_ENUM (smpte_2997);
+ REGISTER_ENUM (smpte_2997drop);
+ REGISTER_ENUM (smpte_30);
+ REGISTER_ENUM (smpte_30drop);
+ REGISTER_ENUM (smpte_5994);
+ REGISTER_ENUM (smpte_60);
REGISTER (_Session_SmpteFormat);
REGISTER_CLASS_ENUM (Session, pullup_Plus4Plus1);
diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc
index 274b0f1d3c..3344c61a9a 100644
--- a/libs/ardour/globals.cc
+++ b/libs/ardour/globals.cc
@@ -622,4 +622,5 @@ std::istream& operator>>(std::istream& o, CrossfadeModel& var) { return int_to_t
std::istream& operator>>(std::istream& o, SlaveSource& var) { return int_to_type<SlaveSource> (o, var); }
std::istream& operator>>(std::istream& o, ShuttleBehaviour& var) { return int_to_type<ShuttleBehaviour> (o, var); }
std::istream& operator>>(std::istream& o, ShuttleUnits& var) { return int_to_type<ShuttleUnits> (o, var); }
+std::istream& operator>>(std::istream& o, SmpteFormat& var) { return int_to_type<SmpteFormat> (o, var); }
diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc
index fe08b40127..e4e3d82b68 100644
--- a/libs/ardour/session_midi.cc
+++ b/libs/ardour/session_midi.cc
@@ -565,7 +565,7 @@ Session::mmc_step (MIDI::MachineControl &mmc, int steps)
}
double diff_secs = diff.tv_sec + (diff.tv_usec / 1000000.0);
- double cur_speed = (((steps * 0.5) * Config->get_smpte_frames_per_second()) / diff_secs) / Config->get_smpte_frames_per_second();
+ double cur_speed = (((steps * 0.5) * smpte_frames_per_second()) / diff_secs) / smpte_frames_per_second();
if (_transport_speed == 0 || cur_speed * _transport_speed < 0) {
/* change direction */
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index fb15de15c4..0afa682d58 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -3020,7 +3020,6 @@ Session::config_changed (const char* parameter_name)
for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) {
if ((*i)->record_enabled ()) {
- //cerr << "switching to input = " << !auto_input << __FILE__ << __LINE__ << endl << endl;
(*i)->monitor_input (!Config->get_auto_input());
}
}
@@ -3080,7 +3079,7 @@ Session::config_changed (const char* parameter_name)
setup_raid_path (Config->get_raid_path());
- } else if (PARAM_IS ("smpte-frames-per-second") || PARAM_IS ("smpte-drop-frames")) {
+ } else if (PARAM_IS ("smpte-format")) {
sync_time_vars ();
diff --git a/libs/ardour/session_time.cc b/libs/ardour/session_time.cc
index 61051e4632..e7bd0a3696 100644
--- a/libs/ardour/session_time.cc
+++ b/libs/ardour/session_time.cc
@@ -48,25 +48,127 @@ Session::bbt_time (nframes_t when, BBT_Time& bbt)
}
/* SMPTE TIME */
+float
+Session::smpte_frames_per_second() const
+{
+ switch (Config->get_smpte_format()) {
+ case smpte_23976:
+ return 23.976;
+
+ break;
+ case smpte_24:
+ return 24;
+
+ break;
+ case smpte_24976:
+ return 24.976;
+
+ break;
+ case smpte_25:
+ return 25;
+
+ break;
+ case smpte_2997:
+ return 29.97;
+
+ break;
+ case smpte_2997drop:
+ return 29.97;
+
+ break;
+ case smpte_30:
+ return 30;
+
+ break;
+ case smpte_30drop:
+ return 30;
+
+ break;
+ case smpte_5994:
+ return 59.94;
+
+ break;
+ case smpte_60:
+ return 60;
+
+ break;
+ default:
+ cerr << "Editor received unexpected smpte type" << endl;
+ }
+ return 30.0;
+}
+bool
+Session::smpte_drop_frames() const
+{
+ switch (Config->get_smpte_format()) {
+ case smpte_23976:
+ return false;
+
+ break;
+ case smpte_24:
+ return false;
+
+ break;
+ case smpte_24976:
+ return false;
+
+ break;
+ case smpte_25:
+ return false;
+
+ break;
+ case smpte_2997:
+ return false;
+ break;
+ case smpte_2997drop:
+ return true;
+
+ break;
+ case smpte_30:
+ return false;
+
+ break;
+ case smpte_30drop:
+ return true;
+
+ break;
+ case smpte_5994:
+ return false;
+
+ break;
+ case smpte_60:
+ return false;
+
+ break;
+ default:
+ cerr << "Editor received unexpected smpte type" << endl;
+ }
+ return false;
+}
void
Session::sync_time_vars ()
{
_current_frame_rate = (nframes_t) round (_base_frame_rate * (1.0 + (Config->get_video_pullup()/100.0)));
- _frames_per_hour = _current_frame_rate * 3600;
- _frames_per_smpte_frame = (double) _current_frame_rate / (double) Config->get_smpte_frames_per_second();
- _smpte_frames_per_hour = (unsigned long) (Config->get_smpte_frames_per_second() * 3600.0);
+ _frames_per_smpte_frame = (double) _current_frame_rate / (double) smpte_frames_per_second();
+ if (smpte_drop_frames()) {
+ _frames_per_hour = (long)(107892 * _frames_per_smpte_frame);
+ } else {
+ _frames_per_hour = (long)(3600 * rint(smpte_frames_per_second()) * _frames_per_smpte_frame);
+ }
+ _smpte_frames_per_hour = (nframes_t)rint(smpte_frames_per_second() * 3600.0);
+
}
int
-Session::set_smpte_type (float fps, bool drop_frames)
+Session::set_smpte_format (SmpteFormat format)
{
- Config->set_smpte_frames_per_second (fps);
- Config->set_smpte_drop_frames (drop_frames);
+
+ Config->set_smpte_format (format);
last_smpte_valid = false;
// smpte type bits are the middle two in the upper nibble
- switch ((int) ceil (fps)) {
+ switch ((int) ceil (smpte_frames_per_second())) {
case 24:
mtc_smpte_bits = 0;
break;
@@ -77,7 +179,7 @@ Session::set_smpte_type (float fps, bool drop_frames)
case 30:
default:
- if (drop_frames) {
+ if (smpte_drop_frames()) {
mtc_smpte_bits = 0x40;
} else {
mtc_smpte_bits = 0x60;
@@ -109,7 +211,8 @@ Session::set_smpte_offset_negative (bool neg)
void
Session::smpte_to_sample( SMPTE::Time& smpte, nframes_t& sample, bool use_offset, bool use_subframes ) const
{
- if (Config->get_smpte_drop_frames()) {
+
+ if (smpte.drop) {
// The drop frame format was created to better approximate the 30000/1001 = 29.97002997002997....
// framerate of NTSC color TV. The used frame rate of drop frame is 29.97, which drifts by about
// 0.108 frame per hour, or about 1.3 frames per 12 hours. This is not perfect, but a lot better
@@ -148,9 +251,10 @@ Session::smpte_to_sample( SMPTE::Time& smpte, nframes_t& sample, bool use_offset
// 0:10:00:00 0.0 0 600.000 26460000 (accurate)
//
// Per Sigmond <per@sigmond.no>
-
+
// Samples inside time dividable by 10 minutes (real time accurate)
- nframes_t base_samples = ((smpte.hours * 60 * 60) + ((smpte.minutes / 10) * 10 * 60)) * frame_rate();
+ nframes_t base_samples = (nframes_t) (((smpte.hours * 107892) + ((smpte.minutes / 10) * 17982)) * _frames_per_smpte_frame);
+
// Samples inside time exceeding the nearest 10 minutes (always offset, see above)
long exceeding_df_minutes = smpte.minutes % 10;
long exceeding_df_seconds = (exceeding_df_minutes * 60) + smpte.seconds;
@@ -158,8 +262,14 @@ Session::smpte_to_sample( SMPTE::Time& smpte, nframes_t& sample, bool use_offset
nframes_t exceeding_samples = (nframes_t) rint(exceeding_df_frames * _frames_per_smpte_frame);
sample = base_samples + exceeding_samples;
} else {
- // Non drop is easy:
- sample = (((smpte.hours * 60 * 60) + (smpte.minutes * 60) + smpte.seconds) * frame_rate()) + (nframes_t)rint(smpte.frames * _frames_per_smpte_frame);
+ /*
+ Non drop is easy.. just note the use of
+ rint(smpte.rate) * _frames_per_smpte_frame
+ (frames per SMPTE second), which is larger than
+ frame_rate() in the non-integer SMPTE rate case.
+ */
+
+ sample = (nframes_t)rint((((smpte.hours * 60 * 60) + (smpte.minutes * 60) + smpte.seconds) * (rint(smpte.rate) * _frames_per_smpte_frame)) + (smpte.frames * _frames_per_smpte_frame));
}
if (use_subframes) {
@@ -186,6 +296,7 @@ Session::smpte_to_sample( SMPTE::Time& smpte, nframes_t& sample, bool use_offset
}
}
}
+
}
@@ -220,7 +331,7 @@ Session::sample_to_smpte( nframes_t sample, SMPTE::Time& smpte, bool use_offset,
// high sample numbers in the calculations that follow.
smpte.hours = offset_sample / _frames_per_hour;
offset_sample = offset_sample % _frames_per_hour;
-
+
// Calculate exact number of (exceeding) smpte frames and fractional frames
smpte_frames_left_exact = (double) offset_sample / _frames_per_smpte_frame;
smpte_frames_fraction = smpte_frames_left_exact - floor( smpte_frames_left_exact );
@@ -236,7 +347,7 @@ Session::sample_to_smpte( nframes_t sample, SMPTE::Time& smpte, bool use_offset,
// Extract hour-exceeding frames for minute, second and frame calculations
smpte_frames_left = ((long) floor( smpte_frames_left_exact ));
- if (Config->get_smpte_drop_frames()) {
+ if (smpte_drop_frames()) {
// See long explanation in smpte_to_sample()...
// Number of 10 minute chunks
@@ -272,18 +383,18 @@ Session::sample_to_smpte( nframes_t sample, SMPTE::Time& smpte, bool use_offset,
}
} else {
// Non drop is easy
- smpte.minutes = smpte_frames_left / ((long) Config->get_smpte_frames_per_second () * 60);
- smpte_frames_left = smpte_frames_left % ((long) Config->get_smpte_frames_per_second () * 60);
- smpte.seconds = smpte_frames_left / (long) Config->get_smpte_frames_per_second ();
- smpte.frames = smpte_frames_left % (long) Config->get_smpte_frames_per_second ();
+ smpte.minutes = smpte_frames_left / ((long) rint (smpte_frames_per_second ()) * 60);
+ smpte_frames_left = smpte_frames_left % ((long) rint (smpte_frames_per_second ()) * 60);
+ smpte.seconds = smpte_frames_left / (long) rint(smpte_frames_per_second ());
+ smpte.frames = smpte_frames_left % (long) rint(smpte_frames_per_second ());
}
if (!use_subframes) {
smpte.subframes = 0;
}
/* set frame rate and drop frame */
- smpte.rate = Config->get_smpte_frames_per_second ();
- smpte.drop = Config->get_smpte_drop_frames();
+ smpte.rate = smpte_frames_per_second ();
+ smpte.drop = smpte_drop_frames();
}
void
@@ -414,7 +525,7 @@ Session::jack_timebase_callback (jack_transport_state_t state,
#ifdef HAVE_JACK_VIDEO_SUPPORT
//poke audio video ratio so Ardour can track Video Sync
- pos->audio_frames_per_video_frame = frame_rate() / Config->get_smpte_frames_per_second ();
+ pos->audio_frames_per_video_frame = frame_rate() / smpte_frames_per_second();
pos->valid = jack_position_bits_t (pos->valid | JackAudioVideoRatio);
#endif
@@ -422,7 +533,7 @@ Session::jack_timebase_callback (jack_transport_state_t state,
/* SMPTE info */
t.smpte_offset = _smpte_offset;
- t.smpte_frame_rate = Config->get_smpte_frames_per_second ();
+ t.smpte_frame_rate = smpte_frames_per_second();
if (_transport_speed) {
@@ -473,7 +584,7 @@ Session::convert_to_frames_at (nframes_t position, AnyTime& any)
secs = any.smpte.hours * 60 * 60;
secs += any.smpte.minutes * 60;
secs += any.smpte.seconds;
- secs += any.smpte.frames / Config->get_smpte_frames_per_second ();
+ secs += any.smpte.frames / smpte_frames_per_second();
if (_smpte_offset_negative)
{
return (nframes_t) floor (secs * frame_rate()) - _smpte_offset;
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index 0ff94324bb..e86c30dd4d 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -924,7 +924,10 @@ TempoMap::round_to_beat_subdivision (nframes_t fr, int sub_num)
return frame_time (the_beat);
- /* XXX just keeping this for reference
+
+
+ /*****************************
+ XXX just keeping this for reference
TempoMap::BBTPointList::iterator i;
TempoMap::BBTPointList *more_zoomed_bbt_points;
@@ -978,7 +981,8 @@ TempoMap::round_to_beat_subdivision (nframes_t fr, int sub_num)
delete more_zoomed_bbt_points;
return fr ;
- */
+ ******************************/
+
}