lmms icon indicating copy to clipboard operation
lmms copied to clipboard

InstrumentSoundShaping refactoring

Open michaelgregorius opened this issue 1 year ago • 1 comments

Accessors for volume, cutoff, resonance

Add accessors for the volume, cutoff and resonance parameters (envelope and LFO). Use references instead of pointers.

This makes the code less technical and more readable as it for example removes lots of static casts. The casts are now done in a special helper method that returns the parameters for a given target.

Remove EnvelopeAndLfoParameters array

Remove the EnvelopeAndLfoParameters array and use explicit instances for volume, cutoff, resonance. This simplifies construction and initialization of the instances.

Besides the array this also removes the Target enum and the NumTargets value.

To simplify storage and retrieval of the parameters three private methods have been added which provide the node names of the volume, cutoff and resonance parameters.

Adjust InstrumentSoundShapingView to the removed NumTargets property.

Remove friend relationship

Remove the friend relationship between InstrumentSoundShaping and InstrumentSoundShapingView by providing the models via getters.

Fix memory leak

This pull request also removes a memory leak because the InstrumentSoundShaping has no explicit destructor and it therefore has never deleted the EnvelopeAndLfoParameters instances that it instantiated in its constructor.

michaelgregorius avatar Apr 27 '24 19:04 michaelgregorius

@DomClark, it seems that you are currently on a review run. :sweat_smile: Can you please check this pull request as well? In my opinion it improves the readability in the context of the instrument sound shaping a lot because it gets rid or for-loops and complex array accesses.

Objects are now defined and named in a much more straight-forward way so that it becomes much more obvious what's happening in the code.

michaelgregorius avatar Aug 11 '24 10:08 michaelgregorius