mutwo.music_converters§

Object

Documentation

mutwo.music_converters.GraceNotesConverter

Apply grace notes and after grace notes on core_events.abc.Event.

mutwo.music_converters.LoudnessToAmplitude

Make an approximation of the needed amplitude for a perceived Loudness.

mutwo.music_converters.RhythmicalStrataToIndispensability

Builds metrical indispensability for a rhythmical strata.

mutwo.music_converters.SimpleEventToPitchList

mutwo.music_converters.SimpleEventToVolume

mutwo.music_converters.SimpleEventToLyric

mutwo.music_converters.SimpleEventToPlayingIndicatorCollection

mutwo.music_converters.SimpleEventToNotationIndicatorCollection

mutwo.music_converters.SimpleEventToGraceNoteSequentialEvent

mutwo.music_converters.SimpleEventToAfterGraceNoteSequentialEvent

mutwo.music_converters.MutwoParameterDictToPitchList

mutwo.music_converters.MutwoParameterDictToVolume

mutwo.music_converters.MutwoParameterDictToPlayingIndicatorCollection

mutwo.music_converters.MutwoParameterDictToNotationIndicatorCollection

mutwo.music_converters.MutwoParameterDictToGraceNoteSequentialEvent

mutwo.music_converters.MutwoParameterDictToAfterGraceNoteSequentialEvent

mutwo.music_converters.MutwoParameterDictToNoteLike

Convert a dict of mutwo parameters to a mutwo.music_events.NoteLike

mutwo.music_converters.ImproveWesternPitchListSequenceReadability

Adjust accidentals of pitches for a tonal-like visual representation

mutwo.music_converters.PlayingIndicatorConverter

Abstract base class to apply PlayingIndicator on a SimpleEvent.

mutwo.music_converters.ArpeggioConverter

Apply arpeggio on SimpleEvent.

mutwo.music_converters.StacattoConverter

Apply staccato on SimpleEvent.

mutwo.music_converters.ArticulationConverter

Apply articulation on SimpleEvent.

mutwo.music_converters.TrillConverter

Apply trill on SimpleEvent.

mutwo.music_converters.PlayingIndicatorsConverter

Apply PlayingIndicator on any Event.

mutwo.music_converters.TwoPitchesToCommonHarmonicTuple

Find the common harmonics between two pitches.

class GraceNotesConverter(minima_grace_notes_duration_factor=0.12, maxima_grace_notes_duration_factor=0.25, minima_number_of_grace_notes=1, maxima_number_of_grace_notes=4, simple_event_to_grace_note_sequential_event=<mutwo.music_converters.parsers.SimpleEventToGraceNoteSequentialEvent object>, simple_event_to_after_grace_note_sequential_event=<mutwo.music_converters.parsers.SimpleEventToAfterGraceNoteSequentialEvent object>)[source]§

Apply grace notes and after grace notes on core_events.abc.Event.

Parameters:
  • minima_grace_notes_duration_factor (float) – Minimal percentage how much of the initial duration of the SimpleEvent shall be moved to the grace notes / after grace notes. This value has to be smaller than 0.5 (so that the SimpleEvent have a duration > 0 if it has both: grace notes and after grace notes) and bigger than 0 (so that the grace notes or after grace notes have a duration > 0). Default to 0.12.

  • maxima_grace_notes_duration_factor (float) – Maxima percentage how much of the initial duration of the SimpleEvent shall be moved to the grace notes / after grace notes. This value has to be smaller than 0.5 (so that the SimpleEvent have a duration > 0 if it has both: grace notes and after grace notes) and bigger than 0 (so that the grace notes or after grace notes have a duration > 0). Default to 0.25.

  • minima_number_of_grace_notes (int) – For how many events in the grace note or after grace note container shall the minima_grace_notes_duration_factor be applied. Default to 1.

  • maxima_number_of_grace_notes (int) – For how many events in the grace note or after grace note container shall the maxima_number_of_grace_notes be applied. Default to 4.

  • simple_event_to_grace_note_sequential_event (Callable[[core_events.SimpleEvent], core_events.SequentialEvent[core_events.SimpleEvent]]) – Function which receives as an input a SimpleEvent and returns a SequentialEvent. By default the function will ask the event for a grace_note_sequential_event attribute, because by default ~mutwo.events.music.NoteLike objects are expected.

  • simple_event_to_after_grace_note_sequential_event (Callable[[core_events.SimpleEvent], core_events.SequentialEvent[core_events.SimpleEvent]]) – Function which receives as an input a SimpleEvent and returns a SequentialEvent. By default the function will ask the event for a grace_note_sequential_event attribute, because by default ~mutwo.events.music.NoteLike objects are expected.

Public Methods:

__init__([...])

convert(event_to_convert)

Apply grace notes and after grace notes of all SimpleEvent.

Inherited from Converter

convert(event_to_convert)

Apply grace notes and after grace notes of all SimpleEvent.

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from EventConverter

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


convert(event_to_convert)[source]§

Apply grace notes and after grace notes of all SimpleEvent.

Parameters:

event_to_convert (core_events.abc.Event) – The event which grace notes and after grace notes shall be converted to normal events in the upper SequentialEvent.

Return type:

Event

class LoudnessToAmplitude(loudspeaker_frequency_response=Envelope([SimpleEvent(curve_shape=0, duration=DirectDuration(duration=2000), value=80), SimpleEvent(curve_shape=0, duration=DirectDuration(duration=0), value=80)]), interpolation_order=4)[source]§

