Context
plugins/patch_cable.cpp currently registers two SynthDefs:
- PatchCable — implemented against the raw C API (
Methcla_SynthDef with construct/connect/process/destroy function pointers).
- Amplifier — already uses the C++ wrapper API (
StaticSynthDef).
plugins/README.md declares the wrapper "preferred". This issue brings PatchCable in line.
Outcome: patch_cable.cpp uses the wrapper for both synths; ~50 lines of raw-C boilerplate dropped.
Scope
Replace the raw-C PatchCable synth (lines 25–92 of plugins/patch_cable.cpp) with a wrapper class alongside the existing Amplifier. Update the loader to call kPatchCableDef(host, METHCLA_PLUGINS_PATCH_CABLE_URI).
typedef NoOptions PatchCableOptions;
class PatchCablePorts
{
public:
enum Port { kInput, kOutput };
static constexpr size_t numPorts() { return 2; }
static Methcla_PortDescriptor descriptor(Port port)
{
switch (port)
{
case kInput: return PortDescriptor::audioInput();
case kOutput: return PortDescriptor::audioOutput();
default:
throw std::runtime_error(METHCLA_PLUGINS_PATCH_CABLE_URI
": Invalid port index");
}
}
};
class PatchCable
{
float* m_ports[PatchCablePorts::numPorts()];
public:
PatchCable(const World<PatchCable>&, const Methcla_SynthDef*,
const PatchCableOptions&) {}
void connect(PatchCablePorts::Port port, void* data)
{
m_ports[port] = static_cast<float*>(data);
}
void process(const World<PatchCable>&, size_t numFrames)
{
const float* src = m_ports[PatchCablePorts::kInput];
float* dst = m_ports[PatchCablePorts::kOutput];
std::copy(src, src + numFrames, dst);
}
};
StaticSynthDef<PatchCable, PatchCableOptions, PatchCablePorts> kPatchCableDef;
Files
plugins/patch_cable.cpp — replace the raw-C PatchCable synth
plugins/README.md — update the "Implementation styles" table row for patch_cable.cpp (already lists wrapper for Amplifier; both synths now use wrapper)
CHANGELOG.md — add a ### Changed entry under ## [Unreleased] referencing this issue
Verification
pre-commit run --all-files
cmake --preset debug # or whatever preset name is in CMakePresets.json
cmake --build build/debug
ctest --test-dir build/debug --output-on-failure
Confirm methcla_plugin_patch_cable builds. Existence + load is sufficient — no nontrivial state to behaviourally diff.
Context
plugins/patch_cable.cppcurrently registers two SynthDefs:Methcla_SynthDefwithconstruct/connect/process/destroyfunction pointers).StaticSynthDef).plugins/README.mddeclares the wrapper "preferred". This issue bringsPatchCablein line.Outcome:
patch_cable.cppuses the wrapper for both synths; ~50 lines of raw-C boilerplate dropped.Scope
Replace the raw-C
PatchCablesynth (lines 25–92 ofplugins/patch_cable.cpp) with a wrapper class alongside the existingAmplifier. Update the loader to callkPatchCableDef(host, METHCLA_PLUGINS_PATCH_CABLE_URI).Files
plugins/patch_cable.cpp— replace the raw-CPatchCablesynthplugins/README.md— update the "Implementation styles" table row forpatch_cable.cpp(already lists wrapper for Amplifier; both synths now use wrapper)CHANGELOG.md— add a### Changedentry under## [Unreleased]referencing this issueVerification
pre-commit run --all-files cmake --preset debug # or whatever preset name is in CMakePresets.json cmake --build build/debug ctest --test-dir build/debug --output-on-failureConfirm
methcla_plugin_patch_cablebuilds. Existence + load is sufficient — no nontrivial state to behaviourally diff.