コード例 #1
0
ファイル: setbase.py プロジェクト: calebsmith/Sator
 def fromint(integer, modulus=12):
     """
     Static method that returns a PCSet object with pc's generated from
     their integer representation.
         Ex:
             0 = [], 1 = [0], 2 = [1], 3 = [0, 1], 4 = [2], 5 = [0, 2]
             PCSet.fromint(5) returns PCSet([0, 2])
     """
     from sator.pcset import PCSet
     new_set = PCSet(mod=modulus)
     new_set.pitches = utils.fromint(integer)
     return new_set
コード例 #2
0
ファイル: setbase.py プロジェクト: calebsmith/Sator
 def forte_name(fname):
     """
     A static method that returns a PCSet object with the fort-name provided
     as a string argument.
     Returns an empty PCSet if the argument is not a string with a valid
     Forte name.
     """
     from sator.pcset import PCSet
     fset = utils.from_forte(fname)
     new_set = PCSet()
     if fset:
         new_set.pitches = fset
     return new_set
コード例 #3
0
ファイル: setbase.py プロジェクト: calebsmith/Sator
 def m_vector(self, m):
     """
     Find David Lewin's M-vector.
     (Also described in Composition with Pitch Classes - Robert Morris)
     Finds the number of each set-class with cardinality m which are
     subsets of a given pitch class. The ICV is equivalent to the m-vector
     of a pitch class when m is 2.
     """
     if m > self._mod:
         return
     from sator.pcset import PCSet
     pc_set = self._pc_set
     vectors = {}
     for index, each in enumerate(self.__class__.each_card_in_mod(m, self._mod)):
         e_prime = each.pcint
         old_value = vectors.get(e_prime, 0)
         to_add = 1 if pc_set.issuperset(each._pc_set) else 0
         vectors[e_prime] = old_value + to_add
     return sorted([(PCSet.fromint(pcint), total) \
                    for pcint, total in vectors.items()],
                    key = lambda x: x[0].pcint)