Notation API documentation¶
UpDownNotation¶
- class xenharmlib.notation.updown.DownwardsEnharmStrategy(notation)¶
The “downwards enharmonic strategy” is a pitch class blueprint strategy that tries to guess notes from pitches as follows:
Create a partial scale with all the natural notes
Into the resulting gaps (if any) add flats from the right bordering note, if the sharpness of the EDO > 0, or from the left bordering note if the sharpness of the EDO < 0. If sharpness = 0 this step will be omitted
Into the leftover gaps add down arrows from the right bordering notes
- class xenharmlib.notation.updown.MixedLeftEnharmStrategy(notation)¶
The “mixed left enharmonic strategy” is a pitch class blueprint strategy that tries to guess notes from pitches as follows:
Create an partial scale with all the natural notes
In the resulting gaps (if any) add sharps/flats from the bordering naturals in an alternating fashion, starting from the left bordering note. If the EDO is perfect this step will be omitted.
In the leftover gaps add ups/downs from the bordering notes in an alternating fashion, starting from the left bordering note.
Since gaps are filled from the left a tie in the middle of gaps will be resolved in the favor of sharps (or, in the special case of superflat EDOs, flats) and ups.
This is the default strategy for UpDownNotation
- class xenharmlib.notation.updown.MixedRightEnharmStrategy(notation)¶
The “mixed right enharmonic strategy” is a pitch class blueprint strategy that tries to guess notes from pitches as follows:
Create an partial scale with all the natural notes
In the resulting gaps (if any) add sharps/flats from the bordering naturals in an alternating fashion, starting from the right bordering note. If the EDO is perfect this step will be omitted.
In the leftover gaps add ups/downs from the bordering notes in an alternating fashion, starting from the right bordering note.
Since gaps are filled from the right a tie in the middle of gaps will be resolved in the favor of flats (or, in the special case of superflat EDOs, sharps) and downs.
- class xenharmlib.notation.updown.UpDownEnharmStrategy(pc_blueprint: Sequence[PeriodicNoteABC])¶
Base class for all enharmonic strategies for UpDownNotation. Implements a collection of helper methods.
- static down_fillers(start_note, end_note)¶
Generator that yields all downed notes between the given bordering notes.
- Parameters:
start_note – The left bordering note
end_note – The right bordering note
- static flat_fillers(start_note, end_note)¶
Generator that yields all flattened notes between the given bordering notes.
- Parameters:
start_note – The left bordering note
end_note – The right bordering note
- static sharp_fillers(start_note, end_note)¶
Generator that yields all sharpened notes between the given bordering notes.
- Parameters:
start_note – The left bordering note
end_note – The right bordering note
- static up_fillers(start_note, end_note)¶
Generator that yields all upped notes between the given bordering notes.
- Parameters:
start_note – The left bordering note
end_note – The right bordering note
- class xenharmlib.notation.updown.UpDownNotation(tuning, note_cls=<class 'xenharmlib.notation.updown.UpDownNote'>, note_interval_cls=<class 'xenharmlib.notation.updown.UpDownNoteInterval'>, note_scale_cls=<class 'xenharmlib.notation.updown.UpDownNoteScale'>, note_interval_seq_cls=<class 'xenharmlib.notation.updown.UpDownNoteIntervalSeq'>)¶
UpDownNotation is an implementation of Kite Giedraitis’ classic ups/down notation for EDOs 5-72. It differs from the paper in a couple of minor ways:
EDOs for which the paper does recommend subnotation are not generated by subnotation in this implementation. The class is a ‘pure’ implementation of the system, that does not resort to heuristics even if the pure implementation is unfitting for a specific EDO. In the future xenharmlib will provide a more generic subnotation wrapper class to make subnotation of trivial EDOs (like 2, 3, 4, 6) or special EDOs like 8-EDO possible.
EDOs that are only mentioned in the variant of a flattened fifth (like 13b, 18b) are calculated in their sharp variant if EDOTuning is used. In order to generate a notation for the flattened variant you have to use the EDOBTuning class which uses the second best fifth as it’s designated fifth.
In interval naming the mid symbol (~) and related symbols (like ^~, v~) are not implemented, because they introduce ambigouity when transposing notes (There is e.g. no strict definition whether in 31-EDO C0 transposed by ~3 results in the note vE or ^Em)
- property edo_category: str¶
Returns the category of this EDO (‘trivial’, ‘pentatonic’, ‘supersharp’, ‘superflat’, ‘perfect’ or ‘diatonic’)
trivial EDOs are subsets of 12-EDO (EDOs 2, 3, 4, 6)
diatonic EDOs have a minor second interval that is smaller than the major second interval (like 12-EDO)
in perfect EDOs minor second and major second are identical (these EDOs do not have sharps or flats)
pentatonic EDOs have a zero-size minor second interval (F=E, B=C)
supsharp EDOs have a negative minor second interval
superflat EDOs have a minor second interval that is bigger than the major second interval
- gen_pc_symbol(nat_index: int, acc_vector: Tuple[int, ...]) Tuple[str, str, str]¶
Creates a pitch class symbol from a natural class index and an accidental vector.
The method will return a tuple of 3 with the following semantics: * First element will be the pitch class symbol * Second element will be the natural class symbol * Third element will be the accidental symbol string
- Parameters:
natc_index – A natural class index of a note
acc_vector – An accidental value vector
- parse_pc_symbol(pc_symbol: str) Tuple[str, str, int, Tuple[int]]¶
Parses a pitch class symbol into its natural class symbol part and its accidental symbol part. Returns a 4-tuple (natc_symbol, acc_symbol, natc_index, acc_vactor) with the parsing result.
- class xenharmlib.notation.updown.UpDownNote(notation, frequency, pitch_index, nat_index: int, acc_vector: Tuple[int, ...], pc_symbol: str, natc_symbol: str, acc_symbol: str)¶
- class xenharmlib.notation.updown.UpDownNoteInterval(notation, frequency_ratio, pitch_diff, ref_note: NatAccNote, nat_diff: int, acc_vector: Tuple[int, ...], symbol: str, number: int)¶
- class xenharmlib.notation.updown.UpDownNoteIntervalSeq(notation, intervals: List[NoteIntervalT] | None = None)¶
- class xenharmlib.notation.updown.UpDownNoteScale(notation, notes=None)¶
- class xenharmlib.notation.updown.UpwardsEnharmStrategy(notation)¶
The “upwards enharmonic strategy” is a pitch class blueprint strategy that tries to guess notes from pitches as follows:
Create a partial scale with all the natural notes
Into the resulting gaps (if any) add sharps from the left bordering note, if the sharpness of the EDO > 0, or from the right bordering note if the sharpness of the EDO < 0. If sharpness = 0 this step will be omitted
Into the leftover gaps add up arrows from the left bordering notes
WesternNotation¶
- class xenharmlib.notation.western.FlatEnharmStrategy(notation)¶
- class xenharmlib.notation.western.SharpEnharmStrategy(notation)¶
- class xenharmlib.notation.western.WesternNotation(note_cls=<class 'xenharmlib.notation.western.WesternNote'>, note_interval_cls=<class 'xenharmlib.notation.western.WesternNoteInterval'>, note_scale_cls=<class 'xenharmlib.notation.western.WesternNoteScale'>, note_interval_seq_cls=<class 'xenharmlib.notation.western.WesternNoteIntervalSeq'>)¶
WesternNotation is an implementation of the contemporary western notation (12 notes per octave, equally tempered, A4 set to 440Hz, interval system with perfect and imperfect interval qualities, etc)
- class xenharmlib.notation.western.WesternNote(notation, frequency, pitch_index, nat_index: int, acc_vector: Tuple[int, ...], pc_symbol: str, natc_symbol: str, acc_symbol: str)¶
- class xenharmlib.notation.western.WesternNoteInterval(notation, frequency_ratio, pitch_diff, ref_note: NatAccNote, nat_diff: int, acc_vector: Tuple[int, ...], symbol: str, number: int)¶
- class xenharmlib.notation.western.WesternNoteIntervalSeq(notation, intervals: List[NoteIntervalT] | None = None)¶
- class xenharmlib.notation.western.WesternNoteScale(notation, notes=None)¶