Home Manual Reference Source Repository
import LayerTimeContext from 'waves-ui/src/core/layer-time-context.js'
public class | source

LayerTimeContext

A LayerTimeContext instance represents a time segment into a TimelineTimeContext. It must be attached to a TimelineTimeContext (the one of the timeline it belongs to). It relies on its parent's timeToPixel (time to pixel transfert function) to create the time to pixel representation of the Layer (the view) it is attached to.

The layerTimeContext has four important attributes:

  • start represent the time at which temporal data must be represented in the timeline (for instance the begining of a soundfile in a DAW).
  • offset represents offset time of the data in the context of a Layer. (@TODO give a use case example here "crop ?", and/or explain that it's not a common use case).
  • duration is the duration of the view on the data.
  • stretchRatio is the stretch applyed to the temporal data contained in the view (this value can be seen as a local zoom on the data, or as a stretch on the time components of the data). When applyed, the stretch ratio maintain the start position of the view in the timeline.
+ timeline -----------------------------------------------------------------
0         5         10          15          20        25          30 seconds
+---+*****************+------------------------------------------+*******+--
    |*** soundfile ***|Layer (view on the sound file)            |*******|
    +*****************+------------------------------------------+*******+

    <---- offset ----><--------------- duration ----------------->
<-------- start ----->

The parts of the sound file represented with '*' are hidden from the view

example usage

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public get

Returns the duration of the time context (in seconds).

public set

Sets the duration of the time context (in seconds).

public get

Returns the offset of the time context (in seconds).

public set

Sets the offset of the time context (in seconds).

public

The TimelineTimeContext instance of the timeline.

public get

Returns the start position of the time context (in seconds).

public set

Sets the start position of the time context (in seconds).

public get

Returns the stretch ratio of the time context.

public set

Sets the stretch ratio of the time context.

public get

Returns the time to pixel transfert function of the time context.

Method Summary

Public Methods
public

Creates a clone of the current time context.

public

Helper function to convert pixel to time.

Public Constructors

public constructor(parent: TimelineTimeContext) source

Params:

NameTypeAttributeDescription
parent TimelineTimeContext

The TimelineTimeContext instance of the timeline.

Public Members

public get duration: Number source

Returns the duration of the time context (in seconds).

public set duration: Number source

Sets the duration of the time context (in seconds).

public get offset: Number source

Returns the offset of the time context (in seconds).

public set offset: Number source

Sets the offset of the time context (in seconds).

public parent: TimelineTimeContext source

The TimelineTimeContext instance of the timeline.

public get start: Number source

Returns the start position of the time context (in seconds).

public set start: Number source

Sets the start position of the time context (in seconds).

public get stretchRatio: Number source

Returns the stretch ratio of the time context.

public set stretchRatio: Number source

Sets the stretch ratio of the time context.

public get timeToPixel: Function source

Returns the time to pixel transfert function of the time context. If the stretchRatio attribute is equal to 1, this function is the global one from the TimelineTimeContext instance.

Public Methods

public clone(): LayerTimeContext source

Creates a clone of the current time context.

public pixelToTime(px: Number): Number source

Helper function to convert pixel to time.

Params:

NameTypeAttributeDescription
px Number

Return:

Number