Skip to content

Migrate sine plugin to the C++ wrapper API (rename sine.c to sine.cpp) #142

Description

@kaoskorobase

Context

plugins/sine.c is implemented against the raw C API (Methcla_SynthDef with C function pointers). plugins/README.md declares the C++ wrapper API "preferred". This issue migrates sine to the wrapper and renames the file to .cpp.

Outcome: sine uses the wrapper API; the last .c source under plugins/ is gone.

Scope

Delete plugins/sine.c and create plugins/sine.cpp as a full rewrite using StaticSynthDef. Behavioural preservation:

  • Phase carried across blocks.
  • freqToPhaseInc = 2π / sampleRate.
  • sinf semantics.

Key shape:

class Sine
{
    float* m_ports[SinePorts::numPorts()];
    double m_phase;
    double m_freqToPhaseInc;
public:
    Sine(const World<Sine>& world, const Methcla_SynthDef*, const NoOptions&)
    : m_phase(0.)
    , m_freqToPhaseInc(2. * kPi / world.sampleRate())
    {}
    // connect, process as usual
};

StaticSynthDef<Sine, NoOptions, SinePorts> kSineDef;

Files

  • plugins/sine.c — delete
  • plugins/sine.cpp — new (rewrite using wrapper)
  • plugins/CMakeLists.txt — line 23: replace sine.c with sine.cpp in the foreach. The if(source MATCHES ".*\\.c$") block on line 14 self-disables once no .c source remains.
  • plugins/README.md — line 9: sine.csine.cpp; update the "Implementation styles" table row to move sine under the wrapper category.
  • CHANGELOG.md — add a ### Changed entry under ## [Unreleased] referencing this issue (mention the file rename).

Verification

pre-commit run --all-files
cmake --preset debug
cmake --build build/debug
ctest --test-dir build/debug --output-on-failure

Confirm methcla_plugin_sine builds. Existence + load is sufficient — no nontrivial state to behaviourally diff.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions