Skip to content

Commit

Permalink
Modulation Index Support
Browse files Browse the repository at this point in the history
Addresses surge-synthesizer#4868

1. Add a source index to modrouting and stream it
2. Use that modrouting to lookup values in processing (but not in all the 'is' or 'get' apis)
3. Const up a bunch of stuff along the way (workign on surge-synthesizer#3808)
4. Plumbing through vector value to formula mod
5. Modify the UI so that by menus you can map formula modulators but not
   by click-to-arm yet.
  • Loading branch information
baconpaul committed Aug 19, 2021
1 parent 49f99b4 commit 8b43989
Show file tree
Hide file tree
Showing 18 changed files with 553 additions and 293 deletions.
5 changes: 4 additions & 1 deletion src/common/ModulationSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ struct ModulationRouting
int destination_id;
float depth;
bool muted = false;
int source_index{0};
};

class ModulationSource
Expand All @@ -275,13 +276,15 @@ class ModulationSource
virtual void attack(){};
virtual void release(){};
virtual void reset(){};
// override these if you support indices
virtual int get_active_outputs() { return 1; }
virtual float get_output(int which) { return output; }
virtual float get_output01(int which) { return output; }
virtual void set_output(int which, float f) { output = f; }

virtual bool per_voice() { return false; }
virtual bool is_bipolar() { return false; }
virtual void set_bipolar(bool b) {}
virtual int get_num_outputs() { return 1; }

protected:
float output;
Expand Down
7 changes: 7 additions & 0 deletions src/common/SurgePatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,12 @@ void SurgePatch::load_xml(const void *data, int datasize, bool is_preset)
else
t.muted = false;

int source_index = 0;
if (mr->QueryIntAttribute("source_index", &source_index) == TIXML_SUCCESS)
t.source_index = source_index;
else
t.source_index = 0;

if (sceneId != 0)
t.destination_id = paramIdInScene;
else
Expand Down Expand Up @@ -2219,6 +2225,7 @@ unsigned int SurgePatch::save_xml(void **data) // allocates mem, must be freed b
mr.SetAttribute("source", r->at(b).source_id);
mr.SetAttribute("depth", float_to_str(r->at(b).depth, tempstr));
mr.SetAttribute("muted", r->at(b).muted);
mr.SetAttribute("source_index", r->at(b).source_index);
p.InsertEndChild(mr);
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/common/SurgeStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ void SurgeStorage::initializePatchDb()
}
}

SurgePatch &SurgeStorage::getPatch() { return *_patch.get(); }
SurgePatch &SurgeStorage::getPatch() const { return *_patch.get(); }

struct PEComparer
{
Expand Down Expand Up @@ -1384,6 +1384,7 @@ void SurgeStorage::clipboard_copy(int type, int scene, int entry)
{
ModulationRouting m;
m.source_id = getPatch().scene[scene].modulation_voice[i].source_id;
m.source_index = getPatch().scene[scene].modulation_voice[i].source_index;
m.depth = getPatch().scene[scene].modulation_voice[i].depth;
m.destination_id =
getPatch().scene[scene].modulation_voice[i].destination_id + idoffset;
Expand All @@ -1395,6 +1396,7 @@ void SurgeStorage::clipboard_copy(int type, int scene, int entry)
{
ModulationRouting m;
m.source_id = getPatch().scene[scene].modulation_scene[i].source_id;
m.source_index = getPatch().scene[scene].modulation_scene[i].source_index;
m.depth = getPatch().scene[scene].modulation_scene[i].depth;
m.destination_id =
getPatch().scene[scene].modulation_scene[i].destination_id + idoffset;
Expand Down Expand Up @@ -1502,6 +1504,7 @@ void SurgeStorage::clipboard_paste(int type, int scene, int entry)
{
ModulationRouting m;
m.source_id = clipboard_modulation_voice[i].source_id;
m.source_index = clipboard_modulation_voice[i].source_index;
m.depth = clipboard_modulation_voice[i].depth;
m.destination_id =
clipboard_modulation_voice[i].destination_id + id - n_global_params;
Expand All @@ -1512,6 +1515,7 @@ void SurgeStorage::clipboard_paste(int type, int scene, int entry)
{
ModulationRouting m;
m.source_id = clipboard_modulation_scene[i].source_id;
m.source_index = clipboard_modulation_scene[i].source_index;
m.depth = clipboard_modulation_scene[i].depth;
m.destination_id =
clipboard_modulation_scene[i].destination_id + id - n_global_params;
Expand Down Expand Up @@ -1540,6 +1544,7 @@ void SurgeStorage::clipboard_paste(int type, int scene, int entry)
{
ModulationRouting m;
m.source_id = clipboard_modulation_voice[i].source_id;
m.source_index = clipboard_modulation_voice[i].source_index;
m.depth = clipboard_modulation_voice[i].depth;
m.destination_id = clipboard_modulation_voice[i].destination_id;
getPatch().scene[scene].modulation_voice.push_back(m);
Expand All @@ -1549,6 +1554,7 @@ void SurgeStorage::clipboard_paste(int type, int scene, int entry)
{
ModulationRouting m;
m.source_id = clipboard_modulation_scene[i].source_id;
m.source_index = clipboard_modulation_scene[i].source_index;
m.depth = clipboard_modulation_scene[i].depth;
m.destination_id = clipboard_modulation_scene[i].destination_id;
getPatch().scene[scene].modulation_scene.push_back(m);
Expand Down
3 changes: 2 additions & 1 deletion src/common/SurgeStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,8 @@ class alignas(16) SurgeStorage

std::unique_ptr<SurgePatch> _patch;

SurgePatch &getPatch();
// SurgePatch &getPatch();
SurgePatch &getPatch() const;

float pitch_bend;

Expand Down
Loading

0 comments on commit 8b43989

Please sign in to comment.