mutwo.parameters.volumes¶
Submodule for the parameter volume.
‘Volume’ is defined as any object that knows a amplitude attribute.
Classes:
|
A simple volume class that gets directly initialised by decibel. |
|
A simple volume class that gets directly initialised by its amplitude. |
|
Volume with a traditional Western nomenclature. |
- class DecibelVolume(decibel)[source]¶
Bases:
mutwo.parameters.abc.VolumeA simple volume class that gets directly initialised by decibel.
- Parameters
decibel (Union[float, fractions.Fraction]) – The decibel of the
DecibelVolumeobject (should be from -120 to 0).
May be used when a converter class needs a volume object, but there is no need or desire for a complex abstraction of the respective volume.
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)¶
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)¶
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)¶
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)¶
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)¶
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
- 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).
- class DirectVolume(amplitude)[source]¶
Bases:
mutwo.parameters.abc.VolumeA simple volume class that gets directly initialised by its amplitude.
- Parameters
amplitude (Union[float, fractions.Fraction]) – The amplitude of the
DirectVolumeobject.
May be used when a converter class needs a volume object, but there is no need or desire for a complex abstraction of the respective volume.
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)¶
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)¶
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)¶
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)¶
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)¶
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
- 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).
- class WesternVolume(name)[source]¶
Bases:
mutwo.parameters.abc.VolumeVolume with a traditional Western nomenclature.
- Parameters
name (str) – Dynamic indicator in traditional Western nomenclature (‘f’, ‘pp’, ‘mf’, ‘sfz’, etc.). For a list of all supported indicators, see
mutwo.parameters.volumes_constants.DYNAMIC_INDICATOR.
>>> from mutwo.parameters import volumes >>> volumes.WesternVolume('fff')
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.
from_amplitude(amplitude)Initialise WesternVolume from amplitude ratio.
from_decibel(decibel)Initialise WesternVolume from decibel.
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).
The western nomenclature name for dynamic.
- static amplitude_ratio_to_decibel(amplitude, reference_amplitude=1)¶
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)¶
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)¶
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)¶
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
- classmethod from_amplitude(amplitude)[source]¶
Initialise WesternVolume from amplitude ratio.
- Parameters
amplitude (Union[float, fractions.Fraction]) – The amplitude which shall be converted to a WesternVolume object.
- Return type
>>> from mutwo.parameters import volumes >>> volumes.WesternVolume.from_amplitude(0.05) WesternVolume(mp)
- classmethod from_decibel(decibel)[source]¶
Initialise WesternVolume from decibel.
- Parameters
decibel (Union[float, fractions.Fraction]) – The decibel which shall be converted to a WesternVolume object.
- Return type
>>> from mutwo.parameters import volumes >>> volumes.WesternVolume.from_decibel(-24) WesternVolume(mf)
- static power_ratio_to_decibel(amplitude, reference_amplitude=1)¶
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
- 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).
- property name: str¶
The western nomenclature name for dynamic.
For a list of all supported indicators, see
mutwo.parameters.volumes_constants.DYNAMIC_INDICATOR.