OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
ossia::time_interval Class Reference

The time_interval class. More...

Detailed Description

The time_interval class.

time_interval is use to describe temporal structure precising which amount of time (the duration) are between two #time_events.

The duration can be fixed or between a minimal and a maximal duration.

time_interval is a #TimeProcess container.

Public Types

using exec_callback = std::optional< smallfun::function< void(bool, ossia::time_value), 32 > >
 to get the interval execution back
 

Public Member Functions

auto get_date () const noexcept
 
auto get_offset () const noexcept
 
double get_internal_speed () const noexcept
 
double get_speed (time_value date) const noexcept
 
double speed_override () const noexcept
 
double local_time_factor (const ossia::token_request &parent_request) const noexcept
 
int64_t advance_for (ossia::time_value, const ossia::token_request &parent_request) const noexcept
 
int64_t take_backward_step (ossia::time_value, const ossia::token_request &parent_request) noexcept
 
void set_offset (ossia::time_value g) noexcept
 
void set_speed (double g) noexcept
 
void set_parent_speed (double sp) noexcept
 
tick_transport_info current_transport_info () const noexcept
 
void tick_current (ossia::time_value offset, const ossia::token_request &parent_request)
 
void tick (ossia::time_value, const ossia::token_request &parent_request, double ratio=1.0)
 Root driver tick: covers the parent request's whole carried sample span.
 
void tick_offset (ossia::time_value, ossia::time_value offset, const ossia::token_request &parent_request, int32_t start_sample=-1, int32_t length_sample=-1)
 
void tick_offset_speed_precomputed (ossia::time_value, ossia::time_value offset, const ossia::token_request &parent_request, int32_t start_sample=-1, int32_t length_sample=-1)
 
 time_interval (time_interval::exec_callback, time_event &, time_event &, time_value=Infinite, ossia::time_value=Zero, ossia::time_value=Infinite)
 
 ~time_interval ()
 destructor
 
void start ()
 start time_interval
 
void start_and_tick ()
 
void stop ()
 stop time_interval
 
void pause ()
 start time_interval
 
void resume ()
 stop time_interval
 
void offset (ossia::time_value)
 set time_interval's offset and process a state at offset date
 
void transport (ossia::time_value)
 
void set_callback (exec_callback)
 sets a new callback for the interval
 
void set_callback (smallfun::function< void(bool, ossia::time_value), 32 >)
 
const time_valueget_nominal_duration () const
 get the time_interval nominal duration
 
time_intervalset_nominal_duration (ossia::time_value)
 set the time_interval duration
 
const time_valueget_min_duration () const
 get the time_interval minimal duration
 
time_intervalset_min_duration (ossia::time_value)
 set the time_interval minimal duration
 
const time_valueget_max_duration () const
 get the time_interval maximal duration
 
time_intervalset_max_duration (ossia::time_value)
 set the time_interval maximal duration
 
time_eventget_start_event () const
 get the event from where the time_interval starts
 
time_eventget_end_event () const
 get the event from where the time_interval starts
 
void add_time_process (std::shared_ptr< time_process >)
 add a #TimeProcess
 
void remove_time_process (time_process *)
 remove a #TimeProcess
 
void reserve_processes (std::size_t sz)
 
const std::vector< std::shared_ptr< time_process > > & get_time_processes () const
 get time processes attached to the time_interval
 
bool running () const noexcept
 
void cleanup ()
 
void mute (bool)
 
void set_time_signature_map (std::optional< time_signature_map > map)
 
void set_quarter_duration (double tu)
 

Static Public Member Functions

static std::shared_ptr< time_intervalcreate (time_interval::exec_callback, time_event &, time_event &, time_value=Infinite, ossia::time_value=Zero, ossia::time_value=Infinite)
 constructor
 

Public Attributes

bool graphal {}
 

Member Typedef Documentation

◆ exec_callback

using ossia::time_interval::exec_callback = std::optional<smallfun::function<void(bool, ossia::time_value), 32> >

to get the interval execution back

Parameters
const#TimeValue position
const#TimeValue date
std::shared_ptr<State>

Member Function Documentation

◆ speed_override()

double ossia::time_interval::speed_override ( ) const
noexcept

Dimensionless rate multiplier last written into the interval node's Speed inlet, 1. if nothing was ever written there. Only meaningful when the interval has a tempo curve, since that is when the inlet exists.

◆ local_time_factor()

double ossia::time_interval::local_time_factor ( const ossia::token_request &  parent_request) const
noexcept

The factor between the parent's model time and ours for this tick: the same one the tick duration is scaled by. A tempo-locked interval runs at its tempo whatever the transport does, hence the parent-speed division.

◆ advance_for()

