pitch

Pitch functions.

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.pitch.pitches" { graph [label="abjad.pitch.pitches"]; node [color=1]; "abjad.pitch.pitches.Pitch" [label=Pitch]; } subgraph cluster_builtins { graph [label=builtins]; node [color=2]; "builtins.object" [URL="https://docs.python.org/3.7/library/functions.html#object", label=object, target=_top]; } subgraph "cluster_evans.pitch" { graph [label="evans.pitch"]; node [color=3]; "evans.pitch.JIPitch" [URL="../api/evans/pitch.html#evans.pitch.JIPitch", color=black, fontcolor=white, label=JIPitch, target=_top]; } "abjad.pitch.pitches.Pitch" -> "evans.pitch.JIPitch"; "builtins.object" -> "abjad.pitch.pitches.Pitch"; }


Classes

JIPitch

Just Intonation Pitch

class evans.pitch.JIPitch(fundamental, ratio, with_quarter_tones=False)[source]

Just Intonation Pitch

>>> pitch = evans.JIPitch("c'", "7/4", with_quarter_tones=True)
>>> note = abjad.Note(pitch, (1, 4))
>>> mark = abjad.Markup(
...     fr"\markup {str(pitch.deviation)}", direction=abjad.Up, literal=True
... )
>>> abjad.attach(mark, note)
>>> abjad.show(note)  
>>> pitch = evans.JIPitch("c'", "7/4", with_quarter_tones=False)
>>> note = abjad.Note(pitch, (1, 4))
>>> mark = abjad.Markup(
...     fr"\markup {str(pitch.deviation)}", direction=abjad.Up, literal=True
... )
>>> abjad.attach(mark, note)
>>> abjad.show(note)  

Attributes Summary

__add__

__lt__

Is true when pitch is less than argument.

__lte__

__mod__

__mul__

__str__

Return str(self).

__sub__

__truediv__

name

Gets name of pitch.

octave

Gets octave of pitch.

pitch_class

Gets pitch-class of pitch.


Special methods

__add__(argument)[source]
(Pitch).__eq__(argument)

Is true when all initialization values of Abjad value object equal the initialization values of argument.

Return type

bool

(Pitch).__float__()

Coerce to float.

Returns float.

(Pitch).__ge__(other, NotImplemented=NotImplemented)

Return a >= b. Computed by @total_ordering from (not a < b).

(Pitch).__gt__(other, NotImplemented=NotImplemented)

Return a > b. Computed by @total_ordering from (not a < b) and (a != b).

(Pitch).__hash__()

Hashes Abjad value object.

Return type

int

(Pitch).__le__(other, NotImplemented=NotImplemented)

Return a <= b. Computed by @total_ordering from (a < b) or (a == b).

overridden __lt__(argument)[source]

Is true when pitch is less than argument.

Returns true or false.

__lte__(argument)[source]
__mod__(argument)[source]
__mul__(argument)[source]
(Pitch).__repr__()

Gets interpreter representation.

Return type

str

overridden __str__()[source]

Return str(self).

__sub__(argument)[source]
__truediv__(argument)[source]

Methods

(Pitch).get_name(locale=None)

Gets name of pitch according to locale.

Returns string.

(Pitch).invert(axis=None)

Inverts pitch about axis.

Interprets axis of none equal to middle C.

Returns new pitch.

(Pitch).multiply(n=1)

Multiplies pitch by n.

Returns new pitch.

(Pitch).transpose(n)

Transposes pitch by index n.

Returns new pitch.


Class & static methods

classmethod (Pitch).from_hertz(hertz)

Creates pitch from hertz.

Returns new pitch.


Read-only properties

(Pitch).arrow

Gets arrow of pitch.

(Pitch).hertz

Gets frequency of pitch in Hertz.

Returns float.

overridden name
(Pitch).number

Gets number of pitch.

Returns number.

overridden octave
overridden pitch_class

Functions

combination_tones

herz_combination_tone_ratios

return_cent_markup

return_vertical_moment_ties

to_nearest_eighth_tone

Rounds number to nearest eighth

to_nearest_quarter_tone

Rounds number to nearest quarter

to_nearest_sixth_tone

Rounds number to nearest sixth

