Skip to content

Commit

Permalink
Re-work the ALternates system; combine with Indices (surge-synthesize…
Browse files Browse the repository at this point in the history
…r#4878)

Closes surge-synthesizer#2678
Closes surge-synthesizer#4868

Rework the alternates system and merge it with indexed modulators

1. A rational data structure for the grid layout, including an
   alternates stack at each grid point.
2. The UI widget now has a vector of possibilities
3. If that vector size > 1 it shows a burger and lets you swap
4. Which updates hte internal state of the SGE properly
  • Loading branch information
baconpaul authored Aug 20, 2021
1 parent f3e80e2 commit 4ec43ef
Show file tree
Hide file tree
Showing 8 changed files with 292 additions and 149 deletions.
46 changes: 1 addition & 45 deletions src/common/ModulationSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const char modsource_names_button[n_modsources][32] = {
"Macro 6", "Macro 7", "Macro 8", "Amp EG", "Filter EG", "LFO 1",
"LFO 2", "LFO 3", "LFO 4", "LFO 5", "LFO 6", "S-LFO 1",
"S-LFO 2", "S-LFO 3", "S-LFO 4", "S-LFO 5", "S-LFO 6", "MPE Timbre",
"Rel Velocity", "Random", "Random Uni", "Alternate", "Alternate Uni", "Breath",
"Rel Velocity", "Random", "RandUni", "Alternate", "Alternate Uni", "Breath",
"Expression", "Sustain", "Lowest Key", "Highest Key", "Latest Key",
};

Expand Down Expand Up @@ -185,50 +185,6 @@ const char modsource_names_tag[n_modsources][32] = {
"breath", "expr", "sustain", "lowest_key", "highest_key", "latest_key",
};

const int modsource_grid_xy[n_modsources][2] = {
{0, 0}, // Velocity
{0, 3}, // Keytrack
{6, 7}, // Poly AT
{2, 3}, // Channel
{3, 3}, // AT
{4, 3}, // Pitch Bend
{5, 3}, // Modwheel
{0, 0}, // Macro 1
{1, 0}, // Macro 2
{2, 0}, // Macro 3
{3, 0}, // Macro 4
{4, 0}, // Macro 5
{5, 0}, // Macro 6
{6, 0}, // Macro 7
{7, 0}, // Macro 8
{7, 5}, // AEG
{6, 5}, // FEG
{0, 5}, // LFO 1
{1, 5}, // LFO 2
{2, 5}, // LFO 3
{3, 5}, // LFO 4
{4, 5}, // LFO 5
{5, 5}, // LFO 6
{0, 7}, // S-LFO 1
{1, 7}, // S-LFO 2
{2, 7}, // S-LFO 3
{3, 7}, // S-LFO 4
{4, 7}, // S-LFO 5
{5, 7}, // S-LFO 6
{9, 3}, // Timbre
{1, 3}, // Release Velocity
{8, 5}, // Random Bi
{8, 5}, // Random Uni
{9, 5}, // Alternate Bi
{9, 5}, // Alternate Uni
{6, 3}, // Breath
{7, 3}, // Expression
{8, 3}, // Sustain
{7, 7}, // Lowest Key
{8, 7}, // Highest Key
{9, 7}, // Latest Key
};

inline bool isScenelevel(modsources ms)
{
return (((ms <= ms_ctrl8) || ((ms >= ms_slfo1) && (ms <= ms_slfo6))) &&
Expand Down
2 changes: 1 addition & 1 deletion src/common/SurgeSynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2765,7 +2765,7 @@ void SurgeSynthesizer::clear_osc_modulation(int scene, int entry)

bool SurgeSynthesizer::supportsIndexedModulator(int scene, modsources modsource) const
{
if (modsource >= ms_lfo1 && modsource <= ms_lfo6)
if (modsource >= ms_lfo1 && modsource <= ms_slfo6)
{
auto lf = &(storage.getPatch().scene[scene].lfo[modsource - ms_lfo1]);
return lf->shape.val.i == lt_formula;
Expand Down
117 changes: 117 additions & 0 deletions src/gui/ModulationGridConfiguration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
** 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_MODULATIONGRIDCONFIGURATION_H
#define SURGE_XT_MODULATIONGRIDCONFIGURATION_H

#include "ModulationSource.h"

#include <unordered_map>

namespace Surge
{
namespace GUI
{
struct ModulationGrid : juce::DeletedAtShutdown
{
ModulationGrid()
{
add(ms_original, 0, 0);

add(ms_velocity, 0, 3);
add(ms_keytrack, 6, 7);
add(ms_polyaftertouch, 2, 3);
add(ms_aftertouch, 3, 3);
add(ms_pitchbend, 4, 3);
add(ms_modwheel, 5, 3);

for (int i = ms_ctrl1; i <= ms_ctrl8; ++i)
{
add((modsources)i, (int)i - ms_ctrl1, 0);
}

add(ms_ampeg, 7, 5);
add(ms_filtereg, 6, 5);

for (int i = ms_lfo1; i <= ms_lfo6; ++i)
{
add((modsources)i, (int)i - ms_lfo1, 5);
}
for (int i = ms_slfo1; i <= ms_slfo6; ++i)
{
add((modsources)i, (int)i - ms_slfo1, 7);
}

add(ms_timbre, 9, 3);
add(ms_releasevelocity, 1, 3);
add(ms_random_bipolar, 8, 5, {ms_random_unipolar});
add(ms_alternate_bipolar, 9, 5, {ms_alternate_unipolar});
add(ms_breath, 6, 3);
add(ms_sustain, 8, 3);
add(ms_expression, 7, 3);
add(ms_lowest_key, 7, 7);
add(ms_highest_key, 8, 7);
add(ms_latest_key, 9, 7);
}

void add(modsources ms, int x, int y) { data[ms] = Entry{x, y, ms}; }
void add(modsources ms, int x, int y, const std::vector<modsources> &alternates)
{
data[ms] = Entry{x, y, ms, alternates};
for (auto a : alternates)
{
data[a] = Entry{a, ms};
}
}
struct Entry
{
Entry() {}
Entry(int x, int y, modsources ms) : x(x), y(y), ms(ms) {}
Entry(int x, int y, modsources ms, const std::vector<modsources> &alternates)
: x(x), y(y), ms(ms), alternates(alternates)
{
}
Entry(modsources sub, modsources primary)
: ms(sub), associatedPrimary(primary), isPrimary(false)
{
}

modsources ms{ms_original};
modsources associatedPrimary{ms_original};
int x{-1}, y{-1};
bool isPrimary{true};
std::vector<modsources> alternates;
};

std::unordered_map<modsources, Entry> data;

const Entry &get(modsources ms) const
{
jassert(data.find(ms) != data.end());
return data.at(ms);
}

static ModulationGrid *grid;
static inline const ModulationGrid *getModulationGrid()
{
// The juce::DeletedAtShutdown makes sure this gets cleared up
if (!grid)
grid = new ModulationGrid();
return grid;
}
};
} // namespace GUI
} // namespace Surge

#endif // SURGE_XT_MODULATIONGRIDCONFIGURATION_H
Loading

0 comments on commit 4ec43ef

Please sign in to comment.