int64_t ossia::time_interval::advance_for ( ossia::time_value  date,
const ossia::token_request &  parent_request 
) const
noexcept

How far a tick of this length would move us, in our own model time, carried fraction included. This is what the tick actually advances by, so anything deciding whether the tick fits must ask this and not recompute.

◆ take_backward_step()

int64_t ossia::time_interval::take_backward_step ( ossia::time_value  date,
const ossia::token_request &  parent_request 
)
noexcept

How far back a rewinding scenario moves us, as a positive magnitude, the carried fraction consumed the same way a forward tick consumes it so that going out and back lands on the date we started from.

◆ tick_offset()

void ossia::time_interval::tick_offset ( ossia::time_value  date,
ossia::time_value  offset,
const ossia::token_request &  parent_request,
int32_t  start_sample = -1,
int32_t  length_sample = -1 
)

The span parameters are the samples of the audio buffer this tick stands for, decided by the caller (the scenario cutting the buffer on interval boundaries, or the root callback handing the whole buffer): they are carried into the tokens verbatim, precisely because they cannot be reconstructed from the flick-quantised model dates. -1 means unknown.

◆ create()

std::shared_ptr< time_interval > ossia::time_interval::create ( time_interval::exec_callback  callback,
time_event startEvent,
time_event endEvent,
ossia::time_value  nominal = Infinite,
ossia::time_value  min = Zero,
ossia::time_value  max = Infinite 
)
static

constructor

by default a time_interval has an infinite duration with no minimal duration and an infinite maximal duration.

Parameters
time_interval::ExecutionCallbackto use to be notified at each step
std::shared_ptr<TimeEvent>event where the time_interval starts
std::shared_ptr<TimeEvent>event where the time_interval ends
const#TimeValue& nominal duration of the time_interval
const#TimeValue& minimal duration of the time_interval
const#TimeValue& maximal duration of the time_interval
Returns
std::shared_ptr<time_interval>

◆ offset()

void ossia::time_interval::offset ( ossia::time_value  date)

set time_interval's offset and process a state at offset date

the returned #State is made of as many as sub States for each TimeProcess the time_interval manages

don't call offset when the time_interval is running

Parameters
const#TimeValue offset date
Returns
std::shared_ptr<#State>

◆ set_callback()

void ossia::time_interval::set_callback ( time_interval::exec_callback  cb)

sets a new callback for the interval

Parameters
time_interval::ExecutionCallbackto use to be notified at each step

◆ get_nominal_duration()

const time_value & ossia::time_interval::get_nominal_duration ( ) const

get the time_interval nominal duration

Returns
const #TimeValue& nominal duration

◆ set_nominal_duration()

time_interval & ossia::time_interval::set_nominal_duration ( ossia::time_value  durationNominal)

set the time_interval duration

Parameters
const#TimeValue& duration
Returns
time_interval the interval

◆ get_min_duration()

const time_value & ossia::time_interval::get_min_duration ( ) const

get the time_interval minimal duration

Returns
const #TimeValue& minimal duration

◆ set_min_duration()

time_interval & ossia::time_interval::set_min_duration ( ossia::time_value  durationMin)

set the time_interval minimal duration

Parameters
const#TimeValue& minimal duration
Returns
time_interval the interval

◆ get_max_duration()

const time_value & ossia::time_interval::get_max_duration ( ) const

get the time_interval maximal duration

Returns
const #TimeValue& maximal duration

◆ set_max_duration()

time_interval & ossia::time_interval::set_max_duration ( ossia::time_value  durationMax)

set the time_interval maximal duration

Parameters
const#TimeValue& maximal duration
Returns
time_interval the interval

◆ get_start_event()

time_event & ossia::time_interval::get_start_event ( ) const

get the event from where the time_interval starts

Returns
std::shared_ptr<#time_event> start event

◆ get_end_event()

time_event & ossia::time_interval::get_end_event ( ) const

get the event from where the time_interval starts

Returns
std::shared_ptr<#time_event> start event

◆ add_time_process()

void ossia::time_interval::add_time_process ( std::shared_ptr< time_process timeProcess)

add a #TimeProcess

it also stores the #TimeProcess's start and end #States into the time_interval's start and end #time_events

Parameters
std::shared_ptr<TimeProcess>to insert

◆ remove_time_process()

void ossia::time_interval::remove_time_process ( time_process timeProcess)

remove a #TimeProcess

it also removes the #TimeProcess's start and end #States from the time_interval's start and end #time_events

Parameters
std::shared_ptr<TimeProcess>to insert

◆ get_time_processes()

const std::vector< std::shared_ptr< time_process > > & ossia::time_interval::get_time_processes ( ) const
inline

get time processes attached to the time_interval

Returns
#Container<#TimeProcess>