mutwo.music_parameters

Object

Documentation

mutwo.music_parameters.OctaveAmbitus

mutwo.music_parameters.Comma

A tuning comma.

mutwo.music_parameters.CommaCompound

Collection of tuning commas.

mutwo.music_parameters.NaturalHarmonic

Model the natural harmonic of a String.

mutwo.music_parameters.String

String represents a string of an instrument.

mutwo.music_parameters.StringInstrumentMixin

Mixin to model instrument with strings.

mutwo.music_parameters.UnpitchedInstrument

Model a musical instruments without any clear pitches.

mutwo.music_parameters.ContinuousPitchedInstrument

Model a musical instrument with continuous pitches (e.g. not fretted).

mutwo.music_parameters.DiscreetPitchedInstrument

Model a musical instrument with discreet pitches (e.g. fretted).

mutwo.music_parameters.ContinuousPitchedStringInstrument

mutwo.music_parameters.DiscreetPitchedStringInstrument

mutwo.music_parameters.Orchestration

Create a name space for the instrumentation of a composition.

mutwo.music_parameters.OrchestrationMixin

Helper base class from which adhoc created Orchestration object inherits.

mutwo.music_parameters.CelticHarp

A typical beginners harp without any pedals.

mutwo.music_parameters.Piccolo

mutwo.music_parameters.Flute

mutwo.music_parameters.Oboe

mutwo.music_parameters.BfClarinet

mutwo.music_parameters.EfClarinet

mutwo.music_parameters.Bassoon

mutwo.music_parameters.DirectLyric

Lyric which is directly initialised by its phonetic representation

mutwo.music_parameters.LanguageBasedLyric

Lyric based on a natural language.

mutwo.music_parameters.LanguageBasedSyllable

Syllable based on a natural language.

mutwo.music_parameters.DirectPitchInterval

Simple interval class which gets directly assigned by its cents value

mutwo.music_parameters.WesternPitchInterval

Model intervals by using European music theory based representations

mutwo.music_parameters.DirectPitch

A simple pitch class that gets directly initialised by its frequency.

mutwo.music_parameters.JustIntonationPitch

Pitch that is defined by a frequency ratio and a reference pitch.

mutwo.music_parameters.Partial

Abstract representation of a harmonic spectrum partial.

mutwo.music_parameters.EqualDividedOctavePitch

Pitch that is tuned to an Equal divided octave tuning system.

mutwo.music_parameters.WesternPitch

Pitch with a traditional Western nomenclature.

mutwo.music_parameters.MidiPitch

Pitch that is defined by its midi pitch number.

mutwo.music_parameters.CommonHarmonic

JustIntonationPitch which is the common harmonic between two or more other pitches.

mutwo.music_parameters.ScalePitch

Pitch that is defined by its scale degree, octave and reference scale.

mutwo.music_parameters.FlexPitch

A flexible pitch.

mutwo.music_parameters.DirectVolume

A simple volume class that gets directly initialised by decibel.

mutwo.music_parameters.FlexVolume

A flexible volume.

mutwo.music_parameters.AmplitudeVolume

A simple volume class that gets directly initialised by its amplitude.

mutwo.music_parameters.WesternVolume

Volume with a traditional Western nomenclature.

mutwo.music_parameters.BarLine

BarLine(abbreviation: Optional[str] = None)

mutwo.music_parameters.Clef

Clef(name: Optional[str] = None)

mutwo.music_parameters.Ottava

Ottava(octave_count: Optional[int] = 0)

mutwo.music_parameters.MarginMarkup

MarginMarkup(content: Optional[str] = None, context: Optional[str] = ‘Staff’)

mutwo.music_parameters.Markup

Markup(content: Optional[str] = None, direction: Optional[str] = None)

mutwo.music_parameters.RehearsalMark

RehearsalMark(markup: Optional[str] = None)

mutwo.music_parameters.NotationIndicatorCollection

Collection of notation indicators

mutwo.music_parameters.Tremolo

Tremolo(flag_count: Optional[int] = None)

mutwo.music_parameters.Articulation

Articulation(name: Optional[Literal[‘accent’, ‘marcato’, ‘staccatissimo’, ‘espressivo’, ‘staccato’, ‘tenuto’, ‘portato’, ‘upbow’, ‘downbow’, ‘flageolet’, ‘thumb’, ‘lheel’, ‘rheel’, ‘ltoe’, ‘rtoe’, ‘open’, ‘halfopen’, ‘snappizzicato’, ‘stopped’, ‘turn’, ‘reverseturn’, ‘trill’, ‘prall’, ‘mordent’, ‘prallprall’, ‘prallmordent’, ‘upprall’, ‘downprall’, ‘upmordent’, ‘downmordent’, ‘pralldown’, ‘prallup’, ‘lineprall’, ‘signumcongruentiae’, ‘shortfermata’, ‘fermata’, ‘longfermata’, ‘verylongfermata’, ‘segno’, ‘coda’, ‘varcoda’, ‘^’, ‘+’, ‘-’, ‘|’, ‘>’, ‘.’, ‘_’]] = None)

mutwo.music_parameters.Arpeggio

Arpeggio(direction: Optional[Literal[‘up’, ‘down’]] = None)

mutwo.music_parameters.Pedal

Pedal(type: Optional[Literal[‘sustain’, ‘sostenuto’, ‘corda’]] = None, activity: Optional[bool] = True)

mutwo.music_parameters.Slur

Slur(activity: Optional[bool] = None)

mutwo.music_parameters.StringContactPoint

StringContactPoint(contact_point: Optional[Literal[‘dietro ponticello’, ‘molto sul ponticello’, ‘molto sul tasto’, ‘ordinario’, ‘pizzicato’, ‘ponticello’, ‘sul ponticello’, ‘sul tasto’, ‘col legno tratto’, ‘d.p.’, ‘m.s.p’, ‘m.s.t.’, ‘ord.’, ‘pizz.’, ‘p.’, ‘s.p.’, ‘s.t.’, ‘c.l.t.’]] = None)

mutwo.music_parameters.Ornamentation

Ornamentation(direction: Optional[Literal[‘up’, ‘down’]] = None, count: int = 1)

mutwo.music_parameters.BendAfter

BendAfter(bend_amount: Optional[float] = None, minimum_length: Optional[float] = 3, thickness: Optional[float] = 3)

mutwo.music_parameters.ArtificalHarmonic

ArtificalHarmonic(semitone_count: Optional[int] = None)

mutwo.music_parameters.NaturalHarmonicNodeList

Assign natural harmonics to your note.

mutwo.music_parameters.Fermata

Fermata(type: Optional[Literal[‘shortfermata’, ‘fermata’, ‘longfermata’, ‘verylongfermata’]] = None)

mutwo.music_parameters.Hairpin

Hairpin(symbol: Optional[Literal[‘<’, ‘>’, ‘<>’, ‘!’]] = None, niente: bool = False)

mutwo.music_parameters.Trill

Trill(pitch: Optional[mutwo.music_parameters.abc.Pitch] = None)

mutwo.music_parameters.WoodwindFingering

WoodwindFingering(cc: Optional[Tuple[str, …]] = None, left_hand: Optional[Tuple[str, …]] = None, right_hand: Optional[Tuple[str, …]] = None, instrument: str = ‘clarinet’)

mutwo.music_parameters.Cue

Cue for electronics etc.

mutwo.music_parameters.PlayingIndicatorCollection

Collection of playing indicators

mutwo.music_parameters.ScaleFamily

A ScaleFamily is a sorted sequence of mutwo.music_parameters.abc.PitchInterval.

mutwo.music_parameters.RepeatingScaleFamily

A RepeatingScaleFamily is a sorted sequence of repeating intervals over a repetition interval.

mutwo.music_parameters.Scale

A Scale is a sorted sequence of Pitch.

Orchestration(**instrument_name_to_instrument)[source]

Create a name space for the instrumentation of a composition.

Parameters:

**instrument_name_to_instrument (music_parameters.abc.Instrument) – Pick any instrument name and map it to a specific instrument.

This returns an adapted namedtuple instance where the keys are the instrument names and the values are the mutwo.music_parameters.abc.Instrument objects. The returned Orchestration object has some additional methods. They are documented in the :class`OrchestrationMixin`.

Example:

>>> from mutwo import music_parameters
>>> music_parameters.Orchestration(
...   oboe0=music_parameters.Oboe(),
...   oboe1=music_parameters.Oboe(),
... )
Orchestration(oboe0=Oboe(name='oboe', short_name='ob.', pitch_count_range=Range[1, 2), transposition_pitch_interval=D(0)), oboe1=Oboe(name='oboe', short_name='ob.', pitch_count_range=Range[1, 2), transposition_pitch_interval=D(0)))
class OctaveAmbitus(minima_pitch, maxima_pitch)[source]

Bases: PitchAmbitus

Public Data Attributes:

Inherited from PitchAmbitus

border_tuple

range

Public Methods:

pitch_to_period(pitch)

Inherited from PitchAmbitus

pitch_to_period(pitch)

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

filter_pitch_sequence(pitch_to_filter_sequence)

Filter all pitches in a sequence which aren't inside the ambitus.

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:
  • minima_pitch (Pitch) –

  • maxima_pitch (Pitch) –

pitch_to_period(pitch)[source]
Parameters:

pitch (Pitch) –

Return type:

PitchInterval

class Comma(ratio)[source]

Bases: object

A tuning comma.

Public Data Attributes:

ratio


Parameters:

ratio (Fraction) –

property ratio: Fraction
class CommaCompound(prime_to_exponent_dict, prime_to_comma_dict)[source]

Bases: Iterable[Comma]

Collection of tuning commas.

Public Data Attributes:

prime_to_exponent_dict

ratio


Parameters:
property prime_to_exponent_dict: dict[int, int]
property ratio: Fraction
class NaturalHarmonic(index, string)[source]

Bases: Partial

Model the natural harmonic of a String.

Parameters:
  • index (int) – The partials index.

  • string (String) – The String on which this harmonic shall be played.

Public Data Attributes:

string

The String on which the harmonic is played.

Inherited from Partial

tonality

index

Public Methods:

pitch

The resulting sounding pitch of a NaturalHarmonic.

node_tuple

Find all NaturalHarmonic.Node on which harmonic is playable.

Inherited from Partial

interval


class Node(interval, natural_harmonic, string)[source]

Bases: object

A position on a string which, if touched, produces a harmonic.

Parameters:
  • interval (music_parameters.abc.PitchInterval) – The interval remarks the position on the string where the player needs to press in order to produce a harmonic. The interval needs to be added to the String tuning in order to gain a pitch. The position where this pitch is played normally on the given string is the node position where the harmonic can be produced.

  • natural_harmonic (NaturalHarmonic) – The natural harmonic which is produced when pressing at the nodes position.

  • string (String) – The string on which to play the node,

interval: PitchInterval
natural_harmonic: NaturalHarmonic
property pitch: Pitch

At which position to press the string to produce the harmonic.

string: String
property node_tuple: tuple[mutwo.music_parameters.instruments.general.NaturalHarmonic.Node, ...]

Find all NaturalHarmonic.Node on which harmonic is playable.

Example:

>>> from mutwo import music_parameters
>>> natural_harmonic = music_parameters.NaturalHarmonic(
...     2,
...     music_parameters.String(0, music_parameters.WesternPitch('g', 3)),
... )
>>> natural_harmonic.node_tuple
(NaturalHarmonic.Node(interval=JustIntonationPitch('2/1'), natural_harmonic=NaturalHarmonic(index=2, tonality=True), string=String(0, WesternPitch('g', 3))),)
property pitch: JustIntonationPitch

The resulting sounding pitch of a NaturalHarmonic.

Example:

>>> from mutwo import music_parameters
>>> string = music_parameters.String(0, music_parameters.WesternPitch("g", 3))
>>> natural_harmonic = music_parameters.NaturalHarmonic(3, string)
>>> natural_harmonic.pitch
WesternPitch('d', 5)
property string: String

The String on which the harmonic is played.

class String(index, tuning, tuning_original=None, max_natural_harmonic_index=6)[source]

Bases: object

String represents a string of an instrument.

