Skip to content

Commit

Permalink
use DAISY preprocessor to avoid dynamic_cast
Browse files Browse the repository at this point in the history
trying to address #1090
  • Loading branch information
DBraun authored and sletz committed Jan 2, 2025
1 parent c0574f3 commit 18ff4c0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions architecture/faust/dsp/poly-dsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,11 @@ struct dsp_voice_group {
ui_interface->closeBox();

// If not grouped, also add individual voices UI
#ifdef DAISY
if (!fGroupControl || ui_interface->isSoundUI()) {
#else
if (!fGroupControl || dynamic_cast<SoundUIInterface*>(ui_interface)) {
#endif
for (size_t i = 0; i < fVoiceTable.size(); i++) {
char buffer[32];
snprintf(buffer, 32, ((fVoiceTable.size() < 8) ? "Voice%ld" : "V%ld"), long(i+1));
Expand Down Expand Up @@ -757,10 +761,17 @@ class mydsp_poly : public dsp_voice_group, public dsp_poly {
void buildUserInterface(UI* ui_interface)
{
// MidiUI ui_interface contains the midi_handler connected to the MIDI driver
#ifdef DAISY
if (ui_interface->isMidiInterface()) {
fMidiHandler = reinterpret_cast<midi_interface*>(ui_interface);
fMidiHandler->addMidiIn(this);
}
#else
if (dynamic_cast<midi_interface*>(ui_interface)) {
fMidiHandler = dynamic_cast<midi_interface*>(ui_interface);
fMidiHandler->addMidiIn(this);
}
#endif
dsp_voice_group::buildUserInterface(ui_interface);
}

Expand Down
4 changes: 4 additions & 0 deletions architecture/faust/gui/DecoratorUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class FAUST_API GenericUI : public UI

GenericUI() {}
virtual ~GenericUI() {}

#ifdef DAISY
virtual bool isSoundUI() const override { return true;
#endif

// -- widget's layouts
virtual void openTabBox(const char* label) {}
Expand Down
4 changes: 4 additions & 0 deletions architecture/faust/gui/MidiUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,10 @@ class MidiUI : public GUI, public midi, public midi_interface, public MetaDataUI
// TODO: use shared_ptr based implementation
if (fDelete) delete fMidiHandler;
}

#ifdef DAISY
virtual bool isMidiInterface() const override { return true; }
#endif

bool run() { return fMidiHandler->startMidi(); }
void stop() { fMidiHandler->stopMidi(); }
Expand Down
4 changes: 4 additions & 0 deletions architecture/faust/gui/UI.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ struct FAUST_API UIReal {
struct FAUST_API UI : public UIReal<FAUSTFLOAT> {
UI() {}
virtual ~UI() {}
#ifdef DAISY
virtual bool isSoundUI() const { return false; }
virtual bool isMidiInterface() const { return false; }
#endif
};

#endif
Expand Down

0 comments on commit 18ff4c0

Please sign in to comment.