mutwo.parameters.abc¶
Abstract base classes for different parameters.
Classes:
|
Abstract base class for any pitch class. |
|
Abstract base class for any volume class. |
- class NotationIndicator[source]¶
Bases:
mutwo.parameters.abc.IndicatorMethods:
Attributes:
- Return type
None
- get_arguments_dict()¶
- Return type
Dict[str, Any]
- property is_active: bool¶
- class Pitch[source]¶
Bases:
mutwo.parameters.abc.ParameterAbstract base class for any pitch class.
If the user wants to define a new pitch class, the abstract property
frequencyhas to be overridden.Methods:
cents_to_ratio(cents)Converts a cent value to its respective frequency ratio.
hertz_to_cents(frequency0, frequency1)Calculates the difference in cents between two frequencies.
hertz_to_midi_pitch_number(frequency)Converts a frequency in hertz to its respective midi pitch.
ratio_to_cents(ratio)Converts a frequency ratio to its respective cent value.
Attributes:
The frequency in Hertz of the pitch.
The midi pitch number (from 0 to 127) of the pitch.
- static cents_to_ratio(cents)[source]¶
Converts a cent value to its respective frequency ratio.
- Parameters
cents (Union[float, fractions.Fraction]) – Cents that shall be converted to a frequency ratio.
- Return type
quicktions.Fraction
Example:
>>> from mutwo.parameters import abc >>> abc.Pitch.cents_to_ratio(1200) Fraction(2, 1)
- static hertz_to_cents(frequency0, frequency1)[source]¶
Calculates the difference in cents between two frequencies.
- Parameters
frequency0 (Union[float, fractions.Fraction]) – The first frequency in Hertz.
frequency1 (Union[float, fractions.Fraction]) – The second frequency in Hertz.
- Returns
The difference in cents between the first and the second frequency.
- Return type
float
Example:
>>> from mutwo.parameters import abc >>> abc.Pitch.hertz_to_cents(200, 400) 1200.0
- static hertz_to_midi_pitch_number(frequency)[source]¶
Converts a frequency in hertz to its respective midi pitch.
- Parameters
frequency (Union[float, fractions.Fraction]) – The frequency that shall be translated to a midi pitch number.
- Returns
The midi pitch number (potentially a floating point number if the entered frequency isn’t on the grid of the equal divided octave tuning with a = 440 Hertz).
- Return type
float
Example:
>>> from mutwo.parameters import abc >>> abc.Pitch.hertz_to_midi_pitch_number(440) 69.0 >>> abc.Pitch.hertz_to_midi_pitch_number(440 * 3 / 2) 75.98044999134612
- static ratio_to_cents(ratio)[source]¶
Converts a frequency ratio to its respective cent value.
- Parameters
ratio (quicktions.Fraction) – The frequency ratio which cent value shall be calculated.
- Return type
float
Example:
>>> from mutwo.parameters import abc >>> abc.Pitch.ratio_to_cents(fractions.Fraction(3, 2)) 701.9550008653874
- abstract property frequency: float¶
The frequency in Hertz of the pitch.
- property midi_pitch_number: float¶
The midi pitch number (from 0 to 127) of the pitch.
- class PlayingIndicator[source]¶
Bases:
mutwo.parameters.abc.IndicatorMethods:
Attributes:
- Return type
None
- get_arguments_dict()¶
- Return type
Dict[str, Any]
- abstract property is_active: bool¶
- class Volume[source]¶
Bases:
mutwo.parameters.abc.ParameterAbstract base class for any volume class.
If the user wants to define a new volume class, the abstract property :attr:`` has to be overridden.
Methods:
amplitude_ratio_to_decibel(amplitude[, ...])Convert amplitude ratio to decibel.
amplitude_to_midi_velocity(amplitude)Convert volume (floating point number from 0 to 1) to midi velocity.
decibel_to_amplitude_ratio(decibel[, ...])Convert decibel to amplitude ratio.
decibel_to_power_ratio(decibel[, ...])Convert decibel to power ratio.
power_ratio_to_decibel(amplitude[, ...])Convert power ratio to decibel.
Attributes:
The amplitude of the Volume (a number from 0 to 1).
The decibel of the volume (from -120 to 0)
The velocity of the volume (from 0 to 1).
- static amplitude_ratio_to_decibel(amplitude, reference_amplitude=1)[source]¶
Convert amplitude ratio to decibel.
- Parameters
amplitude (Union[float, fractions.Fraction]) – The amplitude that shall be converted.
reference_amplitude (Union[float, fractions.Fraction]) – The amplitude for decibel == 0.
- Return type
float
Example:
>>> from mutwo.parameters import abc >>> abc.Volume.amplitude_ratio_to_decibel(1) 0 >>> abc.Volume.amplitude_ratio_to_decibel(0) inf >>> abc.Volume.amplitude_ratio_to_decibel(0.5) -6.020599913279624
- static amplitude_to_midi_velocity(amplitude)[source]¶
Convert volume (floating point number from 0 to 1) to midi velocity.
- Parameters
amplitude (Union[float, fractions.Fraction]) – A value from 0 to 1 that shall be converted to midi velocity (0 to 127).
- Returns
The midi velocity.
- Return type
int
The method clips values that are higher than 1 / lower than 0.
Example:
>>> from mutwo.parameters import abc >>> abc.Volume.amplitude_to_midi_velocity(1) 127 >>> abc.Volume.amplitude_to_midi_velocity(0) 0
- static decibel_to_amplitude_ratio(decibel, reference_amplitude=1)[source]¶
Convert decibel to amplitude ratio.
- Parameters
decibel (Union[float, fractions.Fraction]) – The decibel number that shall be converted.
reference_amplitude (Union[float, fractions.Fraction]) – The amplitude for decibel == 0.
- Return type
float
Example:
>>> from mutwo.parameters import abc >>> abc.Volume.decibel_to_amplitude_ratio(0) 1 >>> abc.Volume.decibel_to_amplitude_ratio(-6) 0.5011872336272722 >>> abc.Volume.decibel_to_amplitude_ratio(0, reference_amplitude=0.25) 0.25
- static decibel_to_power_ratio(decibel, reference_amplitude=1)[source]¶
Convert decibel to power ratio.
- Parameters
decibel (Union[float, fractions.Fraction]) – The decibel number that shall be converted.
reference_amplitude (Union[float, fractions.Fraction]) – The amplitude for decibel == 0.
- Return type
float
Example:
>>> from mutwo.parameters import abc >>> abc.Volume.decibel_to_power_ratio(0) 1 >>> abc.Volume.decibel_to_power_ratio(-6) 0.251188643150958 >>> abc.Volume.decibel_to_power_ratio(0, reference_amplitude=0.25) 0.25
- static power_ratio_to_decibel(amplitude, reference_amplitude=1)[source]¶
Convert power ratio to decibel.
- Parameters
amplitude (Union[float, fractions.Fraction]) – The amplitude that shall be converted.
reference_amplitude (Union[float, fractions.Fraction]) – The amplitude for decibel == 0.
- Return type
float
Example:
>>> from mutwo.parameters import abc >>> abc.Volume.power_ratio_to_decibel(1) 0 >>> abc.Volume.power_ratio_to_decibel(0) inf >>> abc.Volume.power_ratio_to_decibel(0.5) -3.010299956639812
- abstract property amplitude: Union[float, fractions.Fraction]¶
The amplitude of the Volume (a number from 0 to 1).
- property decibel: Union[float, fractions.Fraction]¶
The decibel of the volume (from -120 to 0)
- property midi_velocity: int¶
The velocity of the volume (from 0 to 1).