Allolib  1.0
C++ Components For Interactive Multimedia
al::PresetSequencer Class Reference

The PresetSequencer class allows triggering presets from a PresetHandler over time. More...

#include <C:/Users/Andres/source/repos/casm_viewer/external/tinc/external/allolib/include/al/ui/al_PresetSequencer.hpp>

Inheritance diagram for al::PresetSequencer:
al::osc::MessageConsumer

Classes

struct  EventCallback
 
struct  Step
 

Public Types

enum  StepType { PRESET , EVENT , PARAMETER }
 

Public Member Functions

 PresetSequencer (TimeMasterMode timeMasterMode=TimeMasterMode::TIME_MASTER_CPU)
 
void playSequence (std::string sequenceName, double timeScale=1.0f, double timeOffset=0.0)
 Start playing the sequence specified. More...
 
void stopSequence (bool triggerCallbacks=true)
 
void setTime (double time)
 Set time into the current sequence. More...
 
void rewind ()
 Load sequence an prepare for playback.
 
bool playbackFinished ()
 
std::vector< std::string > getSequenceList ()
 getSequenceList returns a list of sequences in the current sequence directory More...
 
void setDirectory (std::string directory)
 setDirectory sets the working directory for the PresetSequencer More...
 
void setHandlerSubDirectory (std::string subDir)
 Sets the sub-directory for the registered PresetHandler. More...
 
bool running ()
 
PresetSequencerregisterPresetHandler (PresetHandler &presetHandler)
 Register preset handler with sequencer. More...
 
PresetSequenceroperator<< (PresetHandler &presetHandler)
 Register PresetHandler through the << operator. More...
 
PresetSequenceroperator<< (ParameterMeta &param)
 
PresetSequencerregisterParameter (ParameterMeta &param)
 
std::vector< SteploadSequence (std::string sequenceName, double timeScale=1.0)
 Load steps from a sequence file. More...
 
std::string currentSequence ()
 
void registerEventCommand (std::string eventName, std::function< void(void *data, std::vector< ParameterField > &params)> callback, void *data)
 registerEventCommand registers a function associated with an event command More...
 
void setOSCSubPath (std::string subPath)
 
void registerBeginCallback (std::function< void(PresetSequencer *sender)> beginCallback)
 registerBeginCallback More...
 
void enableBeginCallback (bool enable)
 
void toggleEnableBeginCallback ()
 
void registerEndCallback (std::function< void(bool finished, PresetSequencer *sender)> endCallback)
 registerEndCallback More...
 
void enableEndCallback (bool enable)
 
void toggleEnableEndCallback ()
 
void registerTimeChangeCallback (std::function< void(float)> func, float minTimeDeltaSec=-1.0)
 
float getSequenceStartOffset (std::string sequenceName)
 
float getSequenceTotalDuration (std::string sequenceName)
 
void clearSteps ()
 
void appendStep (Step &newStep)
 appendStep More...
 
void setTimeMaster (TimeMasterMode masterMode)
 
void stepSequencer (double dt)
 step sequencer forward dt amount of time More...
 
void stepSequencer ()
 move sequencer forward by time set using setSequencerStepTime()
 
void setSequencerStepTime (double stepTime)
 

Protected Member Functions

virtual bool consumeMessage (osc::Message &m, std::string rootOSCPath) override
 Returns true if message was consumed by this class.
 
void processTimeChangeRequest ()
 
void updateTime (double time)
 
void updateSequencer ()
 

Friends

class Composition
 

Detailed Description

The PresetSequencer class allows triggering presets from a PresetHandler over time.

In order to use a preset sequencer you must register a preset handler with the sequencer:

PresetHandler presetHandler;
PresetSequencer sequencer;
sequencer << presetHandler;

Sequences that trigger presets are stored in text files with the format:

preset1:0.0:3.0
preset2:4.0:2.0
preset3:1.0:1.0
::

The first element in each line specifies the preset name that the PresetHandler should load (i.e. a file called "preset1.preset" in the current directory). The second element determines the time to get to the preset from the current state, i.e. the morph time to reach the preset. The third element determines the time the preset should be held after reaching it.

The file should end with two colons (::).

Individual parameters can also be sequenced through the preset sequencer. They must be registered through registerParameter() or the streaming (<<) operator.

