Plaquette
Loading...
Searching...
No Matches
pq::AbstractOscillator Class Reference

Triangle/sawtooth oscillator. More...

#include <AbstractOscillator.h>

Inheritance diagram for pq::AbstractOscillator:
Collaboration diagram for pq::AbstractOscillator:

Public Types

typedef ParameterSlot< AbstractOscillator > Parameter

Public Member Functions

 AbstractOscillator (float period)
 Constructor.
virtual void start ()
 Starts/restarts the oscillator.
virtual void period (float period)
 Sets the period (in seconds).
virtual float period () const
 Returns the period (in seconds).
Parameter Period ()
 Returns the period as a parameter.
virtual void frequency (float frequency)
 Sets the frequency (in Hz).
virtual float frequency () const
 Returns the frequency (in Hz).
Parameter Frequency ()
 Returns the frequency as a parameter.
virtual void bpm (float bpm)
 Sets the frequency in beats-per-minute.
virtual float bpm () const
 Returns the frequency (in BPM).
Parameter Bpm ()
 Returns the BPM as a parameter.
virtual void phase (float phase)
 Sets the phase at % of period.
virtual float phase () const
 Returns the phase (in % of period).
Parameter Phase ()
 Returns the phase as a parameter.
virtual void phaseShift (float phaseShift)
 Sets the phase shift (ie.
virtual float phaseShift () const
 Returns the phase shift (ie.
Parameter PhaseShift ()
 Returns the phase shift as a parameter.
virtual void jitter (float jitter)
 Sets the jittering level in [0, 1] (0: no jitter, 1: max jitter).
virtual float jitter () const
 Returns the randomness level in [0, 1].
virtual void noJitter ()
 Disables jittering.
Parameter Jitter ()
 Returns the jitter as a parameter.
virtual float jitteredPeriod () const
 Returns the period actually used for the current cycle.
virtual float jitteredFrequency () const
 Returns the frequency actually used for the current cycle.
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 void stop ()
 Interrupts and resets to zero.
virtual void pause ()
 Interrupts process.
virtual void resume ()
 Resumes process.
virtual void togglePause ()
 Toggles pause/unpause.

Protected Member Functions

bool _hasJitter () const
void _stepPhase (float deltaTimeSecondsTimesFixed32Max)
virtual void _setPhase32 (q0_32u_t phase32)
virtual void _setRunning (bool isRunning)
void _randomPickNext ()

Protected Attributes

float _period
float _frequency
float _phaseShiftOrRandomFrequencyRatio
q0_32u_t _phase32
bool _overflowed: 1
bool _isRunning: 1
bool _isForward: 1
bool _valueNeedsUpdate: 1
bool _preSkew: 1
bool _passedSkew: 1
uint8_t _data: 2
float _jitter

Detailed Description

Triangle/sawtooth oscillator.

Constructor & Destructor Documentation

◆ AbstractOscillator()

pq::AbstractOscillator::AbstractOscillator ( float period)

Constructor.

Parameters
periodthe period of oscillation (in seconds)

Member Function Documentation

◆ _setRunning()

void pq::AbstractOscillator::_setRunning ( bool isRunning)
protectedvirtual

Implements pq::Timeable.

◆ addTime()

void pq::AbstractOscillator::addTime ( float time)
virtual

Adds time to current time (in seconds).

Warning
This function is disabled if randomness() > 0.

Implements pq::Timeable.

◆ bpm()

void pq::AbstractOscillator::bpm ( float bpm)
virtual

Sets the frequency in beats-per-minute.

Parameters
bpmthe frequency of oscillation (in BPM)

◆ frequency()

void pq::AbstractOscillator::frequency ( float frequency)
virtual

Sets the frequency (in Hz).

Parameters
frequencythe frequency of oscillation (in Hz)

◆ isRunning()

virtual bool pq::AbstractOscillator::isRunning ( ) const
inlinevirtual

Returns true iff the wave is currently running.

Implements pq::Timeable.

◆ jitteredFrequency()

float pq::AbstractOscillator::jitteredFrequency ( ) const
virtual

Returns the frequency actually used for the current cycle.

When jitter() == 0, this is identical to frequency(). When jitter() > 0, this returns the stochastic (jittered) frequency currently in effect.

◆ jitteredPeriod()

float pq::AbstractOscillator::jitteredPeriod ( ) const
virtual

Returns the period actually used for the current cycle.

When jitter() == 0, this is identical to period(). When jitter() > 0, this returns the stochastic (jittered) period currently in effect.

◆ pause()

void pq::Timeable::pause ( )
virtualinherited

Interrupts process.

Reimplemented in pq::AbstractChronometer.

◆ period()

void pq::AbstractOscillator::period ( float period)
virtual

Sets the period (in seconds).

Parameters
periodthe period of oscillation (in seconds)

◆ phase()

void pq::AbstractOscillator::phase ( float phase)
virtual

Sets the phase at % of period.

Parameters
phasethe phase (in % of period)

◆ phaseShift() [1/2]

float pq::AbstractOscillator::phaseShift ( ) const
virtual

Returns the phase shift (ie.

the offset, in % of period).

Warning
This function always returns 0 when randomness() > 0.

◆ phaseShift() [2/2]

void pq::AbstractOscillator::phaseShift ( float phaseShift)
virtual

Sets the phase shift (ie.

the offset, in % of period).

Parameters
phaseShiftthe phase shift (in % of period)
Warning
This function is disabled if randomness() > 0.

◆ resume()

void pq::Timeable::resume ( )
virtualinherited

Resumes process.

Reimplemented in pq::AbstractChronometer.

◆ setForward()

virtual void pq::AbstractOscillator::setForward ( bool isForward)
inlinevirtual

Sets the direction of oscillation.

Parameters
isForwardtrue iff the wave is moving forward in time

◆ setTime()

void pq::AbstractOscillator::setTime ( float time)
virtual

Forces current time (in seconds).

Warning
This function is disabled if randomness() > 0.

Implements pq::Timeable.

◆ start()

void pq::AbstractOscillator::start ( )
virtual

Starts/restarts the oscillator.

Reimplemented from pq::Timeable.

◆ timeToPhase()

float pq::AbstractOscillator::timeToPhase ( float time) const
virtual

Utility function to convert time to phase.

Parameters
timerelative time in seconds
Returns
the equivalent phase

The documentation for this class was generated from the following files:
  • /home/tats/Documents/workspace/Plaquette/src/AbstractOscillator.h
  • /home/tats/Documents/workspace/Plaquette/src/AbstractOscillator.cpp