to_nearest_third_tone

Rounds number to nearest third

to_nearest_twelfth_tone

Rounds number to nearest twelfth

tonnetz

tune_to_ratio

Tunes pitch to ratio.

evans.pitch.combination_tones(pitches=[0, 5, 7], depth=1)[source]
>>> print(
...     evans.combination_tones(
...         pitches=[
...             8.25,
...             18.75,
...             23.5,
...         ],
...         depth=1,
...     )
... )
[-2.0, 6.0, 8.0, 14.5, 19.0, 23.5, 26.0, 29.5, 33.5]
>>> print(
...     evans.combination_tones(
...         pitches=[7.75, 19, 25.25, 28.5],
...         depth=1,
...     )
... )
[-1.0, 4.0, 6.0, 8.0, 13.5, 17.0, 19.0, 22.0, 25.0, 26.0, 28.5, 30.5, 33.0, 34.0, 36.5, 39.0]
evans.pitch.herz_combination_tone_ratios(fundamental=261.625565, pitches=[327.03195625, 392.43834749999996], depth=2)[source]
>>> print(
...     evans.herz_combination_tone_ratios(
...         fundamental=261.625565,
...         pitches=[327.03195625, 392.43834749999996],
...         depth=1,
...     )
... )
['4503599627370493/18014398509481984', '5/4', '3/2', '11/4']
evans.pitch.return_cent_markup(note_head, ratio, quarter_tones=False)[source]
evans.pitch.return_vertical_moment_ties(score)[source]
>>> staff_1 = abjad.Staff("c'4 c'2 c'4")
>>> staff_2 = abjad.Staff("cs'4 cs'4 cs'2")
>>> staff_3 = abjad.Staff("d'8 d'8 d'8 d'8 d'8 d'8 d'8 d'8")
>>> score = abjad.Score(
...     [
...         staff_1,
...         staff_2,
...         staff_3,
...     ]
... )
>>> for tie in evans.return_vertical_moment_ties(score):
...     tie
... 
LogicalTie([Note("d'8")])
LogicalTie([Note("c'4")])
LogicalTie([Note("cs'4")])
LogicalTie([Note("d'8")])
LogicalTie([Note("d'8")])
LogicalTie([Note("cs'4")])
LogicalTie([Note("c'2")])
LogicalTie([Note("d'8")])
LogicalTie([Note("d'8")])
LogicalTie([Note("cs'2")])
LogicalTie([Note("d'8")])
LogicalTie([Note("d'8")])
LogicalTie([Note("c'4")])
LogicalTie([Note("d'8")])
>>> staff_1 = abjad.Staff("c'4 c'2 c'4")
>>> staff_2 = abjad.Staff("cs'4 cs'4 cs'2")
>>> staff_3 = abjad.Staff("d'8 d'8 d'8 d'8 d'8 d'8 d'8 d'8")
>>> score = abjad.Score(
...     [
...         staff_1,
...         staff_2,
...         staff_3,
...     ]
... )
>>> handler = evans.PitchHandler(
...     pitch_list=[0, 1, 2, 3, 4],
...     forget=False,
...     to_ties=True,
... )
>>> vm_ties = evans.return_vertical_moment_ties(score)
>>> numbers = [_ for _ in range(len(vm_ties))]
>>> for i, tie in zip(numbers, vm_ties):
...     string = f"{i}"
...     markup = abjad.Markup(
...         fr"\markup {string}", direction=abjad.Up, literal=True
...     )
...     abjad.attach(markup, tie[0])
... 
>>> handler(vm_ties)
>>> moment = "#(ly:make-moment 1 25)"
>>> abjad.setting(score).proportional_notation_duration = moment
>>> file = abjad.LilyPondFile(
...     items=[score],
...     includes=["abjad.ily"],
...     global_staff_size=16,
... )
>>> abjad.show(file)  
>>> staff_1 = abjad.Staff("c'4 ~ c'2 c'4")
>>> staff_2 = abjad.Staff("cs'4 cs'4 cs'2")
>>> staff_3 = abjad.Staff("d'8 d'8 d'8 d'8 d'8 d'8 d'8 d'8")
>>> score = abjad.Score(
...     [
...         staff_1,
...         staff_2,
...         staff_3,
...     ]
... )
>>> handler = evans.PitchHandler(pitch_list=[0, 1, 2, 3, 4], forget=False)
>>> vm_ties = evans.return_vertical_moment_ties(score)
>>> numbers = [_ for _ in range(len(vm_ties))]
>>> for i, tie in zip(numbers, vm_ties):
...     string = f"{i}"
...     markup = abjad.Markup(
...         fr"\markup {string}", direction=abjad.Up, literal=True
...     )
...     abjad.attach(markup, tie[0])
...     handler(tie)
... 
>>> moment = "#(ly:make-moment 1 25)"
>>> abjad.setting(score).proportional_notation_duration = moment
>>> file = abjad.LilyPondFile(
...     items=[score],
...     includes=["abjad.ily"],
...     global_staff_size=16,
... )
>>> abjad.show(file)  
evans.pitch.to_nearest_eighth_tone(number, frac=False)[source]