Make an approximation of the needed amplitude for a perceived Loudness.

Parameters:
  • loudspeaker_frequency_response (mutwo.core_events.Envelope) – Optionally the frequency response of the used loudspeaker can be added for balancing out uneven curves in the loudspeakers frequency response. The frequency response is defined with a core_events.Envelope object.

  • interpolation_order (int) – The interpolation order of the equal loudness contour interpolation.

The converter works best with pure sine waves.

Public Methods:

__init__([loudspeaker_frequency_response, ...])

convert(perceived_loudness_in_sone, frequency)

Calculates the needed amplitude to reach a particular loudness for the entered frequency.

Inherited from Converter

convert(perceived_loudness_in_sone, frequency)

Calculates the needed amplitude to reach a particular loudness for the entered frequency.

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


convert(perceived_loudness_in_sone, frequency)[source]§

Calculates the needed amplitude to reach a particular loudness for the entered frequency.

Parameters:
  • perceived_loudness_in_sone (core_constants.Real) – The subjectively perceived loudness that the resulting signal shall have (in the unit Sone).

  • frequency (Union[float, Fraction, int]) – A frequency in Hertz for which the necessary amplitude shall be calculated.

Returns:

Return the amplitude for a sine tone to reach the converters loudness when played with the entered frequency.

Return type:

Union[float, Fraction, int]

Example:

>>> from mutwo.converters import symmetrical
>>> loudness_converter = symmetrical.loudness.LoudnessToAmplitudeConverter(1)
>>> loudness_converter.convert(200)
0.009364120303317933
>>> loudness_converter.convert(50)
0.15497924558613232
class RhythmicalStrataToIndispensability[source]§

Builds metrical indispensability for a rhythmical strata.

This technique has been described by Clarence Barlow in On the Quantification of Harmony and Metre (1992). The technique aims to model the weight of single beats in a particular metre. It allocates each beat of a metre to a specific value that describes the indispensability of a beat: the higher the assigned value, the more accented the beat.

Public Methods:

convert(rhythmical_strata_to_convert)

Convert indispensability for each beat of a particular metre.

Inherited from Converter

convert(rhythmical_strata_to_convert)

Convert indispensability for each beat of a particular metre.

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


convert(rhythmical_strata_to_convert)[source]§

Convert indispensability for each beat of a particular metre.

Parameters:

rhythmical_strata_to_convert (Sequence[int]) – The rhythmical strata defines the metre for which the indispensability shall be calculated. The rhythmical strata is a list of prime numbers which product is the amount of available beats within the particular metre. Earlier prime numbers in the rhythmical strata are considered to be more important than later prime numbers.

Returns:

A tuple of a integer for each beat of the respective metre where each integer describes how accented the particular beat is (the higher the number, the more important the beat).

Return type:

tuple[int, …]

Example:

>>> from mutwo.converters import symmetrical
>>> metricity_converter = symmetrical.metricities.RhythmicalStrataToIndispensability()
>>> metricity_converter.convert((2, 3))  # time signature 3/4
(5, 0, 3, 1, 4, 2)
>>> metricity_converter.convert((3, 2))  # time signature 6/8
(5, 0, 2, 4, 1, 3)
class SimpleEventToPitchList(attribute_name=None, exception_value=[])[source]§

Public Methods:

__init__([attribute_name, exception_value])

Inherited from SimpleEventToAttribute

__init__([attribute_name, exception_value])

convert(simple_event_to_convert)

Extract from a mutwo.core_events.SimpleEvent an attribute.

Inherited from Converter

convert(simple_event_to_convert)

Extract from a mutwo.core_events.SimpleEvent an attribute.

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from SimpleEventToAttribute

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


Parameters:
convert(simple_event_to_convert)§

Extract from a mutwo.core_events.SimpleEvent an attribute.

Parameters:

simple_event_to_convert (mutwo.core_events.SimpleEvent) – The mutwo.core_events.SimpleEvent from which an attribute shall be extracted.

Return type:

Any

Example:

>>> from mutwo import core_converters
>>> from mutwo import core_events
>>> simple_event = core_events.SimpleEvent(duration=10)
>>> simple_event_to_duration = core_converters.SimpleEventToAttribute(
        'duration', 0
    )
>>> simple_event_to_duration.convert(simple_event)
10
>>> simple_event_to_pasta = core_converters.SimpleEventToAttribute(
        'pasta', 'spaghetti'
    )
>>> simple_event_to_pasta.convert(simple_event)
'spaghetti'
>>> simple_event.pasta = 'tagliatelle'
>>> simple_event_to_pasta.convert(simple_event)
'tagliatelle'
class SimpleEventToVolume(attribute_name=None, exception_value=DirectVolume(0))[source]§

Public Methods:

__init__([attribute_name, exception_value])

Inherited from SimpleEventToAttribute

__init__([attribute_name, exception_value])

convert(simple_event_to_convert)

Extract from a mutwo.core_events.SimpleEvent an attribute.

Inherited from Converter

convert(simple_event_to_convert)

Extract from a mutwo.core_events.SimpleEvent an attribute.

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from SimpleEventToAttribute

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


Parameters:
  • attribute_name (Optional[str]) –

  • exception_value (Volume) –

convert(simple_event_to_convert)§

Extract from a mutwo.core_events.SimpleEvent an attribute.

Parameters:

simple_event_to_convert (mutwo.core_events.SimpleEvent) – The mutwo.core_events.SimpleEvent from which an attribute shall be extracted.

