Plaquette
 
Loading...
Searching...
No Matches
pq::TimeSliceField< COUNT > Class Template Reference

TimeSliceField generic class. More...

#include <TimeSliceField.h>

Inheritance diagram for pq::TimeSliceField< COUNT >:
Collaboration diagram for pq::TimeSliceField< COUNT >:

Public Member Functions

 TimeSliceField (float period)
 Constructor.
 
virtual float at (float proportion) override
 Returns value at given proportion in [0, 1].
 
virtual float get () override
 Returns value.
 
virtual float put (float value) override
 Pushes value into the unit.
 
void period (float period)
 Sets period over which the time slice occurs.
 
float period () const
 Returns period.
 
float atIndex (size_t index)
 Returns value at given index.
 
size_t count () const
 Returns count.
 
bool updated ()
 Returns true if the field has been updated and is ready to be used.
 
bool isFull ()
 Returns true if the field is full.
 
void reset ()
 Resets the field.
 
void setRolling (bool rolling)
 Sets rolling mode.
 
void rolling ()
 Activates rolling mode.
 
void noRolling ()
 Deactivates rolling mode.
 
bool isRolling () const
 Returns true if rolling mode is active.
 
virtual void onUpdate (EventCallback callback)
 Registers event callback on update event.
 
template<typename T >
void populate (T *array, size_t size, bool wrap=false)
 Fills an array with values from this field.
 
virtual void clearEvents ()
 
float seconds () const
 Returns engine time in seconds.
 
uint32_t milliSeconds () const
 Returns engine time in milliseconds.
 
uint64_t microSeconds () const
 Returns engine time in microseconds.
 
unsigned long nSteps () const
 Returns number of engine steps.
 
float sampleRate () const
 Returns engine sample rate.
 
float samplePeriod () const
 Returns enginesample period.
 
 operator float ()
 Object can be used directly to access its value.
 
virtual float mapTo (float toLow, float toHigh)
 Maps value to new range.
 
 operator bool ()
 Operator that allows usage in conditional expressions.
 

Static Public Member Functions

static bool analogToDigital (float f)
 Converts analog (float) value to digital (bool) value.
 
static float digitalToAnalog (bool b)
 Converts digital (bool) value to analog (float) value.
 

Protected Member Functions

void _updateBuffer ()
 
virtual void step () override
 
virtual bool eventTriggered (EventType eventType)
 Returns true iff an event of a certain type has been triggered.
 
virtual void begin ()
 
virtual void onEvent (EventCallback callback, EventType eventType)
 Registers event callback.
 
Engineengine () const
 Returns the engine that owns this unit.
 

Protected Attributes

float _buffer [COUNT] = {}
 
size_t _index
 
size_t _previousIndex
 
float _period
 
float _lastValue
 
float _currentSumValuesStep
 
uint16_t _nValuesStep
 
q0_32u_t _phase32
 
bool _full: 1
 
bool _rolling: 1
 
bool _changed: 1
 
uint8_t _unused: 5
 

Static Protected Attributes

static constexpr size_t LAST_INDEX = COUNT - 1
 

Detailed Description

template<size_t COUNT>
class pq::TimeSliceField< COUNT >

TimeSliceField generic class.

Template Parameters
COUNTthe size of the buffer

Constructor & Destructor Documentation

◆ TimeSliceField()

template<size_t COUNT>
pq::TimeSliceField< COUNT >::TimeSliceField ( float  period)
inline

Constructor.

Parameters
periodthe period in seconds

Member Function Documentation

◆ at()

template<size_t COUNT>
virtual float pq::TimeSliceField< COUNT >::at ( float  proportion)
inlineoverridevirtual

Returns value at given proportion in [0, 1].

Parameters
proportionthe proportion of the field to read
Returns
the value

Implements pq::AbstractField.

◆ eventTriggered()

template<size_t COUNT>
virtual bool pq::TimeSliceField< COUNT >::eventTriggered ( EventType  eventType)
inlineprotectedvirtual

Returns true iff an event of a certain type has been triggered.

Reimplemented from pq::Unit.

◆ get()

template<size_t COUNT>
virtual float pq::TimeSliceField< COUNT >::get ( )
inlineoverridevirtual

Returns value.

Reimplemented from pq::Chainable.

◆ mapTo()

virtual float pq::Chainable::mapTo ( float  toLow,
float  toHigh 
)
inlinevirtualinherited

Maps value to new range.

This function guarantees that the value is within [toLow, toHigh]. If the unit's values are unbounded, returns get() constrained to [toLow, toHigh].

Reimplemented in pq::Normalizer, pq::DigitalUnit, pq::AnalogSource, pq::AnalogIn, pq::Ramp, pq::StreamIn, and pq::StreamOut.

◆ period()

template<size_t COUNT>
void pq::TimeSliceField< COUNT >::period ( float  period)
inline

Sets period over which the time slice occurs.

Parameters
periodthe new period (in seconds)

◆ populate()

template<typename T >
void pq::AbstractField::populate ( T *  array,
size_t  size,
bool  wrap = false 
)
inlineinherited

Fills an array with values from this field.

Parameters
arraythe array to read into
sizethe size of the array
wrapif true, the array is considered to be a circular buffer that wraps around

◆ put()

template<size_t COUNT>
virtual float pq::TimeSliceField< COUNT >::put ( float  value)
inlineoverridevirtual

Pushes value into the unit.

Parameters
valuethe value sent to the unit
Returns
the new value of the unit

Reimplemented from pq::Chainable.

◆ setRolling()

template<size_t COUNT>
void pq::TimeSliceField< COUNT >::setRolling ( bool  rolling)
inline

Sets rolling mode.

Parameters
rollingthe rolling mode

◆ step()

template<size_t COUNT>
virtual void pq::TimeSliceField< COUNT >::step ( )
inlineoverrideprotectedvirtual

Reimplemented from pq::Unit.


The documentation for this class was generated from the following file: