ji

Package for Just Intonation.

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_abjadext.microtones.ji" { graph [label="abjadext.microtones.ji"]; node [color=1]; "abjadext.microtones.ji.JIBundle" [URL="../api/abjadext/microtones/ji.html#abjadext.microtones.ji.JIBundle", color=black, fontcolor=white, label=JIBundle, target=_top]; "abjadext.microtones.ji.JIVector" [URL="../api/abjadext/microtones/ji.html#abjadext.microtones.ji.JIVector", color=black, fontcolor=white, label=JIVector, target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=2]; "builtins.object" [URL="https://docs.python.org/3.7/library/functions.html#object", color=2, label=object, target=_top]; } "builtins.object" -> "abjadext.microtones.ji.JIBundle" [minlen=1]; "builtins.object" -> "abjadext.microtones.ji.JIVector" [minlen=2]; }


Classes

JIBundle

JI bundle.

JIVector

JI vector.

class abjadext.microtones.ji.JIBundle(pitch="c'", vector=JIVector(diatonic_accidental='natural', syntonic_commas_down=0, syntonic_commas_up=0, septimal_commas_down=0, septimal_commas_up=0, undecimal_quarter_tones_down=0, undecimal_quarter_tones_up=0, tridecimal_third_tones_down=0, tridecimal_third_tones_up=0, seventeen_limit_schismas_down=0, seventeen_limit_schismas_up=0, nineteen_limit_schismas_down=0, nineteen_limit_schismas_up=0, twenty_three_limit_commas_down=0, twenty_three_limit_commas_up=0))[source]

JI bundle.

>>> bundle = microtones.JIBundle()
>>> bundle.pitch
"c'"
>>> print(abjad.storage(bundle.vector))
microtones.JIVector(
    diatonic_accidental='natural',
    syntonic_commas_down=0,
    syntonic_commas_up=0,
    septimal_commas_down=0,
    septimal_commas_up=0,
    undecimal_quarter_tones_down=0,
    undecimal_quarter_tones_up=0,
    tridecimal_third_tones_down=0,
    tridecimal_third_tones_up=0,
    seventeen_limit_schismas_down=0,
    seventeen_limit_schismas_up=0,
    nineteen_limit_schismas_down=0,
    nineteen_limit_schismas_up=0,
    twenty_three_limit_commas_down=0,
    twenty_three_limit_commas_up=0,
    )

Attributes Summary

__repr__

Gets interpreter representation.


Special methods

overridden __repr__()[source]

Gets interpreter representation.

>>> microtones.JIBundle()
JIBundle(pitch="c'", vector=JIVector(diatonic_accidental='natural', syntonic_commas_down=0, syntonic_commas_up=0, septimal_commas_down=0, septimal_commas_up=0, undecimal_quarter_tones_down=0, undecimal_quarter_tones_up=0, tridecimal_third_tones_down=0, tridecimal_third_tones_up=0, seventeen_limit_schismas_down=0, seventeen_limit_schismas_up=0, nineteen_limit_schismas_down=0, nineteen_limit_schismas_up=0, twenty_three_limit_commas_down=0, twenty_three_limit_commas_up=0))
class abjadext.microtones.ji.JIVector(diatonic_accidental='natural', syntonic_commas_down=0, syntonic_commas_up=0, septimal_commas_down=0, septimal_commas_up=0, undecimal_quarter_tones_down=0, undecimal_quarter_tones_up=0, tridecimal_third_tones_down=0, tridecimal_third_tones_up=0, seventeen_limit_schismas_down=0, seventeen_limit_schismas_up=0, nineteen_limit_schismas_down=0, nineteen_limit_schismas_up=0, twenty_three_limit_commas_down=0, twenty_three_limit_commas_up=0)[source]

JI vector.

>>> from abjadext import microtones
>>> vector = microtones.JIVector(syntonic_commas_down=2)
>>> vector.syntonic_commas_down
2
>>> vector = microtones.JIVector(syntonic_commas_down=2)
>>> vector.syntonic_commas_up
0

Attributes Summary

__repr__

