definitions and stubs to make it compile

This commit is contained in:
Fischlurch 2011-04-27 02:25:36 +02:00
parent bf61ff7248
commit af1561068e
5 changed files with 81 additions and 3 deletions

View file

@ -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<MaterialiseIntoTarget> (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

View file

@ -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 <boost/noncopyable.hpp>
//#include <iostream>
@ -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&);

View file

@ -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,

View file

@ -92,6 +92,8 @@ namespace time {
return supportedFormats_.check<FMT>();
}
static PQuant retrieve (Symbol gridID);
//------Grid-API----------------------------------------------
virtual long gridPoint (TimeValue const& raw) const =0;

View file

@ -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);