Set class package API documentation¶
This module implements utilities for set classes
- xenharmlib.setc.compact_forte(scale: ScaleT) ScaleT¶
A generalization of the
nf_forte()methodReturns a rotation of this scale with minimal interval size from first to last note and the new root element sitting in the first base interval.
If there is more than one rotation having minimal span the tie is broken according to the procedure described by Alan Forte:
For each pair of scales compare the interval from the root to the element at scale position index k, counting upwards, i.e. comparing the intervals between the root element (position 0) and the element at 1, then 2, then 3, etc. On the first interval that differs between the first and the second scale, break the tie in favor of the scale with the smaller interval (the scale in which intervals are more “tightly packed to the left”)
In case of an absolute tie, in which multiple scales have perfectly same uniform distance (for example the whole tone scale), the scale with the lowest pitch class index as root is chosen.
- xenharmlib.setc.compact_rahn(scale: ScaleT) ScaleT¶
A generalization of the
nf_rahn()methodReturns a rotation of this scale with minimal interval size from first to last note and the new root element sitting in the first base interval.
If there is more than one rotation having minimal span the tie is broken according to the procedure described by John Rahn:
For each pair of scales compare the interval from the root to the element at scale position index 0 < k < n, counting downwards, i.e. comparing the intervals between the root element (position 0) and the element at (n - 1), then (n - 2), then (n - 3), etc. On the first interval that differs between the first and the second scale, break the tie in favor of the scale with the smaller interval (the scale in which intervals are more “tightly packed to the left”)
In case of an absolute tie, in which multiple scales have perfectly same uniform distance (for example the whole tone scale), the scale with the lowest pitch class index as root is chosen.
- xenharmlib.setc.nf_forte(scale: ScaleT) ScaleT¶
The normal form of the scale according to Alan Forte.
Returns a rotation of this scale with minimal interval size from first to last note and the new root element sitting in the first base interval.
If there is more than one rotation having minimal span the tie is broken according to the procedure described by Alan Forte:
For each pair of scales compare the interval from the root to the element at scale position index k, counting upwards, i.e. comparing the intervals between the root element (position 0) and the element at 1, then 2, then 3, etc. On the first interval that differs between the first and the second scale, break the tie in favor of the scale with the smaller interval (the scale in which intervals are more “tightly packed to the left”)
In case of an absolute tie, in which multiple scales have perfectly same uniform distance (for example the whole tone scale), the scale with the lowest pitch class index as root is chosen.
Period normalizes the scale and returns the rotation that is most compact and tightly packed to the left.
Note
A generalization of this method is implemented by the
compact_forte()method.
- xenharmlib.setc.nf_rahn(scale: ScaleT) ScaleT¶
The normal form of the scale according to John Rahn.
Returns a rotation of this scale with minimal interval size from first to last note and the new root element sitting in the first base interval.
If there is more than one rotation having minimal span the tie is broken according to the procedure described by John Rahn:
For each pair of scales compare the interval from the root to the element at scale position index 0 < k < n, counting downwards, i.e. comparing the intervals between the root element (position 0) and the element at (n - 1), then (n - 2), then (n - 3), etc. On the first interval that differs between the first and the second scale, break the tie in favor of the scale with the smaller interval (the scale in which intervals are more “tightly packed to the left”)
In case of an absolute tie, in which multiple scales have perfectly same uniform distance (for example the whole tone scale), the scale with the lowest pitch class index as root is chosen.
- xenharmlib.setc.primeform_forte(scale: ScaleT) ScaleT¶
The prime form of the scale according to Alan Forte’s method.
Transforms the scale by first calculating its normal form, then zero-normalizing it to receive the first candidate, then inverting the first candidate and putting the result in normal order, then zero normalizing it to receive the second candidate.
The tie between the two candidates is then broken according to the procedure described by Alan Forte:
For each pair of scales compare the interval from the root to the element at scale position index k, counting upwards, i.e. comparing the intervals between the root element (position 0) and the element at 1, then 2, then 3, etc. On the first interval that differs between the first and the second scale, break the tie in favor of the scale with the smaller interval.
- Parameters:
scale – The input scale
- xenharmlib.setc.primeform_rahn(scale: ScaleT) ScaleT¶
The prime form of the scale according to John Rahn’s method.
Transforms the scale by first calculating its normal form, then zero-normalizing it to receive the first candidate, then inverting the first candidate and putting the result in normal order, then zero normalizing it to receive the second candidate.
The tie between the two candidates is then broken according to the procedure described by John Rahn:
For each pair of scales compare the interval from the root to the element at scale position index 0 < k < n, counting downwards, i.e. comparing the intervals between the root element (position 0) and the element at (n - 1), then (n - 2), then (n - 3), etc. On the first interval that differs between the first and the second scale, break the tie in favor of the scale with the smaller interval.
- Parameters:
scale – The input scale