Return type:

Any

Example:

>>> from mutwo import core_converters
>>> from mutwo import core_events
>>> simple_event = core_events.SimpleEvent(duration=10)
>>> simple_event_to_duration = core_converters.SimpleEventToAttribute(
        'duration', 0
    )
>>> simple_event_to_duration.convert(simple_event)
10
>>> simple_event_to_pasta = core_converters.SimpleEventToAttribute(
        'pasta', 'spaghetti'
    )
>>> simple_event_to_pasta.convert(simple_event)
'spaghetti'
>>> simple_event.pasta = 'tagliatelle'
>>> simple_event_to_pasta.convert(simple_event)
'tagliatelle'
class SimpleEventToLyric(attribute_name=None, exception_value=<mutwo.music_parameters.lyrics.DirectLyric object>)[source]§

Public Methods:

__init__([attribute_name, exception_value])

Inherited from SimpleEventToAttribute

__init__([attribute_name, exception_value])

convert(simple_event_to_convert)

Extract from a mutwo.core_events.SimpleEvent an attribute.

Inherited from Converter

convert(simple_event_to_convert)

Extract from a mutwo.core_events.SimpleEvent an attribute.

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from SimpleEventToAttribute

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


Parameters:
  • attribute_name (Optional[str]) –

  • exception_value (Volume) –

convert(simple_event_to_convert)§

Extract from a mutwo.core_events.SimpleEvent an attribute.

Parameters:

simple_event_to_convert (mutwo.core_events.SimpleEvent) – The mutwo.core_events.SimpleEvent from which an attribute shall be extracted.

Return type:

Any

Example:

>>> from mutwo import core_converters
>>> from mutwo import core_events
>>> simple_event = core_events.SimpleEvent(duration=10)
>>> simple_event_to_duration = core_converters.SimpleEventToAttribute(
        'duration', 0
    )
>>> simple_event_to_duration.convert(simple_event)
10
>>> simple_event_to_pasta = core_converters.SimpleEventToAttribute(
        'pasta', 'spaghetti'
    )
>>> simple_event_to_pasta.convert(simple_event)
'spaghetti'
>>> simple_event.pasta = 'tagliatelle'
>>> simple_event_to_pasta.convert(simple_event)
'tagliatelle'
class SimpleEventToPlayingIndicatorCollection(attribute_name=None, exception_value=None)[source]§

Public Methods:

__init__([attribute_name, exception_value])

Inherited from SimpleEventToAttributeWithDefaultValue

convert(*args, **kwargs)

Extract from a mutwo.core_events.SimpleEvent an attribute.

Inherited from SimpleEventToAttribute

__init__([attribute_name, exception_value])

convert(*args, **kwargs)

Extract from a mutwo.core_events.SimpleEvent an attribute.

Inherited from Converter

convert(*args, **kwargs)

Extract from a mutwo.core_events.SimpleEvent an attribute.

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from SimpleEventToAttributeWithDefaultValue

_abc_impl

Inherited from SimpleEventToAttribute

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


Parameters:
convert(*args, **kwargs)§

Extract from a mutwo.core_events.SimpleEvent an attribute.

Parameters:

simple_event_to_convert (mutwo.core_events.SimpleEvent) – The mutwo.core_events.SimpleEvent from which an attribute shall be extracted.

Return type:

Any

Example:

>>> from mutwo import core_converters
>>> from mutwo import core_events
>>> simple_event = core_events.SimpleEvent(duration=10)
>>> simple_event_to_duration = core_converters.SimpleEventToAttribute(
        'duration', 0
    )
>>> simple_event_to_duration.convert(simple_event)
10
>>> simple_event_to_pasta = core_converters.SimpleEventToAttribute(
        'pasta', 'spaghetti'
    )
>>> simple_event_to_pasta.convert(simple_event)
'spaghetti'
>>> simple_event.pasta = 'tagliatelle'
>>> simple_event_to_pasta.convert(simple_event)
'tagliatelle'
class SimpleEventToNotationIndicatorCollection(attribute_name=None, exception_value=None)[source]§

Public Methods:

__init__([attribute_name, exception_value])

Inherited from SimpleEventToAttributeWithDefaultValue

convert(*args, **kwargs)

Extract from a mutwo.core_events.SimpleEvent an attribute.

Inherited from SimpleEventToAttribute

__init__([attribute_name, exception_value])

convert(*args, **kwargs)

Extract from a mutwo.core_events.SimpleEvent an attribute.

Inherited from Converter

convert(*args, **kwargs)

Extract from a mutwo.core_events.SimpleEvent an attribute.

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from SimpleEventToAttributeWithDefaultValue

_abc_impl

Inherited from SimpleEventToAttribute

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


Parameters:
convert(*args, **kwargs)§

Extract from a mutwo.core_events.SimpleEvent an attribute.

Parameters:

simple_event_to_convert (mutwo.core_events.SimpleEvent) – The mutwo.core_events.SimpleEvent from which an attribute shall be extracted.

Return type:

Any

Example:

>>> from mutwo import core_converters
>>> from mutwo import core_events
>>> simple_event = core_events.SimpleEvent(duration=10)
>>> simple_event_to_duration = core_converters.SimpleEventToAttribute(
        'duration', 0
    )
>>> simple_event_to_duration.convert(simple_event)
10
>>> simple_event_to_pasta = core_converters.SimpleEventToAttribute(
        'pasta', 'spaghetti'
    )
