bpsets: Bohlen-Pierce Pitch Class Sets for Python

Around nine months ago, I wrote a module called pcsets: Pitch Class Sets for Python. Since then, I've tried to improve it, but found it difficult to do so -- it seems like I actually got it right the first time. However, pcsets now has a derivative: I've adapted it to handle the base-13 Bohlen-Pierce scale.

To use this module:

1.

Find it on my pcsets download page. (Or download it via direct link to the zip file: bpsets-experimental-0.1.zip (22K).

2.

You can access it from Python in any of the traditional methods. After you unzip the archive, you can copy bpsets.py wherever you want. From that directory, if you enter Python interactive mode, you might try this:


Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bpsets
>>> dir(bpsets) # Lists available classes and functions
['DefinitionError', 'IllegalCharacter', 'NonIterableDef', 'NullOpSet', 'OpSet', 'OpSetError', 'PICKLE_FILE', 'PcSet', 'PcSetException', 'R0', 'R1', 'R1_or_R2', 'R2', 'Rp', 'Rp_path', 'Rp_prime', 'SetCatalog', 'Zpair', '__all__', '__builtins__', '__doc__', '__file__', '__metaclass__', '__name__', 'all_possible_pcsets', 'any_match', 'binaryvalue', 'common', 'exact_equality', 'fit_in', 'harmonize', 'is_complement', 'is_prime_complement', 'moderate', 'op_path', 'pickle', 'prime_subset_of', 'rel_Tn', 'rel_TnI', 'same_prime', 'set_equality', 'showcatalog', 'subset_of', 'symmetry', 'union']
>>> u = bpsets.PcSet('07AC') # Sets can be defined as base-13 alphanumeric strings.
>>> print u
07AC
>>> print u.T(3) # transpose up 3
3A02
>>> print u.TnI(7) # inversion, then transposition by 7.
70A8
>>> print u.prime() # In prime form, just like that!
0136

Nice, huh? But watch this. I really knocked myself out with functions in the pcsets module. I came up with one called fit_in that will calculate all the possible ways a given pcset can be 'fit in' to a given superset. In this case: how many ways are there to fit the set 07AC (or, really, prime set 0136) into the Lambda scale?

>>> lambdascale = bpsets.PcSet('0234679AC')
>>> results = bpsets.fit_in(lambdascale,u)
>>> print results
T(0) T(3) T(10) T(3)I T(6)I T(9)I
>>>

And sure enough, you can check some of your results:


>>> print u.T(10)
A479
>>> print u.TnI(9)
92CA

3.

You can also generate the catalog of every possible prime set in the Bohlen-Pierce system (assuming equivalent intervals, which is not necessarily true for just intonation, but a fair approximation for compositional purposes). Merely run the module as a script with


python bpsets.py

and you'll see all 379 possible sets scroll by.

4.

Or, if you're merely curious at what such an alternate dimension looks like, just download the text file below, where I captured the catalog output.

AttachmentSize
bohlen-pierce-sets.txt3.55 KB