-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
events/Envelope: Simplify Envelope structure (#28)
This patch aims at significantly simplifying the structure of the 'Envelope' class. A 'Envelope' is a collection of points (= events) that are interpolated to create a continuous curve. 'mutwo' doesn't have a general implementation of the concept 'point', but rather utilizes the event type to simplify the implementation. While the x-axis is naturally time and represented with the 'Duration' class, the y-axis isn't generally specified. It could either be pitch, volume, tempo or anything else. In order to allow flexibility about what the y-axis is, mutwo differentiates between 'parameters' (pitch, volume, ...) and 'values'. 'Values' are the numerical representation of the 'parameters' and 'values' equal the y-axis number. Furthermore mutwo allows the usage of any event type. This flexibility is implemented with methods of the envelope class: - event_to_parameter - event_to_curve_shape - parameter_to_value - value_to_parameter - apply_parameter_on_envelope - apply_curve_shape_on_envelope - initialise_default_event_class - default_event_class Before this patch these methods were arguments of the envelopes initialization. Now they are set as public functions of the envelope class and inherited classes. This means that within one envelope class, a specific type of parameters and objects are expected. Therefore this patch makes the envelope class less flexible. On the other hand all envelope usages in 'mutwo.core' and 'mutwo.music' that used different representations than the default one simply subclassed the 'envelope' class and barely never ad-hoc defined other envelope representations. Therefore the practical usage of envelopes showed that the flexibility that's lost with this patch isn't needed. On the other hand this patch widely improves readablity of the code and simplifies the definition. Furthermore it becomes easier to pickle mutwo events as we don't have anonymous lambda functions in the envelope class anymore. This fixes #28.
- Loading branch information
1 parent
48c611f
commit d85a2a3
Showing
3 changed files
with
74 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters