music.PlainChanges¶
- class music.PlainChanges(nelements=4, nhunts=None, hunts=None)[source]¶
Bases:
objectPresents plain changes as swaps and acts in domains to make peals.
Examples
>>> peal = PlainChanges(4) >>> len(peal.peal_direct) # every permutation of four bells, once 24 >>> rows = peal.act([220, 275, 330, 440]) >>> len(rows), len(rows[0]) (24, 4) >>> notes = [note(freq, duration=0.15) for row in rows for freq in row] >>> write_wav_mono(horizontal_stack(*notes), "peal.wav")
- __init__(nelements=4, nhunts=None, hunts=None)[source]¶
Initializes a PlainChanges object.
- Parameters:
- nelements
int,optional The number of elements. Defaults to 4.
- nhunts
int,optional The number of hunts. Defaults to
saturating_hunts(), which rings every row once.- hunts
dict,optional Not read. It was meant for hunts that start somewhere other than the lead, which was never implemented, and was always replaced by the layout nhunts gives. Passing it warns.
- nelements
- Raises:
ValueErrorIf there are fewer than two elements, or the number of hunts is negative or not fewer than the elements.
Methods
__init__([nelements, nhunts, hunts])Initializes a PlainChanges object.
act([domain, peal])Acts in a domain using a peal.
act_all([domain])Acts in all peals using a domain.
initialize_hunts([nelements, nhunts])Initializes the hunts dictionary.
perform_change(nelements, hunts[, hunt])Performs a change procedure.
perform_peal(nelements[, hunts])Performs a peal.
saturating_hunts(nelements)Number of hunts that yields a peal over the whole symmetric group.
Attributes
- static saturating_hunts(nelements)[source]¶
Number of hunts that yields a peal over the whole symmetric group.
For
nelementsbells this isnelements - 3, floored at one. Below it the peal is a proper subset of the permutations: with the old default of two hunts,PlainChanges(6)produced 120 of the 720 rows andPlainChanges(8)produced 224 of 40320. Above it nothing is gained, which is what the warning in initialize_hunts reports.
- initialize_hunts(nelements=4, nhunts=None)[source]¶
Initializes the hunts dictionary.
- Parameters:
- Returns:
dictThe hunts dictionary.
- Raises:
ValueErrorIf there are fewer than two elements, or the number of hunts is negative or not fewer than the elements. A change swaps two bells, so one bell has none: it failed with an
IndexErrorlooking for its swap, and a negative number of hunts with aKeyErrorlooking for the first. As many hunts as bells leave the last hunt no bell to pass, and failed with anIndexErrortoo, though only more than that was refused.