Rounds number to nearest eighth

>>> l = [0, 1.111, 4.5, 2.23, 6.4, 7.3, 7.15]
>>> l = [evans.to_nearest_eighth_tone(_, frac=True) for _ in l]
>>> l
[Fraction(0, 1), Fraction(1, 1), Fraction(9, 2), Fraction(9, 4), Fraction(13, 2), Fraction(29, 4), Fraction(29, 4)]
evans.pitch.to_nearest_quarter_tone(number, frac=False)[source]

Rounds number to nearest quarter

>>> l = [0, 1.111, 4.5, 2.23, 6.4, 7.3, 7.15]
>>> l = [evans.to_nearest_quarter_tone(_, frac=True) for _ in l]
>>> l
[Fraction(0, 1), Fraction(1, 1), Fraction(9, 2), Fraction(2, 1), Fraction(13, 2), Fraction(7, 1), Fraction(7, 1)]
evans.pitch.to_nearest_sixth_tone(number)[source]

Rounds number to nearest sixth

>>> l = [0, 1.111, 4.5, 2.23, 6.4, 7.3, 7.15]
>>> l = [evans.to_nearest_sixth_tone(_) for _ in l]
>>> l
[Fraction(0, 1), Fraction(1, 1), Fraction(9, 2), Fraction(7, 3), Fraction(19, 3), Fraction(22, 3), Fraction(7, 1)]
evans.pitch.to_nearest_third_tone(number)[source]

Rounds number to nearest third

>>> l = [0, 1.111, 4.5, 2.23, 6.4, 7.3, 7.15]
>>> l = [evans.to_nearest_third_tone(_) for _ in l]
>>> l
[Fraction(0, 1), Fraction(1, 1), Fraction(14, 3), Fraction(2, 1), Fraction(20, 3), Fraction(22, 3), Fraction(7, 1)]
evans.pitch.to_nearest_twelfth_tone(number)[source]

Rounds number to nearest twelfth

