DISTRHO Plugin Framework
Public Member Functions | Public Attributes | List of all members
AudioMidiSyncHelper Struct Reference

#include <DistrhoPluginUtils.hpp>

Public Member Functions

 AudioMidiSyncHelper (float **const o, uint32_t f, const MidiEvent *m, uint32_t mc)
 
bool nextEvent ()
 

Public Attributes

float * outputs [2]
 
uint32_t frames
 
const MidiEventmidiEvents
 
uint32_t midiEventCount
 

Detailed Description

Handy class to help keep audio buffer in sync with incoming MIDI events. To use it, create a local variable (on the stack) and call nextEvent() until it returns false.

for (AudioMidiSyncHelper amsh(outputs, frames, midiEvents, midiEventCount); amsh.nextEvent();)
{
float* const outL = amsh.outputs[0];
float* const outR = amsh.outputs[1];
for (uint32_t i=0; i<amsh.midiEventCount; ++i)
{
const MidiEvent& ev(amsh.midiEvents[i]);
// ... do something with the midi event
}
renderSynth(outL, outR, amsh.frames);
}
Definition: DistrhoPluginUtils.hpp:104
bool nextEvent()
Definition: DistrhoPluginUtils.hpp:131
float * outputs[2]
Definition: DistrhoPluginUtils.hpp:106
Definition: DistrhoDetails.hpp:891

Some important notes when using this class:

  1. MidiEvent::frame retains its original value, but it is useless, do not use it.
  2. The class variable names are the same as the default ones in the run function. Keep that in mind and try to avoid typos. :)

Constructor & Destructor Documentation

◆ AudioMidiSyncHelper()

AudioMidiSyncHelper::AudioMidiSyncHelper ( float **const  o,
uint32_t  f,
const MidiEvent m,
uint32_t  mc 
)
inline

Constructor, using values from the run function.

Member Function Documentation

◆ nextEvent()

bool AudioMidiSyncHelper::nextEvent ( )
inline

Process a batch of events untill no more are available. You must not read any more values from this class after this function returns false.

Member Data Documentation

◆ outputs

float* AudioMidiSyncHelper::outputs[2]

Parameters from the run function, adjusted for event sync


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