Sine oscillator. Phase is expressed as % of period. More...
#include <Wave.h>


Public Member Functions | |
| Wave (float period, Engine &engine=Engine::primary()) | |
| Constructor (creates default square wave). | |
| Wave (WaveShape shape, Engine &engine=Engine::primary()) | |
| Constructor. | |
| Wave (float period, float skew, Engine &engine=Engine::primary()) | |
| Constructor (creates default square wave). | |
| Wave (WaveShape shape, float period, Engine &engine=Engine::primary()) | |
| Constructor. | |
| Wave (WaveShape shape, float period, float skew, Engine &engine=Engine::primary()) | |
| Constructor. | |
| void | shape (WaveShape shape) |
| Sets wave shape. | |
| WaveShape | shape () const |
| Returns current wave shape. | |
| virtual float | get () |
| Returns value in [0, 1]. | |
| virtual float | shiftBy (float phaseShift) |
| Returns oscillator's value with given phase shift (in % of period). | |
| virtual float | shiftByTime (float timeShift) |
| Returns oscillator's value with given phase shift expressed in time (in seconds). | |
| virtual float | atPhase (float phase) |
| Returns the oscillator's value at a given absolute phase (in % of period). | |
| virtual void | amplitude (float amplitude) |
| Sets the amplitude of the wave. | |
| virtual float | amplitude () const |
| Returns the amplitude of the wave. | |
| virtual void | skew (float skew) |
| Sets the skew of the signal as a % of period. | |
| virtual float | skew () const |
| Returns the skew of the signal. | |
| virtual void | width (float width) |
| virtual float | width () const |
| virtual void | onBang (EventCallback callback) |
| Registers event callback on wave end-of-period ("bang") event. | |
| virtual float | mapTo (float toLow, float toHigh) |
| Maps value to new range. | |
| 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 | put (float value) |
| Pushes value into the unit. | |
| operator bool () | |
| Operator that allows usage in conditional expressions. | |
| virtual void | period (float period) |
| Sets the period (in seconds). | |
| virtual float | period () const |
| Returns the period (in seconds). | |
| virtual void | frequency (float frequency) |
| Sets the frequency (in Hz). | |
| virtual float | frequency () const |
| Returns the frequency (in Hz). | |
| virtual void | bpm (float bpm) |
| Sets the frequency in beats-per-minute. | |
| virtual float | bpm () const |
| Returns the frequency (in BPM). | |
| virtual void | phase (float phase) |
| Sets the phase at % of period. | |
| virtual float | phase () const |
| Returns the phase (in % of period). | |
| virtual void | phaseShift (float phaseShift) |
| Sets the phase shift (ie. | |
| virtual float | phaseShift () const |
| Returns the phase shift (ie. | |
| virtual float | timeToPhase (float time) const |
| Utility function to convert time to phase. | |
| virtual void | setTime (float time) |
| Forces current time (in seconds). | |
| virtual void | addTime (float time) |
| Adds time to current time (in seconds). | |
| virtual bool | isRunning () const |
| Returns true iff the wave is currently running. | |
| virtual bool | isForward () const |
| Returns true iff the wave is moving forward in time. | |
| virtual void | setForward (bool isForward) |
| Sets the direction of oscillation. | |
| virtual void | forward () |
| Sets the direction of oscillation to move forward in time. | |
| virtual void | reverse () |
| Sets the direction of oscillation to move backward in time. | |
| virtual void | toggleReverse () |
| Toggles the direction of oscillation. | |
| virtual float | randomness () const |
| Returns the randomness level in [0, 1]. | |
| virtual void | randomize (float randomness=1.0f) |
| Sets the randomness level in [0, 1] (0: no randomness, 1: full randomness). | |
| virtual void | noRandomize () |
| Disables randomness. | |
| virtual void | start () |
| Starts/restarts the chronometer. | |
| virtual void | stop () |
| Interrupts the chronometer and resets to zero. | |
| virtual void | pause () |
| Interrupts the chronometer. | |
| virtual void | resume () |
| Resumes process. | |
| virtual void | togglePause () |
| Toggles pause/unpause. | |
Protected Member Functions | |
| virtual q0_32u_t | _getFixed32 (q0_32u_t t) |
| virtual void | begin () |
| virtual void | step () |
| virtual bool | eventTriggered (EventType eventType) |
| Returns true iff an event of a certain type has been triggered. | |
| virtual float | _getAmplified (q0_32u_t t) |
| virtual void | onEvent (EventCallback callback, EventType eventType) |
| Registers event callback. | |
| Engine * | engine () const |
| Returns the engine that owns this unit. | |
| void | _stepPhase (float deltaTimeSecondsTimesFixed32Max) |
| virtual void | _setPhase32 (q0_32u_t phase32) |
| virtual void | _setRunning (bool isRunning) |
| void | _randomPickNext () |
Sine oscillator. Phase is expressed as % of period.
| pq::Wave::Wave | ( | float | period, |
| Engine & | engine = Engine::primary() |
||
| ) |
Constructor (creates default square wave).
| period | the period of oscillation (in seconds) |
| engine | the engine running this unit |
|
explicit |
Constructor.
Defaults to period of 1 second.
| shape | the wave shape |
| engine | the engine running this unit |
| pq::Wave::Wave | ( | float | period, |
| float | skew, | ||
| Engine & | engine = Engine::primary() |
||
| ) |
Constructor (creates default square wave).
| period | the period of oscillation (in seconds) |
| skew | the duty-cycle as a value in [0, 1] |
| engine | the engine running this unit |
| pq::Wave::Wave | ( | WaveShape | shape, |
| float | period, | ||
| Engine & | engine = Engine::primary() |
||
| ) |
Constructor.
| shape | the wave shape |
| period | the period of oscillation (in seconds) |
| engine | the engine running this unit |
| pq::Wave::Wave | ( | WaveShape | shape, |
| float | period, | ||
| float | skew, | ||
| Engine & | engine = Engine::primary() |
||
| ) |
Constructor.
| shape | the wave shape |
| period | the period of oscillation (in seconds) |
| skew | the duty-cycle as a value in [0, 1] |
| engine | the engine running this unit |
|
protectedvirtual |
Implements pq::AbstractWave.
|
protectedvirtualinherited |
Implements pq::Timeable.
|
virtualinherited |
Adds time to current time (in seconds).
Implements pq::Timeable.
|
virtualinherited |
Sets the amplitude of the wave.
| amplitude | a value in [0, 1] that determines the amplitude of the wave (centered at 0.5). |
|
virtualinherited |
Returns the oscillator's value at a given absolute phase (in % of period).
Supports values outside [0,1], which will be wrapped accordingly. Eg: atPhase(0.25) returns the oscillator value at 25% of its period.
| phase | the absolute phase at which to evaluate the oscillator (in % of period) |
|
protectedvirtualinherited |
Reimplemented from pq::Unit.
|
virtualinherited |
Sets the frequency in beats-per-minute.
| bpm | the frequency of oscillation (in BPM) |
|
protectedvirtualinherited |
Returns true iff an event of a certain type has been triggered.
Reimplemented from pq::Unit.
|
virtualinherited |
Sets the frequency (in Hz).
| frequency | the frequency of oscillation (in Hz) |
|
virtualinherited |
Returns value in [0, 1].
Reimplemented from pq::AnalogSource.
|
inlinevirtualinherited |
Returns true iff the wave is currently running.
Implements pq::Timeable.
|
inlinevirtualinherited |
Maps value to new range.
Reimplemented from pq::Chainable.
Reimplemented in pq::Normalizer, pq::StreamIn, and pq::StreamOut.
|
virtualinherited |
Interrupts the chronometer.
Reimplemented in pq::AbstractChronometer.
|
virtualinherited |
Sets the period (in seconds).
| period | the period of oscillation (in seconds) |
|
virtualinherited |
Sets the phase at % of period.
| phase | the phase (in % of period) |
|
virtualinherited |
Returns the phase shift (ie.
the offset, in % of period).
|
virtualinherited |
Sets the phase shift (ie.
the offset, in % of period).
| phaseShift | the phase shift (in % of period) |
|
inlinevirtualinherited |
Pushes value into the unit.
| value | the value sent to the unit |
Reimplemented in pq::Chronometer, pq::MinMaxScaler, pq::Normalizer, pq::PeakDetector, pq::DigitalUnit, pq::AnalogOut, pq::AbstractServoOut, pq::Ramp, pq::Smoother, pq::StreamOut, pq::PivotField, and pq::TimeSliceField< COUNT >.
|
virtualinherited |
Resumes process.
Reimplemented in pq::AbstractChronometer.
|
inlinevirtualinherited |
Sets the direction of oscillation.
| isForward | true iff the wave is moving forward in time |
|
virtualinherited |
Forces current time (in seconds).
Implements pq::Timeable.
| void pq::Wave::shape | ( | WaveShape | shape | ) |
Sets wave shape.
| shape | the wave shape (SQUARE, TRIANGLE, SINE) |
|
virtualinherited |
Returns oscillator's value with given phase shift (in % of period).
Supports values outside [0,1], which will be wrapped accordingly. Eg. shiftBy(0.2) returns future value of oscillator after 20% of its period would have passed.
| phaseShift | the phase shift (in % of period) |
|
virtualinherited |
Returns oscillator's value with given phase shift expressed in time (in seconds).
| timeShift | the shift in time (seconds) |
|
virtualinherited |
Sets the skew of the signal as a % of period.
| skew | the skew as a value in [0, 1] |
|
virtualinherited |
Starts/restarts the chronometer.
Reimplemented in pq::AbstractTimer, and pq::Ramp.
|
protectedvirtualinherited |
Reimplemented from pq::Unit.
|
virtualinherited |
Utility function to convert time to phase.
| time | relative time in seconds |
|
inlinevirtualinherited |
|
inlinevirtualinherited |
| width | the skew as a value in [0, 1] |