>>> simple_event_to_pasta.convert(simple_event)
'spaghetti'
>>> simple_event.pasta = 'tagliatelle'
>>> simple_event_to_pasta.convert(simple_event)
'tagliatelle'
class SimpleEventToGraceNoteSequentialEvent(attribute_name=None, exception_value=SequentialEvent([]))[source]§

Public Methods:

__init__([attribute_name, exception_value])

Inherited from SimpleEventToAttribute

__init__([attribute_name, exception_value])

convert(simple_event_to_convert)

Extract from a mutwo.core_events.SimpleEvent an attribute.

Inherited from Converter

convert(simple_event_to_convert)

Extract from a mutwo.core_events.SimpleEvent an attribute.

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from SimpleEventToAttribute

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


Parameters:
convert(simple_event_to_convert)§

Extract from a mutwo.core_events.SimpleEvent an attribute.

Parameters:

simple_event_to_convert (mutwo.core_events.SimpleEvent) – The mutwo.core_events.SimpleEvent from which an attribute shall be extracted.

Return type:

Any

Example:

>>> from mutwo import core_converters
>>> from mutwo import core_events
>>> simple_event = core_events.SimpleEvent(duration=10)
>>> simple_event_to_duration = core_converters.SimpleEventToAttribute(
        'duration', 0
    )
>>> simple_event_to_duration.convert(simple_event)
10
>>> simple_event_to_pasta = core_converters.SimpleEventToAttribute(
        'pasta', 'spaghetti'
    )
>>> simple_event_to_pasta.convert(simple_event)
'spaghetti'
>>> simple_event.pasta = 'tagliatelle'
>>> simple_event_to_pasta.convert(simple_event)
'tagliatelle'
class SimpleEventToAfterGraceNoteSequentialEvent(attribute_name=None, exception_value=SequentialEvent([]))[source]§

Public Methods:

__init__([attribute_name, exception_value])

Inherited from SimpleEventToAttribute

__init__([attribute_name, exception_value])

convert(simple_event_to_convert)

Extract from a mutwo.core_events.SimpleEvent an attribute.

Inherited from Converter

convert(simple_event_to_convert)

Extract from a mutwo.core_events.SimpleEvent an attribute.

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from SimpleEventToAttribute

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


Parameters:
convert(simple_event_to_convert)§

Extract from a mutwo.core_events.SimpleEvent an attribute.

Parameters:

simple_event_to_convert (mutwo.core_events.SimpleEvent) – The mutwo.core_events.SimpleEvent from which an attribute shall be extracted.

Return type:

Any

Example:

>>> from mutwo import core_converters
>>> from mutwo import core_events
>>> simple_event = core_events.SimpleEvent(duration=10)
>>> simple_event_to_duration = core_converters.SimpleEventToAttribute(
        'duration', 0
    )
>>> simple_event_to_duration.convert(simple_event)
10
>>> simple_event_to_pasta = core_converters.SimpleEventToAttribute(
        'pasta', 'spaghetti'
    )
>>> simple_event_to_pasta.convert(simple_event)
'spaghetti'
>>> simple_event.pasta = 'tagliatelle'
>>> simple_event_to_pasta.convert(simple_event)
'tagliatelle'
class MutwoParameterDictToPitchList(pitch_list_to_search_name=None, pitch_list_keyword_name=None)[source]§

Public Methods:

__init__([pitch_list_to_search_name, ...])

Inherited from MutwoParameterDictToKeywordArgument

__init__([pitch_list_to_search_name, ...])

convert(mutwo_parameter_dict_to_convert)

Inherited from Converter

convert(mutwo_parameter_dict_to_convert)

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from MutwoParameterDictToKeywordArgument

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


Parameters:
  • pitch_list_to_search_name (Optional[str]) –

  • pitch_list_keyword_name (Optional[str]) –

convert(mutwo_parameter_dict_to_convert)§
Parameters:

mutwo_parameter_dict_to_convert (dict[str, Any]) –

Return type:

Optional[tuple[str, Any]]

class MutwoParameterDictToVolume(volume_to_search_name=None, volume_keyword_name=None)[source]§

Public Methods:

__init__([volume_to_search_name, ...])

Inherited from MutwoParameterDictToKeywordArgument

__init__([volume_to_search_name, ...])

convert(mutwo_parameter_dict_to_convert)

Inherited from Converter

convert(mutwo_parameter_dict_to_convert)

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from MutwoParameterDictToKeywordArgument

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


Parameters:
  • volume_to_search_name (Optional[str]) –

  • volume_keyword_name (Optional[str]) –

convert(mutwo_parameter_dict_to_convert)§
Parameters:

mutwo_parameter_dict_to_convert (dict[str, Any]) –

Return type:

Optional[tuple[str, Any]]

class MutwoParameterDictToPlayingIndicatorCollection(playing_indicator_collection_to_search_name=None, playing_indicator_collection_keyword_name=None)[source]§

Public Methods:

__init__([...])

Inherited from MutwoParameterDictToKeywordArgument

__init__([...])

convert(mutwo_parameter_dict_to_convert)

Inherited from Converter

convert(mutwo_parameter_dict_to_convert)

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from MutwoParameterDictToKeywordArgument

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


Parameters:
  • playing_indicator_collection_to_search_name (Optional[str]) –

  • playing_indicator_collection_keyword_name (Optional[str]) –

convert(mutwo_parameter_dict_to_convert)§
Parameters:

mutwo_parameter_dict_to_convert (dict[str, Any]) –

Return type:

Optional[tuple[str, Any]]

