Skip to content

Commit

Permalink
Start the ModWindow
Browse files Browse the repository at this point in the history
1. Implement a ModEditorWindow class which does basic text dump
2. Hook it up to the RMB sliders
3. Clean up the copyright headers on the new code I've been working on

Addresses surge-synthesizer#2049
  • Loading branch information
baconpaul committed Apr 30, 2021
1 parent 8a0e592 commit 74e4385
Show file tree
Hide file tree
Showing 11 changed files with 208 additions and 20 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ set(SURGE_SHARED_SOURCES
src/common/vt_dsp/lipol.cpp
src/common/vt_dsp/macspecific.cpp
src/common/DebugHelpers.cpp
src/common/ModulatorPresetManager.cpp
src/common/Parameter.cpp
src/common/PatchDB.cpp
src/common/SurgePatch.cpp
Expand Down Expand Up @@ -326,7 +327,7 @@ set(SURGE_GUI_SOURCES
src/gui/CursorControlGuard.cpp
src/gui/CVerticalLabel.cpp
src/gui/guihelpers.cpp
src/common/ModulatorPresetManager.cpp
src/gui/ModulationEditor.cpp
src/gui/MSEGEditor.cpp
src/gui/PatchDBViewer.cpp
src/gui/RuntimeFont.cpp
Expand Down
4 changes: 2 additions & 2 deletions src/common/SurgeSynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2359,7 +2359,7 @@ bool SurgeSynthesizer::isValidModulation(long ptag, modsources modsource)
ModulationRouting *SurgeSynthesizer::getModRouting(long ptag, modsources modsource)
{
if (!isValidModulation(ptag, modsource))
return 0;
return nullptr;

int scene = storage.getPatch().param_ptr[ptag]->scene;
vector<ModulationRouting> *modlist = nullptr;
Expand Down Expand Up @@ -2389,7 +2389,7 @@ ModulationRouting *SurgeSynthesizer::getModRouting(long ptag, modsources modsour
}
}

return 0;
return nullptr;
}

float SurgeSynthesizer::getModDepth(long ptag, modsources modsource)
Expand Down
18 changes: 14 additions & 4 deletions src/gui/CTextButtonWithHover.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
//
// Created by Paul Walker on 12/3/20.
//

/*
** Surge Synthesizer is Free and Open Source Software
**
** Surge is made available under the Gnu General Public License, v3.0
** https://www.gnu.org/licenses/gpl-3.0.en.html
**
** Copyright 2004-2021 by various individuals as described by the Git transaction log
**
** All source at: https://github.com/surge-synthesizer/surge.git
**
** Surge was a commercial product from 2004-2018, with Copyright and ownership
** in that period held by Claes Johanson at Vember Audio. Claes made Surge
** open source in September 2018.
*/
#include "CTextButtonWithHover.h"
#include <iostream>

Expand Down
61 changes: 61 additions & 0 deletions src/gui/ModulationEditor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
** Surge Synthesizer is Free and Open Source Software
**
** Surge is made available under the Gnu General Public License, v3.0
** https://www.gnu.org/licenses/gpl-3.0.en.html
**
** Copyright 2004-2021 by various individuals as described by the Git transaction log
**
** All source at: https://github.com/surge-synthesizer/surge.git
**
** Surge was a commercial product from 2004-2018, with Copyright and ownership
** in that period held by Claes Johanson at Vember Audio. Claes made Surge
** open source in September 2018.
*/

#include "ModulationEditor.h"
#include "SurgeSynthesizer.h"
#include "SurgeGUIEditor.h"
#include "RuntimeFont.h"
#include <sstream>

ModulationEditor::ModulationEditor(SurgeGUIEditor *ed, SurgeSynthesizer *s)
: ed(ed), synth(s), juce::Component("Modulation Editor")
{
setSize(750, 450); // FIXME

textBox = std::make_unique<juce::TextEditor>("Mod editor text box");
textBox->setMultiLine(true, false);
textBox->setBounds(5, 5, 740, 440);
textBox->setFont(Surge::GUI::getFontManager()->getLatoAtSize(9));
addAndMakeVisible(*textBox);

/*
* Obviously clean this up
*/
std::ostringstream oss;
auto append = [&oss, this](const std::string &type, const std::vector<ModulationRouting> &r) {
if (r.empty())
return;
oss << type << "\n";
char nm[TXT_SIZE], dst[TXT_SIZE];
for (auto q : r)
{
SurgeSynthesizer::ID ptagid;
if (synth->fromSynthSideId(q.destination_id, ptagid))
synth->getParameterName(ptagid, nm);
;
oss << " > " << this->ed->modulatorName(q.source_id, false) << " to " << nm << " at "
<< q.depth << "\n";
}
};
append("Global", synth->storage.getPatch().modulation_global);
append("Scene A Voice", synth->storage.getPatch().scene[0].modulation_voice);
append("Scene A Scene", synth->storage.getPatch().scene[0].modulation_scene);
append("Scene B Voice", synth->storage.getPatch().scene[1].modulation_voice);
append("Scene B Scene", synth->storage.getPatch().scene[1].modulation_scene);

textBox->setText(oss.str());
}

ModulationEditor::~ModulationEditor() = default;
35 changes: 35 additions & 0 deletions src/gui/ModulationEditor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
** Surge Synthesizer is Free and Open Source Software
**
** Surge is made available under the Gnu General Public License, v3.0
** https://www.gnu.org/licenses/gpl-3.0.en.html
**
** Copyright 2004-2021 by various individuals as described by the Git transaction log
**
** All source at: https://github.com/surge-synthesizer/surge.git
**
** Surge was a commercial product from 2004-2018, with Copyright and ownership
** in that period held by Claes Johanson at Vember Audio. Claes made Surge
** open source in September 2018.
*/

#ifndef SURGE_XT_MODULATIONEDITOR_H
#define SURGE_XT_MODULATIONEDITOR_H

#include <JuceHeader.h>

class SurgeGUIEditor;
class SurgeSynthesizer;

class ModulationEditor : public juce::Component
{
public:
ModulationEditor(SurgeGUIEditor *ed, SurgeSynthesizer *s);
~ModulationEditor();

std::unique_ptr<juce::TextEditor> textBox;
SurgeGUIEditor *ed;
SurgeSynthesizer *synth;
};

#endif // SURGE_XT_MODULATIONEDITOR_H
17 changes: 14 additions & 3 deletions src/gui/PatchDBViewer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
//
// Created by Paul Walker on 4/15/21.
//
/*
** Surge Synthesizer is Free and Open Source Software
**
** Surge is made available under the Gnu General Public License, v3.0
** https://www.gnu.org/licenses/gpl-3.0.en.html
**
** Copyright 2004-2021 by various individuals as described by the Git transaction log
**
** All source at: https://github.com/surge-synthesizer/surge.git
**
** Surge was a commercial product from 2004-2018, with Copyright and ownership
** in that period held by Claes Johanson at Vember Audio. Claes made Surge
** open source in September 2018.
*/

#include "PatchDBViewer.h"
#include "PatchDB.h"
Expand Down
17 changes: 14 additions & 3 deletions src/gui/PatchDBViewer.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
//
// Created by Paul Walker on 4/15/21.
//
/*
** Surge Synthesizer is Free and Open Source Software
**
** Surge is made available under the Gnu General Public License, v3.0
** https://www.gnu.org/licenses/gpl-3.0.en.html
**
** Copyright 2004-2021 by various individuals as described by the Git transaction log
**
** All source at: https://github.com/surge-synthesizer/surge.git
**
** Surge was a commercial product from 2004-2018, with Copyright and ownership
** in that period held by Claes Johanson at Vember Audio. Claes made Surge
** open source in September 2018.
*/

#ifndef SURGE_PATCHDBVIEWER_H
#define SURGE_PATCHDBVIEWER_H
Expand Down
31 changes: 31 additions & 0 deletions src/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "DebugHelpers.h"
#include "StringOps.h"
#include "ModulatorPresetManager.h"
#include "ModulationEditor.h"

#include <iostream>
#include <iomanip>
Expand Down Expand Up @@ -2132,6 +2133,11 @@ int32_t SurgeGUIEditor::controlModifierClicked(CControl *control, CButtonState b
}
}