Parameters:
  • index (int) – The index of a String. This is important in order to differentiate how far two strings are from each other.

  • tuning (music_parameters.abc.Pitch) – The pitch to which the string is tuned to.

  • tuning_original (Optional[music_parameters.abc.Pitch]) – If the standard tuning of a string differs from its current tuning (e.g. if a scordatura is used) this parameter can be set to the standard tuning. This is useful in case one wants to notate the fingering of a harmonic and not the sounding result. The pitch attribute of NaturalHarmonic.Node uses tuning_original for calculation instead of tuning. If `tuning_original is None it is auto-set to tuning. Default to None.

  • max_natural_harmonic_index (int) – Although we can imagine infinite number of natural harmonics, in the real world it’s not so easy to play higher flageolet. It’s therefore a good idea to denote a limit of the highest natural harmonic. This limit defines the highest NaturalHarmonic which is returned when accessing String`s ``natural_harmonic_tuple` property. No matter what is set to max_natural_harmonic_index, you can still get infinitely high NaturalHarmonic of a String with its index_to_natural_harmonic method. Default to 6.

Example:

>>> from mutwo import music_parameters
>>> g_string = music_parameters.String(0, music_parameters.WesternPitch('g', 3))
>>> g_string
String(0, WesternPitch('g', 3))
>>> retuned_g_string = music_parameters.String(
...     0,
...     music_parameters.WesternPitch('g', 3),
...     tuning_original=music_parameters.JustIntonationPitch('8/11'),
... )
>>> retuned_g_string
String(0, WesternPitch('g', 3))

Public Data Attributes:

tuning_original

max_natural_harmonic_index

index

tuning

Public Methods:

natural_harmonic_tuple

All NaturalHarmonic with index from 2 until max_natural_harmonic_index.

index_to_natural_harmonic(natural_harmonic_index)

Find natural harmonic with given partial index.


index_to_natural_harmonic(natural_harmonic_index)[source]

Find natural harmonic with given partial index.

Parameters:

natural_harmonic_index (int) – The partial index; e.g. 2 is the first overtone (an octave above the root), 3 the second overtone (octave plus fifth), etc.

Return type:

NaturalHarmonic

Example:

>>> from mutwo import music_parameters
>>> g_string = music_parameters.String(
...     0, music_parameters.WesternPitch('g', 3)
... )
>>> g_string.index_to_natural_harmonic(5)
NaturalHarmonic(index=5, tonality=True)
index: int
max_natural_harmonic_index: int = 6
property natural_harmonic_tuple: tuple[mutwo.music_parameters.instruments.general.NaturalHarmonic, ...]

All NaturalHarmonic with index from 2 until max_natural_harmonic_index.

tuning: Pitch
tuning_original: Optional[Pitch] = None
class StringInstrumentMixin(string_tuple)[source]

Bases: object

Mixin to model instrument with strings.

Parameters:

string_tuple (tuple[String, ...]) – All strings which the instrument has.

This class provides additional attributes and methods for an instrument with strings.

The class itself is not an Instrument, but only a mixin. In order to use it with an Instrument, you need to inherit from both and explicitly call ‘__init__’ of both super classes inside your ‘__init__’ method.

It’s recommended to simply use builtin ContinuousPitchedStringInstrument or DiscreetPitchedStringInstrument.

Harmonic pitches have no effect on the __contains__ method of an Instrument. This means the expression

pitch in instrument

ignores all pitches returned by the harmonic_pitch_tuple property. This is because it is assumed that the user needs an explicit additional test to check if a pitch can be played by harmonics (because often we may find ourselves in a situation where we don’t want a harmonic).

Public Data Attributes:

string_tuple

Public Methods:

harmonic_pitch_tuple

List all pitches which can be played with natural harmonics.

harmonic_pitch_ambitus

Get flageolet music_parameters.abc.PitchAmbitus.

get_harmonic_pitch_variant_tuple(pitch[, ...])

Find natural harmonic pitch variants (in all registers) of pitch

pitch_to_natural_harmonic_tuple(pitch[, ...])

Find all NaturalHarmonic which produces pitch.


get_harmonic_pitch_variant_tuple(pitch, period=None, tolerance=D(2))[source]

Find natural harmonic pitch variants (in all registers) of pitch

Parameters:
  • pitch (music_parameters.abc.Pitch) – The pitch which variants shall be found.

  • period (Optional[music_parameters.abc.PitchInterval]) – The repeating period (usually an octave). If the period is set to None the function will fallback to the objects method pitch_to_period(). Default to None.

  • tolerance (music_parameters.abc.PitchInterval) – Because harmonics are just tuned they may differ from tempered pitches. In order to still fetch harmonics the tolerance parameter can help. This is a music_parameters.abc.PitchInterval: if the difference is within the intervals range, it is still considered as equal and the harmonic is returned. Default to DirectPitchInterval with 2 cents.

Return type:

tuple[mutwo.music_parameters.abc.Pitch, …]

pitch_to_natural_harmonic_tuple(pitch, tolerance=D(2))[source]

Find all NaturalHarmonic which produces pitch.

Parameters:
  • pitch (music_parameters.abc.Pitch) – The pitch which shall be equal to the returned harmonics pitch.

  • tolerance (music_parameters.abc.PitchInterval) – Because harmonics are just tuned they may differ from tempered pitches. In order to still fetch harmonics the tolerance parameter can help. This is a music_parameters.abc.PitchInterval: if the difference is within the intervals range, it is still considered as equal and the harmonic is returned. Default to DirectPitchInterval with 2 cents.

Return type:

tuple[mutwo.music_parameters.instruments.general.NaturalHarmonic, …]

property harmonic_pitch_ambitus: PitchAmbitus

Get flageolet music_parameters.abc.PitchAmbitus.

property harmonic_pitch_tuple: tuple[mutwo.music_parameters.abc.Pitch, ...]

List all pitches which can be played with natural harmonics.

This tuple depends on max_natural_harmonic_index attribute of String.

string_tuple: tuple[mutwo.music_parameters.instruments.general.String, ...]
class UnpitchedInstrument(name, short_name=None)[source]

Bases: Instrument

Model a musical instruments without any clear pitches.

Example:

>>> from mutwo import music_parameters
>>> bass_drum = music_parameters.UnpitchedInstrument("bass drum", "bd.")

Public Data Attributes:

is_pitched

Return True if instrument is pitched, False otherwise.

Inherited from Instrument

short_name

is_pitched

Return True if instrument is pitched, False otherwise.

name

Public Methods:

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:
  • name (str) –

  • short_name (Optional[str]) –

property is_pitched: bool

Return True if instrument is pitched, False otherwise.

class ContinuousPitchedInstrument(pitch_ambitus, *args, **kwargs)[source]

Bases: PitchedInstrument

Model a musical instrument with continuous pitches (e.g. not fretted).

Parameters:
  • pitch_ambitus (music_parameters.abc.PitchAmbitus) – The pitch ambitus of the instrument.

  • name (str) – The name of the instrument.

  • short_name (Optional[str]) – The abbreviation of the instrument. If set to None it will be the same like name. Default to None.

  • pitch_count_range (ranges.Range) – Set how many simultaneous pitches the instrument can play. Default to ranges.Range(1, 2), which means that the instrument is monophonic.

  • transposition_pitch_interval (Optional[PitchInterval]) – Some instruments are written with a transposition (so sounding pitch and written pitch differs). This parameter can be used to set the transposition interval in case sounding and written differs. The transposition_pitch_interval is added to the sounding pitches in order to reach the written pitches. If set to None this will be set to DirectPitchInterval(0) which is no transposition. Default to None.

Example:

>>> from mutwo import music_parameters
>>> vl = music_parameters.ContinuousPitchedInstrument(
...     music_parameters.OctaveAmbitus(
...         music_parameters.WesternPitch('g', 3),
...         music_parameters.WesternPitch('e', 7),
...     ),
...     "violin",
...     "vl.",
... )

Public Data Attributes:

pitch_ambitus

Inherited from PitchedInstrument

pitch_count_range

transposition_pitch_interval

pitch_ambitus

is_pitched

Return True if instrument is pitched, False otherwise.

Inherited from Instrument

short_name

is_pitched

Return True if instrument is pitched, False otherwise.

name

Public Methods:

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from PitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


get_pitch_variant_tuple(pitch, period=None)[source]

Find all pitch variants (in all octaves) of the given pitch

Parameters:
  • pitch (Pitch) – The pitch which variants shall be found.

  • period (Optional[PitchInterval]) – The repeating period (usually an octave). If the period is set to None the function will fallback to them objects method PitchAmbitus.pitch_to_period(). Default to None.

Return type:

tuple[mutwo.music_parameters.abc.Pitch, …]

This is not necessarily the same as instrument.pitch_ambitus.get_pitch_variant_tuple(), because a mutwo.music_parameters.DiscreetPitchedInstrument may not be capable of playing a pitch even if the given pitch is within the ambitus of an instrument. It’s therefore recommended to use instrument.get_pitch_variant_tuple if one wants to find out in which octaves the given pitch is actually playable on the instrument.

property pitch_ambitus: PitchAmbitus
class DiscreetPitchedInstrument(pitch_tuple, *args, **kwargs)[source]

Bases: PitchedInstrument

Model a musical instrument with discreet pitches (e.g. fretted).

Parameters:
  • pitch_tuple (tuple[music_parameters.abc.Pitch, ...]) – A tuple of all playable pitches of the instrument.

  • name (str) – The name of the instrument.

  • short_name (Optional[str]) – The abbreviation of the instrument. If set to None it will be the same like name. Default to None.

  • pitch_count_range (ranges.Range) – Set how many simultaneous pitches the instrument can play. Default to ranges.Range(1, 2), which means that the instrument is monophonic.

  • transposition_pitch_interval (Optional[PitchInterval]) – Some instruments are written with a transposition (so sounding pitch and written pitch differs). This parameter can be used to set the transposition interval in case sounding and written differs. The transposition_pitch_interval is added to the sounding pitches in order to reach the written pitches. If set to None this will be set to DirectPitchInterval(0) which is no transposition. Default to None.

Example:

>>> from mutwo import music_parameters
>>> pentatonic_idiophone = music_parameters.DiscreetPitchedInstrument(
...     (
...         music_parameters.JustIntonationPitch('1/1'),
...         music_parameters.JustIntonationPitch('9/8'),
...         music_parameters.JustIntonationPitch('5/4'),
...         music_parameters.JustIntonationPitch('3/2'),
...         music_parameters.JustIntonationPitch('7/4'),
...     ),
...     "idiophone",
...     "id.",
... )

Public Data Attributes:

pitch_ambitus

pitch_tuple

Inherited from PitchedInstrument

pitch_count_range

transposition_pitch_interval

pitch_ambitus

is_pitched

Return True if instrument is pitched, False otherwise.

short_name

Inherited from Instrument

short_name

is_pitched

Return True if instrument is pitched, False otherwise.

name

Public Methods:

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from PitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


get_pitch_variant_tuple(pitch, period=None)[source]

Find all pitch variants (in all octaves) of the given pitch

Parameters:
  • pitch (Pitch) – The pitch which variants shall be found.

  • period (Optional[PitchInterval]) – The repeating period (usually an octave). If the period is set to None the function will fallback to them objects method PitchAmbitus.pitch_to_period(). Default to None.

Return type:

tuple[mutwo.music_parameters.abc.Pitch, …]

This is not necessarily the same as instrument.pitch_ambitus.get_pitch_variant_tuple(), because a mutwo.music_parameters.DiscreetPitchedInstrument may not be capable of playing a pitch even if the given pitch is within the ambitus of an instrument. It’s therefore recommended to use instrument.get_pitch_variant_tuple if one wants to find out in which octaves the given pitch is actually playable on the instrument.

property pitch_ambitus: PitchAmbitus
property pitch_tuple: tuple[mutwo.music_parameters.abc.Pitch, ...]
class ContinuousPitchedStringInstrument(*args, string_tuple, **kwargs)[source]

Bases: ContinuousPitchedInstrument, StringInstrumentMixin

Public Data Attributes:

Inherited from ContinuousPitchedInstrument

pitch_ambitus

Inherited from PitchedInstrument

pitch_count_range

transposition_pitch_interval

pitch_ambitus

is_pitched

Return True if instrument is pitched, False otherwise.

short_name

Inherited from Instrument

short_name

is_pitched

Return True if instrument is pitched, False otherwise.

name

Inherited from StringInstrumentMixin

string_tuple

Public Methods:

Inherited from ContinuousPitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from PitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.

Inherited from StringInstrumentMixin

harmonic_pitch_tuple

List all pitches which can be played with natural harmonics.

harmonic_pitch_ambitus

Get flageolet music_parameters.abc.PitchAmbitus.

get_harmonic_pitch_variant_tuple(pitch[, ...])

Find natural harmonic pitch variants (in all registers) of pitch

pitch_to_natural_harmonic_tuple(pitch[, ...])

Find all NaturalHarmonic which produces pitch.


Parameters:

string_tuple (tuple[String, ...]) –

class DiscreetPitchedStringInstrument(*args, string_tuple, **kwargs)[source]

Bases: DiscreetPitchedInstrument, StringInstrumentMixin

Public Data Attributes:

Inherited from DiscreetPitchedInstrument

pitch_ambitus

pitch_tuple

Inherited from PitchedInstrument

pitch_count_range

transposition_pitch_interval

pitch_ambitus

is_pitched

Return True if instrument is pitched, False otherwise.

short_name

Inherited from Instrument

short_name

is_pitched

Return True if instrument is pitched, False otherwise.

name

Inherited from StringInstrumentMixin

string_tuple

Public Methods:

Inherited from DiscreetPitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from PitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.

Inherited from StringInstrumentMixin

harmonic_pitch_tuple

List all pitches which can be played with natural harmonics.

harmonic_pitch_ambitus

Get flageolet music_parameters.abc.PitchAmbitus.

get_harmonic_pitch_variant_tuple(pitch[, ...])

Find natural harmonic pitch variants (in all registers) of pitch

pitch_to_natural_harmonic_tuple(pitch[, ...])

Find all NaturalHarmonic which produces pitch.


Parameters:

string_tuple (tuple[String, ...]) –

class OrchestrationMixin[source]

Bases: object

Helper base class from which adhoc created Orchestration object inherits.

This class has some methods which extend the functionality of Pythons builtin collections.namedtuple.

Public Methods:

get_subset(*instrument_name)

Return a sub-Orchestration of Orchestration.


get_subset(*instrument_name)[source]

Return a sub-Orchestration of Orchestration.

Parameters:

*instrument_name (str) – Name of the instrument which should be included in the subset.

This method doesn’t change the original Orchestration but creates a new object.

Example:

>>> from mutwo import music_parameters
>>> orch = music_parameters.Orchestration(
...   oboe0=music_parameters.Oboe(),
...   oboe1=music_parameters.Oboe(),
...   oboe2=music_parameters.Oboe(),
... )
>>> orch.get_subset('oboe0', 'oboe2')
Orchestration(oboe0=Oboe(name='oboe', short_name='ob.', pitch_count_range=Range[1, 2), transposition_pitch_interval=D(0)), oboe2=Oboe(name='oboe', short_name='ob.', pitch_count_range=Range[1, 2), transposition_pitch_interval=D(0)))
class CelticHarp(**kwargs)[source]

Bases: DiscreetPitchedInstrument

A typical beginners harp without any pedals.

Public Data Attributes:

Inherited from DiscreetPitchedInstrument

pitch_ambitus

pitch_tuple

Inherited from PitchedInstrument

pitch_count_range

transposition_pitch_interval

pitch_ambitus

is_pitched

Return True if instrument is pitched, False otherwise.

short_name

Inherited from Instrument

short_name

is_pitched

Return True if instrument is pitched, False otherwise.

name

Public Methods:

Inherited from DiscreetPitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from PitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


class Piccolo(**kwargs)[source]

Bases: ContinuousPitchedInstrument

Public Data Attributes:

Inherited from ContinuousPitchedInstrument

pitch_ambitus

Inherited from PitchedInstrument

pitch_count_range

transposition_pitch_interval

pitch_ambitus

is_pitched

Return True if instrument is pitched, False otherwise.

short_name

Inherited from Instrument

short_name

is_pitched

Return True if instrument is pitched, False otherwise.

name

Public Methods:

Inherited from ContinuousPitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from PitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


class Flute(**kwargs)[source]

Bases: ContinuousPitchedInstrument

Public Data Attributes:

Inherited from ContinuousPitchedInstrument

pitch_ambitus

Inherited from PitchedInstrument

pitch_count_range

transposition_pitch_interval

pitch_ambitus

is_pitched

Return True if instrument is pitched, False otherwise.

short_name

Inherited from Instrument

short_name

is_pitched

Return True if instrument is pitched, False otherwise.

name

Public Methods:

Inherited from ContinuousPitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from PitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


class Oboe(**kwargs)[source]

Bases: ContinuousPitchedInstrument

Public Data Attributes:

Inherited from ContinuousPitchedInstrument

pitch_ambitus

Inherited from PitchedInstrument

pitch_count_range

transposition_pitch_interval

pitch_ambitus

is_pitched

Return True if instrument is pitched, False otherwise.

short_name

Inherited from Instrument

short_name

is_pitched

Return True if instrument is pitched, False otherwise.

name

Public Methods:

Inherited from ContinuousPitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from PitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


class BfClarinet(**kwargs)[source]

Bases: ContinuousPitchedInstrument

Public Data Attributes:

Inherited from ContinuousPitchedInstrument

pitch_ambitus

Inherited from PitchedInstrument

pitch_count_range

transposition_pitch_interval

pitch_ambitus

is_pitched

Return True if instrument is pitched, False otherwise.

short_name

Inherited from Instrument

short_name

is_pitched

Return True if instrument is pitched, False otherwise.

name

Public Methods:

Inherited from ContinuousPitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from PitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


class EfClarinet(**kwargs)[source]

Bases: ContinuousPitchedInstrument

Public Data Attributes:

Inherited from ContinuousPitchedInstrument

pitch_ambitus

Inherited from PitchedInstrument

pitch_count_range

transposition_pitch_interval

pitch_ambitus

is_pitched

Return True if instrument is pitched, False otherwise.

short_name

Inherited from Instrument

short_name

is_pitched

Return True if instrument is pitched, False otherwise.

name

Public Methods:

Inherited from ContinuousPitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from PitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


class Bassoon(**kwargs)[source]

Bases: ContinuousPitchedInstrument

Public Data Attributes:

Inherited from ContinuousPitchedInstrument

pitch_ambitus

Inherited from PitchedInstrument

pitch_count_range

transposition_pitch_interval

pitch_ambitus

is_pitched

Return True if instrument is pitched, False otherwise.

short_name

Inherited from Instrument

short_name

is_pitched

Return True if instrument is pitched, False otherwise.

name

Public Methods:

Inherited from ContinuousPitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from PitchedInstrument

get_pitch_variant_tuple(pitch[, period])

Find all pitch variants (in all octaves) of the given pitch

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


class DirectLyric(xsampa)[source]

Bases: Lyric

Lyric which is directly initialised by its phonetic representation

Parameters:

xsampa (str) – The phonetic representation of the text.

In this class the written_representation is simply equal to xsampa.

Public Data Attributes:

xsampa

written_representation

Get text as it would be written in natural language

Inherited from Lyric

written_representation

Get text as it would be written in natural language

xsampa

Public Methods:

Inherited from Lyric

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


property written_representation: str

Get text as it would be written in natural language

property xsampa: str
class LanguageBasedLyric(written_representation, language_code=None)[source]

Bases: Lyric

Lyric based on a natural language.

Parameters:
  • written_representation (str) – The text.

  • language_code (Optional[str]) – The code for the language of the text. If this is None the constant mutwo.music_parameters.configurations.DEFAULT_LANGUAGE_CODE will be used. Default to None.

Public Data Attributes:

language_code_to_epitran_dict

language_code

written_representation

Get text as it would be written in natural language

xsampa

Inherited from Lyric

written_representation

Get text as it would be written in natural language

xsampa

Public Methods:

Inherited from Lyric

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


property language_code: str
language_code_to_epitran_dict: dict[str, epitran._epitran.Epitran] = {}
property written_representation: str

Get text as it would be written in natural language

property xsampa: str
class LanguageBasedSyllable(is_last_syllable, *args, **kwargs)[source]

Bases: Syllable, LanguageBasedLyric

Syllable based on a natural language.

Parameters:
  • is_last_syllable (bool) – True if it is the last syllable of a word and False if it isn’t the last syllable

  • written_representation (str) – The text.

  • language_code (Optional[str]) – The code for the language of the text. If this is None the constant mutwo.music_parameters.configurations.DEFAULT_LANGUAGE_CODE will be used. Default to None.

Warning:

It is a known bug that a split word (syllables) and the word itself will return different values for xsampa. For instance:

>>> LanguageBasedLyric('hallo').xsampa
'halo:'
>>> # And now splitted to syllables:
>>> LanguageBasedSyllable(False, 'hal').xsampa
'hA:l'
>>> LanguageBasedSyllable(True, 'lo').xsampa
'lo:'

Public Data Attributes:

Inherited from LanguageBasedLyric

language_code_to_epitran_dict

language_code

written_representation

Get text as it would be written in natural language

xsampa

Inherited from Lyric

written_representation

Get text as it would be written in natural language

xsampa

Public Methods:

Inherited from Lyric

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


class DirectPitchInterval(cents)[source]

Bases: PitchInterval

Simple interval class which gets directly assigned by its cents value

Parameters:

cents (float) – Defines how big or small the interval is (in cents).

Example:

>>> from mutwo import music_parameters
>>> rising_octave = music_parameters.DirectPitchInterval(1200)
>>> falling_minor_third = music_parameters.DirectPitchInterval(-300)

Public Data Attributes:

cents

Inherited from PitchInterval

cents

Inherited from SingleNumberParameter

direct_comparison_type_tuple

digit_to_round_to_count

Public Methods:

inverse()

Makes falling interval to rising and vice versa.

Inherited from PitchInterval

inverse()

Makes falling interval to rising and vice versa.

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


inverse()[source]

Makes falling interval to rising and vice versa.

Example:

>>> from mutwo import music_parameters
>>> music_parameters.DirectPitchInterval(700).inverse().cents
-700
Return type:

DirectPitchInterval

property cents: float
class WesternPitchInterval(interval_name_or_semitone_count='p1')[source]

Bases: PitchInterval

Model intervals by using European music theory based representations

Parameters:

interval_name_or_semitone_count (str | core_constants.Real) – Can be either an interval name (a string) or a number for semitones. When using an interval name is should have the form: QUALITY-IS_FALLING-TYPE, e.g. for having a rising perfect fourth (where ‘fourth’ is the type and ‘perfect’ the quality) you can write “p4”. For a falling perfect fourth it would be “p-4”. The interval names are equal to the specification used in the python library music21. Please also consult the specification of the quality abbreviations at mutwo.music_parameters.configurations.WESTERN_PITCH_INTERVAL_QUALITY_NAME_TO_ABBREVIATION_DICT and the specification of the is-interval-falling indicator mutwo.music_parameters.configurations.FALLING_WESTERN_PITCH_INTERVAL_INDICATOR. Both can be changed by the user. Default to ‘p1’.

This class is particularly useful in combination with mutwo.music_parameters.WesternPitch.

Disclaimer:

Although mutwo.music_parameters.WesternPitch does support microtones, WesternPitchInterval does not.

Example:

>>> from mutwo import music_parameters
>>> perfect_fifth = music_parameters.WesternPitchInterval('p5')
>>> falling_major_third = music_parameters.WesternPitchInterval('M-3')
>>> minor_third = music_parameters.WesternPitchInterval('m3')
>>> falling_octave = music_parameters.WesternPitchInterval(-12)
>>> augmented_octave = music_parameters.WesternPitchInterval('A8')
>>> very_diminished_sixth = music_parameters.WesternPitchInterval('dddd6')

Public Data Attributes:

is_interval_rising

Return True if the interval is upwards and False if it falls

interval_quality_tuple

Parsed the interval_quality abbreviation to their full names.

interval_type

The base interval type (e.g.

interval_quality

The abbreviation of its quality (e.g.

interval_type_base_type

interval_type_cent_deviation

Get cent deviation defined by the interval type.

interval_quality_cent_deviation

Get cent deviation defined by the interval quality.

diatonic_pitch_class_count

How many diatonic pitch classes have to be moved

name

Full interval name

is_perfect_interval

Return True if interval is perfect and otherwise False.

is_imperfect_interval

Return True if interval is imperfect and otherwise False.

cents

semitone_count

can_be_simplified

True if interval could be written in a simpler way, False otherwise.

Inherited from PitchInterval

cents

Inherited from SingleNumberParameter

direct_comparison_type_tuple

digit_to_round_to_count

Public Methods:

is_interval_type_perfect(interval_type)

is_interval_type_imperfect(interval_type)

inverse()

Makes falling interval to rising and vice versa.

Inherited from PitchInterval

inverse()

Makes falling interval to rising and vice versa.

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


inverse()[source]

Makes falling interval to rising and vice versa.

Example:

>>> from mutwo import music_parameters
>>> music_parameters.WesternPitchInterval('m3').inverse()
WesternPitchInterval('m-3')
Return type:

WesternPitchInterval

static is_interval_type_imperfect(interval_type)[source]
Parameters:

interval_type (str) –

Return type:

bool

static is_interval_type_perfect(interval_type)[source]
Parameters:

interval_type (str) –

Return type:

bool

property can_be_simplified: bool

True if interval could be written in a simpler way, False otherwise.

property cents: float
property diatonic_pitch_class_count: int

How many diatonic pitch classes have to be moved

property interval_quality: str

The abbreviation of its quality (e.g. augmented, perfect, …).

property interval_quality_cent_deviation: float

Get cent deviation defined by the interval quality.

property interval_quality_tuple: tuple[str, ...]

Parsed the interval_quality abbreviation to their full names.

property interval_type: str

The base interval type (e.g. octave, prime, second, …).

property interval_type_base_type: str
property interval_type_cent_deviation: float

Get cent deviation defined by the interval type.

property is_imperfect_interval: bool

Return True if interval is imperfect and otherwise False.

With ‘imperfect’ all intervals are included which can have the interval qualities ‘augmented’, ‘diminished’, ‘minor’ and ‘major’.

This excludes intervals as prime, fourth, … which have the ‘perfect’ quality.

property is_interval_rising: bool

Return True if the interval is upwards and False if it falls

property is_perfect_interval: bool

Return True if interval is perfect and otherwise False.

With ‘perfect’ all intervals are included which can have the interval qualities ‘augmented’, ‘diminished’ and ‘perfect’.

This excludes intervals as sixth, thirds, … which have ‘minor’ and ‘major’ qualities.

property name: str

Full interval name

property semitone_count: float
class DirectPitch(hertz, *args, **kwargs)[source]

Bases: Pitch

A simple pitch class that gets directly initialised by its frequency.

Parameters:

hertz (core_constants.Real) – The hertz of the DirectPitch object.

May be used when a converter class needs a pitch object, but there is no need or desire for a complex abstraction of the respective pitch (that classes like JustIntonationPitch or WesternPitch offer).

Example:

>>> from mutwo import music_parameters
>>> my_pitch = music_parameters.DirectPitch(440)

Public Data Attributes:

hertz

The frequency of the pitch.

Inherited from Pitch

Type

Pitch.Type hosts all types that are supported by the pitch parser Pitch.from_any().

midi_pitch_number

The midi pitch number (from 0 to 127) of the pitch.

hertz

Inherited from SingleNumberParameter

direct_comparison_type_tuple

digit_to_round_to_count

Public Methods:

add(pitch_interval)

Inherited from Pitch

hertz_to_cents(frequency0, frequency1)

Calculates the difference in cents between two frequencies.

ratio_to_cents(ratio)

Converts a frequency ratio to its respective cent value.

cents_to_ratio(cents)

Converts a cent value to its respective frequency ratio.

hertz_to_midi_pitch_number(frequency)

Converts a frequency in hertz to its respective midi pitch.

from_any(object)

Parse any object to Parameter.

add(pitch_interval)

subtract(pitch_interval)

get_pitch_interval(pitch_to_compare)

Get PitchInterval between itself and other pitch

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


add(pitch_interval)[source]
Parameters:

pitch_interval (PitchInterval) –

Return type:

DirectPitch

property hertz: float

The frequency of the pitch.

class JustIntonationPitch(ratio_or_exponent_tuple='1/1', concert_pitch=None, *args, **kwargs)[source]

Bases: Pitch, PitchInterval

Pitch that is defined by a frequency ratio and a reference pitch.

Parameters:
  • ratio_or_exponent_tuple (Union[str, fractions.Fraction, Iterable[int]]) – The frequency ratio of the JustIntonationPitch. This can either be a string that indicates the frequency ratio (for instance: “1/1”, “3/2”, “9/2”, etc.), or a fractions.Fraction object that indicates the frequency ratio (for instance: fractions.Fraction(3, 2), fractions.Fraction(7, 4)) or a sequence of integer that represents the :attr:exponent_tuple of the respective prime numbers of the decomposed frequency ratio. The prime numbers are rising and start with 2. Therefore the tuple (2, 0, -1) would return the frequency ratio 4/5 because (2 ** 2) * (3 ** 0) * (5 ** -1) = 4/5.

  • concert_pitch (ConcertPitch) – The reference pitch of the tuning system (the pitch for a frequency ratio of 1/1). Can either be another Pitch object or any number to indicate a particular frequency in Hertz.

The resulting frequency is calculated by multiplying the frequency ratio with the respective reference pitch.

Example:

>>> from mutwo import music_parameters
>>> # 3 different variations of initialising the same pitch
>>> music_parameters.JustIntonationPitch('3/2')
JustIntonationPitch('3/2')
>>> import fractions
>>> music_parameters.JustIntonationPitch(fractions.Fraction(3, 2))
JustIntonationPitch('3/2')
>>> music_parameters.JustIntonationPitch((-1, 1))
JustIntonationPitch('3/2')
>>> # using a different concert pitch
>>> music_parameters.JustIntonationPitch('7/5', concert_pitch=432)
JustIntonationPitch('7/5')

Public Data Attributes:

exponent_tuple

prime_tuple

Return ascending list of primes, until the highest contained Prime.

occupied_primes

Return all occurring prime numbers of a JustIntonationPitch object.

concert_pitch

hertz

ratio

Return the JustIntonationPitch transformed to a Ratio.

numerator

Return the numerator of a JustIntonationPitch - object.

denominator

Return the denominator of JustIntonationPitch.

cents

factorised

Return factorised / decomposed version of itsef.

factorised_numerator_and_denominator

octave

helmholtz_ellis_just_intonation_notation_commas

Commas of JustIntonationPitch.

closest_pythagorean_interval

cent_deviation_from_closest_western_pitch_class

blueprint

tonality

Return the tonality (bool) of a JustIntonationPitch - object.

harmonic

Return the nth - harmonic / subharmonic the pitch may represent.

primes_for_numerator_and_denominator

harmonicity_wilson

harmonicity_vogel

harmonicity_euler

Return the 'gradus suavitatis' of euler.

harmonicity_barlow

Calculate the barlow-harmonicity of an interval.

harmonicity_simplified_barlow

Calculate a simplified barlow-harmonicity of an interval.

harmonicity_tenney

Calculate Tenneys harmonic distance of an interval

Inherited from Pitch

Type

Pitch.Type hosts all types that are supported by the pitch parser Pitch.from_any().

midi_pitch_number

The midi pitch number (from 0 to 127) of the pitch.

hertz

Inherited from PitchInterval

cents

Inherited from SingleNumberParameter

direct_comparison_type_tuple

digit_to_round_to_count

Public Methods:

get_closest_pythagorean_pitch_name([reference])

get_pitch_interval(pitch_to_compare)

Get PitchInterval between itself and other pitch

register(octave)

Move JustIntonationPitch to the given octave.

move_to_closest_register(reference)

normalize([prime])

Normalize JustIntonationPitch.

inverse([axis])

Inverse current pitch on given axis.

add(pitch_interval)

Add JustIntonationPitch to current pitch.

subtract(pitch_interval)

Subtract JustIntonationPitch from current pitch.

intersection(other[, strict])

Make intersection with other JustIntonationPitch.

Inherited from Pitch

hertz_to_cents(frequency0, frequency1)

Calculates the difference in cents between two frequencies.

ratio_to_cents(ratio)

Converts a frequency ratio to its respective cent value.

cents_to_ratio(cents)

Converts a cent value to its respective frequency ratio.

hertz_to_midi_pitch_number(frequency)

Converts a frequency in hertz to its respective midi pitch.

from_any(object)

Parse any object to Parameter.

add(pitch_interval)

subtract(pitch_interval)

get_pitch_interval(pitch_to_compare)

Get PitchInterval between itself and other pitch

value_name

Inherited from PitchInterval

inverse()

Makes falling interval to rising and vice versa.

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


add(pitch_interval)[source]

Add JustIntonationPitch to current pitch.

Parameters:
Return type:

JustIntonationPitch

Example:

>>> from mutwo import music_parameters
>>> p = music_parameters.JustIntonationPitch('3/2')
>>> p.add(music_parameters.JustIntonationPitch('3/2'))
JustIntonationPitch('9/4')
>>> p
JustIntonationPitch('9/4')
get_closest_pythagorean_pitch_name(reference='a')[source]
Parameters:

reference (str) –

Return type:

str

get_pitch_interval(pitch_to_compare)[source]

Get PitchInterval between itself and other pitch

Parameters:

pitch_to_compare (Pitch) – The pitch which shall be compared to the active pitch.

Returns:

PitchInterval between

Return type:

PitchInterval

Example:

>>> from mutwo import music_parameters
>>> a4 = music_parameters.DirectPitch(hertz=440)
>>> a5 = music_parameters.DirectPitch(hertz=880)
>>> pitch_interval = a4.get_pitch_interval(a5)
intersection(other, strict=False)[source]

Make intersection with other JustIntonationPitch.

Parameters:
  • other (JustIntonationPitch) – The JustIntonationPitch to build the intersection with.

  • strict (bool) – If set to True only exponent_tuple are included into the intersection if their value is equal. If set to False the method will also include exponent_tuple if both pitches own them on the same axis but with different values (the method will take the smaller exponent).

Return type:

JustIntonationPitch

Example:

>>> from mutwo import music_parameters
>>> p0 = music_parameters.JustIntonationPitch('5/3')
>>> p0.intersection(music_parameters.JustIntonationPitch('7/6'))
JustIntonationPitch('1/3')
>>> p0
JustIntonationPitch('1/3')
>>> p1 = music_parameters.JustIntonationPitch('9/7')
>>> p1.intersection(music_parameters.JustIntonationPitch('3/2'))
JustIntonationPitch('3/1')
>>> p1
JustIntonationPitch('3/1')
>>> p2 = music_parameters.JustIntonationPitch('9/7')
>>> p2.intersection(music_parameters.JustIntonationPitch('3/2'), strict=True)
JustIntonationPitch('1/1')
>>> p2
JustIntonationPitch('1/1')
inverse(axis=None)[source]

Inverse current pitch on given axis.

Parameters:

axis (JustIntonationPitch, optional) – The JustIntonationPitch from which the pitch shall be inversed.

Return type:

JustIntonationPitch

Example:

>>> from mutwo import music_parameters
>>> p = music_parameters.JustIntonationPitch('3/2')
>>> p.inverse()
JustIntonationPitch('2/3')
>>> p
JustIntonationPitch('2/3')
move_to_closest_register(reference)[source]
Parameters:

reference (JustIntonationPitch) –

Return type:

JustIntonationPitch

normalize(prime=2)[source]

Normalize JustIntonationPitch.

Parameters:

prime (int) – The normalization period (2 for octave, 3 for twelfth, …). Default to 2.

Return type:

JustIntonationPitch

Example:

>>> from mutwo import music_parameters
>>> p = music_parameters.JustIntonationPitch('12/2')
>>> p.normalize()
JustIntonationPitch('3/2')
>>> p
JustIntonationPitch('3/2')
register(octave)[source]

Move JustIntonationPitch to the given octave.

Parameters:

octave (int) – 0 for the octave from 1/1 to 2/1, negative values for octaves below 1/1 and positive values for octaves above 2/1.

Return type:

JustIntonationPitch

Example:

>>> from mutwo import music_parameters
>>> p = music_parameters.JustIntonationPitch('3/2')
>>> p.register(1)
JustIntonationPitch('3/1')
>>> p
JustIntonationPitch('3/1')
>>> p.register(-1)
JustIntonationPitch('3/4')
>>> p
JustIntonationPitch('3/4')
>>> p.register(0)
JustIntonationPitch('3/2')
>>> p
JustIntonationPitch('3/2')
subtract(pitch_interval)[source]

Subtract JustIntonationPitch from current pitch.

Parameters:
Return type:

JustIntonationPitch

Example:

>>> from mutwo import music_parameters
>>> p = music_parameters.JustIntonationPitch('9/4')
>>> p.subtract(music_parameters.JustIntonationPitch('3/2'))
JustIntonationPitch('3/2')
>>> p
JustIntonationPitch('3/2')
property blueprint: tuple[tuple[int, ...], ...]
property cent_deviation_from_closest_western_pitch_class: float
property cents: float
property closest_pythagorean_interval: JustIntonationPitch
property concert_pitch: Pitch
property denominator: int

Return the denominator of JustIntonationPitch.

Example:

>>> just_intonation_pitch0 = JustIntonationPitch((0, 1,))
>>> just_intonation_pitch0.denominator
1
property exponent_tuple: tuple
property factorised: tuple

Return factorised / decomposed version of itsef.

Example:

>>> just_intonation_pitch0 = JustIntonationPitch((-2, 0, 1))
>>> just_intonation_pitch0.factorised
(2, 2, 5)
>>> just_intonation_pitch1 = JustIntonationPitch("7/6")
>>> just_intonation_pitch1.factorised
(2, 3, 7)
property factorised_numerator_and_denominator: tuple
property harmonic: int

Return the nth - harmonic / subharmonic the pitch may represent.

Returns:

May be positive for harmonic and negative for subharmonic pitches. If the return - value is 0, the interval may occur neither between the first harmonic and any other pitch of the harmonic scale nor between the first subharmonic in the and any other pitch of the subharmonic scale.

Example:

>>> just_intonation_pitch0 = JustIntonationPitch((-1, 1))
>>> just_intonation_pitch0.ratio
Fraction(3, 2)
>>> just_intonation_pitch0.harmonic
3
>>> just_intonation_pitch1 = JustIntonationPitch((1, -1))
>>> just_intonation_pitch1.harmonic
-3
property harmonicity_barlow: float

Calculate the barlow-harmonicity of an interval.

This implementation follows Clarence Barlows definition, given in ‘The Ratio Book’ (1992).

A higher number means a more harmonic interval / a less complex harmony.

barlow(1/1) is definied as infinite.

Example:

>>> just_intonation_pitch0 = JustIntonationPitch((-1, 1))
>>> just_intonation_pitch1 = JustIntonationPitch()
>>> just_intonation_pitch2 = JustIntonationPitch((-2, 0, 1))
>>> just_intonation_pitch3 = JustIntonationPitch((-3, 0, -1))
>>> just_intonation_pitch0.harmonicity_barlow
0.27272727272727276
>>> just_intonation_pitch1.harmonicity_barlow # 1/1 is infinite harmonic
inf
>>> just_intonation_pitch2.harmonicity_barlow
0.11904761904761904
>>> just_intonation_pitch3.harmonicity_barlow
-0.10638297872340426
property harmonicity_euler: int

Return the ‘gradus suavitatis’ of euler.

A higher number means a less consonant interval / a more complicated harmony. euler(1/1) is definied as 1.

Example:

>>> just_intonation_pitch0 = JustIntonationPitch((-1, 1))
>>> just_intonation_pitch1 = JustIntonationPitch()
>>> just_intonation_pitch2 = JustIntonationPitch((-2, 0, 1))
>>> just_intonation_pitch3 = JustIntonationPitch((-3, 0, -1))
>>> just_intonation_pitch0.harmonicity_euler
4
>>> just_intonation_pitch1.harmonicity_euler
1
>>> just_intonation_pitch2.harmonicity_euler
7
>>> just_intonation_pitch3.harmonicity_euler
8
property harmonicity_simplified_barlow: float

Calculate a simplified barlow-harmonicity of an interval.

This implementation follows Clarence Barlows definition, given in ‘The Ratio Book’ (1992), with the difference that only positive numbers are returned and that (1/1) is defined as 1 instead of infinite.

>>> just_intonation_pitch0 = JustIntonationPitch((-1, 1))
>>> just_intonation_pitch1 = JustIntonationPitch()
>>> just_intonation_pitch2 = JustIntonationPitch((-2, 0, 1))
>>> just_intonation_pitch3 = JustIntonationPitch((-3, 0, -1))
>>> just_intonation_pitch0.harmonicity_simplified_barlow
0.27272727272727276
>>> just_intonation_pitch1.harmonicity_simplified_barlow # 1/1 is not infinite but 1
1
>>> just_intonation_pitch2.harmonicity_simplified_barlow
0.11904761904761904
>>> just_intonation_pitch3.harmonicity_simplified_barlow # positive return value
0.10638297872340426
property harmonicity_tenney: float

Calculate Tenneys harmonic distance of an interval

A higher number means a more consonant interval / a less complicated harmony.

tenney(1/1) is definied as 0.

>>> just_intonation_pitch0 = JustIntonationPitch((0, 1,))
>>> just_intonation_pitch1 = JustIntonationPitch()
>>> just_intonation_pitch2 = JustIntonationPitch((0, 0, 1,))
>>> just_intonation_pitch3 = JustIntonationPitch((0, 0, -1,))
>>> just_intonation_pitch0.harmonicity_tenney
1.5849625007211563
>>> just_intonation_pitch1.harmonicity_tenney
0.0
>>> just_intonation_pitch2.harmonicity_tenney
2.321928094887362
>>> just_intonation_pitch3.harmonicity_tenney
2.321928094887362
property harmonicity_vogel: int
property harmonicity_wilson: int
property helmholtz_ellis_just_intonation_notation_commas: CommaCompound

Commas of JustIntonationPitch.

property hertz: float
property numerator: int

Return the numerator of a JustIntonationPitch - object.

Example:

>>> just_intonation_pitch0 = JustIntonationPitch((0, -1,))
>>> just_intonation_pitch0.numerator
1
property occupied_primes: tuple

Return all occurring prime numbers of a JustIntonationPitch object.

property octave: int
property prime_tuple: tuple

Return ascending list of primes, until the highest contained Prime.

Example:

>>> just_intonation_pitch0 = JustIntonationPitch((0, 1, 2))
>>> just_intonation_pitch0.prime_tuple
(2, 3, 5)
>>> just_intonation_pitch1 = JustIntonationPitch((0, -1, 0, 0, 1), 1)
>>> just_intonation_pitch1.prime_tuple
(2, 3, 5, 7, 11)
property primes_for_numerator_and_denominator: tuple
property ratio: Fraction

Return the JustIntonationPitch transformed to a Ratio.

Example:

>>> just_intonation_pitch = JustIntonationPitch((0, 0, 1,))
>>> just_intonation_pitch.ratio
Fraction(5, 1)
>>> just_intonation_pitch = JustIntonationPitch("3/2")
>>> just_intonation_pitch.ratio
Fraction(3, 2)
property tonality: bool

Return the tonality (bool) of a JustIntonationPitch - object.

The tonality of a JustIntonationPitch - may be True (otonality) if the exponent of the highest occurring prime number is a positive number and False if the exponent is a negative number (utonality).

Example:

>>> from mutwo import music_parameters
>>> just_intonation_pitch0 = music_parameters.JustIntonationPitch((-2, 1))
>>> just_intonation_pitch0.tonality
True
>>> just_intonation_pitch1 = music_parameters.JustIntonationPitch((-2, -1))
>>> just_intonation_pitch1.tonality
False
>>> just_intonation_pitch2 = music_parameters.JustIntonationPitch([])
>>> just_intonation_pitch2.tonality
True
class Partial(index, tonality=True)[source]

Bases: object

Abstract representation of a harmonic spectrum partial.

Parameters:
  • index (int) – The number of the partial (starting with 1 for the root note).

  • tonality (bool) – True for overtone and False for a (theoretical) undertone. Default to True.

Example:

>>> from mutwo import music_parameters
>>> strong_clarinet_partial_tuple = (
...     music_parameters.Partial(1),
...     music_parameters.Partial(3),
...     music_parameters.Partial(5),
...     music_parameters.Partial(7),
... )

Public Data Attributes:

tonality

index

Public Methods:

interval


index: int
property interval: JustIntonationPitch
tonality: bool = True
class EqualDividedOctavePitch(n_pitch_classes_per_octave, pitch_class, octave, concert_pitch_pitch_class, concert_pitch_octave, concert_pitch=None, *args, **kwargs)[source]

Bases: Pitch

Pitch that is tuned to an Equal divided octave tuning system.

Parameters:
  • n_pitch_classes_per_octave (int) – how many pitch classes in each octave occur (for instance 12 for a chromatic system, 24 for quartertones, etc.)

  • pitch_class (core_constants.Real) – The pitch class of the new EqualDividedOctavePitch object.

  • octave (int) – The octave of the new EqualDividedOctavePitch object (where 0 is the middle octave, 1 is one octave higher and -1 is one octave lower).

  • concert_pitch_pitch_class (core_constants.Real) – The pitch class of the reference pitch (for instance 9 in a chromatic 12 tone system where a should be the reference pitch).

  • concert_pitch_octave (int) – The octave of the reference pitch.

  • concert_pitch (ConcertPitch) – The frequency of the reference pitch (for instance 440 for a).

>>> from mutwo import music_parameters
>>> # making a middle `a`
>>> pitch = music_parameters.EqualDividedOctavePitch(12, 9, 4, 9, 4, 440)

Public Data Attributes:

n_pitch_classes_per_octave

Defines in how many different pitch classes one octave get divided.

concert_pitch

The referential concert pitch for the respective pitch object.

concert_pitch_pitch_class

The pitch class of the referential concert pitch.

pitch_class

The pitch class of the pitch.

step_factor

The factor with which to multiply a frequency to reach the next pitch.

n_cents_per_step

This property describes how many cents are between two adjacent pitches.

hertz

Inherited from Pitch

Type

Pitch.Type hosts all types that are supported by the pitch parser Pitch.from_any().

midi_pitch_number

The midi pitch number (from 0 to 127) of the pitch.

hertz

Inherited from SingleNumberParameter

direct_comparison_type_tuple

digit_to_round_to_count

Public Methods:

add(pitch_interval)

Transposes the EqualDividedOctavePitch by n_pitch_classes_difference.

subtract(pitch_interval)

Transposes the EqualDividedOctavePitch by n_pitch_classes_difference.

Inherited from Pitch

hertz_to_cents(frequency0, frequency1)

Calculates the difference in cents between two frequencies.

ratio_to_cents(ratio)

Converts a frequency ratio to its respective cent value.

cents_to_ratio(cents)

Converts a cent value to its respective frequency ratio.

hertz_to_midi_pitch_number(frequency)

Converts a frequency in hertz to its respective midi pitch.

from_any(object)

Parse any object to Parameter.

add(pitch_interval)

subtract(pitch_interval)

get_pitch_interval(pitch_to_compare)

Get PitchInterval between itself and other pitch

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


add(pitch_interval)[source]

Transposes the EqualDividedOctavePitch by n_pitch_classes_difference.

Parameters:

pitch_interval (mutwo.music_parameters.abc.PitchInterval | float | fractions.Fraction | int | quicktions.Fraction) –

Return type:

EqualDividedOctavePitch

subtract(pitch_interval)[source]

Transposes the EqualDividedOctavePitch by n_pitch_classes_difference.

Parameters:

pitch_interval (mutwo.music_parameters.abc.PitchInterval | float | fractions.Fraction | int | quicktions.Fraction) –

Return type:

EqualDividedOctavePitch

property concert_pitch: Pitch

The referential concert pitch for the respective pitch object.

property concert_pitch_pitch_class: float | fractions.Fraction | int | quicktions.Fraction

The pitch class of the referential concert pitch.

property hertz: float
property n_cents_per_step: float

This property describes how many cents are between two adjacent pitches.

property n_pitch_classes_per_octave: int

Defines in how many different pitch classes one octave get divided.

property pitch_class: float | fractions.Fraction | int | quicktions.Fraction

The pitch class of the pitch.

property step_factor

The factor with which to multiply a frequency to reach the next pitch.

class WesternPitch(pitch_class_or_pitch_class_name=0, octave=4, concert_pitch_pitch_class=None, concert_pitch_octave=None, concert_pitch=None, *args, **kwargs)[source]

Bases: EqualDividedOctavePitch

Pitch with a traditional Western nomenclature.

Parameters:
  • pitch_class_or_pitch_class_name (PitchClassOrPitchClassName) – Name or number of the pitch class of the new WesternPitch object. The nomenclature is English (c, d, e, f, g, a, b). It uses an equal divided octave system in 12 chromatic steps. Accidentals are indicated by (s = sharp) and (f = flat). Further microtonal accidentals are supported (see mutwo.music_parameters.constants.ACCIDENTAL_NAME_TO_PITCH_CLASS_MODIFICATION_DICT for all supported accidentals).

  • octave (int) – The octave of the new WesternPitch object. Indications for the specific octave follow the MIDI Standard where 4 is defined as one line.

  • concert_pitch_pitch_class (core_constants.Real) –

  • concert_pitch_octave (int) –

  • concert_pitch (ConcertPitch) –

Example:

>>> from mutwo import music_parameters
>>> music_parameters.WesternPitch('cs', 4)  # c-sharp 4
WesternPitch('cs', 4)
>>> music_parameters.WesternPitch('aqs', 2)  # a-quarter-sharp 2
WesternPitch('aqs', 2)

Public Data Attributes:

name

The name of the pitch in Western nomenclature.

pitch_class_name

The name of the pitch class in Western nomenclature.

pitch_class

The pitch class of the pitch.

diatonic_pitch_class_name

Only get the diatonic part of the pitch name

accidental_name

Only get accidental part of pitch name

is_microtonal

Return True if accidental isn't on chromatic grid.

enharmonic_pitch_tuple

Return pitches with equal frequency but different name.

Inherited from EqualDividedOctavePitch

n_pitch_classes_per_octave

Defines in how many different pitch classes one octave get divided.

concert_pitch

The referential concert pitch for the respective pitch object.

concert_pitch_pitch_class

The pitch class of the referential concert pitch.

pitch_class

The pitch class of the pitch.

step_factor

The factor with which to multiply a frequency to reach the next pitch.

n_cents_per_step

This property describes how many cents are between two adjacent pitches.

hertz

Inherited from Pitch

Type

Pitch.Type hosts all types that are supported by the pitch parser Pitch.from_any().

midi_pitch_number

The midi pitch number (from 0 to 127) of the pitch.

hertz

Inherited from SingleNumberParameter

direct_comparison_type_tuple

digit_to_round_to_count

Public Methods:

from_midi_pitch_number(midi_pitch_number)

add(pitch_interval)

Transposes the EqualDividedOctavePitch by n_pitch_classes_difference.

subtract(pitch_interval)

Transposes the EqualDividedOctavePitch by n_pitch_classes_difference.

get_pitch_interval(pitch_to_compare)

Get PitchInterval between itself and other pitch

round_to([allowed_division_sequence])

Round to closest accidental (helpful to avoid microtones).

Inherited from EqualDividedOctavePitch

add(pitch_interval)

Transposes the EqualDividedOctavePitch by n_pitch_classes_difference.

subtract(pitch_interval)

Transposes the EqualDividedOctavePitch by n_pitch_classes_difference.

Inherited from Pitch

hertz_to_cents(frequency0, frequency1)

Calculates the difference in cents between two frequencies.

ratio_to_cents(ratio)

Converts a frequency ratio to its respective cent value.

cents_to_ratio(cents)

Converts a cent value to its respective frequency ratio.

hertz_to_midi_pitch_number(frequency)

Converts a frequency in hertz to its respective midi pitch.

from_any(object)

Parse any object to Parameter.

add(pitch_interval)

subtract(pitch_interval)

get_pitch_interval(pitch_to_compare)

Get PitchInterval between itself and other pitch

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


add(pitch_interval)[source]

Transposes the EqualDividedOctavePitch by n_pitch_classes_difference.

Parameters:

pitch_interval (str | mutwo.music_parameters.abc.PitchInterval | float | fractions.Fraction | int | quicktions.Fraction) –

Return type:

WesternPitch

classmethod from_midi_pitch_number(midi_pitch_number)[source]
Parameters:

midi_pitch_number (float) –

Return type:

WesternPitch

get_pitch_interval(pitch_to_compare)[source]

Get PitchInterval between itself and other pitch

Parameters:

pitch_to_compare (Pitch) – The pitch which shall be compared to the active pitch.

Returns:

PitchInterval between

Return type:

PitchInterval

Example:

>>> from mutwo import music_parameters
>>> a4 = music_parameters.DirectPitch(hertz=440)
>>> a5 = music_parameters.DirectPitch(hertz=880)
>>> pitch_interval = a4.get_pitch_interval(a5)
round_to(allowed_division_sequence=(Fraction(1, 1),))[source]

Round to closest accidental (helpful to avoid microtones).

param allowed_division_sequence: Only accidentals are allowed which

pitch class modification are dividable by any of the provided numbers. So for instance if only chromatic pitches should be allowed this should be [fractions.Fraction(1, 1)]. But if both chromatic and quartertone pitches are allowed this must be [fractions.Fraction(1, 1), fractions.Fraction(1, 2)]. Default to (fractions.Fraction(1, 1),) (only chromatic pitches are allowed).

type allowed_division_sequence: typing.Sequence[fractions.Fraction]

Parameters:

allowed_division_sequence (Sequence[Fraction]) –

Return type:

WesternPitch

subtract(pitch_interval)[source]

Transposes the EqualDividedOctavePitch by n_pitch_classes_difference.

Parameters:

pitch_interval (str | mutwo.music_parameters.abc.PitchInterval | float | fractions.Fraction | int | quicktions.Fraction) –

Return type:

WesternPitch

property accidental_name: str

Only get accidental part of pitch name

property diatonic_pitch_class_name: str

Only get the diatonic part of the pitch name

property enharmonic_pitch_tuple: tuple[mutwo.music_parameters.pitches.WesternPitch.WesternPitch, ...]

Return pitches with equal frequency but different name.

Disclaimer:

This doesn’t work in some corner cases yet (e.g. it won’t find “css” for “eff”)

property is_microtonal: bool

Return True if accidental isn’t on chromatic grid.

property name: str

The name of the pitch in Western nomenclature.

property pitch_class: float | fractions.Fraction | int | quicktions.Fraction

The pitch class of the pitch.

property pitch_class_name: str

The name of the pitch class in Western nomenclature.

Mutwo uses the English nomenclature for pitch class names:

(c, d, e, f, g, a, b)

class MidiPitch(midi_pitch_number, *args, **kwargs)[source]

Bases: Pitch

Pitch that is defined by its midi pitch number.

Parameters:

midi_pitch_number (float) – The midi pitch number of the pitch. Floating point numbers are possible for microtonal deviations from the chromatic scale.

Example:

>>> from mutwo import music_parameters
>>> middle_c = music_parameters.MidiPitch(60)
>>> middle_c_quarter_tone_high = music_parameters.MidiPitch(60.5)

Public Data Attributes:

hertz

midi_pitch_number

The midi pitch number (from 0 to 127) of the pitch.

Inherited from Pitch

Type

Pitch.Type hosts all types that are supported by the pitch parser Pitch.from_any().

midi_pitch_number

The midi pitch number (from 0 to 127) of the pitch.

hertz

Inherited from SingleNumberParameter

direct_comparison_type_tuple

digit_to_round_to_count

Public Methods:

add(pitch_interval)

Inherited from Pitch

hertz_to_cents(frequency0, frequency1)

Calculates the difference in cents between two frequencies.

ratio_to_cents(ratio)

Converts a frequency ratio to its respective cent value.

cents_to_ratio(cents)

Converts a cent value to its respective frequency ratio.

hertz_to_midi_pitch_number(frequency)

Converts a frequency in hertz to its respective midi pitch.

from_any(object)

Parse any object to Parameter.

add(pitch_interval)

subtract(pitch_interval)

get_pitch_interval(pitch_to_compare)

Get PitchInterval between itself and other pitch

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


add(pitch_interval)[source]
Parameters:

pitch_interval (PitchInterval) –

Return type:

MidiPitch

property hertz: float
property midi_pitch_number: float

The midi pitch number (from 0 to 127) of the pitch.

class CommonHarmonic(partial_tuple, ratio_or_exponent_tuple='1/1', concert_pitch=None, *args, **kwargs)[source]

Bases: JustIntonationPitch

JustIntonationPitch which is the common harmonic between two or more other pitches.

Parameters:

Public Data Attributes:

Inherited from JustIntonationPitch

exponent_tuple

prime_tuple

Return ascending list of primes, until the highest contained Prime.

occupied_primes

Return all occurring prime numbers of a JustIntonationPitch object.

concert_pitch

hertz

ratio

Return the JustIntonationPitch transformed to a Ratio.

numerator

Return the numerator of a JustIntonationPitch - object.

denominator

Return the denominator of JustIntonationPitch.

cents

factorised

Return factorised / decomposed version of itsef.

factorised_numerator_and_denominator

octave

helmholtz_ellis_just_intonation_notation_commas

Commas of JustIntonationPitch.

closest_pythagorean_interval

cent_deviation_from_closest_western_pitch_class

blueprint

tonality

Return the tonality (bool) of a JustIntonationPitch - object.

harmonic

Return the nth - harmonic / subharmonic the pitch may represent.

primes_for_numerator_and_denominator

harmonicity_wilson

harmonicity_vogel

harmonicity_euler

Return the 'gradus suavitatis' of euler.

harmonicity_barlow

Calculate the barlow-harmonicity of an interval.

harmonicity_simplified_barlow

Calculate a simplified barlow-harmonicity of an interval.

harmonicity_tenney

Calculate Tenneys harmonic distance of an interval

Inherited from Pitch

Type

Pitch.Type hosts all types that are supported by the pitch parser Pitch.from_any().

midi_pitch_number

The midi pitch number (from 0 to 127) of the pitch.

hertz

Inherited from PitchInterval

cents

Inherited from SingleNumberParameter

direct_comparison_type_tuple

digit_to_round_to_count

Public Methods:

Inherited from JustIntonationPitch

get_closest_pythagorean_pitch_name([reference])

get_pitch_interval(pitch_to_compare)

Get PitchInterval between itself and other pitch

register(octave)

Move JustIntonationPitch to the given octave.

move_to_closest_register(reference)

normalize([prime])

Normalize JustIntonationPitch.

inverse([axis])

Inverse current pitch on given axis.

add(pitch_interval)

Add JustIntonationPitch to current pitch.

subtract(pitch_interval)

Subtract JustIntonationPitch from current pitch.

intersection(other[, strict])

Make intersection with other JustIntonationPitch.

Inherited from Pitch

hertz_to_cents(frequency0, frequency1)

Calculates the difference in cents between two frequencies.

ratio_to_cents(ratio)

Converts a frequency ratio to its respective cent value.

cents_to_ratio(cents)

Converts a cent value to its respective frequency ratio.

hertz_to_midi_pitch_number(frequency)

Converts a frequency in hertz to its respective midi pitch.

from_any(object)

Parse any object to Parameter.

add(pitch_interval)

subtract(pitch_interval)

get_pitch_interval(pitch_to_compare)

Get PitchInterval between itself and other pitch

value_name

Inherited from PitchInterval

inverse()

Makes falling interval to rising and vice versa.

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


class ScalePitch(scale_degree=0, octave=0, scale=None, *args, **kwargs)[source]

Bases: Pitch

Pitch that is defined by its scale degree, octave and reference scale.

Parameters:
  • scale_degree (int) – The scale degree of the pitch, starting from 0. For instance in a C major scale, the scale degree of 0 corresponds to the pitch “c”, the scale degree 2 to the pitch “e”. Default to 0.

  • octave (int) – The octave of the pitch. Default to 0.

  • scale (music_parameters.Scale) – The scale to which scale degree and octave refer to. If set to None the default scale is used (mutwo.music_parameters.configurations.DEFAULT_SCALE). Default to None.

Example:

>>> from mutwo import music_parameters
>>> p = music_parameters.ScalePitch(scale_degree=1, octave=-1)

Public Data Attributes:

scale_position

scale_pitch

hertz

Inherited from Pitch

Type

Pitch.Type hosts all types that are supported by the pitch parser Pitch.from_any().

midi_pitch_number

The midi pitch number (from 0 to 127) of the pitch.

hertz

Inherited from SingleNumberParameter

direct_comparison_type_tuple

digit_to_round_to_count

Public Methods:

add(pitch_interval)

Inherited from Pitch

hertz_to_cents(frequency0, frequency1)

Calculates the difference in cents between two frequencies.

ratio_to_cents(ratio)

Converts a frequency ratio to its respective cent value.

cents_to_ratio(cents)

Converts a cent value to its respective frequency ratio.

hertz_to_midi_pitch_number(frequency)

Converts a frequency in hertz to its respective midi pitch.

from_any(object)

Parse any object to Parameter.

add(pitch_interval)

subtract(pitch_interval)

get_pitch_interval(pitch_to_compare)

Get PitchInterval between itself and other pitch

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


add(pitch_interval)[source]
Parameters:

pitch_interval (PitchInterval) –

Return type:

ScalePitch

property hertz: float
property scale_pitch: Pitch
property scale_position: tuple[int, int]
class FlexPitch(event_iterable_or_point_sequence=[], *args, **kwargs)[source]

Bases: Pitch, FlexParameterMixin

A flexible pitch.

This can be used to create dynamically changing pitches (e.g. glissandi, portamenti, …).

Example:

>>> from mutwo import music_parameters
>>> p = music_parameters.FlexPitch([[0, 'f4'], [1, 'c4']])

Public Data Attributes:

hertz

Inherited from Pitch

Type

Pitch.Type hosts all types that are supported by the pitch parser Pitch.from_any().

midi_pitch_number

The midi pitch number (from 0 to 127) of the pitch.

hertz

Inherited from SingleNumberParameter

direct_comparison_type_tuple

digit_to_round_to_count

Inherited from FlexParameterMixin

parameter_name

default_parameter

Inherited from Envelope

Value

Parameter

CurveShape

Point

parameter_tuple

Get parameter for each event inside Envelope.

value_tuple

Get value for each event inside Envelope.

curve_shape_tuple

Get curve_shape for each event inside Envelope.

is_static

Return True if Envelope only has one static value.

Inherited from Consecution

duration

The duration of an event.

absolute_time_tuple

Return start time as core_parameters.abc.Duration for each event.

absolute_time_in_floats_tuple

Return start time as float for each event.

start_and_end_time_per_event

Return start and end time for each event.

Inherited from Compound

duration

The duration of an event.

Inherited from Event

duration

The duration of an event.

tempo

The tempo of an event.

Public Methods:

parameter_name

default_parameter

Inherited from Pitch

hertz_to_cents(frequency0, frequency1)

Calculates the difference in cents between two frequencies.

ratio_to_cents(ratio)

Converts a frequency ratio to its respective cent value.

cents_to_ratio(cents)

Converts a cent value to its respective frequency ratio.

hertz_to_midi_pitch_number(frequency)

Converts a frequency in hertz to its respective midi pitch.

from_any(object)

Parse any object to Parameter.

add(pitch_interval)

subtract(pitch_interval)

get_pitch_interval(pitch_to_compare)

Get PitchInterval between itself and other pitch

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from FlexParameterMixin

from_parameter(parameter)

value_to_parameter(value)

Convert from 'value' to 'parameter'.

parameter_to_value(parameter)

Convert from 'parameter' to 'value'.

apply_parameter_on_event(event, parameter)

Apply 'parameter' on given event

event_to_parameter(event)

Fetch 'parameter' from event.

Inherited from Envelope

event_to_parameter(event)

Fetch 'parameter' from event.

event_to_curve_shape(event)

Fetch 'curve_shape' from event.

parameter_to_value(parameter)

Convert from 'parameter' to 'value'.

value_to_parameter(value)

Convert from 'value' to 'parameter'.

apply_parameter_on_event(event, parameter)

Apply 'parameter' on given event

apply_curve_shape_on_event(event, curve_shape)

Apply 'curve_shape' on given event

initialise_default_event_class(duration)

Create new event object from event type.

value_at(absolute_time)

Get value at absolute_time.

parameter_at(absolute_time)

Get parameter at absolute_time.

curve_shape_at(absolute_time)

Get curve_shape at absolute_time.

point_at(absolute_time)

Get point at absolute_time.

sample_at(absolute_time[, append_duration])

Discretize envelope at given time

time_range_to_point_tuple(time_range)

Return all control points in given time range.

integrate_interval(start, end)

Integrate envelope above given interval.

get_average_value([start, end])

Find average value in given interval.

get_average_parameter([start, end])

Find average parameter in given interval.

cut_out(start, end)

Time-based slicing of the respective event.

cut_off(start, end)

Time-based deletion / shortening of the respective event.

extend_until(duration[, ...])

Prolong event until at least duration by appending an empty event.

split_at(*absolute_time[, ...])

Split event into n events at absolute_time.

Inherited from Consecution

get_event_index_at(absolute_time)

Get index of event which is active at the passed absolute_time.

get_event_at(absolute_time)

Get event which is active at the passed absolute_time.

cut_out(start, end)

Time-based slicing of the respective event.

cut_off(start, end)

Time-based deletion / shortening of the respective event.

squash_in(start, event_to_squash_in)

Time-based insert of a new event with overriding given event.

slide_in(start, event_to_slide_in)

Time-based insert of a new event into the present event.

split_child_at(absolute_time)

Split child event in two events at absolute_time.

split_at(*absolute_time[, ...])

Split event into n events at absolute_time.

extend_until(duration[, ...])

Prolong event until at least duration by appending an empty event.

Inherited from Compound

destructive_copy()

Adapted deep copy method that returns a new object for every leaf.

empty_copy()

Make a copy of the Compound without any child events.

get_event_from_index_sequence(index_sequence)

Get nested Event from a sequence of indices.

get_parameter(parameter_name[, flat, ...])

Return event attribute with the entered name.

remove_by(condition)

Condition-based deletion of child events.

tie_by(condition[, process_surviving_event, ...])

Condition-based deletion of neighboring child events.

metrize()

Apply tempo of event on itself

squash_in(start, event_to_squash_in)

Time-based insert of a new event with overriding given event.

slide_in(start, event_to_slide_in)

Time-based insert of a new event into the present event.

split_child_at(absolute_time)

Split child event in two events at absolute_time.

extend_until(duration[, ...])

Prolong event until at least duration by appending an empty event.

Inherited from Event

destructive_copy()

Adapted deep copy method that returns a new object for every leaf.

set(attribute_name, value)

Set an attribute of the object to a specific value

get_parameter(parameter_name[, flat, ...])

Return event attribute with the entered name.

set_parameter(parameter_name, object_or_function)

Sets parameter to new value for all children events.

mutate_parameter(parameter_name, function)

Mutate parameter with a function.

reset_tempo()

Set events tempo so that one beat equals one second (tempo 60).

metrize()

Apply tempo of event on itself

cut_out(start, end)

Time-based slicing of the respective event.

cut_off(start, end)

Time-based deletion / shortening of the respective event.

split_at(*absolute_time[, ...])

Split event into n events at absolute_time.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.

Inherited from list

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

append(object, /)

Append object to the end of the list.

insert(index, object, /)

Insert object before index.

extend(iterable, /)

Extend list by appending elements from the iterable.

pop([index])

Remove and return item at index (default last).

remove(value, /)

Remove first occurrence of value.

index(value[, start, stop])

Return first index of value.

count(value, /)

Return number of occurrences of value.

reverse()

Reverse IN PLACE.

sort(*[, key, reverse])

Sort the list in ascending order and return None.


class property default_parameter: Pitch

A simple pitch class that gets directly initialised by its frequency.

Parameters:

hertz – The hertz of the DirectPitch object.

May be used when a converter class needs a pitch object, but there is no need or desire for a complex abstraction of the respective pitch (that classes like JustIntonationPitch or WesternPitch offer).

Example:

>>> from mutwo import music_parameters
>>> my_pitch = music_parameters.DirectPitch(440)
property hertz
class property parameter_name: str

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

class DirectVolume(decibel)[source]

Bases: Volume

A simple volume class that gets directly initialised by decibel.

Parameters:

decibel (float | fractions.Fraction | int | quicktions.Fraction) – The decibel of the DecibelVolume object (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.

Public Data Attributes:

decibel

Inherited from Volume

Type

Volume.Type hosts all types that are supported by the volume parser Volume.from_any().

amplitude

midi_velocity

The velocity of the volume (from 0 to 127).

decibel

Inherited from SingleNumberParameter

direct_comparison_type_tuple

digit_to_round_to_count

Public Methods:

Inherited from Volume

decibel_to_amplitude_ratio(decibel[, ...])

Convert decibel to amplitude ratio.

decibel_to_power_ratio(decibel[, ...])

Convert decibel to power ratio.

amplitude_ratio_to_decibel(amplitude[, ...])

Convert amplitude ratio to decibel.

power_ratio_to_decibel(amplitude[, ...])

Convert power ratio to decibel.

amplitude_ratio_to_midi_velocity(amplitude)

Convert amplitude ratio to midi velocity.

decibel_to_midi_velocity(decibel_to_convert)

Convert decibel to midi velocity (0 to 127).

from_any(object)

Parse any object to Parameter.

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


property decibel: float | fractions.Fraction | int | quicktions.Fraction
class FlexVolume(event_iterable_or_point_sequence=[], *args, **kwargs)[source]

Bases: Volume, FlexParameterMixin

A flexible volume.

This can be used to create dynamically changing volumes (e.g. crescendo, decrescendo, …).

Example:

>>> from mutwo import music_parameters
>>> v = music_parameters.FlexVolume([[0, 'ff'], [1, 'ppp']])

Public Data Attributes:

decibel

Inherited from Volume

Type

Volume.Type hosts all types that are supported by the volume parser Volume.from_any().

amplitude

midi_velocity

The velocity of the volume (from 0 to 127).

decibel

Inherited from SingleNumberParameter

direct_comparison_type_tuple

digit_to_round_to_count

Inherited from FlexParameterMixin

parameter_name

default_parameter

Inherited from Envelope

Value

Parameter

CurveShape

Point

parameter_tuple

Get parameter for each event inside Envelope.

value_tuple

Get value for each event inside Envelope.

curve_shape_tuple

Get curve_shape for each event inside Envelope.

is_static

Return True if Envelope only has one static value.

Inherited from Consecution

duration

The duration of an event.

absolute_time_tuple

Return start time as core_parameters.abc.Duration for each event.

absolute_time_in_floats_tuple

Return start time as float for each event.

start_and_end_time_per_event

Return start and end time for each event.

Inherited from Compound

duration

The duration of an event.

Inherited from Event

duration

The duration of an event.

tempo

The tempo of an event.

Public Methods:

parameter_name

default_parameter

Inherited from Volume

decibel_to_amplitude_ratio(decibel[, ...])

Convert decibel to amplitude ratio.

decibel_to_power_ratio(decibel[, ...])

Convert decibel to power ratio.

amplitude_ratio_to_decibel(amplitude[, ...])

Convert amplitude ratio to decibel.

power_ratio_to_decibel(amplitude[, ...])

Convert power ratio to decibel.

amplitude_ratio_to_midi_velocity(amplitude)

Convert amplitude ratio to midi velocity.

decibel_to_midi_velocity(decibel_to_convert)

Convert decibel to midi velocity (0 to 127).

from_any(object)

Parse any object to Parameter.

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from FlexParameterMixin

from_parameter(parameter)

value_to_parameter(value)

Convert from 'value' to 'parameter'.

parameter_to_value(parameter)

Convert from 'parameter' to 'value'.

apply_parameter_on_event(event, parameter)

Apply 'parameter' on given event

event_to_parameter(event)

Fetch 'parameter' from event.

Inherited from Envelope

event_to_parameter(event)

Fetch 'parameter' from event.

event_to_curve_shape(event)

Fetch 'curve_shape' from event.

parameter_to_value(parameter)

Convert from 'parameter' to 'value'.

value_to_parameter(value)

Convert from 'value' to 'parameter'.

apply_parameter_on_event(event, parameter)

Apply 'parameter' on given event

apply_curve_shape_on_event(event, curve_shape)

Apply 'curve_shape' on given event

initialise_default_event_class(duration)

Create new event object from event type.

value_at(absolute_time)

Get value at absolute_time.

parameter_at(absolute_time)

Get parameter at absolute_time.

curve_shape_at(absolute_time)

Get curve_shape at absolute_time.

point_at(absolute_time)

Get point at absolute_time.

sample_at(absolute_time[, append_duration])

Discretize envelope at given time

time_range_to_point_tuple(time_range)

Return all control points in given time range.

integrate_interval(start, end)

Integrate envelope above given interval.

get_average_value([start, end])

Find average value in given interval.

get_average_parameter([start, end])

Find average parameter in given interval.

cut_out(start, end)

Time-based slicing of the respective event.

cut_off(start, end)

Time-based deletion / shortening of the respective event.

extend_until(duration[, ...])

Prolong event until at least duration by appending an empty event.

split_at(*absolute_time[, ...])

Split event into n events at absolute_time.

Inherited from Consecution

get_event_index_at(absolute_time)

Get index of event which is active at the passed absolute_time.

get_event_at(absolute_time)

Get event which is active at the passed absolute_time.

cut_out(start, end)

Time-based slicing of the respective event.

cut_off(start, end)

Time-based deletion / shortening of the respective event.

squash_in(start, event_to_squash_in)

Time-based insert of a new event with overriding given event.

slide_in(start, event_to_slide_in)

Time-based insert of a new event into the present event.

split_child_at(absolute_time)

Split child event in two events at absolute_time.

split_at(*absolute_time[, ...])

Split event into n events at absolute_time.

extend_until(duration[, ...])

Prolong event until at least duration by appending an empty event.

Inherited from Compound

destructive_copy()

Adapted deep copy method that returns a new object for every leaf.

empty_copy()

Make a copy of the Compound without any child events.

get_event_from_index_sequence(index_sequence)

Get nested Event from a sequence of indices.

get_parameter(parameter_name[, flat, ...])

Return event attribute with the entered name.

remove_by(condition)

Condition-based deletion of child events.

tie_by(condition[, process_surviving_event, ...])

Condition-based deletion of neighboring child events.

metrize()

Apply tempo of event on itself

squash_in(start, event_to_squash_in)

Time-based insert of a new event with overriding given event.

slide_in(start, event_to_slide_in)

Time-based insert of a new event into the present event.

split_child_at(absolute_time)

Split child event in two events at absolute_time.

extend_until(duration[, ...])

Prolong event until at least duration by appending an empty event.

Inherited from Event

destructive_copy()

Adapted deep copy method that returns a new object for every leaf.

set(attribute_name, value)

Set an attribute of the object to a specific value

get_parameter(parameter_name[, flat, ...])

Return event attribute with the entered name.

set_parameter(parameter_name, object_or_function)

Sets parameter to new value for all children events.

mutate_parameter(parameter_name, function)

Mutate parameter with a function.

reset_tempo()

Set events tempo so that one beat equals one second (tempo 60).

metrize()

Apply tempo of event on itself

cut_out(start, end)

Time-based slicing of the respective event.

cut_off(start, end)

Time-based deletion / shortening of the respective event.

split_at(*absolute_time[, ...])

Split event into n events at absolute_time.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.

Inherited from list

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

append(object, /)

Append object to the end of the list.

insert(index, object, /)

Insert object before index.

extend(iterable, /)

Extend list by appending elements from the iterable.

pop([index])

Remove and return item at index (default last).

remove(value, /)

Remove first occurrence of value.

index(value[, start, stop])

Return first index of value.

count(value, /)

Return number of occurrences of value.

reverse()

Reverse IN PLACE.

sort(*[, key, reverse])

Sort the list in ascending order and return None.


property decibel
class property default_parameter: Pitch[source]

A simple volume class that gets directly initialised by decibel.

Parameters:

decibel – The decibel of the DecibelVolume object (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.

class property parameter_name: str

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

class AmplitudeVolume(amplitude)[source]

Bases: Volume

A simple volume class that gets directly initialised by its amplitude.

Parameters:

amplitude (float | fractions.Fraction | int | quicktions.Fraction) – The amplitude of the DirectVolume object.

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.

Public Data Attributes:

amplitude

decibel

Inherited from Volume

Type

Volume.Type hosts all types that are supported by the volume parser Volume.from_any().

amplitude

midi_velocity

The velocity of the volume (from 0 to 127).

decibel

Inherited from SingleNumberParameter

direct_comparison_type_tuple

digit_to_round_to_count

Public Methods:

Inherited from Volume

decibel_to_amplitude_ratio(decibel[, ...])

Convert decibel to amplitude ratio.

decibel_to_power_ratio(decibel[, ...])

Convert decibel to power ratio.

amplitude_ratio_to_decibel(amplitude[, ...])

Convert amplitude ratio to decibel.

power_ratio_to_decibel(amplitude[, ...])

Convert power ratio to decibel.

amplitude_ratio_to_midi_velocity(amplitude)

Convert amplitude ratio to midi velocity.

decibel_to_midi_velocity(decibel_to_convert)

Convert decibel to midi velocity (0 to 127).

from_any(object)

Parse any object to Parameter.

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


property amplitude: float | fractions.Fraction | int | quicktions.Fraction
property decibel: float
class WesternVolume(name, minimum_decibel=None, maximum_decibel=None)[source]

Bases: Volume

Volume 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.music_parameters.constants.DYNAMIC_INDICATOR_TUPLE.

  • minimum_decibel (core_constants.Real, optional) – The decibel value which is equal to the lowest dynamic indicator (ppppp).

  • maximum_decibel (core_constants.Real, optional) – The decibel value which is equal to the highest dynamic indicator (fffff).

Example:

>>> from mutwo import music_parameters
>>> music_parameters.WesternVolume('fff')
WesternVolume(fff)

Public Data Attributes:

name

The western nomenclature name for dynamic.

decibel

Inherited from Volume

Type

Volume.Type hosts all types that are supported by the volume parser Volume.from_any().

amplitude

midi_velocity

The velocity of the volume (from 0 to 127).

decibel

Inherited from SingleNumberParameter

direct_comparison_type_tuple

digit_to_round_to_count

Public Methods:

from_amplitude(amplitude)

Initialise WesternVolume from amplitude ratio.

from_decibel(decibel)

Initialise WesternVolume from decibel.

Inherited from Volume

decibel_to_amplitude_ratio(decibel[, ...])

Convert decibel to amplitude ratio.

decibel_to_power_ratio(decibel[, ...])

Convert decibel to power ratio.

amplitude_ratio_to_decibel(amplitude[, ...])

Convert amplitude ratio to decibel.

power_ratio_to_decibel(amplitude[, ...])

Convert power ratio to decibel.

amplitude_ratio_to_midi_velocity(amplitude)

Convert amplitude ratio to midi velocity.

decibel_to_midi_velocity(decibel_to_convert)

Convert decibel to midi velocity (0 to 127).

from_any(object)

Parse any object to Parameter.

value_name

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


classmethod from_amplitude(amplitude)[source]

Initialise WesternVolume from amplitude ratio.

Parameters:

amplitude (float | fractions.Fraction | int | quicktions.Fraction) – The amplitude which shall be converted to a WesternVolume object.

Return type:

WesternVolume

>>> from mutwo import music_parameters
>>> music_parameters.WesternVolume.from_amplitude(0.05)
WesternVolume(p)
classmethod from_decibel(decibel)[source]

Initialise WesternVolume from decibel.

Parameters:

decibel (float | fractions.Fraction | int | quicktions.Fraction) – The decibel which shall be converted to a WesternVolume object.

Return type:

WesternVolume

>>> from mutwo import music_parameters
>>> music_parameters.WesternVolume.from_decibel(-24)
WesternVolume(p)
property decibel: float | fractions.Fraction | int | quicktions.Fraction
property name: str

The western nomenclature name for dynamic.

For a list of all supported indicators, see mutwo.music_parameters.constants.DYNAMIC_INDICATOR_TUPLE.

class BarLine(abbreviation: Optional[str] = None)[source]

Bases: NotationIndicator

Public Data Attributes:

abbreviation

Inherited from NotationIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:

abbreviation (Optional[str]) –

abbreviation: Optional[str] = None
class Clef(name: Optional[str] = None)[source]

Bases: NotationIndicator

Public Data Attributes:

name

Inherited from NotationIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:

name (Optional[str]) –

name: Optional[str] = None
class Ottava(octave_count: Optional[int] = 0)[source]

Bases: NotationIndicator

Public Data Attributes:

octave_count

Inherited from NotationIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:

octave_count (Optional[int]) –

octave_count: Optional[int] = 0
class MarginMarkup(content: Optional[str] = None, context: Optional[str] = 'Staff')[source]

Bases: NotationIndicator

Public Data Attributes:

content

context

Inherited from NotationIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:
  • content (Optional[str]) –

  • context (Optional[str]) –

content: Optional[str] = None
context: Optional[str] = 'Staff'
class Markup(content: Optional[str] = None, direction: Optional[str] = None)[source]

Bases: NotationIndicator

Public Data Attributes:

content

direction

Inherited from NotationIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:
  • content (Optional[str]) –

  • direction (Optional[str]) –

content: Optional[str] = None
direction: Optional[str] = None
class RehearsalMark(markup: Optional[str] = None)[source]

Bases: NotationIndicator

Public Data Attributes:

markup

Inherited from NotationIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:

markup (Optional[str]) –

markup: Optional[str] = None
class NotationIndicatorCollection(*args, **kwargs)[source]

Bases: IndicatorCollection[NotationIndicator]

Collection of notation indicators

Public Data Attributes:

Inherited from IndicatorCollection

Type

IndicatorCollection.Type hosts all types that are supported by the indicator collection parser IndicatorCollection.from_any().

indicator_tuple

indicator_dict

Public Methods:

Inherited from IndicatorCollection

from_any(object)

Parse any object to Parameter.

register(indicator[, name])

Register new indicator type to collection.

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


class Tremolo(flag_count: Optional[int] = None)[source]

Bases: ImplicitPlayingIndicator

Public Data Attributes:

flag_count

Inherited from ImplicitPlayingIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:

flag_count (Optional[int]) –

flag_count: Optional[int] = None
class Articulation(name: Optional[Literal['accent', 'marcato', 'staccatissimo', 'espressivo', 'staccato', 'tenuto', 'portato', 'upbow', 'downbow', 'flageolet', 'thumb', 'lheel', 'rheel', 'ltoe', 'rtoe', 'open', 'halfopen', 'snappizzicato', 'stopped', 'turn', 'reverseturn', 'trill', 'prall', 'mordent', 'prallprall', 'prallmordent', 'upprall', 'downprall', 'upmordent', 'downmordent', 'pralldown', 'prallup', 'lineprall', 'signumcongruentiae', 'shortfermata', 'fermata', 'longfermata', 'verylongfermata', 'segno', 'coda', 'varcoda', '^', '+', '-', '|', '>', '.', '_']] = None)[source]

Bases: ImplicitPlayingIndicator

Public Data Attributes:

name

Inherited from ImplicitPlayingIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:

name (Optional[Literal['accent', 'marcato', 'staccatissimo', 'espressivo', 'staccato', 'tenuto', 'portato', 'upbow', 'downbow', 'flageolet', 'thumb', 'lheel', 'rheel', 'ltoe', 'rtoe', 'open', 'halfopen', 'snappizzicato', 'stopped', 'turn', 'reverseturn', 'trill', 'prall', 'mordent', 'prallprall', 'prallmordent', 'upprall', 'downprall', 'upmordent', 'downmordent', 'pralldown', 'prallup', 'lineprall', 'signumcongruentiae', 'shortfermata', 'fermata', 'longfermata', 'verylongfermata', 'segno', 'coda', 'varcoda', '^', '+', '-', '|', '>', '.', '_']]) –

name: Optional[Literal['accent', 'marcato', 'staccatissimo', 'espressivo', 'staccato', 'tenuto', 'portato', 'upbow', 'downbow', 'flageolet', 'thumb', 'lheel', 'rheel', 'ltoe', 'rtoe', 'open', 'halfopen', 'snappizzicato', 'stopped', 'turn', 'reverseturn', 'trill', 'prall', 'mordent', 'prallprall', 'prallmordent', 'upprall', 'downprall', 'upmordent', 'downmordent', 'pralldown', 'prallup', 'lineprall', 'signumcongruentiae', 'shortfermata', 'fermata', 'longfermata', 'verylongfermata', 'segno', 'coda', 'varcoda', '^', '+', '-', '|', '>', '.', '_']] = None
class Arpeggio(direction: Optional[Literal['up', 'down']] = None)[source]

Bases: ImplicitPlayingIndicator

Public Data Attributes:

direction

Inherited from ImplicitPlayingIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:

direction (Optional[Literal['up', 'down']]) –

direction: Optional[Literal['up', 'down']] = None
class Pedal(type: Optional[Literal['sustain', 'sostenuto', 'corda']] = None, activity: Optional[bool] = True)[source]

Bases: ImplicitPlayingIndicator

Public Data Attributes:

type

activity

Inherited from ImplicitPlayingIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:
  • type (Optional[Literal['sustain', 'sostenuto', 'corda']]) –

  • activity (Optional[bool]) –

activity: Optional[bool] = True
type: Optional[Literal['sustain', 'sostenuto', 'corda']] = None
class Slur(activity: Optional[bool] = None)[source]

Bases: ImplicitPlayingIndicator

Public Data Attributes:

activity

Inherited from ImplicitPlayingIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:

activity (Optional[bool]) –

activity: Optional[bool] = None
class StringContactPoint(contact_point: Optional[Literal['dietro ponticello', 'molto sul ponticello', 'molto sul tasto', 'ordinario', 'pizzicato', 'ponticello', 'sul ponticello', 'sul tasto', 'col legno tratto', 'd.p.', 'm.s.p', 'm.s.t.', 'ord.', 'pizz.', 'p.', 's.p.', 's.t.', 'c.l.t.']] = None)[source]

Bases: ImplicitPlayingIndicator

Public Data Attributes:

contact_point

Inherited from ImplicitPlayingIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:

contact_point (Optional[Literal['dietro ponticello', 'molto sul ponticello', 'molto sul tasto', 'ordinario', 'pizzicato', 'ponticello', 'sul ponticello', 'sul tasto', 'col legno tratto', 'd.p.', 'm.s.p', 'm.s.t.', 'ord.', 'pizz.', 'p.', 's.p.', 's.t.', 'c.l.t.']]) –

contact_point: Optional[Literal['dietro ponticello', 'molto sul ponticello', 'molto sul tasto', 'ordinario', 'pizzicato', 'ponticello', 'sul ponticello', 'sul tasto', 'col legno tratto', 'd.p.', 'm.s.p', 'm.s.t.', 'ord.', 'pizz.', 'p.', 's.p.', 's.t.', 'c.l.t.']] = None
class Ornamentation(direction: Optional[Literal['up', 'down']] = None, count: int = 1)[source]

Bases: ImplicitPlayingIndicator

Public Data Attributes:

direction

count

Inherited from ImplicitPlayingIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:
  • direction (Optional[Literal['up', 'down']]) –

  • count (int) –

count: int = 1
direction: Optional[Literal['up', 'down']] = None
class BendAfter(bend_amount: Optional[float] = None, minimum_length: Optional[float] = 3, thickness: Optional[float] = 3)[source]

Bases: ImplicitPlayingIndicator

Public Data Attributes:

bend_amount

minimum_length

thickness

Inherited from ImplicitPlayingIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:
  • bend_amount (Optional[float]) –

  • minimum_length (Optional[float]) –

  • thickness (Optional[float]) –

bend_amount: Optional[float] = None
minimum_length: Optional[float] = 3
thickness: Optional[float] = 3
class ArtificalHarmonic(semitone_count: Optional[int] = None)[source]

Bases: ImplicitPlayingIndicator

Public Data Attributes:

semitone_count

Inherited from ImplicitPlayingIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:

semitone_count (Optional[int]) –

semitone_count: Optional[int] = None
class NaturalHarmonicNodeList(natural_harmonic_list=None, harmonic_note_head_style=True, write_string=True, parenthesize_lower_note_head=False)[source]

Bases: list[Node], PlayingIndicator

Assign natural harmonics to your note.

Example:

>>> from mutwo import music_events, music_parameters
>>> n = music_events.NoteLike('c', 4)
>>> n.playing_indicator_collection.natural_harmonic_node_list.is_active
False
>>> n.playing_indicator_collection.natural_harmonic_node_list.append(
...     music_parameters.NaturalHarmonic(
...         2,
...         music_parameters.String(0, music_parameters.WesternPitch('c', 3))
...     ).node_tuple[0]
... )
>>> n.playing_indicator_collection.natural_harmonic_node_list.is_active
True

Public Data Attributes:

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from list

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

append(object, /)

Append object to the end of the list.

insert(index, object, /)

Insert object before index.

extend(iterable, /)

Extend list by appending elements from the iterable.

pop([index])

Remove and return item at index (default last).

remove(value, /)

Remove first occurrence of value.

index(value[, start, stop])

Return first index of value.

count(value, /)

Return number of occurrences of value.

reverse()

Reverse IN PLACE.

sort(*[, key, reverse])

Sort the list in ascending order and return None.

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:
property is_active: bool
class Fermata(type: Optional[Literal['shortfermata', 'fermata', 'longfermata', 'verylongfermata']] = None)[source]

Bases: ImplicitPlayingIndicator

Public Data Attributes:

type

Inherited from ImplicitPlayingIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:

type (Optional[Literal['shortfermata', 'fermata', 'longfermata', 'verylongfermata']]) –

type: Optional[Literal['shortfermata', 'fermata', 'longfermata', 'verylongfermata']] = None
class Hairpin(symbol: Optional[Literal['<', '>', '<>', '!']] = None, niente: bool = False)[source]

Bases: ImplicitPlayingIndicator

Public Data Attributes:

symbol

niente

Inherited from ImplicitPlayingIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:
  • symbol (Optional[Literal['<', '>', '<>', '!']]) –

  • niente (bool) –

niente: bool = False
symbol: Optional[Literal['<', '>', '<>', '!']] = None
class Trill(pitch: Optional[mutwo.music_parameters.abc.Pitch] = None)[source]

Bases: ImplicitPlayingIndicator

Public Data Attributes:

pitch

Inherited from ImplicitPlayingIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:

pitch (Optional[Pitch]) –

pitch: Optional[Pitch] = None
class WoodwindFingering(cc: Optional[Tuple[str, ...]] = None, left_hand: Optional[Tuple[str, ...]] = None, right_hand: Optional[Tuple[str, ...]] = None, instrument: str = 'clarinet')[source]

Bases: ImplicitPlayingIndicator

Public Data Attributes:

cc

left_hand

right_hand

instrument

Inherited from ImplicitPlayingIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:
  • cc (Optional[Tuple[str, ...]]) –

  • left_hand (Optional[Tuple[str, ...]]) –

  • right_hand (Optional[Tuple[str, ...]]) –

  • instrument (str) –

cc: Optional[Tuple[str, ...]] = None
instrument: str = 'clarinet'
left_hand: Optional[Tuple[str, ...]] = None
right_hand: Optional[Tuple[str, ...]] = None
class Cue(index=None)[source]

Bases: ImplicitPlayingIndicator

Cue for electronics etc.

Public Data Attributes:

index

Inherited from ImplicitPlayingIndicator

is_active

Inherited from Indicator

is_active

Public Methods:

Inherited from Indicator

get_arguments_dict()

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


Parameters:

index (Optional[int]) –

index: Optional[int] = None
class PlayingIndicatorCollection(*args, **kwargs)[source]

Bases: IndicatorCollection[PlayingIndicator]

Collection of playing indicators

Public Data Attributes:

Inherited from IndicatorCollection

Type

IndicatorCollection.Type hosts all types that are supported by the indicator collection parser IndicatorCollection.from_any().

indicator_tuple

indicator_dict

Public Methods:

Inherited from IndicatorCollection

from_any(object)

Parse any object to Parameter.

register(indicator[, name])

Register new indicator type to collection.

Inherited from Parameter

from_any(object)

Parse any object to Parameter.

Inherited from MutwoObject

copy()

Return a deep copy of mutwo object.


class ScaleFamily(interval_sequence, weight_sequence=None, scale_degree_sequence=None, period_repetition_count_sequence=None)[source]

Bases: object

A ScaleFamily is a sorted sequence of mutwo.music_parameters.abc.PitchInterval.

Scale families are frozen/immutable.

The equivalent of a ScaleFamily in music21 is an AbstractScale.

Mutwos implementation supports assigning weights to each interval to express an hierarchy within the scale.

You need to explicitly add the prime (1/1) to the interval set if the tonic should appear within the given scale.

Public Data Attributes:

interval_tuple

weight_tuple

scale_degree_tuple

period_repetition_count_tuple

is_rising

Public Methods:

is_falling

scale_degree_count


Parameters:
  • interval_sequence (Sequence[PitchInterval]) –

  • weight_sequence (Optional[Sequence[float | fractions.Fraction | int | quicktions.Fraction]]) –

  • scale_degree_sequence (Optional[Sequence[int]]) –

  • period_repetition_count_sequence (Optional[Sequence[int]]) –

property interval_tuple: tuple[mutwo.music_parameters.abc.PitchInterval, ...]
property is_falling: bool
property is_rising: bool
property period_repetition_count_tuple: tuple[int, ...]
property scale_degree_count: int
property scale_degree_tuple: tuple[int, ...]
property weight_tuple: tuple[float | fractions.Fraction | int | quicktions.Fraction, ...]
class RepeatingScaleFamily(repeating_interval_sequence, repetition_interval=D(1200), min_pitch_interval=D(-6000), max_pitch_interval=D(6000), repeating_weight_sequence=None, repeating_scale_degree_sequence=None, repeating_period_repetition_count_sequence=None)[source]

Bases: ScaleFamily

A RepeatingScaleFamily is a sorted sequence of repeating intervals over a repetition interval.

Most musical scales are based on RepeatingScaleFamily, because most musical scales repeat after one octave.

Public Data Attributes:

Inherited from ScaleFamily

interval_tuple

weight_tuple

scale_degree_tuple

period_repetition_count_tuple

is_rising

Public Methods:

Inherited from ScaleFamily

is_falling

scale_degree_count


Parameters:
  • repeating_interval_sequence (Sequence[PitchInterval]) –

  • repetition_interval (PitchInterval) –

  • min_pitch_interval (PitchInterval) –

  • max_pitch_interval (PitchInterval) –

  • repeating_weight_sequence (Optional[Sequence[float | fractions.Fraction | int | quicktions.Fraction]]) –

  • repeating_scale_degree_sequence (Optional[Sequence[int]]) –

  • repeating_period_repetition_count_sequence (Optional[Sequence[int]]) –

class Scale(tonic, scale_family)[source]

Bases: object

A Scale is a sorted sequence of Pitch.

The equivalent of a Scale in music21 is an ConcreteScale.

Scale uses a specific nomenclature to differentiate between different positions in a musical scale:

  1. scale_degree: A scale degree is an octave independent position of a Pitch.

  2. scale_index: A scale index is an absolute index of a Pitch within a specific scale.

Public Data Attributes:

tonic

scale_family

weight_tuple

scale_degree_tuple

period_repetition_count_tuple

is_rising

is_falling

scale_degree_count

Public Methods:

pitch_tuple

scale_position_tuple

pitch_to_scale_degree(pitch)

scale_position_to_pitch(scale_position)

pitch_to_scale_position(pitch)

pitch_to_scale_index(pitch)

scale_index_to_pitch(scale_index)

scale_degree_to_pitch_class(scale_degree)


Parameters:
pitch_to_scale_degree(pitch)[source]
Parameters:

pitch (Pitch) –

Return type:

int

pitch_to_scale_index(pitch)[source]
Parameters:

pitch (Pitch) –

Return type:

int

pitch_to_scale_position(pitch)[source]
Parameters:

pitch (Pitch) –

Return type:

Pitch

scale_degree_to_pitch_class(scale_degree)[source]
Parameters:

scale_degree (int) –

Return type:

Pitch

scale_index_to_pitch(scale_index)[source]
Parameters:

scale_index (int) –

Return type:

Pitch

scale_position_to_pitch(scale_position)[source]
Parameters:

scale_position (tuple[int, int]) –

Return type:

Pitch

property is_falling: bool
property is_rising: bool
property period_repetition_count_tuple: tuple[int, ...]
property pitch_tuple: tuple[mutwo.music_parameters.abc.Pitch, ...]
property scale_degree_count: int
property scale_degree_tuple: tuple[int, ...]
property scale_family: ScaleFamily
property scale_position_tuple: tuple[tuple[int, int], ...]
property tonic: Pitch
property weight_tuple: tuple[float | fractions.Fraction | int | quicktions.Fraction, ...]

mutwo.music_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 ExplicitPlayingIndicator(is_active=False)[source]

Bases: PlayingIndicator

Parameters:

is_active (bool) –

get_arguments_dict()[source]
Return type:

dict[str, Any]

property is_active: bool
class ImplicitPlayingIndicator[source]

Bases: PlayingIndicator

property is_active: bool
class Indicator[source]

Bases: Parameter

get_arguments_dict()[source]
Return type:

dict[str, Any]

abstract property is_active: bool
class IndicatorCollection(*args, **kwargs)[source]

Bases: Parameter, Generic[T]

An IndicatorCollection hosts a collection of indicators.

classmethod from_any(object)[source]

Parse any object to Parameter.

Parameters:

object (Union[None, str, IndicatorCollection]) – Object that is parsed to the parameter.

Raises:

core_utilities.CannotParseError in case the object can’t be parsed to the parameter type.

Return type:

IndicatorCollection

This method is useful for allowing syntactic sugar.

classmethod register(indicator, name=None)[source]

Register new indicator type to collection.

Parameters:
  • indicator (Type[Indicator]) – The indicator type that is registered.

  • name (Optional[str] = None) – The attribute name of the collection that points to the indicator. If None this is automatically set to a lower snake case version of the type name (e.g. ‘MarginMarkup’ is converted to ‘margin_markup’). Default to None.

Type

IndicatorCollection.Type hosts all types that are supported by the indicator collection parser IndicatorCollection.from_any().

alias of Union[None, str, IndicatorCollection]

property indicator_dict: dict[str, mutwo.music_parameters.abc.Indicator]
property indicator_tuple: tuple[T, ...]
class Instrument(name, short_name=None)[source]

Bases: Parameter

Model a musical instrument.

Parameters:
  • name (str) – The name of the instrument.

  • short_name (Optional[str]) – The abbreviation of the instrument. If set to None it will be the same like name. Default to None.

This is an abstract class. To create a new concrete class you need to override the abstract is_pitched property. Alternatively you can use the ready-to-go classes mutwo.music_parameters.UnpitchedInstrument or mutwo.music_parameters.ContinuousPitchedInstrument or mutwo.music_parameters.DiscreetPitchedInstrument.

abstract property is_pitched: bool

Return True if instrument is pitched, False otherwise.

name: str
short_name: Optional[str] = None
class Lyric[source]

Bases: SingleValueParameter

Abstract base class for any spoken, sung or written text.

If the user wants to define a new lyric class, the abstract properties xampa and written_representation have to be overridden.

The xsampa should return a string of X-SAMPA format phonemes, separated by space to indicate new words. Consult wikipedia entry for detailed information regarding X-SAMPA.

The written_representation should return a string of normal written text, separated by space to indicate new words.

class property value_name

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

property written_representation: str

Get text as it would be written in natural language

abstract property xsampa: value_return_type
class NotationIndicator[source]

Bases: Indicator

Abstract base class for any notation indicator.

property is_active: bool
class Pitch[source]

Bases: SingleNumberParameter

Abstract base class for any pitch class.

If the user wants to define a new pitch class, the abstract property hertz has to be overridden. Starting from mutwo version = 0.46.0 the user will furthermore have to define an add() method.

abstract add(pitch_interval)[source]
Parameters:

pitch_interval (PitchInterval) –

Return type:

Pitch

static cents_to_ratio(cents)[source]

Converts a cent value to its respective frequency ratio.

Parameters:

cents (float | fractions.Fraction | int | quicktions.Fraction) – Cents that shall be converted to a frequency ratio.

Return type:

Fraction

Example:

>>> from mutwo import music_parameters
>>> music_parameters.abc.Pitch.cents_to_ratio(1200)
Fraction(2, 1)
classmethod from_any(object)[source]

Parse any object to Parameter.

Parameters:

object (Union[Fraction, float, int, str, Pitch]) – Object that is parsed to the parameter.

Raises:

core_utilities.CannotParseError in case the object can’t be parsed to the parameter type.

Return type:

Pitch

This method is useful for allowing syntactic sugar.

get_pitch_interval(pitch_to_compare)[source]

Get PitchInterval between itself and other pitch

Parameters:

pitch_to_compare (Pitch) – The pitch which shall be compared to the active pitch.

Returns:

PitchInterval between

Return type:

PitchInterval

Example:

>>> from mutwo import music_parameters
>>> a4 = music_parameters.DirectPitch(hertz=440)
>>> a5 = music_parameters.DirectPitch(hertz=880)
>>> pitch_interval = a4.get_pitch_interval(a5)
static hertz_to_cents(frequency0, frequency1)[source]

Calculates the difference in cents between two frequencies.

Parameters:
  • frequency0 (float | fractions.Fraction | int | quicktions.Fraction) – The first frequency in Hertz.

  • frequency1 (float | fractions.Fraction | int | quicktions.Fraction) – The second frequency in Hertz.

Returns:

The difference in cents between the first and the second frequency.

Return type:

float

Example:

>>> from mutwo import music_parameters
>>> music_parameters.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 (float | fractions.Fraction | int | quicktions.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 import music_parameters
>>> music_parameters.abc.Pitch.hertz_to_midi_pitch_number(440)
69.0
>>> music_parameters.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 (Fraction) – The frequency ratio which cent value shall be calculated.

Return type:

float

Example:

>>> from mutwo import music_parameters
>>> music_parameters.abc.Pitch.ratio_to_cents(fractions.Fraction(3, 2))
701.9550008653874
subtract(pitch_interval)[source]
Parameters:

pitch_interval (PitchInterval) –

Return type:

Pitch

Type

Pitch.Type hosts all types that are supported by the pitch parser Pitch.from_any().

alias of Union[Fraction, float, int, str, Pitch]

abstract property hertz: value_return_type
property midi_pitch_number: float

The midi pitch number (from 0 to 127) of the pitch.

class property value_name

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

class PitchAmbitus(minima_pitch, maxima_pitch)[source]

Bases: Parameter

Abstract base class for all pitch ambituses.

To setup a new PitchAmbitus class override the abstract method pitch_to_period.

Parameters:
  • minima_pitch (Pitch) –

  • maxima_pitch (Pitch) –

filter_pitch_sequence(pitch_to_filter_sequence)[source]

Filter all pitches in a sequence which aren’t inside the ambitus.

Parameters:

pitch_to_filter_sequence (Sequence[Pitch]) – A sequence with pitches which shall be filtered.

Return type:

tuple[mutwo.music_parameters.abc.Pitch, …]

Example:

>>> from mutwo import music_parameters
>>> ambitus0 = music_parameters.OctaveAmbitus(
...     music_parameters.JustIntonationPitch('1/2'),
...     music_parameters.JustIntonationPitch('2/1'),
... )
>>> ambitus0.filter_pitch_sequence(
...     [
...         music_parameters.JustIntonationPitch("3/8"),
...         music_parameters.JustIntonationPitch("3/4"),
...         music_parameters.JustIntonationPitch("3/2"),
...         music_parameters.JustIntonationPitch("3/1"),
...     ]
... )
(JustIntonationPitch('3/4'), JustIntonationPitch('3/2'))
get_pitch_variant_tuple(pitch, period=None)[source]

Find all pitch variants (in all octaves) of the given pitch

Parameters:
  • pitch (Pitch) – The pitch which variants shall be found.

  • period (Optional[PitchInterval]) – The repeating period (usually an octave). If the period is set to None the function will fallback to them objects method PitchAmbitus.pitch_to_period(). Default to None.

Return type:

tuple[mutwo.music_parameters.abc.Pitch, …]

abstract pitch_to_period(pitch)[source]
Parameters:

pitch (Pitch) –

Return type:

PitchInterval

property border_tuple: tuple[mutwo.music_parameters.abc.Pitch, mutwo.music_parameters.abc.Pitch]
property range: PitchInterval
class PitchInterval[source]

Bases: SingleNumberParameter

Abstract base class for any pitch interval class

If the user wants to define a new pitch interval class, the abstract property cents and the abstract method inverse have to be overridden.

See wikipedia entry for definition of ‘cents’.

abstract inverse()[source]

Makes falling interval to rising and vice versa.

In music21 the method for equal semantics is called reverse.

Return type:

PitchInterval

abstract property cents: value_return_type
class property value_name

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

class PitchList(iterable=(), /)[source]

Bases: Parameter, list[Pitch]

PitchList provides functionality to parse objects to a list of pitches

classmethod from_any(object)[source]

Parse any object to Parameter.

Parameters:

object (Union[Fraction, float, int, str, Pitch]) – Object that is parsed to the parameter.

Raises:

core_utilities.CannotParseError in case the object can’t be parsed to the parameter type.

Return type:

Pitch

This method is useful for allowing syntactic sugar.

Type

PitchList.Type hosts all types that are supported by the pitch list parser PitchList.from_any().

alias of Optional[Union[Fraction, float, int, str, Pitch, list[Pitch], tuple[Pitch]]]

class PitchedInstrument(name, short_name=None, pitch_count_range=Range[1, 2), transposition_pitch_interval=None)[source]

Bases: Instrument

Model a pitched musical instrument.

Parameters:
  • name (str) – The name of the instrument.

  • short_name (Optional[str]) – The abbreviation of the instrument. If set to None it will be the same like name. Default to None.

  • pitch_count_range (ranges.Range) – Set how many simultaneous pitches the instrument can play. Default to ranges.Range(1, 2), which means that the instrument is monophonic.

  • transposition_pitch_interval (Optional[PitchInterval]) – Some instruments are written with a transposition (so sounding pitch and written pitch differs). This parameter can be used to set the transposition interval in case sounding and written differs. The transposition_pitch_interval is added to the sounding pitches in order to reach the written pitches. If set to None this will be set to DirectPitchInterval(0) which is no transposition. Default to None.

You can use pythons in syntax to find out if a pitch is playable by the given instrument.

This is an abstract class. You need to override abstract method __contains__ and abstract property pitch_ambitus.

abstract get_pitch_variant_tuple(pitch, period=None)[source]

Find all pitch variants (in all octaves) of the given pitch

Parameters:
  • pitch (Pitch) – The pitch which variants shall be found.

  • period (Optional[PitchInterval]) – The repeating period (usually an octave). If the period is set to None the function will fallback to them objects method PitchAmbitus.pitch_to_period(). Default to None.

Return type:

tuple[mutwo.music_parameters.abc.Pitch, …]

This is not necessarily the same as instrument.pitch_ambitus.get_pitch_variant_tuple(), because a mutwo.music_parameters.DiscreetPitchedInstrument may not be capable of playing a pitch even if the given pitch is within the ambitus of an instrument. It’s therefore recommended to use instrument.get_pitch_variant_tuple if one wants to find out in which octaves the given pitch is actually playable on the instrument.

property is_pitched: bool

Return True if instrument is pitched, False otherwise.

name: str
abstract property pitch_ambitus: PitchAmbitus
pitch_count_range: ranges.Range = Range[1, 2)
transposition_pitch_interval: Optional[music_parameters.abc.DirectPitchInterval] = None
class PlayingIndicator[source]

Bases: Indicator

Abstract base class for any playing indicator.

class Syllable(is_last_syllable)[source]

Bases: Lyric

Syllable mixin for classes which inherit from Lyric.

This adds the new attribute is_last_syllable. This should be True if it is the last syllable of a word and False if it isn’t.

Parameters:

is_last_syllable (bool) –

class Volume[source]

Bases: SingleNumberParameter

Abstract base class for any volume class.

If the user wants to define a new volume class, the abstract property decibel has to be overridden.

static amplitude_ratio_to_decibel(amplitude, reference_amplitude=1)[source]

Convert amplitude ratio to decibel.

Parameters:
  • amplitude (float | fractions.Fraction | int | quicktions.Fraction) – The amplitude that shall be converted.

  • reference_amplitude (float | fractions.Fraction | int | quicktions.Fraction) – The amplitude for decibel == 0.

Return type:

float

Example:

>>> from mutwo import music_parameters
>>> music_parameters.abc.Volume.amplitude_ratio_to_decibel(1)
0.0
>>> music_parameters.abc.Volume.amplitude_ratio_to_decibel(0)
-inf
>>> music_parameters.abc.Volume.amplitude_ratio_to_decibel(0.5)
-6.020599913279624
static amplitude_ratio_to_midi_velocity(amplitude, reference_amplitude=1)[source]

Convert amplitude ratio to midi velocity.

Parameters:
  • amplitude (core_constants.Real) – The amplitude which shall be converted.

  • reference_amplitude (float | fractions.Fraction | int | quicktions.Fraction) – The amplitude for decibel == 0.

Returns:

The midi velocity.

Return type:

int

The method clips values that are higher than 1 / lower than 0.

Example:

>>> from mutwo import music_parameters
>>> music_parameters.abc.Volume.amplitude_ratio_to_midi_velocity(1)
127
>>> music_parameters.abc.Volume.amplitude_ratio_to_midi_velocity(0)
0
static decibel_to_amplitude_ratio(decibel, reference_amplitude=1)[source]

Convert decibel to amplitude ratio.

Parameters:
  • decibel (float | fractions.Fraction | int | quicktions.Fraction) – The decibel number that shall be converted.

  • reference_amplitude (float | fractions.Fraction | int | quicktions.Fraction) – The amplitude for decibel == 0.

Return type:

float

Example:

>>> from mutwo import music_parameters
>>> music_parameters.abc.Volume.decibel_to_amplitude_ratio(0)
1.0
>>> music_parameters.abc.Volume.decibel_to_amplitude_ratio(-6)
0.5011872336272722
>>> music_parameters.abc.Volume.decibel_to_amplitude_ratio(0, reference_amplitude=0.25)
0.25
static decibel_to_midi_velocity(decibel_to_convert, minimum_decibel=None, maximum_decibel=None)[source]

Convert decibel to midi velocity (0 to 127).

Parameters:
  • decibel (core_constants.Real) – The decibel value which shall be converted..

  • minimum_decibel (core_constants.Real, optional) – The decibel value which is equal to the lowest midi velocity (0).

  • maximum_decibel (core_constants.Real, optional) – The decibel value which is equal to the highest midi velocity (127).

  • decibel_to_convert (float | fractions.Fraction | int | quicktions.Fraction) –

Returns:

The midi velocity.

Return type:

int

The method clips values which are higher than ‘maximum_decibel’ and lower than ‘minimum_decibel’.

Example:

>>> from mutwo import music_parameters
>>> music_parameters.abc.Volume.decibel_to_midi_velocity(0)
127
>>> music_parameters.abc.Volume.decibel_to_midi_velocity(-40)
0
static decibel_to_power_ratio(decibel, reference_amplitude=1)[source]

Convert decibel to power ratio.

Parameters:
  • decibel (float | fractions.Fraction | int | quicktions.Fraction) – The decibel number that shall be converted.

  • reference_amplitude (float | fractions.Fraction | int | quicktions.Fraction) – The amplitude for decibel == 0.

Return type:

float

Example:

>>> from mutwo import music_parameters
>>> music_parameters.abc.Volume.decibel_to_power_ratio(0)
1.0
>>> music_parameters.abc.Volume.decibel_to_power_ratio(-6)
0.251188643150958
>>> music_parameters.abc.Volume.decibel_to_power_ratio(0, reference_amplitude=0.25)
0.25
classmethod from_any(object)[source]

Parse any object to Parameter.

Parameters:

object (Union[float, Fraction, int, Fraction, str, Volume]) – Object that is parsed to the parameter.

Raises:

core_utilities.CannotParseError in case the object can’t be parsed to the parameter type.

Return type:

Volume

This method is useful for allowing syntactic sugar.

static power_ratio_to_decibel(amplitude, reference_amplitude=1)[source]

Convert power ratio to decibel.

Parameters:
  • amplitude (float | fractions.Fraction | int | quicktions.Fraction) – The amplitude that shall be converted.

  • reference_amplitude (float | fractions.Fraction | int | quicktions.Fraction) – The amplitude for decibel == 0.

Return type:

float

Example:

>>> from mutwo import music_parameters
>>> music_parameters.abc.Volume.power_ratio_to_decibel(1)
0.0
>>> music_parameters.abc.Volume.power_ratio_to_decibel(0)
-inf
>>> music_parameters.abc.Volume.power_ratio_to_decibel(0.5)
-3.010299956639812
Type

Volume.Type hosts all types that are supported by the volume parser Volume.from_any().

alias of Union[float, Fraction, int, Fraction, str, Volume]

property amplitude: float | fractions.Fraction | int | quicktions.Fraction
abstract property decibel: value_return_type
property midi_velocity: int

The velocity of the volume (from 0 to 127).

class property value_name

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

mutwo.music_parameters.configurations.instruments

DEFAULT_BASSOON_DICT = {'name': 'bassoon', 'pitch_ambitus': OctaveAmbitus(WesternPitch('bf', 1), WesternPitch('ef', 5)), 'pitch_count_range': Range[1, 2), 'short_name': 'bs.', 'transposition_pitch_interval': WesternPitchInterval('p1')}

Default arguments for mutwo.music_parameters.Bassoon.

DEFAULT_BF_CLARINET_DICT = {'name': 'bf-clarinet', 'pitch_ambitus': OctaveAmbitus(WesternPitch('d', 3), WesternPitch('bf', 6)), 'pitch_count_range': Range[1, 2), 'short_name': 'bf-cl.', 'transposition_pitch_interval': WesternPitchInterval('m2')}

Default arguments for mutwo.music_parameters.BfClarinet.

DEFAULT_CELTIC_HARP_DICT = {'name': 'harp', 'pitch_count_range': Range[1, 8), 'pitch_tuple': (WesternPitch('c', 2), WesternPitch('d', 2), WesternPitch('e', 2), WesternPitch('f', 2), WesternPitch('g', 2), WesternPitch('a', 2), WesternPitch('b', 2), WesternPitch('c', 3), WesternPitch('d', 3), WesternPitch('e', 3), WesternPitch('f', 3), WesternPitch('g', 3), WesternPitch('a', 3), WesternPitch('b', 3), WesternPitch('c', 4), WesternPitch('d', 4), WesternPitch('e', 4), WesternPitch('f', 4), WesternPitch('g', 4), WesternPitch('a', 4), WesternPitch('b', 4), WesternPitch('bs', 4), WesternPitch('d', 5), WesternPitch('e', 5), WesternPitch('f', 5), WesternPitch('g', 5), WesternPitch('a', 5), WesternPitch('b', 5), WesternPitch('bs', 5), WesternPitch('d', 6), WesternPitch('e', 6), WesternPitch('f', 6), WesternPitch('g', 6), WesternPitch('a', 6), WesternPitch('b', 6)), 'short_name': 'hp.', 'transposition_pitch_interval': WesternPitchInterval('p1')}

Default arguments for mutwo.music_parameters.CelticHarp.

DEFAULT_EF_CLARINET_DICT = {'name': 'ef-clarinet', 'pitch_ambitus': OctaveAmbitus(WesternPitch('g', 3), WesternPitch('ef', 7)), 'pitch_count_range': Range[1, 2), 'short_name': 'ef-cl.', 'transposition_pitch_interval': WesternPitchInterval('m-3')}

Default arguments for mutwo.music_parameters.EfClarinet.

DEFAULT_FLUTE_DICT = {'name': 'flute', 'pitch_ambitus': OctaveAmbitus(WesternPitch('c', 4), WesternPitch('d', 7)), 'pitch_count_range': Range[1, 2), 'short_name': 'flt.', 'transposition_pitch_interval': WesternPitchInterval('p1')}

Default arguments for mutwo.music_parameters.Flute.

DEFAULT_OBOE_DICT = {'name': 'oboe', 'pitch_ambitus': OctaveAmbitus(WesternPitch('bf', 3), WesternPitch('a', 6)), 'pitch_count_range': Range[1, 2), 'short_name': 'ob.', 'transposition_pitch_interval': WesternPitchInterval('p1')}

Default arguments for mutwo.music_parameters.Oboe.

DEFAULT_PICCOLO_DICT = {'name': 'piccolo', 'pitch_ambitus': OctaveAmbitus(WesternPitch('d', 5), WesternPitch('c', 8)), 'pitch_count_range': Range[1, 2), 'short_name': 'pcl.', 'transposition_pitch_interval': WesternPitchInterval('p-8')}

Default arguments for mutwo.music_parameters.Piccolo.

mutwo.music_parameters.constants