[LV2] Another Question

Warren Koontz profwub at gmail.com
Sat Dec 28 11:29:55 PST 2013


Michael,

Thanks. Just to clarify, I wrote Multiverb as a class that inherits from
the plugin template in lv2-c++-tools. Multiverb uses another class called
DelayLine, which has its own ctor and dtor. The private variables of
Multiverb include two fixed-length arrays of DelayLine objects. As I
understand C++, these objects are implicitly instantiated and destroyed
when, respectively, Multiverb is instantiated and destroyed. The DelayLine
create method (not the ctor), which is called by the Multiverb ctor,
allocates the float array with a new command. The DelayLine dtor frees this
array. SO - I do believe that all allocation occurs during Multiverb
instantiation and all freeing occurs during Multiverb destruction, as it
should!

Warren


On Sat, Dec 28, 2013 at 1:20 PM, Michael R. Fisher <mfisher31 at gmail.com>wrote:

> With lv2-c++-tools, the ctor and dtor of your plugin match up with
> 'instantiate' and 'cleanup' respectively.
>
>
>
>
> On Dec 27, 2013, at 8:23 AM, Warren Koontz <profwub at gmail.com> wrote:
>
> My plugin uses an array of buffers with different lengths. I am
> considering options for implementation:
>
> Programming 101 option:
>
> #define ORDER 8 // number of buffers
> #define MAXLEN 5000 // length of largest buffer
> float buffer[ORDER][MAXLEN];
> unsigned ptr[ORDER];
>
> Programming 201 option:
>
> #define ORDER 8
> struct Buffer {
>     float *buf;
>     unsigned ptr;
> } buffer[ORDER];
> unsigned size[] = {/* list of buffer lengths */};
> for (unsigned i = 0; i < ORDER; i++)
>     buffer[i].buf = new float[size[i]];
>
> Programming 301 option:
>
> class Buffer etc.
>
> The latter two options require dynamic allocation and freeing. Can this be
> safely done in activate and deactivate? I could also do the allocation in
> the constructor for my plugin but, since I am using lv2-c++-tools and
> inheriting from the plugin class, I am not sure where I can do the
> freeing. I hate to go with the 101 option - looks too much like my MATLAB
> implementation. But if it is the safest way ...
>
> Thanks again.
>
> Warren
>
> _______________________________________________
> Devel mailing list
> Devel at lists.lv2plug.in
> http://lists.lv2plug.in/listinfo.cgi/devel-lv2plug.in
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lv2plug.in/pipermail/devel-lv2plug.in/attachments/20131228/1a44f43a/attachment-0002.htm>


More information about the Devel mailing list