better use a dedicated 'materialise' operation on the Quantiser
This commit is contained in:
parent
80f7dba334
commit
ccd40c3fee
3 changed files with 28 additions and 4 deletions
|
|
@ -197,7 +197,7 @@ namespace time {
|
|||
public:
|
||||
explicit
|
||||
MaterialiseIntoTarget (QuTime const& quant)
|
||||
: SetNewStartTimeMutation (Secs(quant).getTime())
|
||||
: SetNewStartTimeMutation (PQuant(quant)->materialise(quant))
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -264,8 +264,10 @@ namespace time {
|
|||
virtual void
|
||||
change (QuTime& target) const
|
||||
{
|
||||
long gridPoint = FrameNr(target)+steps_;
|
||||
imposeChange (target, PQuant(target)->timeOf(gridPoint));
|
||||
PQuant const& grid (target);
|
||||
int64_t originalGridPoint = grid->gridPoint(target);
|
||||
int64_t adjustedGridPoint = originalGridPoint + steps_;
|
||||
imposeChange (target, grid->timeOf (adjustedGridPoint));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace time {
|
|||
advice::Request<PQuant> query(gridID);
|
||||
PQuant grid_found = query.getAdvice();
|
||||
if (!grid_found)
|
||||
throw error::Logic ("unable to fetch the quantisation grid -- is it already defined?"
|
||||
throw error::Logic ("unable to fetch the quantisation grid -- was it already defined?" ////////TICKET #197
|
||||
, LUMIERA_ERROR_UNKNOWN_GRID);
|
||||
return grid_found;
|
||||
}
|
||||
|
|
@ -112,6 +112,27 @@ namespace time {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/** convenience shortcut: \em materialise a raw time value
|
||||
* based on this grid or time axis, but returning a raw time value.
|
||||
* Implemented as combination of the #gridAlign and #timeOf operations,
|
||||
* i.e. we quantise into this scale, but transform the result back onto
|
||||
* the raw time value scale.
|
||||
* @warning this operation incurs information loss. Values may be rounded
|
||||
* and / or clipped, according to the grid used. And, contrary to
|
||||
* a QuTime value, the information about the actual grid is
|
||||
* discarded. Please don't use this operation if you just
|
||||
* "want a number" but feel to too lazy to understand
|
||||
* properly what quantisation means!
|
||||
*/
|
||||
TimeValue
|
||||
Quantiser::materialise (TimeValue const& raw) const
|
||||
{
|
||||
return timeOf (gridPoint (raw));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** alignment to a simple fixed size grid.
|
||||
* The actual calculation first determines the number
|
||||
* of the grid interval containing the given rawTime,
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ namespace time {
|
|||
}
|
||||
|
||||
static PQuant retrieve (Symbol gridID);
|
||||
TimeValue materialise (TimeValue const& raw) const;
|
||||
|
||||
|
||||
//------Grid-API----------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue