Graham Wakefield's C++ template question

clazarou's icon

Hi there:

I'm attempting to understand Graham Wakefield's C++ template for developing externals, but I'm stuck on the "perform" method defined in the sample MSP object.

// signal processing example: inverts sign of inputs
        void perform(int vs, t_sample ** inputs, t_sample ** outputs) {
                for (int channel = 0; channel < 2; channel++) {
                        t_sample * in = inputs[channel];
                        t_sample * out = outputs[channel];
                        for (int i=0; i

The other methods provided, test and bang, are bound to text symbols in by the use of REGISTER_METHOD(Example, bang) and REGISTER_METHOD_GIMME(Example, test), but perform is not. In order to use this function, should I somehow "register" it first? Attempts at adding REGISTER_METHOD_GIMME(Example, perform), REGISTER_METHOD_FLOAT(Example, perform), etc. to main() are not working out.

I'm getting two errors

1. could not convert template argument '&Example::perform' to 'void (Example::*)(long int, t_symbol*, long int, t_atom*)'
2. 'call' is not a member of ''

Source code for template is at

oli larkin's icon

no, just implement it:

#include "maxcpp5.h"

class myob : public MspCpp5
{
private:

public:
    myob(t_symbol * sym, long ac, t_atom * av)
    {
        setupIO(&myob::perform, 1, 1);
    }

    ~myob()
    {
    }    

    // methods:
    void bang(long inlet)
    {
    }

    void dsp() {}

    void perform(int vs, t_sample ** inputs, t_sample ** outputs)
    {
        t_sample * triggerIn = inputs[0];
        t_sample * out = outputs[0];

        // do stuff to samples
    }
};

extern "C" int main(void)
{
    myob::makeMaxClass("myob~");
    REGISTER_METHOD(myob, bang);
}