Eliminate circular dependency kludge for control_protocol/smpte.o.
authorDavid Robillard <d@drobilla.net>
Mon, 13 Dec 2010 20:46:07 +0000 (20:46 +0000)
committerDavid Robillard <d@drobilla.net>
Mon, 13 Dec 2010 20:46:07 +0000 (20:46 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@8262 d708f5d6-7413-0410-9779-e7cbd77b26cf

15 files changed:
gtk2_ardour/ardev_common.sh.in
libs/ardour/ardour/timecode.h
libs/ardour/ardour/types.h
libs/ardour/wscript
libs/midi++2/midi++/mmc.h
libs/midi++2/mmc.cc
libs/midi++2/wscript
libs/musictime/musictime/time.h [new file with mode: 0644]
libs/musictime/src/time.cc [new file with mode: 0644]
libs/musictime/wscript [new file with mode: 0644]
libs/surfaces/control_protocol/control_protocol/basic_ui.h
libs/surfaces/control_protocol/control_protocol/timecode.h [deleted file]
libs/surfaces/control_protocol/smpte.cc [deleted file]
libs/surfaces/control_protocol/wscript
wscript

index a551b050fccd4af8a61b39e7b62d7aaff8461f3b..51864cf6dcf67fa13364f035109f1b5590a952b8 100644 (file)
@@ -16,7 +16,7 @@ fi
 
 export VAMP_PATH=$libs/vamp-plugins${VAMP_PATH:+:$VAMP_PATH}
 
-export LD_LIBRARY_PATH=$libs/vamp-sdk:$libs/surfaces:$libs/surfaces/control_protocol:$libs/ardour:$libs/midi++2:$libs/pbd:$libs/rubberband:$libs/soundtouch:$libs/gtkmm2ext:$libs/gnomecanvas:$libs/libsndfile:$libs/appleutility:$libs/taglib:$libs/evoral:$libs/evoral/src/libsmf:$libs/audiographer${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
+export LD_LIBRARY_PATH=$libs/vamp-sdk:$libs/surfaces:$libs/surfaces/control_protocol:$libs/ardour:$libs/midi++2:$libs/pbd:$libs/rubberband:$libs/soundtouch:$libs/gtkmm2ext:$libs/gnomecanvas:$libs/libsndfile:$libs/appleutility:$libs/taglib:$libs/evoral:$libs/evoral/src/libsmf:$libs/audiographer:$libs/musictime:${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
 
 # DYLD_LIBRARY_PATH is for darwin.
 export DYLD_FALLBACK_LIBRARY_PATH=$LD_LIBRARY_PATH
index 732a728c26bc84cd32166cefd193588b8ae7d25e..f0fb13b16f4d33145f29fae2f1f7d1241b9382e7 100644 (file)
@@ -19,6 +19,6 @@
 #ifndef __libardour_timecode_h__
 #define __libardour_timecode_h__
 
-#include "control_protocol/timecode.h"
+#include "musictime/time.h"
 
 #endif  // __libardour_timecode_h__
index 92739c3cd6be058fda75007dc67279cdbc18ebda..006ec447d7dbd7c12b99e46d575f761c31815e29 100644 (file)
@@ -30,7 +30,7 @@
 #include <inttypes.h>
 #include <jack/types.h>
 #include <jack/midiport.h>
-#include "control_protocol/timecode.h"
+#include "musictime/time.h"
 #include "pbd/id.h"
 
 #include "ardour/bbt_time.h"
index 346a350865bde546e60dd898aef927f3a8ca4042..03e602ee5a7e9725b4fe6b14d2ff227a8dc67fbf 100644 (file)
@@ -302,12 +302,6 @@ def build(bld):
        #obj.uselib += ' SOUNDTOUCH '
        #obj.add_objects = 'default/libs/surfaces/control_protocol/smpte_1.o'
        
-       obj.env.append_value('LINKFLAGS', 'default/libs/surfaces/control_protocol/smpte_1.o')
-       #
-       #       TODO: The above is an ugly hack that shouldn't be needed.  We really need
-       #       to refactor SMPTE out of libardour_cp to get rid of that circular dependency
-       #       alltogether.
-       #
        if bld.env['HAVE_SLV2']:
                obj.source += [ 'lv2_plugin.cc', 'lv2_event_buffer.cc', 'uri_map.cc', 'lv2_pfile.c' ]
                obj.uselib += ' SLV2 '
index cc8891db2ca9602aea57a1154522876f929863e1..e6716e16f3832e703a68ba8442dd5e09ed3e3f7a 100644 (file)
@@ -21,7 +21,7 @@
 #define __midipp_mmc_h_h__
 
 #include <jack/types.h>
-#include "control_protocol/timecode.h"
+#include "musictime/time.h"
 #include "pbd/signals.h"
 #include "pbd/ringbuffer.h"
 #include "midi++/types.h"
index 31e0fdfa23b1f9aaeb2a509a2bf15c45bd9bbf45..0275c0def30ae8e1ae72c67b100b6f34748f8213 100644 (file)
@@ -21,7 +21,7 @@
 #include <fcntl.h>
 #include <map>
 
-#include "control_protocol/timecode.h"
+#include "musictime/time.h"
 #include "pbd/error.h"
 #include "midi++/mmc.h"
 #include "midi++/port.h"
index aa6f8a67ca03749e4f9eeaee39e0e63d5f069fa5..6c3d251a55caa3106cb1de0164654143e0c82fd3 100644 (file)
@@ -62,7 +62,7 @@ def build(bld):
        obj.name         = 'libmidipp'
        obj.target       = 'midipp'
        obj.uselib       = 'GLIBMM SIGCPP XML JACK OSX'
-       obj.uselib_local = 'libpbd libevoral'
+       obj.uselib_local = 'libpbd libevoral libmusictime'
        obj.vnum         = LIBMIDIPP_LIB_VERSION
        obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
 
diff --git a/libs/musictime/musictime/time.h b/libs/musictime/musictime/time.h
new file mode 100644 (file)
index 0000000..6b04b70
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+       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_timecode_h__
+#define __ardour_timecode_h__
+
+#include <ostream>
+#include <inttypes.h>
+
+namespace Timecode {
+
+enum Wrap {
+       NONE = 0,
+       FRAMES,
+       SECONDS,
+       MINUTES,
+       HOURS
+};
+
+struct Time {
+       bool       negative;
+       uint32_t   hours;
+       uint32_t   minutes;
+       uint32_t   seconds;
+       uint32_t   frames;        ///< Timecode 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 Timecode
+
+       Time(float a_rate = default_rate) {
+               negative = false;
+               hours = 0;
+               minutes = 0;
+               seconds = 0;
+               frames = 0;
+               subframes = 0;
+               rate = a_rate;
+       }
+
+        std::ostream& print (std::ostream& ostr) const {
+               if (negative) {
+                       ostr << '-';
+               }
+               ostr << hours << ':' << minutes << ':' << seconds << ':' << frames << '.' << subframes << " @" << rate << (drop ? " drop" : " nondrop");
+               return ostr;
+       }
+
+};
+
+Wrap increment( Time& timecode, uint32_t );
+Wrap decrement( Time& timecode, uint32_t );
+Wrap increment_subframes( Time& timecode, uint32_t );
+Wrap decrement_subframes( Time& timecode, uint32_t );
+Wrap increment_seconds( Time& timecode, uint32_t );
+Wrap increment_minutes( Time& timecode, uint32_t );
+Wrap increment_hours( Time& timecode, uint32_t );
+void frames_floor( Time& timecode );
+void seconds_floor( Time& timecode );
+void minutes_floor( Time& timecode );
+void hours_floor( Time& timecode );
+
+} // namespace Timecode
+
+std::ostream& operator<<(std::ostream& ostr, const Timecode::Time& t);
+
+#endif  // __ardour_timecode_h__
diff --git a/libs/musictime/src/time.cc b/libs/musictime/src/time.cc
new file mode 100644 (file)
index 0000000..8784a90
--- /dev/null
@@ -0,0 +1,435 @@
+/*
+       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 Timecode_IS_AROUND_ZERO( sm ) (!(sm).frames && !(sm).seconds && !(sm).minutes && !(sm).hours)
+#define Timecode_IS_ZERO( sm ) (!(sm).frames && !(sm).seconds && !(sm).minutes && !(sm).hours && !(sm.subframes))
+
+#include <math.h>
+
+#include "musictime/time.h"
+
+namespace Timecode {
+
+float Time::default_rate = 30.0;
+
+
+/** Increment @a timecode by exactly one frame (keep subframes value).
+ * Realtime safe.
+ * @return true if seconds wrap.
+ */
+Wrap
+increment( Time& timecode, uint32_t subframes_per_frame )
+{
+       Wrap wrap = NONE;
+
+       if (timecode.negative) {
+               if (Timecode_IS_AROUND_ZERO(timecode) && timecode.subframes) {
+                       // We have a zero transition involving only subframes
+                       timecode.subframes = subframes_per_frame - timecode.subframes;
+                       timecode.negative = false;
+                       return SECONDS;
+               }
+    
+               timecode.negative = false;
+               wrap = decrement( timecode, subframes_per_frame );
+               if (!Timecode_IS_ZERO( timecode )) {
+                       timecode.negative = true;
+               }
+               return wrap;
+       }
+
+       switch ((int)ceil(timecode.rate)) {
+       case 24:
+               if (timecode.frames == 23) {
+                       timecode.frames = 0;
+                       wrap = SECONDS;
+               }
+               break;
+       case 25:
+               if (timecode.frames == 24) {
+                       timecode.frames = 0;
+                       wrap = SECONDS;
+               }
+               break;
+       case 30:
+               if (timecode.drop) {
+                      if (timecode.frames == 29) {
+                             if ( ((timecode.minutes + 1) % 10) && (timecode.seconds == 59) ) {
+                                    timecode.frames = 2;
+                             }
+                             else {
+                                    timecode.frames = 0;
+                             }
+                             wrap = SECONDS;
+                      }
+               } else {
+
+                      if (timecode.frames == 29) {
+                             timecode.frames = 0;
+                             wrap = SECONDS;
+                      }
+               }
+               break;
+       case 60:
+               if (timecode.frames == 59) {
+                       timecode.frames = 0;
+                       wrap = SECONDS;
+               }
+               break;
+       }
+  
+       if (wrap == SECONDS) {
+               if (timecode.seconds == 59) {
+                       timecode.seconds = 0;
+                       wrap = MINUTES;
+                       if (timecode.minutes == 59) {
+                               timecode.minutes = 0;
+                               wrap = HOURS;
+                               timecode.hours++;
+                       } else {
+                               timecode.minutes++;
+                       }
+               } else {
+                       timecode.seconds++;
+               }
+       } else {
+               timecode.frames++;
+       }
+  
+       return wrap;
+}
+
+
+/** Decrement @a timecode by exactly one frame (keep subframes value)
+ * Realtime safe.
+ * @return true if seconds wrap. */
+Wrap
+decrement( Time& timecode, uint32_t subframes_per_frame )
+{
+       Wrap wrap = NONE;
+  
+  
+       if (timecode.negative || Timecode_IS_ZERO(timecode)) {
+               timecode.negative = false;
+               wrap = increment( timecode, subframes_per_frame );
+               timecode.negative = true;
+               return wrap;
+       } else if (Timecode_IS_AROUND_ZERO(timecode) && timecode.subframes) {
+               // We have a zero transition involving only subframes
+               timecode.subframes = subframes_per_frame - timecode.subframes;
+               timecode.negative = true;
+               return SECONDS;
+       }
+  
+       switch ((int)ceil(timecode.rate)) {
+       case 24:
+               if (timecode.frames == 0) {
+                       timecode.frames = 23;
+                       wrap = SECONDS;
+               }
+               break;
+       case 25:
+               if (timecode.frames == 0) {
+                       timecode.frames = 24;
+                       wrap = SECONDS;
+               }
+               break;
+       case 30:
+               if (timecode.drop) {
+                       if ((timecode.minutes % 10) && (timecode.seconds == 0)) {
+                               if (timecode.frames <= 2) {
+                                       timecode.frames = 29;
+                                       wrap = SECONDS;
+                               }
+                       } else if (timecode.frames == 0) {
+                               timecode.frames = 29;
+                               wrap = SECONDS;
+                       }
+                       
+               } else {
+                       if (timecode.frames == 0) {
+                               timecode.frames = 29;
+                               wrap = SECONDS;
+                       }
+               }
+               break;
+       case 60:
+               if (timecode.frames == 0) {
+                       timecode.frames = 59;
+                       wrap = SECONDS;
+               }
+               break;
+       }
+  
+       if (wrap == SECONDS) {
+               if (timecode.seconds == 0) {
+                       timecode.seconds = 59;
+                       wrap = MINUTES;
+                       if (timecode.minutes == 0) {
+                               timecode.minutes = 59;
+                               wrap = HOURS;
+                               timecode.hours--;
+                       }
+                       else {
+                               timecode.minutes--;
+                       }
+               } else {
+                       timecode.seconds--;
+               }
+       } else {
+               timecode.frames--;
+       }
+  
+       if (Timecode_IS_ZERO( timecode )) {
+               timecode.negative = false;
+       }
+  
+       return wrap;
+}
+
+
+/** Go to lowest absolute subframe value in this frame (set to 0 :-) ) */
+void
+frames_floor( Time& timecode )
+{
+       timecode.subframes = 0;
+       if (Timecode_IS_ZERO(timecode)) {
+               timecode.negative = false;
+       }
+}
+
+
+/** Increment @a timecode by one subframe */
+Wrap
+increment_subframes( Time& timecode, uint32_t subframes_per_frame )
+{
+       Wrap wrap = NONE;
+  
+       if (timecode.negative) {
+               timecode.negative = false;
+               wrap = decrement_subframes( timecode, subframes_per_frame );
+               if (!Timecode_IS_ZERO(timecode)) {
+                       timecode.negative = true;
+               }
+               return wrap;
+       }
+  
+       timecode.subframes++;
+       if (timecode.subframes >= subframes_per_frame) {
+               timecode.subframes = 0;
+               increment( timecode, subframes_per_frame );
+               return FRAMES;
+       }
+       return NONE;
+}
+
+
+/** Decrement @a timecode by one subframe */
+Wrap
+decrement_subframes( Time& timecode, uint32_t subframes_per_frame )
+{
+       Wrap wrap = NONE;
+  
+       if (timecode.negative) {
+               timecode.negative = false;
+               wrap = increment_subframes( timecode, subframes_per_frame );
+               timecode.negative = true;
+               return wrap;
+       }
+  
+       if (timecode.subframes <= 0) {
+               timecode.subframes = 0;
+               if (Timecode_IS_ZERO(timecode)) {
+                       timecode.negative = true;
+                       timecode.subframes = 1;
+                       return FRAMES;
+               } else {
+                       decrement( timecode, subframes_per_frame );
+                       timecode.subframes = 79;
+                       return FRAMES;
+               }
+       } else {
+               timecode.subframes--;
+               if (Timecode_IS_ZERO(timecode)) {
+                       timecode.negative = false;
+               }
+               return NONE;
+       }
+}
+
+
+/** Go to next whole second (frames == 0 or frames == 2) */
+Wrap
+increment_seconds( Time& timecode, uint32_t subframes_per_frame )
+{
+       Wrap wrap = NONE;
+  
+       // Clear subframes
+       frames_floor( timecode );
+  
+       if (timecode.negative) {
+               // Wrap second if on second boundary
+               wrap = increment(timecode, subframes_per_frame);
+               // Go to lowest absolute frame value
+               seconds_floor( timecode );
+               if (Timecode_IS_ZERO(timecode)) {
+                       timecode.negative = false;
+               }
+       } else {
+               // Go to highest possible frame in this second
+         switch ((int)ceil(timecode.rate)) {
+               case 24:
+                       timecode.frames = 23;
+                       break;
+               case 25:
+                       timecode.frames = 24;
+                       break;
+               case 30:
+                       timecode.frames = 29;
+                       break;
+               case 60:
+                       timecode.frames = 59;
+                       break;
+               }
+    
+               // Increment by one frame
+               wrap = increment( timecode, subframes_per_frame );
+       }
+  
+       return wrap;
+}
+
+
+/** Go to lowest (absolute) frame value in this second
+ * Doesn't care about positive/negative */
+void
+seconds_floor( Time& timecode )
+{
+       // Clear subframes
+       frames_floor( timecode );
+  
+       // Go to lowest possible frame in this second
+       switch ((int)ceil(timecode.rate)) {
+       case 24:
+       case 25:
+       case 30:
+       case 60:
+               if (!(timecode.drop)) {
+                       timecode.frames = 0;
+               } else {
+
+                       if ((timecode.minutes % 10) && (timecode.seconds == 0)) {
+                               timecode.frames = 2;
+                       } else {
+                               timecode.frames = 0;
+                       }
+               }
+               break;
+       }
+  
+       if (Timecode_IS_ZERO(timecode)) {
+               timecode.negative = false;
+       }
+}
+
+
+/** Go to next whole minute (seconds == 0, frames == 0 or frames == 2) */
+Wrap
+increment_minutes( Time& timecode, uint32_t subframes_per_frame )
+{
+       Wrap wrap = NONE;
+  
+       // Clear subframes
+       frames_floor( timecode );
+  
+       if (timecode.negative) {
+               // Wrap if on minute boundary
+               wrap = increment_seconds( timecode, subframes_per_frame );
+               // Go to lowest possible value in this minute
+               minutes_floor( timecode );
+       } else {
+               // Go to highest possible second
+               timecode.seconds = 59;
+               // Wrap minute by incrementing second
+               wrap = increment_seconds( timecode, subframes_per_frame );
+       }
+  
+       return wrap;
+}
+
+
+/** Go to lowest absolute value in this minute */
+void
+minutes_floor( Time& timecode )
+{
+       // Go to lowest possible second
+       timecode.seconds = 0;
+       // Go to lowest possible frame
+       seconds_floor( timecode );
+
+       if (Timecode_IS_ZERO(timecode)) {
+               timecode.negative = false;
+       }
+}
+
+
+/** Go to next whole hour (minute = 0, second = 0, frame = 0) */
+Wrap
+increment_hours( Time& timecode, uint32_t subframes_per_frame )
+{
+       Wrap wrap = NONE;
+  
+       // Clear subframes
+       frames_floor(timecode);
+  
+       if (timecode.negative) {
+               // Wrap if on hour boundary
+               wrap = increment_minutes( timecode, subframes_per_frame );
+               // Go to lowest possible value in this hour
+               hours_floor( timecode );
+       } else {
+               timecode.minutes = 59;
+               wrap = increment_minutes( timecode, subframes_per_frame );
+       }
+  
+       return wrap;
+}
+
+
+/** Go to lowest absolute value in this hour */
+void
+hours_floor( Time& timecode )
+{
+       timecode.minutes = 0;
+       timecode.seconds = 0;
+       timecode.frames = 0;
+       timecode.subframes = 0;
+  
+       if (Timecode_IS_ZERO(timecode)) {
+               timecode.negative = false;
+       }
+}
+
+
+} // namespace Timecode
+
+std::ostream& 
+operator<<(std::ostream& ostr, const Timecode::Time& t) 
+{
+       return t.print (ostr);
+}
diff --git a/libs/musictime/wscript b/libs/musictime/wscript
new file mode 100644 (file)
index 0000000..938ef6e
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+import autowaf
+import Options
+import os
+
+# Version of this package (even if built as a child)
+MUSICTIME_VERSION = '0.0.0'
+
+# Library version (UNIX style major, minor, micro)
+# major increment <=> incompatible changes
+# minor increment <=> compatible changes (additions)
+# micro increment <=> no interface changes
+# Version history:
+#   0.0.0 = 0,0,0
+MUSICTIME_LIB_VERSION = '0.0.0'
+
+# Variables for 'waf dist'
+APPNAME = 'musictime'
+VERSION = MUSICTIME_VERSION
+
+# Mandatory variables
+srcdir = '.'
+blddir = 'build'
+
+def set_options(opt):
+       autowaf.set_options(opt)
+
+def configure(conf):
+       autowaf.configure(conf)
+
+       conf.check_tool('compiler_cxx')
+
+def build(bld):
+       # Library
+       obj = bld.new_task_gen('cxx', 'shlib')
+       obj.source         = 'src/time.cc'
+       obj.export_incdirs = ['.']
+       obj.includes       = ['.', './src']
+       obj.name           = 'libmusictime'
+       obj.target         = 'musictime'
+       obj.vnum           = MUSICTIME_LIB_VERSION
+       obj.install_path   = os.path.join(bld.env['LIBDIR'], 'ardour3')
+
+def shutdown():
+       autowaf.shutdown()
+
index 4f53ed43ae3139d71290590d36260181679d60d9..f555ed326a63a9d8e85e84feee670a23293dc098 100644 (file)
@@ -30,7 +30,7 @@
 
 #include <jack/types.h>
 
-#include "control_protocol/timecode.h"
+#include "musictime/time.h"
 
 namespace ARDOUR {
        class Session;
diff --git a/libs/surfaces/control_protocol/control_protocol/timecode.h b/libs/surfaces/control_protocol/control_protocol/timecode.h
deleted file mode 100644 (file)
index 6b04b70..0000000
+++ /dev/null
@@ -1,82 +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_timecode_h__
-#define __ardour_timecode_h__
-
-#include <ostream>
-#include <inttypes.h>
-
-namespace Timecode {
-
-enum Wrap {
-       NONE = 0,
-       FRAMES,
-       SECONDS,
-       MINUTES,
-       HOURS
-};
-
-struct Time {
-       bool       negative;
-       uint32_t   hours;
-       uint32_t   minutes;
-       uint32_t   seconds;
-       uint32_t   frames;        ///< Timecode 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 Timecode
-
-       Time(float a_rate = default_rate) {
-               negative = false;
-               hours = 0;
-               minutes = 0;
-               seconds = 0;
-               frames = 0;
-               subframes = 0;
-               rate = a_rate;
-       }
-
-        std::ostream& print (std::ostream& ostr) const {
-               if (negative) {
-                       ostr << '-';
-               }
-               ostr << hours << ':' << minutes << ':' << seconds << ':' << frames << '.' << subframes << " @" << rate << (drop ? " drop" : " nondrop");
-               return ostr;
-       }
-
-};
-
-Wrap increment( Time& timecode, uint32_t );
-Wrap decrement( Time& timecode, uint32_t );
-Wrap increment_subframes( Time& timecode, uint32_t );
-Wrap decrement_subframes( Time& timecode, uint32_t );
-Wrap increment_seconds( Time& timecode, uint32_t );
-Wrap increment_minutes( Time& timecode, uint32_t );
-Wrap increment_hours( Time& timecode, uint32_t );
-void frames_floor( Time& timecode );
-void seconds_floor( Time& timecode );
-void minutes_floor( Time& timecode );
-void hours_floor( Time& timecode );
-
-} // namespace Timecode
-
-std::ostream& operator<<(std::ostream& ostr, const Timecode::Time& t);
-
-#endif  // __ardour_timecode_h__
diff --git a/libs/surfaces/control_protocol/smpte.cc b/libs/surfaces/control_protocol/smpte.cc
deleted file mode 100644 (file)
index 10edd62..0000000
+++ /dev/null
@@ -1,434 +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 Timecode_IS_AROUND_ZERO( sm ) (!(sm).frames && !(sm).seconds && !(sm).minutes && !(sm).hours)
-#define Timecode_IS_ZERO( sm ) (!(sm).frames && !(sm).seconds && !(sm).minutes && !(sm).hours && !(sm.subframes))
-
-#include "control_protocol/timecode.h"
-#include "ardour/rc_configuration.h"
-
-namespace Timecode {
-
-float Time::default_rate = 30.0;
-
-
-/** Increment @a timecode by exactly one frame (keep subframes value).
- * Realtime safe.
- * @return true if seconds wrap.
- */
-Wrap
-increment( Time& timecode, uint32_t subframes_per_frame )
-{
-       Wrap wrap = NONE;
-
-       if (timecode.negative) {
-               if (Timecode_IS_AROUND_ZERO(timecode) && timecode.subframes) {
-                       // We have a zero transition involving only subframes
-                       timecode.subframes = subframes_per_frame - timecode.subframes;
-                       timecode.negative = false;
-                       return SECONDS;
-               }
-    
-               timecode.negative = false;
-               wrap = decrement( timecode, subframes_per_frame );
-               if (!Timecode_IS_ZERO( timecode )) {
-                       timecode.negative = true;
-               }
-               return wrap;
-       }
-
-       switch ((int)ceil(timecode.rate)) {
-       case 24:
-               if (timecode.frames == 23) {
-                       timecode.frames = 0;
-                       wrap = SECONDS;
-               }
-               break;
-       case 25:
-               if (timecode.frames == 24) {
-                       timecode.frames = 0;
-                       wrap = SECONDS;
-               }
-               break;
-       case 30:
-               if (timecode.drop) {
-                      if (timecode.frames == 29) {
-                             if ( ((timecode.minutes + 1) % 10) && (timecode.seconds == 59) ) {
-                                    timecode.frames = 2;
-                             }
-                             else {
-                                    timecode.frames = 0;
-                             }
-                             wrap = SECONDS;
-                      }
-               } else {
-
-                      if (timecode.frames == 29) {
-                             timecode.frames = 0;
-                             wrap = SECONDS;
-                      }
-               }
-               break;
-       case 60:
-               if (timecode.frames == 59) {
-                       timecode.frames = 0;
-                       wrap = SECONDS;
-               }
-               break;
-       }
-  
-       if (wrap == SECONDS) {
-               if (timecode.seconds == 59) {
-                       timecode.seconds = 0;
-                       wrap = MINUTES;
-                       if (timecode.minutes == 59) {
-                               timecode.minutes = 0;
-                               wrap = HOURS;
-                               timecode.hours++;
-                       } else {
-                               timecode.minutes++;
-                       }
-               } else {
-                       timecode.seconds++;
-               }
-       } else {
-               timecode.frames++;
-       }
-  
-       return wrap;
-}
-
-
-/** Decrement @a timecode by exactly one frame (keep subframes value)
- * Realtime safe.
- * @return true if seconds wrap. */
-Wrap
-decrement( Time& timecode, uint32_t subframes_per_frame )
-{
-       Wrap wrap = NONE;
-  
-  
-       if (timecode.negative || Timecode_IS_ZERO(timecode)) {
-               timecode.negative = false;
-               wrap = increment( timecode, subframes_per_frame );
-               timecode.negative = true;
-               return wrap;
-       } else if (Timecode_IS_AROUND_ZERO(timecode) && timecode.subframes) {
-               // We have a zero transition involving only subframes
-               timecode.subframes = subframes_per_frame - timecode.subframes;
-               timecode.negative = true;
-               return SECONDS;
-       }
-  
-       switch ((int)ceil(timecode.rate)) {
-       case 24:
-               if (timecode.frames == 0) {
-                       timecode.frames = 23;
-                       wrap = SECONDS;
-               }
-               break;
-       case 25:
-               if (timecode.frames == 0) {
-                       timecode.frames = 24;
-                       wrap = SECONDS;
-               }
-               break;
-       case 30:
-               if (timecode.drop) {
-                       if ((timecode.minutes % 10) && (timecode.seconds == 0)) {
-                               if (timecode.frames <= 2) {
-                                       timecode.frames = 29;
-                                       wrap = SECONDS;
-                               }
-                       } else if (timecode.frames == 0) {
-                               timecode.frames = 29;
-                               wrap = SECONDS;
-                       }
-                       
-               } else {
-                       if (timecode.frames == 0) {
-                               timecode.frames = 29;
-                               wrap = SECONDS;
-                       }
-               }
-               break;
-       case 60:
-               if (timecode.frames == 0) {
-                       timecode.frames = 59;
-                       wrap = SECONDS;
-               }
-               break;
-       }
-  
-       if (wrap == SECONDS) {
-               if (timecode.seconds == 0) {
-                       timecode.seconds = 59;
-                       wrap = MINUTES;
-                       if (timecode.minutes == 0) {
-                               timecode.minutes = 59;
-                               wrap = HOURS;
-                               timecode.hours--;
-                       }
-                       else {
-                               timecode.minutes--;
-                       }
-               } else {
-                       timecode.seconds--;
-               }
-       } else {
-               timecode.frames--;
-       }
-  
-       if (Timecode_IS_ZERO( timecode )) {
-               timecode.negative = false;
-       }
-  
-       return wrap;
-}
-
-
-/** Go to lowest absolute subframe value in this frame (set to 0 :-) ) */
-void
-frames_floor( Time& timecode )
-{
-       timecode.subframes = 0;
-       if (Timecode_IS_ZERO(timecode)) {
-               timecode.negative = false;
-       }
-}
-
-
-/** Increment @a timecode by one subframe */
-Wrap
-increment_subframes( Time& timecode, uint32_t subframes_per_frame )
-{
-       Wrap wrap = NONE;
-  
-       if (timecode.negative) {
-               timecode.negative = false;
-               wrap = decrement_subframes( timecode, subframes_per_frame );
-               if (!Timecode_IS_ZERO(timecode)) {
-                       timecode.negative = true;
-               }
-               return wrap;
-       }
-  
-       timecode.subframes++;
-       if (timecode.subframes >= subframes_per_frame) {
-               timecode.subframes = 0;
-               increment( timecode, subframes_per_frame );
-               return FRAMES;
-       }
-       return NONE;
-}
-
-
-/** Decrement @a timecode by one subframe */
-Wrap
-decrement_subframes( Time& timecode, uint32_t subframes_per_frame )
-{
-       Wrap wrap = NONE;
-  
-       if (timecode.negative) {
-               timecode.negative = false;
-               wrap = increment_subframes( timecode, subframes_per_frame );
-               timecode.negative = true;
-               return wrap;
-       }
-  
-       if (timecode.subframes <= 0) {
-               timecode.subframes = 0;
-               if (Timecode_IS_ZERO(timecode)) {
-                       timecode.negative = true;
-                       timecode.subframes = 1;
-                       return FRAMES;
-               } else {
-                       decrement( timecode, subframes_per_frame );
-                       timecode.subframes = 79;
-                       return FRAMES;
-               }
-       } else {
-               timecode.subframes--;
-               if (Timecode_IS_ZERO(timecode)) {
-                       timecode.negative = false;
-               }
-               return NONE;
-       }
-}
-
-
-/** Go to next whole second (frames == 0 or frames == 2) */
-Wrap
-increment_seconds( Time& timecode, uint32_t subframes_per_frame )
-{
-       Wrap wrap = NONE;
-  
-       // Clear subframes
-       frames_floor( timecode );
-  
-       if (timecode.negative) {
-               // Wrap second if on second boundary
-               wrap = increment(timecode, subframes_per_frame);
-               // Go to lowest absolute frame value
-               seconds_floor( timecode );
-               if (Timecode_IS_ZERO(timecode)) {
-                       timecode.negative = false;
-               }
-       } else {
-               // Go to highest possible frame in this second
-         switch ((int)ceil(timecode.rate)) {
-               case 24:
-                       timecode.frames = 23;
-                       break;
-               case 25:
-                       timecode.frames = 24;
-                       break;
-               case 30:
-                       timecode.frames = 29;
-                       break;
-               case 60:
-                       timecode.frames = 59;
-                       break;
-               }
-    
-               // Increment by one frame
-               wrap = increment( timecode, subframes_per_frame );
-       }
-  
-       return wrap;
-}
-
-
-/** Go to lowest (absolute) frame value in this second
- * Doesn't care about positive/negative */
-void
-seconds_floor( Time& timecode )
-{
-       // Clear subframes
-       frames_floor( timecode );
-  
-       // Go to lowest possible frame in this second
-       switch ((int)ceil(timecode.rate)) {
-       case 24:
-       case 25:
-       case 30:
-       case 60:
-               if (!(timecode.drop)) {
-                       timecode.frames = 0;
-               } else {
-
-                       if ((timecode.minutes % 10) && (timecode.seconds == 0)) {
-                               timecode.frames = 2;
-                       } else {
-                               timecode.frames = 0;
-                       }
-               }
-               break;
-       }
-  
-       if (Timecode_IS_ZERO(timecode)) {
-               timecode.negative = false;
-       }
-}
-
-
-/** Go to next whole minute (seconds == 0, frames == 0 or frames == 2) */
-Wrap
-increment_minutes( Time& timecode, uint32_t subframes_per_frame )
-{
-       Wrap wrap = NONE;
-  
-       // Clear subframes
-       frames_floor( timecode );
-  
-       if (timecode.negative) {
-               // Wrap if on minute boundary
-               wrap = increment_seconds( timecode, subframes_per_frame );
-               // Go to lowest possible value in this minute
-               minutes_floor( timecode );
-       } else {
-               // Go to highest possible second
-               timecode.seconds = 59;
-               // Wrap minute by incrementing second
-               wrap = increment_seconds( timecode, subframes_per_frame );
-       }
-  
-       return wrap;
-}
-
-
-/** Go to lowest absolute value in this minute */
-void
-minutes_floor( Time& timecode )
-{
-       // Go to lowest possible second
-       timecode.seconds = 0;
-       // Go to lowest possible frame
-       seconds_floor( timecode );
-
-       if (Timecode_IS_ZERO(timecode)) {
-               timecode.negative = false;
-       }
-}
-
-
-/** Go to next whole hour (minute = 0, second = 0, frame = 0) */
-Wrap
-increment_hours( Time& timecode, uint32_t subframes_per_frame )
-{
-       Wrap wrap = NONE;
-  
-       // Clear subframes
-       frames_floor(timecode);
-  
-       if (timecode.negative) {
-               // Wrap if on hour boundary
-               wrap = increment_minutes( timecode, subframes_per_frame );
-               // Go to lowest possible value in this hour
-               hours_floor( timecode );
-       } else {
-               timecode.minutes = 59;
-               wrap = increment_minutes( timecode, subframes_per_frame );
-       }
-  
-       return wrap;
-}
-
-
-/** Go to lowest absolute value in this hour */
-void
-hours_floor( Time& timecode )
-{
-       timecode.minutes = 0;
-       timecode.seconds = 0;
-       timecode.frames = 0;
-       timecode.subframes = 0;
-  
-       if (Timecode_IS_ZERO(timecode)) {
-               timecode.negative = false;
-       }
-}
-
-
-} // namespace Timecode
-
-std::ostream& 
-operator<<(std::ostream& ostr, const Timecode::Time& t) 
-{
-       return t.print (ostr);
-}
index b118ca5726787736d9454756011af55ca0849bca..00c9613c77055ef3e237ff4c42f9b52fe9fd0e55 100644 (file)
@@ -24,14 +24,13 @@ def build(bld):
        obj.source = '''
                basic_ui.cc
                control_protocol.cc
-               smpte.cc
        '''
        obj.export_incdirs = ['.', './control_protocol' ]
        obj.cxxflags     = '-DPACKAGE="ardour_cp"'
        obj.includes     = ['.', './control_protocol']
        obj.name         = 'libardour_cp'
        obj.target       = 'ardourcp'
-       obj.uselib_local = 'libardour'
+       obj.uselib_local = 'libardour libmusictime'
        obj.vnum         = LIBARDOUR_CP_LIB_VERSION
        obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
 
diff --git a/wscript b/wscript
index 63b091d4fde14d160ff8c641af4b9e8dc1b3e563..44192ad4ac5f0e28ba640698b42d630207e49c7c 100644 (file)
--- a/wscript
+++ b/wscript
@@ -25,6 +25,7 @@ children = [
        'libs/taglib',
        'libs/rubberband',
        'libs/surfaces',
+       'libs/musictime',
        'libs/ardour',
        'libs/gtkmm2ext',
        'libs/clearlooks-newer',
@@ -582,6 +583,7 @@ def build(bld):
         bld.path.find_dir ('libs/evoral/evoral')
         bld.path.find_dir ('libs/vamp-sdk/vamp-sdk')
         bld.path.find_dir ('libs/surfaces/control_protocol/control_protocol')
+       bld.path.find_dir ('libs/musictime/musictime')
         bld.path.find_dir ('libs/rubberband/rubberband')
         bld.path.find_dir ('libs/gtkmm2ext/gtkmm2ext')
         bld.path.find_dir ('libs/ardour/ardour')