>>> l = [0, 1.111, 4.5, 2.23, 6.4, 7.3, 7.15]
>>> l = [evans.to_nearest_twelfth_tone(_) for _ in l]
>>> l
[Fraction(0, 1), Fraction(7, 6), Fraction(9, 2), Fraction(9, 4), Fraction(19, 3), Fraction(22, 3), Fraction(43, 6)]
evans.pitch.tonnetz(chord, chord_quality, transforms)[source]
>>> source = ["1/1", "6/5", "3/2"]
>>> triads = evans.tonnetz(source, "minor", ["p", "l", "r"])
>>> for triad in triads:
...     print(triad)
... 
(1, 6/5, 3/2)
(1, 5/4, 3/2)
(5/4, 3/2, 15/8)
(3/2, 15/8, 9/8)
>>> source = ["1/1", "5/4", "3/2"]
>>> triads = evans.tonnetz(source, "major", ["p", "l", "r"])
>>> for triad in triads:
...     print(triad)
... 
(1, 5/4, 3/2)
(1, 6/5, 3/2)
(4/5, 1, 6/5)
(2/3, 4/5, 1)
>>> source = ["1/1", "12/7", "3/2"]
>>> triads = evans.tonnetz(source, "minor", ["p", "l7", "r7"])
>>> for triad in triads:
...     print(triad)
... 
(1, 12/7, 3/2)
(1, 7/8, 3/2)
(7/4, 3/2, 21/16)
(3/2, 21/16, 9/8)
>>> source = ["1/1", "7/4", "3/2"]
>>> triads = evans.tonnetz(source, "major", ["p", "l7", "r7"])
>>> for triad in triads:
...     print(triad)
... 
(1, 7/4, 3/2)
(1, 6/7, 3/2)
(4/7, 1, 6/7)
(2/3, 4/7, 1/2)
>>> source = ["1/1", "12/11", "3/2"]
>>> triads = evans.tonnetz(source, "minor", ["p", "l11", "r11"])
>>> for triad in triads:
...     print(triad)
... 
(1, 12/11, 3/2)
(1, 11/8, 3/2)
(11/8, 3/2, 33/32)
(3/2, 33/32, 9/8)
>>> source = ["1/1", "11/8", "3/2"]
>>> triads = evans.tonnetz(source, "major", ["p", "l11", "r11"])
>>> for triad in triads:
...     print(triad)
... 
(1, 11/8, 3/2)
(1, 12/11, 3/2)
(8/11, 1, 12/11)
(2/3, 8/11, 1)
>>> source = ["1/1", "24/13", "3/2"]
>>> triads = evans.tonnetz(source, "minor", ["p", "l13", "r13"])
>>> for triad in triads:
...     print(triad)
... 
(1, 24/13, 3/2)
(1, 13/16, 3/2)
(13/8, 3/2, 39/32)
(3/2, 39/32, 9/8)
>>> source = ["1/1", "13/8", "3/2"]
>>> triads = evans.tonnetz(source, "major", ["p", "l13", "r13"])
>>> for triad in triads:
...     print(triad)
... 
(1, 13/8, 3/2)
(1, 12/13, 3/2)
(8/13, 1, 12/13)
(2/3, 8/13, 1/2)
>>> source = ["1/1", "24/17", "3/2"]
>>> triads = evans.tonnetz(source, "minor", ["p", "l17", "r17"])
>>> for triad in triads:
...     print(triad)
... 
(1, 24/17, 3/2)
(1, 17/16, 3/2)
(17/16, 3/2, 51/32)
(3/2, 51/32, 9/8)
>>> source = ["1/1", "17/16", "3/2"]
>>> triads = evans.tonnetz(source, "major", ["p", "l17", "r17"])
>>> for triad in triads:
...     print(triad)
... 
(1, 17/16, 3/2)
(1, 24/17, 3/2)
(16/17, 1, 24/17)
(2/3, 16/17, 1)
>>> source = ["1/1", "24/19", "3/2"]
>>> triads = evans.tonnetz(source, "minor", ["p", "l19", "r19"])
>>> for triad in triads:
...     print(triad)
... 
(1, 24/19, 3/2)
(1, 19/16, 3/2)
(19/16, 3/2, 57/32)
(3/2, 57/32, 9/8)
>>> source = ["1/1", "19/16", "3/2"]
>>> triads = evans.tonnetz(source, "major", ["p", "l19", "r19"])
>>> for triad in triads:
...     print(triad)
... 
(1, 19/16, 3/2)
(1, 24/19, 3/2)
(16/19, 1, 24/19)
(2/3, 16/19, 1)
>>> source = ["1/1", "24/23", "3/2"]
>>> triads = evans.tonnetz(source, "minor", ["p", "l23", "r23"])
>>> for triad in triads:
...     print(triad)
... 
(1, 24/23, 3/2)
(1, 23/16, 3/2)
(23/16, 3/2, 69/64)
(3/2, 69/64, 9/8)
>>> source = ["1/1", "23/16", "3/2"]
>>> triads = evans.tonnetz(source, "major", ["p", "l23", "r23"])
>>> for triad in triads:
...     print(triad)
... 
(1, 23/16, 3/2)
(1, 24/23, 3/2)
(16/23, 1, 24/23)
(2/3, 16/23, 1)
evans.pitch.tune_to_ratio(note_head, ratio, quarter_tones=False)[source]

Tunes pitch to ratio.