From af1561068eaca02ba2be813c1f151f2ed98fd02e Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 27 Apr 2011 02:25:36 +0200 Subject: [PATCH] definitions and stubs to make it compile --- src/lib/time/mutation.cpp | 62 +++++++++++++++++++++++++++ src/lib/time/mutation.hpp | 5 ++- src/lib/time/quantiser.cpp | 11 +++++ src/lib/time/quantiser.hpp | 2 + tests/lib/time/time-mutation-test.cpp | 4 +- 5 files changed, 81 insertions(+), 3 deletions(-) diff --git a/src/lib/time/mutation.cpp b/src/lib/time/mutation.cpp index 6555c22b4..6e0082f6e 100644 --- a/src/lib/time/mutation.cpp +++ b/src/lib/time/mutation.cpp @@ -24,6 +24,7 @@ #include "lib/error.hpp" #include "lib/time/timevalue.hpp" #include "lib/time/timequant.hpp" +#include "lib/time/timecode.hpp" #include "lib/time/mutation.hpp" //#include "lib/time.h" //#include "lib/util.hpp" @@ -183,6 +184,23 @@ namespace time { }; + /** + * concrete time value mutation: + * make the grid aligned time value explicit, + * and impose the resulting value to the given + * time points (or start points). + */ + class MaterialiseIntoTarget + : public SetNewStartTimeMutation + { + public: + explicit + MaterialiseIntoTarget (QuTime const& quant) + : SetNewStartTimeMutation (Secs(quant).getTime()) + { } + }; + + /** Convenience factory to yield a simple Mutation changing the absolute start time. * This whole procedure might look quite inefficient, but actually most of the @@ -221,6 +239,28 @@ namespace time { } + /** Convenience factory: materialise the given quantised time into an explicit fixed + * internal time value, according to the underlying time grid; impose the resulting + * value then as new time point or start point to the target + * @note same as materialising and then invoking #changeTime + */ + EncapsulatedMutation + Mutation::materialise (QuTime const& gridAlignedTime) + { + return EncapsulatedMutation::build (gridAlignedTime); + } + + + /** build a time mutation to \em nudge the target time value by an offset, + * defined as number of steps on an implicit nudge grid. If the target is an + * continuous (not quantised) time value or duration, an internal 'default nudge grid' + * will be used to calculate the offset value. Typically, this grid counts in seconds. + * To the contrary, when the target is a quantised value, it will be aligned to the + * grid point relative to the current value's next grid point, measured in number + * of steps. This includes \em materialising the internal to the exact grid + * position. If especially the adjustment is zero, the internal value will + * be changed to literally equal the current value's next grid point. + */ EncapsulatedMutation Mutation::nudge (int adjustment) { @@ -228,6 +268,28 @@ namespace time { } + /** build a time mutation to \em nudge the target time value; the nudge time grid + * is specified explicitly here, instead of using a global or 'natural' nudge grid. + * In case the target itself is a quantised time value, a chaining of the two + * grids will happen: first, the nudge grid is used to get an offset value, + * according to the number of steps, then this offset is applied to the + * raw value underlying the quantised target. If this resulting target + * value later will be cast into any kind of time code or materialised + * otherwise, the quantised value's own grid will apply as well, + * resulting in the net result of two quantisation operations + * being applied in sequence. + * @param adjustment number of grid steps to apply as offset + * @param gridID symbolic name used to register or define a + * suitable nudge grid, typically somewhere globally + * in the session (as meta asset) + */ + EncapsulatedMutation + Mutation::nudge (int adjustment, Symbol gridID) + { + UNIMPLEMENTED ("Nudge by a predefined nudge amount"); + } + + }} // lib::time diff --git a/src/lib/time/mutation.hpp b/src/lib/time/mutation.hpp index 13c1b6bca..b05fcaacc 100644 --- a/src/lib/time/mutation.hpp +++ b/src/lib/time/mutation.hpp @@ -56,7 +56,7 @@ #include "lib/error.hpp" #include "lib/time/timevalue.hpp" #include "lib/polymorphic-value.hpp" -//#include "lib/symbol.hpp" +#include "lib/symbol.hpp" #include //#include @@ -67,6 +67,7 @@ namespace lib { namespace time { + using lib::Symbol; //using std::string; //using lib::Literal; @@ -106,7 +107,9 @@ namespace time { static EncapsulatedMutation changeTime (Time); static EncapsulatedMutation changeDuration (Duration); static EncapsulatedMutation adjust (Offset); + static EncapsulatedMutation materialise (QuTime const&); static EncapsulatedMutation nudge (int adjustment); + static EncapsulatedMutation nudge (int adjustment, Symbol gridID); protected: static void imposeChange (TimeValue&, TimeValue const&); diff --git a/src/lib/time/quantiser.cpp b/src/lib/time/quantiser.cpp index 9c4eca790..6ae061587 100644 --- a/src/lib/time/quantiser.cpp +++ b/src/lib/time/quantiser.cpp @@ -101,6 +101,17 @@ namespace time { + /** Access an existing grid definition or quantiser, known by the given symbolic ID. + * Typically this fetches a meta::TimeGrid (asset) from the session. + * @throw error::Logic if the given gridID wasn't registered + * @return smart-ptr to the quantiser instance */ + PQuant + Quantiser::retrieve (Symbol gridID) + { + return retrieveQuantiser (gridID); + } + + /** alignment to a simple fixed size grid. * The actual calculation first determines the number * of the grid interval containing the given rawTime, diff --git a/src/lib/time/quantiser.hpp b/src/lib/time/quantiser.hpp index 369c48055..a8efad7a1 100644 --- a/src/lib/time/quantiser.hpp +++ b/src/lib/time/quantiser.hpp @@ -92,6 +92,8 @@ namespace time { return supportedFormats_.check(); } + static PQuant retrieve (Symbol gridID); + //------Grid-API---------------------------------------------- virtual long gridPoint (TimeValue const& raw) const =0; diff --git a/tests/lib/time/time-mutation-test.cpp b/tests/lib/time/time-mutation-test.cpp index e1d461334..e54b32655 100644 --- a/tests/lib/time/time-mutation-test.cpp +++ b/tests/lib/time/time-mutation-test.cpp @@ -246,10 +246,10 @@ namespace test{ CHECK (t.dur == t.var + change * FrameRate::PAL.duration()); // ....this time the change was measured in grid units, // taken relative to the origin of the specified grid - PGrid testGrid = TimeGrid::retrieve("test_grid"); + PQuant testGrid = Quantiser::retrieve("test_grid"); Offset distance (testGrid->timeOf(0), testGrid->timeOf(change)); CHECK (distance == change * FrameRate::PAL.duration()); - CHECK (Time(t.dur) - t.var == distance); + CHECK (t.dur - t.var == distance);