Allolib
1.0
C++ Components For Interactive Multimedia
|
Event Sequencer triggering audio visual "notes". More...
Public Member Functions | |
SynthSequencer (TimeMasterMode masterMode=TimeMasterMode::TIME_MASTER_CPU) | |
SynthSequencer (PolySynth &synth) | |
void | render (AudioIOData &io) |
Insert this function within the audio callback. | |
void | render (Graphics &g) |
Insert this function within the graphics callback. | |
void | update (double dt) |
void | setGraphicsFrameRate (float fps) |
template<class TSynthVoice > | |
TSynthVoice & | add (double startTime, double duration=-1) |
insert an event in the sequencer More... | |
template<class TSynthVoice > | |
void | addVoice (TSynthVoice *voice, double startTime, double duration=-1) |
template<class TSynthVoice > | |
void | addVoiceFromNow (TSynthVoice *voice, double startTime, double duration=-1) |
void | print () |
print current sequence | |
bool | playing () |
bool | verbose () |
void | verbose (bool verbose) |
void | setTempo (float tempo) |
bool | playSequence (std::string sequenceName="", float startTime=0.0f) |
void | stopSequence () |
void | setTime (float newTime) |
void | setDirectory (std::string directory) |
std::string | buildFullPath (std::string sequenceName) |
std::list< SynthSequencerEvent > | loadSequence (std::string sequenceName, double timeOffset=0, double timeScale=1.0) |
void | playEvents (std::list< SynthSequencerEvent > events, double timeOffset=0.1) |
play the event list provided all other events in list are discarded | |
std::vector< std::string > | getSequenceList () |
double | getSequenceDuration (std::string sequenceName) |
PolySynth & | synth () |
void | registerTimeChangeCallback (std::function< void(float)> func, float minTimeDeltaSec=0) |
void | registerSequenceBeginCallback (std::function< void(std::string)> func) |
void | registerSequenceEndCallback (std::function< void(std::string)> func) |
registerSequenceEndCallback More... | |
void | registerSynth (PolySynth &synth) |
void | operator<< (PolySynth &synth) |
Static Public Member Functions | |
static void | audioCB (AudioIOData &io) |
Basic audio callback for quick prototyping. More... | |
Event Sequencer triggering audio visual "notes".
Sequences can be created programatically:
The render() functions need to be places within their relevant contexts like the audio callback (e.g. onSound() ) or the graphics callback (e.g. onDraw())
A time master can be selected in the constructor to define where the sequencer runs. TimeMasterMode::TIME_MASTER_AUDIO is more precise in time, but you might want to use TIME_MASTER_GRAPHICS if your "note" produces no audio.
Sequences can also be read from text files with the extension ".synthSequence". You need to register the voices used in the sequence with the PolySynth using this->synth().registerSynthClass<MyVoice>("MyVoice") to connect the voice name in the text file to a class name.
The following commands are accepted:
Event @ absTime duration synthName pFields....
e.g. @ 0.981379 0.116669 MyVoice 0 0 1 698.456 0.1 1
Turnon
e.g. + 0.981379 25 MyVoice 0 0 1 698.456 0.1 1
Turnoff
When using Turnon and Turnoff events, be careful not to use ids set automatically for @ events.
eventId looks of the oldest id match adn turns it off e.g. - 1.3 25
Tempo t tempoBpm
e.g. t 120
Only the last tempo statement present in a file will have effect, overriding any previous ones.
Insert another sequence = absTime sequenceName timeScale
e.g. = 201.0000 "endEtherial.synthSequence" 1
Time offset
timeOffset
All events following will have this offset added to their start time. Negative numbers are allowed.
Definition at line 176 of file al_SynthSequencer.hpp.
TSynthVoice & al::SynthSequencer::add | ( | double | startTime, |
double | duration = -1 |
||
) |
insert an event in the sequencer
startTime | |
duration |
The voice will be inserted into the sequencer immediately, so you may want to add all your notes before starting the sequencer. If you need to insert events on the fly, use addVoice() or use triggerOn() directly on the PolySynth
The TSynthVoice template must be a class inherited from SynthVoice.
Definition at line 347 of file al_SynthSequencer.hpp.
void al::SynthSequencer::addVoice | ( | TSynthVoice * | voice, |
double | startTime, | ||
double | duration = -1 |
||
) |
Insert configured voice into sequencer.
Definition at line 356 of file al_SynthSequencer.hpp.
void al::SynthSequencer::addVoiceFromNow | ( | TSynthVoice * | voice, |
double | startTime, | ||
double | duration = -1 |
||
) |
Insert configured voice into sequencer using time offset from current time
Definition at line 372 of file al_SynthSequencer.hpp.
|
inlinestatic |
Basic audio callback for quick prototyping.
io | Pass this audio callback to an AudioIO object with a pointer to a SynthSequencer instance to hear the sequence. |
Definition at line 242 of file al_SynthSequencer.hpp.
void al::SynthSequencer::registerSequenceEndCallback | ( | std::function< void(std::string)> | func | ) |
registerSequenceEndCallback
func | Note that this callback is called whenever the event list empties, so it will be triggered after events added dynamically through addVoice() and addVoiceFromNow() are consumed. The callback will be called after the last trigger off time, which means there might still be voices being processed while if the have release envelopes, for example |
|
inline |
Set the frame rate at which the graphics run (i.e. how often render(Graphics &g) will be called
Definition at line 203 of file al_SynthSequencer.hpp.