class MutwoParameterDictToNotationIndicatorCollection(notation_indicator_collection_to_search_name=None, notation_indicator_collection_keyword_name=None)[source]§

Public Methods:

__init__([...])

Inherited from MutwoParameterDictToKeywordArgument

__init__([...])

convert(mutwo_parameter_dict_to_convert)

Inherited from Converter

convert(mutwo_parameter_dict_to_convert)

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from MutwoParameterDictToKeywordArgument

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


Parameters:
  • notation_indicator_collection_to_search_name (Optional[str]) –

  • notation_indicator_collection_keyword_name (Optional[str]) –

convert(mutwo_parameter_dict_to_convert)§
Parameters:

mutwo_parameter_dict_to_convert (dict[str, Any]) –

Return type:

Optional[tuple[str, Any]]

class MutwoParameterDictToGraceNoteSequentialEvent(grace_note_sequential_event_to_search_name=None, grace_note_sequential_event_keyword_name=None)[source]§

Public Methods:

__init__([...])

Inherited from MutwoParameterDictToKeywordArgument

__init__([...])

convert(mutwo_parameter_dict_to_convert)

Inherited from Converter

convert(mutwo_parameter_dict_to_convert)

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from MutwoParameterDictToKeywordArgument

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


Parameters:
  • grace_note_sequential_event_to_search_name (Optional[str]) –

  • grace_note_sequential_event_keyword_name (Optional[str]) –

convert(mutwo_parameter_dict_to_convert)§
Parameters:

mutwo_parameter_dict_to_convert (dict[str, Any]) –

Return type:

Optional[tuple[str, Any]]

class MutwoParameterDictToAfterGraceNoteSequentialEvent(after_grace_note_sequential_event_to_search_name=None, after_grace_note_sequential_event_keyword_name=None)[source]§

Public Methods:

__init__([...])

Inherited from MutwoParameterDictToKeywordArgument

__init__([...])

convert(mutwo_parameter_dict_to_convert)

Inherited from Converter

convert(mutwo_parameter_dict_to_convert)

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from MutwoParameterDictToKeywordArgument

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


Parameters:
  • after_grace_note_sequential_event_to_search_name (Optional[str]) –

  • after_grace_note_sequential_event_keyword_name (Optional[str]) –

convert(mutwo_parameter_dict_to_convert)§
Parameters:

mutwo_parameter_dict_to_convert (dict[str, Any]) –

Return type:

Optional[tuple[str, Any]]

class MutwoParameterDictToNoteLike(mutwo_parameter_dict_to_keyword_argument_sequence=None, simple_event_class=<class 'mutwo.music_events.music.NoteLike'>)[source]§

Convert a dict of mutwo parameters to a mutwo.music_events.NoteLike

Parameters:

Public Methods:

__init__([...])

Inherited from MutwoParameterDictToSimpleEvent

__init__([...])

convert(mutwo_parameter_dict_to_convert)

Inherited from Converter

convert(mutwo_parameter_dict_to_convert)

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from MutwoParameterDictToSimpleEvent

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


convert(mutwo_parameter_dict_to_convert)§
Parameters:

mutwo_parameter_dict_to_convert (dict[str, Any]) –

Return type:

SimpleEvent

class ImproveWesternPitchListSequenceReadability(simultaneous_pitch_weight=1, sequential_pitch_weight=0.7, iteration_count=10000, optimizer_class=<class 'gradient_free_optimizers.high_lvl_api.RandomSearchOptimizer'>, verbosity_list=[], seed=100)[source]§

Adjust accidentals of pitches for a tonal-like visual representation

Parameters:
  • simultaneous_pitch_weight (float) – Factor with which the weights of the resulting fitness from pitches of the same pitch list will be multiplied. Use higher value if a good form of simultaneous pitches is more important for you. Default to 1.

  • sequential_pitch_weight (float) – Factor with which the weights of the resulting fitness from pitches of neighbouring pitch lists will be multiplied. Use higher value if a good form of sequential pitches is more important for you. Default to 0.7.

  • iteration_count (int) – How many iterations the heuristic algorithm shall run. Use higher number for better (but slower) results. Default to 10000.

  • optimizer_class (BaseOptimizer) – Sets optimizer class used within the converter. This can be any optimizer defined in the gradient_free_optimizers package. Default to gradient_free_optimizers.RandomSearchOptimizer.

  • verbosity_list (list[str]) – From ‘gradient_free_optimizers’ documentation: “The verbosity list determines what part of the optimization information will be printed in the command line.”. The complete list would be [“progress_bar”, “print_results”, “print_times”]. Default to [] (no logging, silent).

  • seed (Optional[int]) – The random seed used within the algorithm. Can be None for not-deterministic output. Default to 100.

Type:

gradient_free_optimizers.optimizers.base_optimizer.BaseOptimizer,

This converter aims to adjust :class:`music_parameters.WesternPitch`s in order to improve the quality of western notation created with these pitches. Non-tonal music should be notated in a way to make it look as tonal as possible (e.g. it should notate intervals musicians are used to, it should avoid augmented or diminished intervals). The converter aims to maximize simple intervals (without changing the actual pitch content) by heuristic techniques. The converter may not return the best solution, but a very good approximation.

Disclaimer:

This converter doesn’t work with microtonal pitches! This is due to the fact that mutwo.music_parameters.WesternPitchInterval doesn’t support microtonal pitches yet.

Public Methods:

__init__([simultaneous_pitch_weight, ...])

convert(western_pitch_list_sequence_to_convert)