contextMenu->addSeparator();
addCallbackMenu(contextMenu, Surge::UI::toOSCaseForMenu("Modulation Editor"), [this]() {
if (!isAnyOverlayPresent(MODULATION_EDITOR))
showModulationEditorDialog();
});
int n_total_md = synth->storage.getPatch().param_ptr.size();

const int max_md = 4096;
Expand Down Expand Up @@ -3073,6 +3079,12 @@ int32_t SurgeGUIEditor::controlModifierClicked(CControl *control, CButtonState b
}
}

addCallbackMenu(contextMenu,
Surge::UI::toOSCaseForMenu("Open Modulation Editor..."), [this]() {
if (!isAnyOverlayPresent(MODULATION_EDITOR))
showModulationEditorDialog();
});

switch (p->ctrltype)
{
case ct_freq_audible_with_tunability:
Expand Down Expand Up @@ -8251,6 +8263,25 @@ void SurgeGUIEditor::closePatchBrowserDialog()
}
}

void SurgeGUIEditor::showModulationEditorDialog()
{
auto *c = new CViewContainer(CRect(CPoint(0, 0), CPoint(750, 450)));
auto pt = std::make_unique<ModulationEditor>(this, this->synth);
c->juceComponent()->addAndMakeVisible(*pt);
pt->setBounds(0, 0, 750, 450);
c->takeOwnership(std::move(pt));
addEditorOverlay(c, "Open Modulation Editor...", MODULATION_EDITOR, CPoint(50, 50), false, true,
[this]() {});
}

