mutwo.core_parameters§
Abstractions for attributes that can be assigned to Event objects.
Object |
Documentation |
---|---|
Simple Duration which is directly initialised by its value. |
|
Represent the active tempo at a specific moment in time. |
- class DirectDuration(duration)[source]§
Simple Duration which is directly initialised by its value.
Example:
>>> from mutwo import core_parameters >>> # create duration with duration = 10 beats >>> my_duration = core_parameters.DirectDuration(10) >>> my_duration.duration 10
Public Data Attributes:
Inherited from
Duration
Inherited from
SingleNumberParameter
Public Methods:
__init__
(duration)__repr__
()Return repr(self).
Inherited from
Duration
add
(other)subtract
(other)multiply
(other)divide
(other)__add__
(other)__sub__
(other)__mul__
(other)__truediv__
(other)__float__
()Inherited from
SingleNumberParameter
__float__
()__int__
()__eq__
(other)Return self==value.
__lt__
(other)Return self<value.
__gt__
(other[, NotImplemented])Return a > b.
__le__
(other[, NotImplemented])Return a <= b.
__ge__
(other[, NotImplemented])Return a >= b.
Inherited from
SingleValueParameter
__init_subclass__
([value_name, ...])This method is called when a class is subclassed.
__str__
()Return str(self).
__eq__
(other)Return self==value.
Private Data Attributes:
_abc_impl
Inherited from
Duration
_abc_impl
Inherited from
SingleNumberParameter
_abc_impl
Inherited from
SingleValueParameter
_abc_impl
Inherited from
ABC
_abc_impl
- Parameters:
duration (float) –
- property digit_to_round_to_count: Optional[int]§
- direct_comparison_type_tuple = (<class 'float'>, <class 'int'>, <class 'quicktions.Fraction'>)§
- property duration: Fraction§
- property duration_in_floats: float§
- property value_name§
- class TempoPoint(tempo_or_tempo_range_in_beats_per_minute, reference=1, textual_indication=None)[source]§
Represent the active tempo at a specific moment in time.
- Parameters:
tempo_or_tempo_range_in_beats_per_minute (Union[float, tuple[float, float]]) – Specify a tempo in beats per minute. Tempo can also be a tempo range where the first value indicates a minimal tempo and the second value the maximum tempo. If the user specifies a range
mutwo
will use the minimal tempo in internal calculations.reference (Union[float, Fraction, int]) – The reference with which the tempo will be multiplied. In terms of Western notation a reference = 1 will be a 1/4 beat, a reference of 2 will be a 1/2 beat, etc. Default to 1.
textual_indication (Optional[str]) – Sometimes it is desired to specify an extra text indication how fast or slow the music should be (for instance “Adagio” in Western music). Default to None.
Example:
>>> from mutwo import core_events >>> from mutwo import core_parameters >>> tempo_envelope = core_events.TempoEnvelope([ >>> [0, core_parameters.TempoPoint(60, reference=2)] >>> ])
Public Data Attributes:
Get tempo in beats per minute
Get absolute tempo in beats per minute
Public Methods:
__init__
(...[, reference, textual_indication])__repr__
()Return repr(self).
__eq__
(other)Return self==value.
- property absolute_tempo_in_beats_per_minute: float§
Get absolute tempo in beats per minute
The absolute tempo takes the
reference
of theTempoPoint
into account.
- property tempo_in_beats_per_minute: float§
Get tempo in beats per minute
If
tempo_or_tempo_range_in_beats_per_minute
is a range mutwo will return the minimal tempo.
mutwo.core_parameters.abc§
Abstract base classes for different parameters.
This module defines the public API of parameters. Most other mutwo classes rely on this API. This means when someone creates a new class inheriting from any of the abstract parameter classes which are defined in this module, she or he can make use of all other mutwo modules with this newly created parameter class.
- class Duration[source]§
Abstract base class for any duration.
If the user wants to define a Duration class, the abstract property
duration
has to be overridden.The attribute
duration
is stored in unit beats.- property digit_to_round_to_count: Optional[int]§
- direct_comparison_type_tuple = (<class 'float'>, <class 'int'>, <class 'quicktions.Fraction'>)§
- abstract property duration: Fraction§
- property duration_in_floats: float§
- property value_name§
- class ParameterWithEnvelope(envelope)[source]§
Abstract base class for all parameters with an envelope.
- Parameters:
envelope (core_events.RelativeEnvelope) –
- resolve_envelope(duration, resolve_envelope_class=None)[source]§
- Parameters:
duration (Union[float, Fraction, int]) –
resolve_envelope_class (Optional[type[mutwo.core_events.envelopes.Envelope]]) –
- Return type:
- property envelope: RelativeEnvelope§
- class SingleNumberParameter[source]§
Abstract base class for all parameters which are defined by one number.
Classes which inherit from this base class have to override the same methods and properties as one have to override when inheriting from
SingleValueParameter
.Furthermore the property digit_to_round_to_count can be overridden. This should return an integer or None. If it returns an integer it will first round two numbers before comparing them with the == or < or <= or > or >= operators. The default implementation always returns `None.
Example:
>>> from mutwo import core_parameters >>> class Speed( core_parameters.abc.SingleNumberParameter, value_name="meter_per_seconds", value_return_type=float ): def __init__(self, meter_per_seconds: float): self._meter_per_seconds = meter_per_seconds @property def meter_per_seconds(self) -> float: return self._meter_per_seconds >>> light_speed = Speed(299792458) >>> sound_speed = Speed(343) >>> light_speed > sound_speed True
- property digit_to_round_to_count: Optional[int]§
- direct_comparison_type_tuple = ()§
- class SingleValueParameter[source]§
Abstract base class for all parameters which are defined by one value.
Classes which inherit from this base class have to provide an additional keyword argument value_name. Furthermore they can provide the optional keyword argument value_return_type.
Example:
>>> from mutwo import core_parameters >>> class Color( core_parameters.abc.SingleValueParameter, value_name="color", value_return_type=str ): def __init__(self, color: str): self._color = color @property def color(self) -> str: return self._color >>> red = Color('red') >>> red.color 'red' >>> orange = Color('orange') >>> red2 = Color('red') >>> red == orange False >>> red == red2 True
mutwo.core_parameters.configurations§
Configurations which are shared for all parameter classes in mutwo.core_parameters
.
- ROUND_DURATION_TO_N_DIGITS = 10§
Set floating point precision for the duration_in_floats property of all
Duration
classes in themutwo.core_parameters
module.When returning the duration_in_floats property all mentioned events will round their actual duration if the duration type is float. This behaviour has been added with version 0.28.1 to avoid floating point rounding errors which could occur in all duration related methods of the different event classes (as it can happen in for instance the
mutwo.core_events.abc.ComplexEvent.squash_in()
method or themutwo.core_events.abc.Event.cut_off()
method).