The line should start with the '+' character followed by the delta time to the previous line. Note that parameters have delta times relative to both preset and parameter steps, but preset events are relative to other preset steps and ignore parameter and event steps.

preset1:0.0:3.0
+0.1:/X:0.3
+0.1:/X:0.4
+0.1:/X:0.5
preset2:4.0:2.0
::

The directory where sequences are loaded is taken from the PresetHandler object registered with the sequencer.

Definition at line 118 of file al_PresetSequencer.hpp.

Member Function Documentation

◆ appendStep()

void al::PresetSequencer::appendStep ( Step newStep)

appendStep

Parameters
newStepThis function will block while the sequence is playing. Always stop sequence before calling this function.

◆ getSequenceList()

std::vector<std::string> al::PresetSequencer::getSequenceList ( )

getSequenceList returns a list of sequences in the current sequence directory

Returns
a list of sequence names without path and without the '.sequence' extension

◆ loadSequence()

std::vector<Step> al::PresetSequencer::loadSequence ( std::string  sequenceName,
double  timeScale = 1.0 
)

Load steps from a sequence file.

Parameters
sequenceNameThe name of the sequence
timeScaleThe times in the sequence are multiplied by this factor
Returns
the steps

The sequence is searched in the PresetHandler current path or the PresetSequencer's directory if PresetHandler not registered.

◆ operator<<()

PresetSequencer& al::PresetSequencer::operator<< ( PresetHandler presetHandler)
inline

Register PresetHandler through the << operator.

Parameters
presetHandler
Returns
reference to this object

Definition at line 217 of file al_PresetSequencer.hpp.

◆ playSequence()

void al::PresetSequencer::playSequence ( std::string  sequenceName,
double  timeScale = 1.0f,
double  timeOffset = 0.0 
)

Start playing the sequence specified.

Parameters
sequenceName
timeScaleTimes in sequence are multiplied by this factor

There is a single sequencer engine in the PresetSequencer class, so if a sequence is playing when this command is issued, the current playback is interrupted and the new sequence requested starts immediately.

◆ registerBeginCallback()

void al::PresetSequencer::registerBeginCallback ( std::function< void(PresetSequencer *sender)>  beginCallback)

registerBeginCallback

When registered this function is called from the playback thread as soon as it is ready to start playing before calling the first step.

◆ registerEndCallback()

void al::PresetSequencer::registerEndCallback ( std::function< void(bool finished, PresetSequencer *sender)>  endCallback)

registerEndCallback

The callback provides a finished argument. If the sequence reached the end naturally, this argument will be passed as true. If it was stopped by the user prematurely, it will send false.

◆ registerEventCommand()

void al::PresetSequencer::registerEventCommand ( std::string  eventName,
std::function< void(void *data, std::vector< ParameterField > &params)>  callback,
void *  data 
)

registerEventCommand registers a function associated with an event command

Sequences can have events commands prefixed by . Whenever an event is found in a sequence, it triggers the callback registered here if the event name matches

◆ registerPresetHandler()

PresetSequencer& al::PresetSequencer::registerPresetHandler ( PresetHandler presetHandler)

Register preset handler with sequencer.

Parameters
presetHandler
Returns
Sequencer will recall presets through the registered preset handler. The sequencer's directory is set to the preset handler's directory

◆ setDirectory()

void al::PresetSequencer::setDirectory ( std::string  directory)
inline

setDirectory sets the working directory for the PresetSequencer

Parameters
directoryThis function can be used in cases where the actual sequencer is not needed, because preset recall and morphing is done by the PresetHandler. This is useful for instance if you need to query the step of a sequence for a different purpose. If a PresetHandler is registered, this value is ignored.

Definition at line 190 of file al_PresetSequencer.hpp.

◆ setHandlerSubDirectory()

void al::PresetSequencer::setHandlerSubDirectory ( std::string  subDir)

Sets the sub-directory for the registered PresetHandler.

Useful when you need to set the sub-dir but don't have easy access to the PresetHandler object.

◆ setTime()

void al::PresetSequencer::setTime ( double  time)

Set time into the current sequence.

Parameters
timeWill load the state at the time position for the currently playing se

◆ stepSequencer()

void al::PresetSequencer::stepSequencer ( double  dt)

step sequencer forward dt amount of time

Parameters
dtamount of time (seconds) to step

Any parameter and preset events that fall within this delta time will be applied.


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