Skip to content

Commit

Permalink
Add Modulator Index to SurgePy (#6020)
Browse files Browse the repository at this point in the history
Closes #4871
  • Loading branch information
baconpaul authored Apr 5, 2022
1 parent 52ffb4f commit 4d6a25c
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions src/surge-python/surgepy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ struct SurgePyModRouting
{
SurgePyModSource source;
SurgePyNamedParam dest;
int source_scene;
int source_index;
float depth;
float normalizedDepth;
};
Expand Down Expand Up @@ -598,25 +600,27 @@ class SurgeSynthesizerWithPythonExtensions : public SurgeSynthesizer
(const float *)(&output[0][0]));
}

void setModulationPy(const SurgePyNamedParam &to, SurgePyModSource const &from, float amt)
void setModulationPy(const SurgePyNamedParam &to, SurgePyModSource const &from, float amt,
int scene, int index)
{
// FIXME - 4871
setModulation(to.getID().getSynthSideId(), (modsources)from.getModSource(), amt, 0, 0);
setModulation(to.getID().getSynthSideId(), (modsources)from.getModSource(), scene, index,
amt);
}
float getModulationPy(const SurgePyNamedParam &to, const SurgePyModSource &from)
float getModulationPy(const SurgePyNamedParam &to, const SurgePyModSource &from, int scene,
int index)
{
// FIXME - 4871
return getModulation(to.getID().getSynthSideId(), (modsources)from.getModSource(), 0, 0);
return getModulation(to.getID().getSynthSideId(), (modsources)from.getModSource(), scene,
index);
}
bool isValidModulationPy(const SurgePyNamedParam &to, const SurgePyModSource &from)
{
return isValidModulation(to.getID().getSynthSideId(), (modsources)from.getModSource());
}
bool isActiveModulationPy(const SurgePyNamedParam &to, const SurgePyModSource &from)
bool isActiveModulationPy(const SurgePyNamedParam &to, const SurgePyModSource &from, int scene,
int index)
{
// FIXME - 4871
return isActiveModulation(to.getID().getSynthSideId(), (modsources)from.getModSource(), 0,
0);
return isActiveModulation(to.getID().getSynthSideId(), (modsources)from.getModSource(),
scene, index);
}
bool isBipolarModulationPy(const SurgePyModSource &from)
{
Expand Down Expand Up @@ -739,8 +743,10 @@ class SurgeSynthesizerWithPythonExtensions : public SurgeSynthesizer
r.source = SurgePyModSource((modsources)gm.source_id);
r.dest = surgePyNamedParamById(gm.destination_id);
r.depth = gm.depth;
// FIXME 4871
r.normalizedDepth = getModulation(gm.destination_id, (modsources)gm.source_id, 0, 0);
r.source_scene = gm.source_scene;
r.source_index = gm.source_index;
r.normalizedDepth = getModulation(gm.destination_id, (modsources)gm.source_id,
gm.source_scene, gm.source_index);
gmr.append(r);
}

Expand All @@ -759,10 +765,11 @@ class SurgeSynthesizerWithPythonExtensions : public SurgeSynthesizer
r.dest =
surgePyNamedParamById(gm.destination_id + storage.getPatch().scene_start[sc]);
r.depth = gm.depth;
// FIXME 4871
r.source_scene = gm.source_scene;
r.source_index = gm.source_index;
r.normalizedDepth =
getModulation(gm.destination_id + storage.getPatch().scene_start[sc],
(modsources)gm.source_id, 0, 0);
(modsources)gm.source_id, r.source_scene, r.source_index);
sms.append(r);
}
ts["scene"] = sms;
Expand All @@ -776,10 +783,11 @@ class SurgeSynthesizerWithPythonExtensions : public SurgeSynthesizer
r.dest =
surgePyNamedParamById(gm.destination_id + storage.getPatch().scene_start[sc]);
r.depth = gm.depth;
// FIXME 4871
r.source_scene = gm.source_scene;
r.source_index = gm.source_index;
r.normalizedDepth =
getModulation(gm.destination_id + storage.getPatch().scene_start[sc],
(modsources)gm.source_id, 0, 0);
(modsources)gm.source_id, gm.source_scene, gm.source_index);
smv.append(r);
}
ts["voice"] = smv;
Expand Down Expand Up @@ -910,16 +918,18 @@ PYBIND11_MODULE(surgepy, m)
py::arg("modId"))
.def("setModulation", &SurgeSynthesizerWithPythonExtensions::setModulationPy,
"Set a modulation to a given depth", py::arg("targetParameter"),
py::arg("modulationSource"), py::arg("depth"))
py::arg("modulationSource"), py::arg("depth"), py::arg("scene") = 0,
py::arg("index") = 0)
.def("getModulation", &SurgeSynthesizerWithPythonExtensions::getModulationPy,
"Get the modulation depth from a source to a parameter.", py::arg("targetParameter"),
py::arg("modulationSource"))
py::arg("modulationSource"), py::arg("scene") = 0, py::arg("index") = 0)
.def("isValidModulation", &SurgeSynthesizerWithPythonExtensions::isValidModulationPy,
"Is it possible to modulate between target and source?", py::arg("targetParameter"),
py::arg("modulationSource"))
.def("isActiveModulation", &SurgeSynthesizerWithPythonExtensions::isActiveModulationPy,
"Is there an established modulation between target and source?",
py::arg("targetParameter"), py::arg("modulationSource"))
py::arg("targetParameter"), py::arg("modulationSource"), py::arg("scene") = 0,
py::arg("index") = 0)
.def("isBipolarModulation", &SurgeSynthesizerWithPythonExtensions::isBipolarModulationPy,
"Is the given modulation source bipolar?", py::arg("modulationSource"))

Expand Down Expand Up @@ -983,6 +993,8 @@ PYBIND11_MODULE(surgepy, m)
py::class_<SurgePyModRouting>(m, "SurgeModRouting")
.def("getSource", [](const SurgePyModRouting &r) { return r.source; })
.def("getDest", [](const SurgePyModRouting &r) { return r.dest; })
.def("getSourceScene", [](const SurgePyModRouting &r) { return r.source_scene; })
.def("getSourceIndex", [](const SurgePyModRouting &r) { return r.source_index; })
.def("getDepth", [](const SurgePyModRouting &r) { return r.depth; })
.def("getNormalizedDepth", [](const SurgePyModRouting &r) { return r.normalizedDepth; })
.def("__repr__", [](const SurgePyModRouting &r) {
Expand Down

0 comments on commit 4d6a25c

Please sign in to comment.