Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modulation Index Support #4870

Merged
merged 1 commit into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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