summaryrefslogtreecommitdiff
path: root/libs/surfaces/control_protocol
diff options
context:
space:
mode:
Diffstat (limited to 'libs/surfaces/control_protocol')
-rw-r--r--libs/surfaces/control_protocol/SConscript2
-rw-r--r--libs/surfaces/control_protocol/control_protocol/smpte.h22
-rw-r--r--libs/surfaces/control_protocol/smpte.cc118
3 files changed, 77 insertions, 65 deletions
diff --git a/libs/surfaces/control_protocol/SConscript b/libs/surfaces/control_protocol/SConscript
index 88aeeda376..026698500a 100644
--- a/libs/surfaces/control_protocol/SConscript
+++ b/libs/surfaces/control_protocol/SConscript
@@ -50,7 +50,7 @@ Default(libardour_cp)
if env['NLS']:
i18n (cp, cp_files, env)
-env.Alias('install', env.Install(os.path.join(install_prefix, 'lib/ardour2'), libardour_cp))
+env.Alias('install', env.Install(os.path.join(install_prefix, env['LIBDIR'], 'ardour2'), libardour_cp))
env.Alias('tarball', env.Distribute (env['DISTTREE'],
[ 'SConscript' ] +
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 55d0660c59..5df159a52b 100644
--- a/libs/surfaces/control_protocol/smpte.cc
+++ b/libs/surfaces/control_protocol/smpte.cc
@@ -20,10 +20,11 @@
#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 {
-FPS Time::default_rate = MTC_30_FPS;
+float Time::default_rate = 30.0;
/** Increment @a smpte by exactly one frame (keep subframes value).
@@ -38,7 +39,7 @@ increment( Time& smpte )
if (smpte.negative) {
if (SMPTE_IS_AROUND_ZERO(smpte) && smpte.subframes) {
// We have a zero transition involving only subframes
- smpte.subframes = 80 - smpte.subframes;
+ smpte.subframes = ARDOUR::Config->get_subframes_per_frame() - smpte.subframes;
smpte.negative = false;
return SECONDS;
}
@@ -50,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;
@@ -121,38 +130,46 @@ decrement( Time& smpte )
return wrap;
} else if (SMPTE_IS_AROUND_ZERO(smpte) && smpte.subframes) {
// We have a zero transition involving only subframes
- smpte.subframes = 80 - smpte.subframes;
+ smpte.subframes = ARDOUR::Config->get_subframes_per_frame() - smpte.subframes;
smpte.negative = true;
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;
@@ -212,7 +229,7 @@ increment_subframes( Time& smpte )
}
smpte.subframes++;
- if (smpte.subframes >= 80) {
+ if (smpte.subframes >= ARDOUR::Config->get_subframes_per_frame()) {
smpte.subframes = 0;
increment( smpte );
return FRAMES;
@@ -274,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
@@ -304,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;
}