def __init__(self, principal_chord_template, secondary_scale_degree, secondary_modality): """ Constructor. Args: principal_chord_template: ChordTemplate for the numerator. secondary_scale_degree: (int) which scale degree 1 --> 6. secondary_modality: Modality for the denominator if specified (None if not specified). """ ChordTemplate.__init__(self) self.__principal_chord_template = principal_chord_template self.__secondary_scale_degree = secondary_scale_degree self.__secondary_modality = secondary_modality
def __init__(self, diatonic_basis, scale_degree, chord_type, tension_intervals, inversion, inversion_interval=None): """ Constructor Args: diatonic_basis: DiatonicTone used as root of chord, e.g. C major chord, the C part scale_degree: int version of roman numeral chord_type: The chord type ala TertianChordType tension_intervals: list of Interval's comprising the tensions inversion: int for which of the chord tones (ordinal) serves as root [origin 1] inversion_interval: if specified, indicates which interval should be the base. (both this in interval cannot be non-null.) """ ChordTemplate.__init__(self) self.__diatonic_basis = diatonic_basis # DiatonicTone self.__scale_degree = scale_degree self.__chord_type = chord_type self.__tension_intervals = tension_intervals # list of [number, augmentation] representing intervals self.__inversion = inversion # which tone of n is the bass self.__inversion_interval = inversion_interval self.__base_intervals = [] if chord_type: self.__base_intervals.extend(TertianChordTemplate.TERTIAN_CHORD_TYPE_MAP[self.chord_type.value]) # Remove duplicate tensions seen = set() seen_add = seen.add deduped_tension_intervals = [tension for tension in self.tension_intervals if not (tension.semitones() in seen or seen_add(tension.semitones()))] self.__tension_intervals = deduped_tension_intervals # Inversion check - only if chord type was given, not for cases like II if self.chord_type and (self.inversion is not None) and \ self.inversion > len(self.base_intervals) + len(self.tension_intervals): raise Exception('Illegal inversion {0} for {1}'.format(self.inversion, self.__str__())) if self.inversion_interval is not None and \ self.inversion_interval not in self.base_intervals and \ self.inversion_interval not in self.tension_intervals: raise Exception('Illegal inversion_interval {0}'.format(self.inversion_interval))
def __init__(self, diatonic_basis, scale_degree, chord_type, specified_seconds, inversion): """ Constructor Args: diatonic_basis: DiatonicTone used as root of chord, e.g. C major chord, the C part scale_degree: int version of roman numeral chord_type: The chord type ala SecundalChordType specified_seconds: list of Interval's secondary notes inversion: int for which of the chord tones (ordinal) serves as root [origin 1] """ ChordTemplate.__init__(self) self.__diatonic_basis = diatonic_basis # DiatonicTone self.__scale_degree = scale_degree self.__chord_type = chord_type self.__inversion = inversion # which tone of n is the bass self.__base_intervals = list() if chord_type: self.__base_intervals.extend( SecundalChordTemplate.SECUNDAL_CHORD_TYPE_MAP[ chord_type.value]) self.__specified_seconds = specified_seconds if specified_seconds: intervals = list() intervals.append(Interval(1, IntervalType.Perfect)) for ltr in specified_seconds: intervals.append( Interval( 2, IntervalType.Major if ltr == 'M' else IntervalType.Minor)) self.__base_intervals.extend(intervals) # Inversion check - only if chord type was given, not for cases like II if self.chord_type and self.inversion > len(self.base_intervals): raise Exception('Illegal inversion {0} for {1}'.format( self.inversion, self.__str__()))
def __init__(self, diatonic_basis, scale_degree, chord_type, specified_fourths, inversion): """ Constructor Args: diatonic_basis: DiatonicTone used as root of chord, e.g. C major chord, the C part scale_degree: int version of roman numeral chord_type: The chord type ala SecundalChordType specified_fourths: list of incremental fourth Interval's comprising the chord, e.g. [p, P, P] usually used in lieu of, or addition to chord_type chord_type inversion: int for which of the chord tones (ordinal) serves as root [origin 1] """ ChordTemplate.__init__(self) self.__diatonic_basis = diatonic_basis # DiatonicTone self.__scale_degree = scale_degree self.__chord_type = chord_type self.__inversion = inversion # which tone of n is the bass self.__base_intervals = [] if chord_type: self.__base_intervals.extend( QuartalChordTemplate.QUARTAL_CHORD_TYPE_MAP[chord_type.value]) self.__specified_fourths = specified_fourths if specified_fourths: intervals = list() intervals.append(Interval(1, IntervalType.Perfect)) for ltr in specified_fourths: intervals.append( Interval( 4, IntervalType.Perfect if ltr == 'P' or ltr == 'p' else IntervalType.Augmented)) self.__base_intervals.extend(intervals) # Inversion check - only if chord type was given, not for cases like II if self.chord_type and self.inversion > len(self.base_intervals): raise Exception('Illegal inversion {0} for {1}'.format( self.inversion, self.__str__()))