Simplify western pitch notation.

Inherited from Converter

convert(western_pitch_list_sequence_to_convert)

Simplify western pitch notation.

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_space_separator

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


PitchNameTupleToIntervalQualityDict§

alias of dict[tuple[str], bool]

PitchVariantListTuple§

alias of tuple[list[tuple[WesternPitch, …]], …]

RealSearchSpace§

alias of dict[str, tuple[WesternPitch]]

SearchSpace§

alias of dict[str, int]

convert(western_pitch_list_sequence_to_convert)[source]§

Simplify western pitch notation.

Parameters:

western_pitch_list_sequence_to_convert (Sequence[list[music_parameters.WesternPitch]]) – A sequence filled with lists of mutwo.music_parameters.WesternPitch. The pitches will be simplified.

Returns:

A tuple with lists that contain music_parameters.WesternPitch. The raw pitch content will be the same as the input data, but the accidentals and diatonic pitch class names may differ.

Return type:

tuple[list[mutwo.music_parameters.pitches.WesternPitch.WesternPitch], …]

class PlayingIndicatorConverter(simple_event_to_playing_indicator_collection=<mutwo.music_converters.parsers.SimpleEventToPlayingIndicatorCollection object>)[source]§

Abstract base class to apply PlayingIndicator on a SimpleEvent.

Parameters:

simple_event_to_playing_indicator_collection (Callable[[core_events.SimpleEvent], music_parameters.PlayingIndicatorCollection], optional) – Function to extract from a mutwo.core_events.SimpleEvent a mutwo.music_parameters.PlayingIndicatorCollection object. By default it asks the Event for its playing_indicator_collection attribute (because by default mutwo.ext.events.music.NoteLike objects are expected). When using different Event classes than NoteLike with a different name for their playing_indicator_collection property, this argument should be overridden. If the function call raises an AttributeError (e.g. if no playing indicator collection can be extracted), mutwo will build a playing indicator collection from DEFAULT_PLAYING_INDICATORS_COLLECTION_CLASS.

To write a new PlayingIndicatorConverter the abstract method _apply_playing_indicator() and the abstract properties playing_indicator_name and default_playing_indicator have to be overridden.

Public Methods:

__init__([...])

convert(simple_event_to_convert)

Apply PlayingIndicator on simple_event.

Inherited from Converter

convert(simple_event_to_convert)

Apply PlayingIndicator on simple_event.

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


convert(simple_event_to_convert)[source]§

Apply PlayingIndicator on simple_event.

Parameters:

simple_event_to_convert (core_events.SimpleEvent) – The event which shall be converted.

Return type:

SequentialEvent[SimpleEvent]

abstract property default_playing_indicator: PlayingIndicator§
abstract property playing_indicator_name: str§
class ArpeggioConverter(duration_for_each_attack=0.1, simple_event_to_pitch_list=<mutwo.music_converters.parsers.SimpleEventToPitchList object>, simple_event_to_playing_indicator_collection=<mutwo.music_converters.parsers.SimpleEventToPlayingIndicatorCollection object>, set_pitch_list_for_simple_event=<function ArpeggioConverter.<lambda>>)[source]§

Apply arpeggio on SimpleEvent.

Parameters:
  • duration_for_each_attack (constants.DurationType) – Set how long each attack of the Arpeggio lasts. Default to 0.1.

  • simple_event_to_pitch_list (Callable[[core_events.SimpleEvent], music_parameters.abc.Pitch], optional) – Function to extract from a mutwo.core_events.SimpleEvent a tuple that contains pitch objects (objects that inherit from mutwo.music_parameters.abc.Pitch). By default it asks the Event for its pitch_list attribute (because by default mutwo.ext.events.music.NoteLike objects are expected). When using different Event classes than NoteLike with a different name for their pitch property, this argument should be overridden. If the function call raises an AttributeError (e.g. if no pitch can be extracted), mutwo will assume an event without any pitches.

  • simple_event_to_playing_indicator_collection (Callable[[core_events.SimpleEvent], music_parameters.PlayingIndicatorCollection,], optional) – Function to extract from a mutwo.core_events.SimpleEvent a mutwo.music_parameters.PlayingIndicatorCollection object. By default it asks the Event for its playing_indicator_collection attribute (because by default mutwo.ext.events.music.NoteLike objects are expected). When using different Event classes than NoteLike with a different name for their playing_indicator_collection property, this argument should be overridden. If the function call raises an AttributeError (e.g. if no playing indicator collection can be extracted), mutwo will build a playing indicator collection from DEFAULT_PLAYING_INDICATORS_COLLECTION_CLASS.

  • set_pitch_list_for_simple_event (Callable[[core_events.SimpleEvent, list[music_parameters.abc.Pitch]], None]) – Function which assigns a list of Pitch objects to a SimpleEvent. By default the function assigns the passed pitches to the pitch_list attribute (because by default mutwo.ext.events.music.NoteLike objects are expected).

Public Methods:

__init__([duration_for_each_attack, ...])

Inherited from PlayingIndicatorConverter

__init__([duration_for_each_attack, ...])

convert(simple_event_to_convert)

Apply PlayingIndicator on simple_event.

Inherited from Converter

convert(simple_event_to_convert)

Apply PlayingIndicator on simple_event.

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from PlayingIndicatorConverter

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


convert(simple_event_to_convert)§

Apply PlayingIndicator on simple_event.

Parameters:

simple_event_to_convert (core_events.SimpleEvent) – The event which shall be converted.

