This is part of my microtonalizing plugin wrapper.
I would like the user to be able to change the number of available voices, i.e. copies of the desired plugin, in real time. That way, they can add voices to cover complex passages but save CPU on other parts of a piece.
The parameters should all be the same for all instances, but different MIDI messages will be distributed to different instances. If the user adds a voice, I want to clone the main instance, including all internal parameter values. It doesn’t seem logical to keep track of all parameter values in my wrapper and then set those values for newly created instances, if it is possible to bulk copy all the data, i.e. the instance itself.
The wrapper code I started with uses ScopedPointer which I read should be replaced with std::unique_ptr, and I suppose I will want the array version of unique_ptr. I’m not finding much info, though, on copying the value of what the pointer references in C++ materials. They mention the pointer itself can’t be copied, fine; I want to create a different pointer to a different address with the same value. All of the C++ std::unique_ptr examples I can find use pointers to int or char, which seems pretty pointless, since they make it seem as simple as pie to assign a constant int value to a new instance.
Is it going to be as simple as initializing a new unique_ptr by dereferencing the value of an existing one?
I will also need to copy the entire array to a new one, in the case where someone reduces the number of voices (instances) while some of them are active, as this may involve removing inactive instances from the middle of the block of memory.
Or, for such needs, is unique_ptr not ideal?
Thanks for any tips.