Code

Random Pitch-Class Set


Below you will find a randomly-selected set class and its prime form (and alternate prime form if applicable), interval vector (and Z partner if applicable), interval string (the distance in semitones between each adjacent pitch class), degrees of symmetry (the number of transposition and inversion indexes at which this set class maps to itself), and index vector (the number of pitch classes held invariant at each inversional index from 0–11). This is very similar to the random pitch-class set of the day generated by my PitchClassSetBot except that this script randomly selects a set class rather than an individual pitch-class set and does so each time the page is refreshed rather than once a day.


Normal Order Finder


This script iterates through all the rotations of the given set and searches for the rotation that is most packed "to the left" and returns that rotation.


Prime Form Finder


This script iterates through all the rotations of the given set and searches through a list of prime forms to find the one that matches. It then returns the Forte number for this set.


Interval Vector


This script finds the interval vector of any pitch-class set. The user provides a pitch-class set, and the script then measures the distance from every element in the pitch-class set to every element in the pitch-class set and tallies these results into six interval classes (where 1 and 11 half steps = IC1, 2 and 10 = IC2, etc.). The script then returns the total number of each interval class as an ordered sextuple where position one equals the number of times inverval class one occurs, position two equals the number of times interval class two occurs, etc.


Find Relation


This script uses the transposition, inversion, and interval vector scripts to see if two given pitch-class sets map onto each other under any transposition or inversion, or if they are Z-related (share the same interval vector).


Transposition


This is a pitch-class set transposer. The user provides a pitch-class set and a transposition value (n) between 0 and 11 (number of half steps) and the script returns the pitch-class set transposed n half steps heigher.


Inversion


This is a pitch-class set inverter. The user provides a pitch-class set and an inversional axis between 0 and 11 and the script returns the pitch-class set inverted around the axis provided.


Characteristic Function


This script looks through the given pitch-class set to see which of the twelve pitch classes are present. It outupts these results as a binary value (1 = present, 0 = absent) for each pitch class in the format: 0, 1, 2, etc.


Degrees of Symmetry


This script tallies the total number of transposition and inversion values at which a given pitch-class set maps onto itself and outputs these values as a ordered pair (transposition, inversion). The transposition value is always at least 1 because all pitch class-sets map unto themselves at T0.


Index Vector


This script calculates the number of pitch-classes that are held invariant at each inversional axis (0–11) and outputs this information as twelve values where the value at position one indicates the number of pitch classes held invariant around the axis of 0, the value at position two indicates the number of pitch classes held invariant around the axis of 1, etc. Any value that is equal to the cardinality of the given pitch-class set indicates an axis at which the pitch-class set will map onto itself.


Interval String


This script calculates the dsitance in half steps between each consecutive member of the given pitch-class set.


Aural Skills Bookkeeping


This script can be used in an aural-skills class to take attendance, randomly choose students to perform rhythm and melodic exercises, and record students' scores for their performances. Once again, due to the constraints of embedded Python scripts, this information is simply printed to the terminal, but it can be modified to actually write to a file and retrieve this information when it is run locally.


Dice Roller


This is a simple dice rolling game. The user is asked to input the number of dice to be thrown (which we will call x) and the number of sides on each of these dice (which we will call y). The script then generates x random integers between one and y + 1 (so as to be inclusive) and saves these integers in an array. The array and the sum of all the integers in the array are then outputted to the user.


Password Generator


This script allows you to generate random, highly secure passwords and save them for future reference. Due to the constraints of embedded Python code, saved passwords are erased after the program is quit. If you run the program locally on your own computer, however, Python's Pickle module can be used to save this data to a file and allow you to retrieve it later.


Contact


Please feel free to contact me at the email address below with any bugs you find on this site, questions you might have, or with inquiries about private lessons in music theory, composition, or guitar.