Return type:

SequentialEvent[SimpleEvent]

property default_playing_indicator: PlayingIndicator§
property playing_indicator_name: str§
class StacattoConverter(factor=0.5, allowed_articulation_name_sequence=('staccato', '.'), simple_event_to_playing_indicator_collection=<mutwo.music_converters.parsers.SimpleEventToPlayingIndicatorCollection object>)[source]§

Apply staccato on SimpleEvent.

Parameters:

Public Methods:

__init__([factor, ...])

Inherited from PlayingIndicatorConverter

__init__([factor, ...])

convert(simple_event_to_convert)

Apply PlayingIndicator on simple_event.

Inherited from Converter

convert(simple_event_to_convert)

Apply PlayingIndicator on simple_event.

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from PlayingIndicatorConverter

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


convert(simple_event_to_convert)§

Apply PlayingIndicator on simple_event.

Parameters:

simple_event_to_convert (core_events.SimpleEvent) – The event which shall be converted.

Return type:

SequentialEvent[SimpleEvent]

property default_playing_indicator: PlayingIndicator§
property playing_indicator_name: str§
class ArticulationConverter(articulation_name_tuple_to_playing_indicator_converter={('staccato', '.'): <mutwo.music_converters.playing_indicators.StacattoConverter object>}, simple_event_to_playing_indicator_collection=<mutwo.music_converters.parsers.SimpleEventToPlayingIndicatorCollection object>)[source]§

Apply articulation on SimpleEvent.

Parameters:

Public Methods:

__init__([...])

Inherited from PlayingIndicatorConverter

__init__([...])

convert(simple_event_to_convert)

Apply PlayingIndicator on simple_event.

Inherited from Converter

convert(simple_event_to_convert)

Apply PlayingIndicator on simple_event.

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from PlayingIndicatorConverter

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


convert(simple_event_to_convert)§

Apply PlayingIndicator on simple_event.

Parameters:

simple_event_to_convert (core_events.SimpleEvent) – The event which shall be converted.

Return type:

SequentialEvent[SimpleEvent]

property default_playing_indicator: PlayingIndicator§
property playing_indicator_name: str§
class TrillConverter(trill_size=Fraction(1, 16), simple_event_to_pitch_list=<mutwo.music_converters.parsers.SimpleEventToPitchList object>, simple_event_to_playing_indicator_collection=<mutwo.music_converters.parsers.SimpleEventToPitchList object>)[source]§

Apply trill on SimpleEvent.

Parameters:
  • trill_size (constants.DurationType) –

  • simple_event_to_pitch_list (Callable[[core_events.SimpleEvent], music_parameters.abc.Pitch], optional) – Function to extract from a mutwo.core_events.SimpleEvent a tuple that contains pitch objects (objects that inherit from mutwo.music_parameters.abc.Pitch). By default it asks the Event for its pitch_list attribute (because by default mutwo.ext.events.music.NoteLike objects are expected). When using different Event classes than NoteLike with a different name for their pitch property, this argument should be overridden. If the function call raises an AttributeError (e.g. if no pitch can be extracted), mutwo will assume an event without any pitches.

  • simple_event_to_playing_indicator_collection (Callable[[core_events.SimpleEvent], music_parameters.PlayingIndicatorCollection,], optional) – Function to extract from a mutwo.core_events.SimpleEvent a mutwo.ext.parameters.playing_indicators.PlayingIndicatorCollection object. By default it asks the Event for its playing_indicator_collection attribute (because by default mutwo.ext.events.music.NoteLike objects are expected). When using different Event classes than NoteLike with a different name for their playing_indicator_collection property, this argument should be overridden. If the function call raises an AttributeError (e.g. if no playing indicator collection can be extracted), mutwo will build a playing indicator collection from DEFAULT_PLAYING_INDICATORS_COLLECTION_CLASS.

Public Methods:

__init__([trill_size, ...])

Inherited from PlayingIndicatorConverter

__init__([trill_size, ...])

convert(simple_event_to_convert)

Apply PlayingIndicator on simple_event.

Inherited from Converter

convert(simple_event_to_convert)

Apply PlayingIndicator on simple_event.

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from PlayingIndicatorConverter

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


convert(simple_event_to_convert)§

Apply PlayingIndicator on simple_event.

Parameters:

simple_event_to_convert (core_events.SimpleEvent) – The event which shall be converted.

Return type:

SequentialEvent[SimpleEvent]

property default_playing_indicator: PlayingIndicator§
property playing_indicator_name: str§
class PlayingIndicatorsConverter(playing_indicator_converter_sequence)[source]§

Apply PlayingIndicator on any Event.

Parameters:

playing_indicator_converter_sequence (Sequence[PlayingIndicatorConverter]) – A sequence of PlayingIndicatorConverter which shall be applied on each SimpleEvent.

Public Methods:

__init__(playing_indicator_converter_sequence)

convert(event_to_convert)

Inherited from Converter

convert(event_to_convert)

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from SymmetricalEventConverter

_abc_impl

Inherited from EventConverter

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


convert(event_to_convert)[source]§
Parameters:

event_to_convert (Event) –

Return type:

Event

class TwoPitchesToCommonHarmonicTuple(tonality, lowest_partial, highest_partial)[source]§

Find the common harmonics between two pitches.