void SurgeGUIEditor::closeModulationEditorDialog()
{
if (isAnyOverlayPresent(MODULATION_EDITOR))
{
dismissEditorOfType(MODULATION_EDITOR);
}
}

/*
* The edit state is independent per LFO. We want to sync some of ti as if it is not
* so this is called at the appropriate time.
Expand Down
8 changes: 7 additions & 1 deletion src/gui/SurgeGUIEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ class SurgeGUIEditor : public EditorType,
NO_EDITOR,
MSEG_EDITOR,
STORE_PATCH,
PATCH_BROWSER
PATCH_BROWSER,
MODULATION_EDITOR
};

void addEditorOverlay(
Expand Down Expand Up @@ -331,6 +332,9 @@ class SurgeGUIEditor : public EditorType,
void closePatchBrowserDialog();
void showPatchBrowserDialog();

void closeModulationEditorDialog();
void showModulationEditorDialog();

void lfoShapeChanged(int prior, int curr);
void showMSEGEditor();
void closeMSEGEditor();
Expand Down Expand Up @@ -454,8 +458,10 @@ class SurgeGUIEditor : public EditorType,
VSTGUI::CTextLabel *lfoNameLabel = nullptr;
VSTGUI::CTextLabel *fxPresetLabel = nullptr;

public:
std::string modulatorName(int ms, bool forButton);

private:
Parameter *typeinEditTarget = nullptr;
int typeinModSource = -1;

Expand Down
17 changes: 14 additions & 3 deletions src/gui/SurgeJUCELookAndFeel.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
//
// Created by Paul Walker on 4/24/21.
//
/*
** Surge Synthesizer is Free and Open Source Software
**
** Surge is made available under the Gnu General Public License, v3.0
** https://www.gnu.org/licenses/gpl-3.0.en.html
**
** Copyright 2004-2021 by various individuals as described by the Git transaction log
**
** All source at: https://github.com/surge-synthesizer/surge.git
**
** Surge was a commercial product from 2004-2018, with Copyright and ownership
** in that period held by Claes Johanson at Vember Audio. Claes made Surge
** open source in September 2018.
*/

#include "SurgeJUCELookAndFeel.h"
void SurgeJUCELookAndFeel::drawLabel(juce::Graphics &graphics, juce::Label &label)
Expand Down
17 changes: 14 additions & 3 deletions src/gui/SurgeJUCELookAndFeel.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
//
// Created by Paul Walker on 4/24/21.
//
/*
** Surge Synthesizer is Free and Open Source Software
**
** Surge is made available under the Gnu General Public License, v3.0
** https://www.gnu.org/licenses/gpl-3.0.en.html
**
** Copyright 2004-2021 by various individuals as described by the Git transaction log
**
** All source at: https://github.com/surge-synthesizer/surge.git
**
** Surge was a commercial product from 2004-2018, with Copyright and ownership
** in that period held by Claes Johanson at Vember Audio. Claes made Surge
** open source in September 2018.
*/

#ifndef SURGE_XT_SURGEJUCELOOKANDFEEL_H
#define SURGE_XT_SURGEJUCELOOKANDFEEL_H
Expand Down

0 comments on commit 74e4385

Please sign in to comment.