Gets interpreter representation.

calculate_ji_markup

Calculates JI markup.

has_just_accidentals

Is true when vector has just accidentals.


Special methods

overridden __repr__()[source]

Gets interpreter representation.

>>> microtones.JIVector()
JIVector(diatonic_accidental='natural', syntonic_commas_down=0, syntonic_commas_up=0, septimal_commas_down=0, septimal_commas_up=0, undecimal_quarter_tones_down=0, undecimal_quarter_tones_up=0, tridecimal_third_tones_down=0, tridecimal_third_tones_up=0, seventeen_limit_schismas_down=0, seventeen_limit_schismas_up=0, nineteen_limit_schismas_down=0, nineteen_limit_schismas_up=0, twenty_three_limit_commas_down=0, twenty_three_limit_commas_up=0)

Methods

calculate_ji_markup()[source]

Calculates JI markup.

>>> vector = microtones.JIVector(syntonic_commas_down=1)
>>> print(abjad.lilypond(vector.calculate_ji_markup()))
\markup { \natural-one-syntonic-comma-down  }
has_just_accidentals()[source]

Is true when vector has just accidentals.

>>> vector = microtones.JIVector()
>>> vector.has_just_accidentals()
False
>>> vector = microtones.JIVector(syntonic_commas_down=1)
>>> vector.has_just_accidentals()
True

Functions

make_ji_bundle

Makes JI bundle.

return_cent_deviation_markup

tune_to_ratio

Transposes notehead in place and tweaks accidental stencil.

abjadext.microtones.ji.make_ji_bundle(pitch, ratio)[source]

Makes JI bundle.

>>> bundle = microtones.make_ji_bundle(abjad.NamedPitch("c'"), "3/2")
>>> bundle.pitch
NamedPitch("g'")
>>> print(abjad.storage(bundle.vector))
microtones.JIVector(
    diatonic_accidental='natural',
    syntonic_commas_down=0,
    syntonic_commas_up=0,
    septimal_commas_down=0,
    septimal_commas_up=0,
    undecimal_quarter_tones_down=0,
    undecimal_quarter_tones_up=0,
    tridecimal_third_tones_down=0,
    tridecimal_third_tones_up=0,
    seventeen_limit_schismas_down=0,
    seventeen_limit_schismas_up=0,
    nineteen_limit_schismas_down=0,
    nineteen_limit_schismas_up=0,
    twenty_three_limit_commas_down=0,
    twenty_three_limit_commas_up=0,
    )
abjadext.microtones.ji.return_cent_deviation_markup(ratio=1, fundamental="a'", chris=False)[source]
abjadext.microtones.ji.tune_to_ratio(note_head, ratio, *, omit_just_accidental=False, tempered=False)[source]

Transposes notehead in place and tweaks accidental stencil.

All implemented accidentals are available for both stylesheets:

>>> note = abjad.Note("c'4")
>>> microtones.tune_to_ratio(note.note_head, "7/4")
>>> staff = abjad.Staff([note])
>>> score = abjad.Score([staff])
>>> moment = "#(ly:make-moment 1 25)"
>>> abjad.setting(score).proportional_notation_duration = moment
>>> lilypond_file = abjad.LilyPondFile(
...     items=[score, abjad.Block(name="layout")],
...     includes=["default.ily", "ekmelos-ji-accidental-markups.ily"],
...     global_staff_size=16,
... )
>>> style = '"dodecaphonic"'
>>> lilypond_file.layout_block.items.append(fr"\accidentalStyle {style}")
>>> abjad.show(lilypond_file)  
>>> note = abjad.Note("c'4")
>>> microtones.tune_to_ratio(note.note_head, "7/4")
>>> staff = abjad.Staff([note])
>>> score = abjad.Score([staff])
>>> moment = "#(ly:make-moment 1 25)"
>>> abjad.setting(score).proportional_notation_duration = moment
>>> lilypond_file = abjad.LilyPondFile(
...     items=[score, abjad.Block(name="layout")],
...     includes=["default.ily", "heji2-ji-accidental-markups.ily"],
...     global_staff_size=16,
... )
>>> style = '"dodecaphonic"'
>>> lilypond_file.layout_block.items.append(fr"\accidentalStyle {style}")
>>> abjad.show(lilypond_file)  

