summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorNick Mainsbridge <beatroute@iprimus.com.au>2006-12-08 22:08:36 +0000
committerNick Mainsbridge <beatroute@iprimus.com.au>2006-12-08 22:08:36 +0000
commit6146d6aa6f32b79bb0fe573fe00134b6159a7325 (patch)
tree8364ed5b81deab92c3c70d8a671a0a2d846586fb /libs
parent3039691723ae9fb11f05d763c2813222488a59e3 (diff)
Unbreak SMPTE ruler at non-30fps rates. Display 60fps properly. Use the same data types for SMPTE::Time.rate and dropframe as are used in Config.
git-svn-id: svn://localhost/ardour2/trunk@1198 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/session_time.cc3
-rw-r--r--libs/surfaces/control_protocol/control_protocol/smpte.h22
-rw-r--r--libs/surfaces/control_protocol/smpte.cc111
3 files changed, 75 insertions, 61 deletions
diff --git a/libs/ardour/session_time.cc b/libs/ardour/session_time.cc
index bc9778052f..61051e4632 100644
--- a/libs/ardour/session_time.cc
+++ b/libs/ardour/session_time.cc
@@ -281,6 +281,9 @@ Session::sample_to_smpte( nframes_t sample, SMPTE::Time& smpte, bool use_offset,
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();
}
void
diff --git a/libs/surfaces/control_protocol/control_protocol/smpte.h b/libs/surfaces/control_protocol/control_protocol/smpte.h
index 09c1c9616a..b25a268aac 100644
--- a/libs/surfaces/control_protocol/control_protocol/smpte.h
+++ b/libs/surfaces/control_protocol/control_protocol/smpte.h
@@ -31,28 +31,18 @@ enum Wrap {
HOURS
};
-/** SMPTE frame rate (in frames per second).
- *
- * This should be eliminated in favour of a float to support arbitrary rates.
- */
-enum FPS {
- MTC_24_FPS = 0,
- MTC_25_FPS = 1,
- MTC_30_FPS_DROP = 2,
- MTC_30_FPS = 3
-};
-
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
- FPS rate; ///< Frame rate of this Time
- static FPS default_rate; ///< Rate to use for default constructor
+ 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(FPS a_rate = default_rate) {
+ Time(float a_rate = default_rate) {
negative = false;
hours = 0;
minutes = 0;
diff --git a/libs/surfaces/control_protocol/smpte.cc b/libs/surfaces/control_protocol/smpte.cc
index 9b99d05160..5df159a52b 100644
--- a/libs/surfaces/control_protocol/smpte.cc
+++ b/libs/surfaces/control_protocol/smpte.cc
@@ -24,7 +24,7 @@
namespace SMPTE {
-FPS Time::default_rate = MTC_30_FPS;
+float Time::default_rate = 30.0;
/** Increment @a smpte by exactly one frame (keep subframes value).
@@ -51,34 +51,42 @@ increment( Time& smpte )
}
return wrap;
}
-
- switch (smpte.rate) {
- case MTC_24_FPS:
+
+ switch ((int)ceil(smpte.rate)) {
+ case 24:
if (smpte.frames == 23) {
smpte.frames = 0;
wrap = SECONDS;
}
break;
- case MTC_25_FPS:
+ case 25:
if (smpte.frames == 24) {
smpte.frames = 0;
wrap = SECONDS;
}
break;
- case MTC_30_FPS_DROP:
- if (smpte.frames == 29) {
- if ( ((smpte.minutes + 1) % 10) && (smpte.seconds == 59) ) {
- smpte.frames = 2;
- }
- else {
- smpte.frames = 0;
- }
- wrap = SECONDS;
+ 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 MTC_30_FPS:
- if (smpte.frames == 29) {
- smpte.frames = 0;
+ case 60:
+ if (smpte.frames == 59) {
+ smpte.frames = 0;
wrap = SECONDS;
}
break;
@@ -127,33 +135,41 @@ decrement( Time& smpte )
return SECONDS;
}
- switch (smpte.rate) {
- case MTC_24_FPS:
+ switch ((int)ceil(smpte.rate)) {
+ case 24:
if (smpte.frames == 0) {
smpte.frames = 23;
wrap = SECONDS;
}
break;
- case MTC_25_FPS:
+ case 25:
if (smpte.frames == 0) {
smpte.frames = 24;
wrap = SECONDS;
}
break;
- case MTC_30_FPS_DROP:
- if ((smpte.minutes % 10) && (smpte.seconds == 0)) {
- if (smpte.frames <= 2) {
- smpte.frames = 29;
+ 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;
}
- } else if (smpte.frames == 0) {
- smpte.frames = 29;
- wrap = SECONDS;
}
break;
- case MTC_30_FPS:
- if (smpte.frames == 0) {
- smpte.frames = 29;
+ case 60:
+ if (smpte.frames == 0) {
+ smpte.frames = 59;
wrap = SECONDS;
}
break;
@@ -275,17 +291,19 @@ increment_seconds( Time& smpte )
}
} else {
// Go to highest possible frame in this second
- switch (smpte.rate) {
- case MTC_24_FPS:
+ switch ((int)ceil(smpte.rate)) {
+ case 24:
smpte.frames = 23;
break;
- case MTC_25_FPS:
+ case 25:
smpte.frames = 24;
break;
- case MTC_30_FPS_DROP:
- case MTC_30_FPS:
+ case 30:
smpte.frames = 29;
break;
+ case 60:
+ smpte.frames = 59;
+ break;
}
// Increment by one frame
@@ -305,17 +323,20 @@ seconds_floor( Time& smpte )
frames_floor( smpte );
// Go to lowest possible frame in this second
- switch (smpte.rate) {
- case MTC_24_FPS:
- case MTC_25_FPS:
- case MTC_30_FPS:
- smpte.frames = 0;
- break;
- case MTC_30_FPS_DROP:
- if ((smpte.minutes % 10) && (smpte.seconds == 0)) {
- smpte.frames = 2;
+ switch ((int)ceil(smpte.rate)) {
+ case 24:
+ case 25:
+ case 30:
+ case 60:
+ if (!(smpte.drop)) {
+ smpte.frames = 0;
} else {
- smpte.frames = 0;
+
+ if ((smpte.minutes % 10) && (smpte.seconds == 0)) {
+ smpte.frames = 2;
+ } else {
+ smpte.frames = 0;
+ }
}
break;
}