Async UI update from audio thread

pull/1/head
asb2m10 11 years ago
parent 9d27438638
commit 28d04c91f2
  1. BIN
      Builds/MacOSX/Dexed.xcodeproj/project.xcworkspace/xcuserdata/asb2m10.xcuserdatad/UserInterfaceState.xcuserstate
  2. 2
      Source/PluginData.cpp
  3. 2
      Source/PluginEditor.cpp
  4. 2
      Source/PluginParam.cpp
  5. 15
      Source/PluginProcessor.cpp
  6. 12
      Source/PluginProcessor.h

@ -194,7 +194,7 @@ void DexedAudioProcessor::packProgram(int idx, const char *name) {
void DexedAudioProcessor::updateProgramFromSysex(const uint8 *rawdata) {
memcpy(data, rawdata, 160);
refreshUI = true;
triggerAsyncUpdate();
}
void DexedAudioProcessor::loadBuiltin(int idx) {

@ -250,8 +250,6 @@ void DexedAudioProcessorEditor::timerCallback() {
int32_t env[6];
if ( processor->refreshUI ) {
if ( processor->refreshUI & DexedAudioProcessor::REFRESH_COMP )
updateUI();
if ( processor->refreshUI & DexedAudioProcessor::REFRESH_MSG )
global.repaint();
processor->refreshUI = 0;

@ -417,7 +417,7 @@ void DexedAudioProcessor::setCurrentProgram(int index) {
unpackProgram(index);
lfo.reset(data + 137);
currentProgram = index;
updateUI();
triggerAsyncUpdate();
}
const String DexedAudioProcessor::getProgramName(int index) {

@ -28,6 +28,7 @@
#include "msfa/pitchenv.h"
#include "msfa/aligned_buf.h"
//==============================================================================
DexedAudioProcessor::DexedAudioProcessor() {
#ifdef DEBUG
@ -189,7 +190,7 @@ void DexedAudioProcessor::processMidiMessage(MidiMessage *msg) {
}
TRACE("program update sysex");
updateProgramFromSysex(buf+4);
refreshUI |= REFRESH_COMP;
triggerAsyncUpdate();
return;
}
@ -202,7 +203,7 @@ void DexedAudioProcessor::processMidiMessage(MidiMessage *msg) {
TRACE("update 32bulk voice)");
importSysex((const char *)buf+4);
currentProgram = 0;
refreshUI |= REFRESH_COMP;
triggerAsyncUpdate();
}
return;
}
@ -222,6 +223,8 @@ void DexedAudioProcessor::processMidiMessage(MidiMessage *msg) {
case 0xb0 : {
int controller = buf[1];
int value = buf[2];
// pedal
if (controller == 64) {
sustain = value != 0;
if (!sustain) {
@ -417,6 +420,9 @@ bool DexedAudioProcessor::hasEditor() const {
void DexedAudioProcessor::updateUI() {
// notify host something has changed
updateHostDisplay();
AudioProcessorEditor *editor = getActiveEditor();
if ( editor == NULL ) {
return;
@ -429,6 +435,11 @@ AudioProcessorEditor* DexedAudioProcessor::createEditor() {
return new DexedAudioProcessorEditor (this);
}
void DexedAudioProcessor::handleAsyncUpdate() {
updateUI();
}
void DexedAudioProcessor::log(const char *source, const char *fmt, ...) {
char output[4096];
va_list argptr;

@ -41,7 +41,7 @@ struct ProcessorVoice {
//==============================================================================
/**
*/
class DexedAudioProcessor : public AudioProcessor
class DexedAudioProcessor : public AudioProcessor, public AsyncUpdater
{
static const int MAX_ACTIVE_NOTES = 16;
ProcessorVoice voices[MAX_ACTIVE_NOTES];
@ -89,13 +89,17 @@ class DexedAudioProcessor : public AudioProcessor
void keydown(uint8_t pitch, uint8_t velo);
void keyup(uint8_t pitch);
void processSamples(int n_samples, int16_t *buffer);
/**
* this is called from the Audio thread to tell
* to update the UI / hostdata
*/
void handleAsyncUpdate();
void initCtrl();
public :
static const int REFRESH_MSG = 1;
static const int REFRESH_COMP = 1 << 1;
int refreshUI;
char data[161];

Loading…
Cancel
Save