diff --git a/src/lib/time/digxel.hpp b/src/lib/time/digxel.hpp index fddae6168..1e4aa8f95 100644 --- a/src/lib/time/digxel.hpp +++ b/src/lib/time/digxel.hpp @@ -144,9 +144,9 @@ namespace time { template<> struct Formatter - : PrintfFormatter + : PrintfFormatter { - Formatter() : PrintfFormatter("%3d") { } + Formatter() : PrintfFormatter("%3d") { } }; template<> @@ -271,6 +271,14 @@ namespace time { + //---Supporting-increments-------------- + Digxel& operator+= (NUM inc) { value_ += inc; return *this; } + Digxel& operator-= (NUM dec) { value_ -= dec; return *this; } + Digxel& operator++ () { value_ += 1; return *this; } + Digxel& operator-- () { value_ -= 1; return *this; } + NUM operator++ (int) { NUM p(value_++); return p; } + NUM operator-- (int) { NUM p(value_--); return p; } + //---Supporting-totally_ordered--------- bool operator< (Digxel const& o) const { return value_ < NUM(o); } bool operator== (Digxel const& o) const { return value_ == NUM(o); } diff --git a/src/lib/time/formats.hpp b/src/lib/time/formats.hpp index a5cccc321..df7b83db2 100644 --- a/src/lib/time/formats.hpp +++ b/src/lib/time/formats.hpp @@ -81,7 +81,7 @@ namespace time { struct Smpte : NoInstance { - static void rebuild (SmpteTC&, QuantR); + static void rebuild (SmpteTC&, QuantR, TimeValue const&); static TimeValue evaluate (SmpteTC const&, QuantR); }; @@ -96,7 +96,7 @@ namespace time { struct Hms : NoInstance { - static void rebuild (HmsTC&, QuantR); + static void rebuild (HmsTC&, QuantR, TimeValue const&); static TimeValue evaluate (HmsTC const&, QuantR); }; @@ -113,7 +113,7 @@ namespace time { struct Seconds : NoInstance { - static void rebuild (Secs&, QuantR); + static void rebuild (Secs&, QuantR, TimeValue const&); static TimeValue evaluate (Secs const&, QuantR); }; diff --git a/src/lib/time/timecode.cpp b/src/lib/time/timecode.cpp index 4af2fec19..1f3201cf0 100644 --- a/src/lib/time/timecode.cpp +++ b/src/lib/time/timecode.cpp @@ -27,8 +27,10 @@ #include "lib/time/timequant.hpp" #include "lib/time/formats.hpp" #include "lib/time.h" +#include "lib/util.hpp" +using util::unConst; using std::string; @@ -56,6 +58,25 @@ namespace time { return quantiser.timeOf (framecnt); } + + /** build up a frame count + * by quantising the given time value + */ + void + Smpte::rebuild (SmpteTC& tc, QuantR quantiser, TimeValue const& rawTime) + { +// framecnt.setValueRaw(quantiser.gridPoint (rawTime)); + UNIMPLEMENTED("build smpte components from raw time"); + } + + /** calculate the time point denoted by this frame count */ + TimeValue + Smpte::evaluate (SmpteTC const& tc, QuantR quantiser) + { +// return quantiser.timeOf (framecnt); + UNIMPLEMENTED("calculate time from smpte"); + } + } @@ -72,7 +93,6 @@ namespace time { /** */ SmpteTC::SmpteTC (QuTime const& quantisedTime) : TCode(quantisedTime) -// : tpoint_(quantisedTime) /////////////////////////////TODO eternal bullshit { } @@ -91,32 +111,41 @@ namespace time { - /** */ - int - SmpteTC::getSecs() const + void + SmpteTC::rebuild() const { - return lumiera_time_seconds (tpoint_); + TimeValue point = Format::evaluate(*this, *quantiser_); + Format::rebuild(unConst(*this), *quantiser_, point); } - /** */ - int - SmpteTC::getMins() const + + string + SmpteTC::show() const { - return lumiera_time_minutes (tpoint_); + rebuild(); + string tc; + tc.reserve(15); + tc += sgn.show(); + tc += hours.show(); + tc += ':'; + tc += mins.show(); + tc += ':'; + tc += secs.show(); + tc += ':'; + tc += frames.show(); + return tc; } - /** */ - int - SmpteTC::getHours() const + SmpteTC& + SmpteTC::operator++ () { - return lumiera_time_hours (tpoint_); + UNIMPLEMENTED ("SMPTE unit increment"); } - /** */ - int - SmpteTC::getFrames() const + SmpteTC& + SmpteTC::operator-- () { - UNIMPLEMENTED ("Frame-Quantisation"); + UNIMPLEMENTED ("SMPTE unit decrement"); } /** */ diff --git a/src/lib/time/timecode.hpp b/src/lib/time/timecode.hpp index 704db4293..e633ccf58 100644 --- a/src/lib/time/timecode.hpp +++ b/src/lib/time/timecode.hpp @@ -30,7 +30,7 @@ #include "lib/symbol.hpp" //#include -//#include +#include #include ///////////////TODO #include @@ -105,22 +105,28 @@ namespace time { */ class SmpteTC : public TCode + , boost::unit_steppable { - TimeVar tpoint_; - - virtual string show() const { return string(tpoint_); } + + virtual string show() const ; virtual Literal tcID() const { return "SMPTE"; } - virtual TimeValue value() const { return tpoint_; } + virtual TimeValue value() const { return Format::evaluate (*this, *quantiser_); } public: typedef format::Smpte Format; SmpteTC (QuTime const& quantisedTime); - int getSecs () const; - int getMins () const; - int getHours () const; - int getFrames () const; + void rebuild() const; + + Digxel hours; + SexaDigit mins; + SexaDigit secs; + SexaDigit frames; + Signum sgn; + + SmpteTC& operator++(); + SmpteTC& operator--(); }; diff --git a/tests/lib/time/time-formats-test.cpp b/tests/lib/time/time-formats-test.cpp index e22c8ce1b..2fa68ec18 100644 --- a/tests/lib/time/time-formats-test.cpp +++ b/tests/lib/time/time-formats-test.cpp @@ -23,24 +23,28 @@ #include "lib/test/run.hpp" //#include "lib/test/test-helper.hpp" +#include "proc/asset/meta/time-grid.hpp" +#include "lib/time/timequant.hpp" #include "lib/time/timecode.hpp" +#include "lib/time/display.hpp" #include "lib/util.hpp" #include -//#include +#include //#include using boost::lexical_cast; using util::isnil; //using std::rand; -//using std::cout; -//using std::endl; +using std::cout; +using std::endl; namespace lib { namespace time{ namespace test{ + using asset::meta::TimeGrid; /******************************************************** * @test verify handling of grid aligned timecode values. @@ -52,28 +56,33 @@ namespace test{ class TimeFormats_test : public Test { virtual void - run (Arg arg) + run (Arg) { - long refval= isnil(arg)? 1 : lexical_cast (arg[1]); + TimeGrid::build("pal0", FrameRate::PAL); - TimeValue ref (refval); - - checkTimecodeUsageCycle (ref); - checkFrames (); - checkSeconds (); - checkHms (); +// checkTimecodeUsageCycle (); +// checkFrames (); +// checkSeconds (); +// checkHms (); checkSmpte(); - checkDropFrame(); +// checkDropFrame(); } void - checkTimecodeUsageCycle (TimeValue ref) + checkTimecodeUsageCycle () { UNIMPLEMENTED ("full usage cycle for a timecode value"); } + template + void + showTimeCode (TC timecode) + { + cout << timecode.describe()<<"=\""<(); // and now performing quantisation is OK SmpteTC smpte (funny); // also converting into SMPTE (which implies frame quantisation) - CHECK (0 == smpte.getFrames()); // we have 1fps, thus the frame part is always zero! - CHECK (cnt % 60 == smpte.getSecs()); // and the seconds part will be in sync with the frame count + CHECK (0 == smpte.frames); // we have 1fps, thus the frame part is always zero! + CHECK (cnt % 60 == smpte.secs); // and the seconds part will be in sync with the frame count } };