Dusk Audio Framework
Loading...
Searching...
No Matches
AudioMidiSyncHelper Struct Reference

#include <DafPluginUtils.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 MidiEvent * midiEvents
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);
}
float * outputs[2]
Definition DafPluginUtils.hpp:137
AudioMidiSyncHelper(float **const o, uint32_t f, const MidiEvent *m, uint32_t mc)
Definition DafPluginUtils.hpp:145
Definition DafDetails.hpp:939

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 until 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: