ASPiK SDK
Loading...
Searching...
No Matches
Use the ICustomView Pointer

Back in the PluginCore's PluginCore::processMessage( ) function, we add the code to the handler for the PLUGINGUI_TIMERPING message that will pump out the queued audio data and call the repaint message on the custom view object. Note that we are sharing the same lock-free ring buffer that the PluginCore object owns and distributing (copying) data to both custom views:

case PLUGINGUI_TIMERPING:
{
if (waveView || spectrumView)
{
float audioSample = 0.0;
// --- try to get a value from queue
bool success = customViewDataQueue.try_dequeue(audioSample);
// --- if succeeds:
if (success)
{
// --- empty queue into views; the each handle this differently
while (success)
{
if (waveView)
waveView->pushDataValue(audioSample);
if (spectrumView)
spectrumView->pushDataValue(audioSample);
// -- try to get next value until queue is empty
success = customViewDataQueue.try_dequeue(audioSample);
}
}
// --- update and mark view as dirty
if (waveView)
waveView->updateView();
if (spectrumView)
spectrumView->updateView();
return true;
}
return false;
}
//

This is all the code that you need to make the system work. The lock-free ring buffers and the custom view object handle the rest of the work.