1 #ifndef AL_SYNTHRECORDER_HPP 
    2 #define AL_SYNTHRECORDER_HPP 
   49 #include "al/io/al_File.hpp" 
   50 #include "al/scene/al_SynthSequencer.hpp" 
  103   SynthRecorder(TextFormat format = SEQUENCER_EVENT) { mFormat = format; }
 
  105   void setDirectory(std::string path) {
 
  108         std::cout << 
"Error creating directory: " << path << std::endl;
 
  114   void startRecord(std::string name = 
"", 
bool overwrite = 
false,
 
  115                    bool startOnEvent = 
true);
 
  119   void setMaxRecordTime(al_sec maxTime) { mMaxRecordTime = maxTime; }
 
  121   void verbose(
bool verbose) { mVerbose = 
true; }
 
  122   bool verbose() { 
return mVerbose; }
 
  131     registerPolySynth(handler);
 
  135   void registerPolySynth(
PolySynth &polySynth);
 
  146     std::chrono::high_resolution_clock::time_point now =
 
  147         std::chrono::high_resolution_clock::now();
 
  149     if (rec->mRecording) {
 
  150       std::unique_lock<std::mutex> lk(rec->mSequenceLock);
 
  151       if (rec->mStartOnEvent) {
 
  152         rec->mSequenceStart = now;
 
  153         rec->mStartOnEvent = 
false;
 
  155       std::chrono::duration<double> diff = now - rec->mSequenceStart;
 
  159       event.type = SynthEventType::TRIGGER_ON;
 
  160       event.id = voice->
id();
 
  161       event.time = diff.count();
 
  162       event.synthName = demangle(
typeid(*voice).name());
 
  164       event.pFields = pFields;
 
  165       rec->mSequence.push_back(event);
 
  166       if (rec->verbose()) {
 
  167         std::cout << 
"trigger at " << 
event.time << 
":" << 
event.synthName
 
  168                   << 
":" << voice->
id() << std::endl;
 
  180     std::chrono::high_resolution_clock::time_point now =
 
  181         std::chrono::high_resolution_clock::now();
 
  183     if (rec->mRecording) {
 
  184       std::unique_lock<std::mutex> lk(rec->mSequenceLock);
 
  189       std::chrono::duration<double> diff = now - rec->mSequenceStart;
 
  192       event.type = SynthEventType::TRIGGER_OFF;
 
  194       event.time = diff.count();
 
  200       rec->mSequence.push_back(event);
 
  201       if (rec->verbose()) {
 
  202         std::cout << 
"trigger OFF at " << 
event.time << 
":" << 
event.synthName
 
  203                   << 
":" << 
id << std::endl;
 
  210   std::string mDirectory;
 
  216   std::string mSequenceName;
 
  218   std::mutex mSequenceLock;
 
  220   bool mRecording{
false};
 
  221   bool mStartOnEvent{
true};
 
  223   al_sec mMaxRecordTime;
 
  224   std::chrono::high_resolution_clock::time_point mSequenceStart;
 
  225   std::vector<SynthEvent> mSequence;
 
static bool make(const std::string &path)
Constructor. This does not attempt to open the directory.
 
static bool exists(const std::string &path)
Returns whether a file or directory exists.
 
A PolySynth manages polyphony and rendering of SynthVoice instances.
 
The SynthRecorder class records the events arriving at a PolySynth.
 
static bool onTriggerOn(SynthVoice *voice, int offsetFrames, int id, void *userData)
onTriggerOn callback for trigger on events
 
static bool onTriggerOff(int id, void *userData)
onTriggerOff callback for trigger off events
 
void id(int idValue)
Set the id for this voice.
 
virtual int getTriggerParams(float *pFields, int maxParams=-1)
Get this instance's parameter fields.