Parameters:
  • tonality (Optional[bool]) – True for finding common harmonics, False for finding common subharmonics and None for finding common pitches between the harmonics of the first pitch and the subharmonics of the second pitch.

  • lowest_partial (int) – The lowest partial to get investigated. Shouldn’t be smaller than 1.

  • highest_partial (int) – The highest partial to get investigated. Shouldn’t be bigger than 1.

Public Methods:

__init__(tonality, lowest_partial, ...)

convert(pitch_pair_to_examine)

Inherited from Converter

convert(pitch_pair_to_examine)

__call__(*args, **kwargs)

Call self as a function.

Private Data Attributes:

_abc_impl

Inherited from Converter

_abc_impl

Inherited from ABC

_abc_impl


convert(pitch_pair_to_examine)[source]§
Parameters:

pitch_pair_to_examine (tuple[mutwo.music_parameters.pitches.JustIntonationPitch.JustIntonationPitch, mutwo.music_parameters.pitches.JustIntonationPitch.JustIntonationPitch]) –

Return type:

tuple[mutwo.music_parameters.pitches.CommonHarmonic.CommonHarmonic, …]

mutwo.music_converters.configurations§

Configure the default behaviour of mutwo.music_converters

DEFAULT_AFTER_GRACE_NOTE_SEQUENTIAL_EVENT_KEYWORD_NAME = 'after_grace_note_sequential_event'§

Default value for :param:`after_grace_note_sequential_event_keyword_name` parameter in mutwo.core_converters.MutwoParameterDictToAfterGraceNoteSequentialEvent

DEFAULT_AFTER_GRACE_NOTE_SEQUENTIAL_EVENT_TO_SEARCH_NAME = 'after_grace_note_sequential_event'§

Default value for :param:`after_grace_note_sequential_event_to_search_name` parameter in mutwo.music_converters.MutwoParameterDictToAfterGraceNoteSequentialEvent and default value for :param:`attribute_name` in mutwo.music_converters.SimpleEventToAfterGraceNoteSequentialEvent.

DEFAULT_GRACE_NOTE_SEQUENTIAL_EVENT_KEYWORD_NAME = 'grace_note_sequential_event'§

Default value for :param:`grace_note_sequential_event_keyword_name` parameter in mutwo.core_converters.MutwoParameterDictToGraceNoteSequentialEvent

DEFAULT_GRACE_NOTE_SEQUENTIAL_EVENT_TO_SEARCH_NAME = 'grace_note_sequential_event'§

Default value for :param:`grace_note_sequential_event_to_search_name` parameter in mutwo.music_converters.MutwoParameterDictToGraceNoteSequentialEvent and default value for :param:`attribute_name` in mutwo.music_converters.SimpleEventToGraceNoteSequentialEvent.

DEFAULT_LYRIC_TO_SEARCH_NAME = 'lyric'§

Default value for :param:`lyric_to_search_name` parameter in mutwo.music_converters.MutwoParameterDictToLyric and default value for :param:`attribute_name` in mutwo.music_converters.SimpleEventToLyric.

DEFAULT_NOTATION_INDICATOR_COLLECTION_KEYWORD_NAME = 'notation_indicator_collection'§

Default value for :param:`notation_indicator_collection_keyword_name` parameter in mutwo.core_converters.MutwoParameterDictToNotationIndicatorCollection

DEFAULT_NOTATION_INDICATOR_COLLECTION_TO_SEARCH_NAME = 'notation_indicator_collection'§

Default value for :param:`notation_indicator_collection_to_search_name` parameter in mutwo.music_converters.MutwoParameterDictToNotationIndicatorCollection and default value for :param:`attribute_name` in mutwo.music_converters.SimpleEventToNotationIndicatorCollection.

DEFAULT_PITCH_LIST_KEYWORD_NAME = 'pitch_list'§

Default value for :param:`pitch_list_keyword_name` parameter in mutwo.core_converters.MutwoParameterDictToPitchList

DEFAULT_PITCH_LIST_TO_SEARCH_NAME = 'pitch_list'§

Default value for :param:`pitch_list_to_search_name` parameter in mutwo.music_converters.MutwoParameterDictToPitchList and default value for :param:`attribute_name` in mutwo.music_converters.SimpleEventToPitchList.

DEFAULT_PLAYING_INDICATOR_COLLECTION_KEYWORD_NAME = 'playing_indicator_collection'§

Default value for :param:`playing_indicator_collection_keyword_name` parameter in mutwo.core_converters.MutwoParameterDictToPlayingIndicatorCollection

DEFAULT_PLAYING_INDICATOR_COLLECTION_TO_SEARCH_NAME = 'playing_indicator_collection'§

Default value for :param:`playing_indicator_collection_to_search_name` parameter in mutwo.music_converters.MutwoParameterDictToPlayingIndicatorCollection and default value for :param:`attribute_name` in mutwo.music_converters.SimpleEventToPlayingIndicatorCollection.

DEFAULT_VOLUME_KEYWORD_NAME = 'volume'§

Default value for :param:`volume_keyword_name` parameter in mutwo.core_converters.MutwoParameterDictToVolume

DEFAULT_VOLUME_TO_SEARCH_NAME = 'volume'§

Default value for :param:`volume_to_search_name` parameter in mutwo.music_converters.MutwoParameterDictToVolume and default value for :param:`attribute_name` in mutwo.music_converters.SimpleEventToVolume.

mutwo.music_converters.constants§

Several constants which are used for the loudness converter module.

AUDITORY_THRESHOLD_AT_1KHZ = 2e-05§

Roughly the sound of a mosquito flying 3 m away (see https://en.wikipedia.org/wiki/Sound_pressure).