Allolib
1.0
C++ Components For Interactive Multimedia
|
The PresetSequencer class allows triggering presets from a PresetHandler over time. More...
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 () |
PresetSequencer & | registerPresetHandler (PresetHandler &presetHandler) |
Register preset handler with sequencer. More... | |
PresetSequencer & | operator<< (PresetHandler &presetHandler) |
Register PresetHandler through the << operator. More... | |
PresetSequencer & | operator<< (ParameterMeta ¶m) |
PresetSequencer & | registerParameter (ParameterMeta ¶m) |
std::vector< Step > | loadSequence (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 > ¶ms)> 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 |
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:
Sequences that trigger presets are stored in text files with the format:
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.
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.
void al::PresetSequencer::appendStep | ( | Step & | newStep | ) |
appendStep
newStep | This function will block while the sequence is playing. Always stop sequence before calling this function. |
std::vector<std::string> al::PresetSequencer::getSequenceList | ( | ) |
getSequenceList returns a list of sequences in the current sequence directory
std::vector<Step> al::PresetSequencer::loadSequence | ( | std::string | sequenceName, |
double | timeScale = 1.0 |
||
) |
Load steps from a sequence file.
sequenceName | The name of the sequence |
timeScale | The times in the sequence are multiplied by this factor |
The sequence is searched in the PresetHandler current path or the PresetSequencer's directory if PresetHandler not registered.
|
inline |
Register PresetHandler through the << operator.
presetHandler |
Definition at line 217 of file al_PresetSequencer.hpp.
void al::PresetSequencer::playSequence | ( | std::string | sequenceName, |
double | timeScale = 1.0f , |
||
double | timeOffset = 0.0 |
||
) |
Start playing the sequence specified.
sequenceName | |
timeScale | Times 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.
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.
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.
void al::PresetSequencer::registerEventCommand | ( | std::string | eventName, |
std::function< void(void *data, std::vector< ParameterField > ¶ms)> | 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
PresetSequencer& al::PresetSequencer::registerPresetHandler | ( | PresetHandler & | presetHandler | ) |
Register preset handler with sequencer.
presetHandler |
|
inline |
setDirectory sets the working directory for the PresetSequencer
directory | This 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.
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.
void al::PresetSequencer::setTime | ( | double | time | ) |
Set time into the current sequence.
time | Will load the state at the time position for the currently playing se |
void al::PresetSequencer::stepSequencer | ( | double | dt | ) |
step sequencer forward dt amount of time
dt | amount of time (seconds) to step |
Any parameter and preset events that fall within this delta time will be applied.