Skip to content

Commit

Permalink
maintenance of source code by identification of certain unused parts
Browse files Browse the repository at this point in the history
  • Loading branch information
FulopNandor committed May 21, 2024
1 parent d2df194 commit 755544f
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 9 deletions.
4 changes: 3 additions & 1 deletion Source/DXLookNFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ DXLookNFeel::DXLookNFeel() {
}
}
}

#ifdef IMPLEMENT_DEADCODE_DXLookNFeel
// TODO: THIS IS DEAD CODE. NOBODY IS USING THIS.
forEachXmlChildElementWithTagName(*root, image, "image") {
String name = image->getStringAttribute("id", "");
Expand Down Expand Up @@ -156,6 +156,8 @@ DXLookNFeel::DXLookNFeel() {
continue;
}
}
TRACE("WARNING! Dead code snippet is implemented!");
#endif // IMPLEMENT_DEADCODE_DXLookNFeel
}

Typeface::Ptr DXLookNFeel::getTypefaceForFont(const Font &) {
Expand Down
7 changes: 7 additions & 0 deletions Source/DXLookNFeel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@

#include "../JuceLibraryCode/JuceHeader.h"

/// If the macro ''IMPLEMENT_DEADCODE_DXLookAndFeel'' is defined as any NONZERO value,
/// then a recently unused code snippet in constuctor ''DXLookNFeel::DXLookNFeel()''
/// in file ''DXLookNFeel.cpp'', is implemented.
/// Use 0 to exclude the related source snippets.
/// WARNING: this code snippet mentioned is very likely a candidate for deprecation/obsolescence.
#define IMPLEMENT_DEADCODE_DXLookNFeel 0

class LightedToggleButton : public ToggleButton {
public:
LightedToggleButton(const char*l) : ToggleButton(l) { }
Expand Down
25 changes: 18 additions & 7 deletions Source/GlobalEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,19 @@
* Ugly but useful midi monitor to know if you are really sending/receiving something from the DX7
* If the midi is not configured this component wont show up
*
*/
#if IMPLEMENT_MidiMonitor
class MidiMonitor : public Component {
SysexComm *midi;
Image light;

SharedResourcePointer<DXLookNFeel> lookAndFeel;
public:
MidiMonitor(SysexComm *sysexComm) {
midi = sysexComm;
light = DXLookNFeel::getLookAndFeel()->imageLight;
light = lookAndFeel->imageLight;

TRACE("WARNING! This functionality is a candidate for deprecation/obsolescence!");
}

void paint(Graphics &g) {
Expand All @@ -58,13 +63,14 @@ class MidiMonitor : public Component {
midi->outActivity = false;
}
}
};*/
};
#endif // IMPLEMENT_MidiMonitor

class AboutBox : public DialogWindow {
public:
Image logo_png;
std::unique_ptr<juce::HyperlinkButton> dexed; // changed to std::unique_ptr from juce::ScopedPointer
std::unique_ptr<juce::HyperlinkButton> surge; // changed to std__unique_ptr from juce::ScopedPointer
std::unique_ptr<juce::HyperlinkButton> surge; // changed to std::unique_ptr from juce::ScopedPointer

AboutBox(Component *parent) : DialogWindow("About", Colour(0xFF000000), true),
dexed(std::make_unique<juce::HyperlinkButton>("https://asb2m10.github.io/dexed/", URL("https://asb2m10.github.io/dexed/"))),
Expand Down Expand Up @@ -708,9 +714,11 @@ void GlobalEditor::bind(DexedAudioProcessorEditor *edit) {

editor = edit;

//midiMonitor = new MidiMonitor(&(processor->sysexComm));
//addAndMakeVisible(midiMonitor);
//midiMonitor->setBounds(155, 21, 80, 45);
#if IMPLEMENT_MidiMonitor
midiMonitor = std::make_unique<MidiMonitor>(&(processor->sysexComm));
addAndMakeVisible(*midiMonitor);
midiMonitor->setBounds(116, 14, 80, 45); //midiMonitor->setBounds(155, 21, 80, 45);
#endif //IMPLEMENT_MidiMonitor

repaint();
}
Expand All @@ -736,7 +744,10 @@ void GlobalEditor::updatePitchPos(int pos) {
void GlobalEditor::updateVu(float f) {
m_vuMeterMain->v = f;
m_vuMeterMain->repaint();
//midiMonitor->repaint();

#if IMPLEMENT_MidiMonitor
midiMonitor->repaint();
#endif
}

void GlobalEditor::setMonoState(bool state) {
Expand Down
8 changes: 7 additions & 1 deletion Source/GlobalEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include "PluginProcessor.h"
#include "DXComponents.h"
#include "AlgoDisplay.h"
#ifdef IMPLEMENT_MidiMonitor
#include "SysexComm.h"
#endif // IMPLEMENT_MidiMonitor

class DexedAudioProcessorEditor;
//[/Headers]
Expand Down Expand Up @@ -59,7 +62,10 @@ class GlobalEditor : public Component,

void setMonoState(bool state);
ProgramSelector *programs;
//std::unique_ptr<Component> midiMonitor;

#if IMPLEMENT_MidiMonitor
std::unique_ptr<Component> midiMonitor;
#endif //IMPLEMENT_MidiMonitor

void mouseDown(const MouseEvent& e) override;
//[/UserMethods]
Expand Down
2 changes: 2 additions & 0 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,9 @@ void DexedAudioProcessor::handleIncomingMidiMessage(MidiInput* source, const Mid
if ( message.isActiveSense() )
return;

#if IMPLEMENT_MidiMonitor
sysexComm.inActivity = true;
#endif IMPLEMENT_MidiMonitor

const uint8 *buf = message.getRawData();
int sz = message.getRawDataSize();
Expand Down
9 changes: 9 additions & 0 deletions Source/SysexComm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ SysexComm::SysexComm() {
input = NULL;
output = NULL;
inputOutput = false;

#if IMPLEMENT_MidiMonitor
inActivity = false;
outActivity = false;
#endif //IMPLEMENT_MidiMonitor
}

String SysexComm::getInput() {
Expand Down Expand Up @@ -132,7 +137,11 @@ void SysexComm::setChl(int chl) {
int SysexComm::send(const MidiMessage &message) {
if ( output == NULL )
return 2;

#if IMPLEMENT_MidiMonitor
outActivity = true;
#endif // IMPLEMENT_MidiMonitor

output->sendMessageNow(message);
return 0;
}
Expand Down
9 changes: 9 additions & 0 deletions Source/SysexComm.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@

#include "../JuceLibraryCode/JuceHeader.h"

// If the macro ''IMPLEMENT_MidiMonitor'' is defined as any NONZREO value,
// then the class ''MidiMonitor'' and its related variables
// and invocations occurring in other classes are implemented.
// Use 0 to exclude the related source snippets (RECOMMENDED!).
// WARNING: this class and related variables and invocations are very likely candidates for deprecation / obsolescence.
#define IMPLEMENT_MidiMonitor 0

class SysexComm {
std::unique_ptr<MidiInput> input;
std::unique_ptr<MidiOutput> output;
Expand All @@ -35,8 +42,10 @@ class SysexComm {
MidiBuffer noteOutput;
public :
MidiInputCallback *listener;
#if IMPLEMENT_MidiMonitor
bool inActivity;
bool outActivity;
#endif //IMPLEMENT_MidiMonitor

SysexComm();

Expand Down

0 comments on commit 755544f

Please sign in to comment.