Tweaks accidentals when omit_just_accidental=False:

>>> note = abjad.Note("c'4")
>>> microtones.tune_to_ratio(note.note_head, "5/1", omit_just_accidental=False)
>>> print(abjad.lilypond(note))  
\tweak Accidental.stencil #ly:text-interface::print
\tweak Accidental.text \markup { \natural-one-syntonic-comma-down  }
e'''4

Does not tweak accidentals when omit_just_accidental=True:

>>> note = abjad.Note("c'4")
>>> microtones.tune_to_ratio(note.note_head, "5/1", omit_just_accidental=True)
>>> print(abjad.lilypond(note))  
e'''4

A harmonic series with the ekmelos font.

>>> ratios = [f"{_ + 1}/1" for _ in range(23)]
>>> notes = [abjad.Note("a,,,8") for _ in ratios]
>>> for note, ratio in zip(notes, ratios):
...     microtones.tune_to_ratio(note.note_head, ratio)
... 
>>> staff = abjad.Staff()
>>> staff.extend(notes)
>>> abjad.attach(abjad.Clef("bass"), staff[0])
>>> abjad.attach(abjad.Clef("treble"), staff[6])
>>> score = abjad.Score([staff])
>>> moment = "#(ly:make-moment 1 25)"
>>> abjad.setting(score).proportional_notation_duration = moment
>>> lilypond_file = abjad.LilyPondFile(
...     items=[score, abjad.Block(name="layout")],
...     includes=[
...         "default.ily",
...         "harmonic-series-layout.ily",
...         "ekmelos-ji-accidental-markups.ily",
...     ],
...     global_staff_size=16,
... )
>>> style = '"dodecaphonic"'
>>> lilypond_file.layout_block.items.append(fr"\accidentalStyle {style}")
>>> abjad.show(lilypond_file)  

A harmonic series with the HEJI2 font.

>>> ratios = [f"{_ + 1}/1" for _ in range(23)]
>>> notes = [abjad.Note("a,,,8") for _ in ratios]
>>> for note, ratio in zip(notes, ratios):
...     microtones.tune_to_ratio(note.note_head, ratio)
... 
>>> staff = abjad.Staff()
>>> staff.extend(notes)
>>> abjad.attach(abjad.Clef("bass"), staff[0])
>>> abjad.attach(abjad.Clef("treble"), staff[6])
>>> abjad.attach(abjad.TimeSignature((24, 32)), staff[0])
>>> score = abjad.Score([staff])
>>> moment = "#(ly:make-moment 1 25)"
>>> abjad.setting(score).proportional_notation_duration = moment
>>> lilypond_file = abjad.LilyPondFile(
...     items=[score, abjad.Block(name="layout")],
...     includes=[
...         "default.ily",
...         "harmonic-series-layout.ily",
...         "heji2-ji-accidental-markups.ily",
...     ],
...     global_staff_size=16,
... )
>>> style = '"dodecaphonic"'
>>> lilypond_file.layout_block.items.append(fr"\accidentalStyle {style}")
>>> abjad.show(lilypond_file)  

Prints tempered accidentals when tempered=True:

>>> note = abjad.Note("c'4")
>>> microtones.tune_to_ratio(note.note_head, "5/1", tempered=True)
>>> staff = abjad.Staff([note])
>>> score = abjad.Score([staff])
>>> moment = "#(ly:make-moment 1 25)"
>>> abjad.setting(score).proportional_notation_duration = moment
>>> lilypond_file = abjad.LilyPondFile(
...     items=[score, abjad.Block(name="layout")],
...     includes=["default.ily", "ekmelos-ji-accidental-markups.ily"],
...     global_staff_size=16,
... )
>>> style = '"dodecaphonic"'
>>> lilypond_file.layout_block.items.append(fr"\accidentalStyle {style}")
>>> abjad.show(lilypond_file)