def __init__(self, symbol='V7'): from abjad.tools import tonalanalysistools groups = self._symbol_regex.match(symbol).groups() accidental, roman_numeral, quality, figured_bass = groups scale_degree = accidental + roman_numeral scale_degree = tonalanalysistools.ScaleDegree(scale_degree) figured_bass_parts = figured_bass.split('/') naive_figured_bass = [x for x in figured_bass_parts if '-' not in x] naive_figured_bass = '/'.join(naive_figured_bass) extent = self._figured_bass_string_to_extent[naive_figured_bass] extent = tonalanalysistools.ChordExtent(extent) uppercase = roman_numeral == roman_numeral.upper() quality = self._get_quality_name(uppercase, quality, extent.number) quality = tonalanalysistools.ChordQuality(quality) inversion = self._figured_bass_string_to_inversion[naive_figured_bass] inversion = tonalanalysistools.ChordInversion(inversion) suspension = [x for x in figured_bass_parts if '-' in x] if not suspension: suspension = None elif 1 < len(suspension): message = 'no multiple suspensions yet.' raise NotImplementedError(message) else: suspension = tonalanalysistools.ChordSuspension(suspension[0]) self._root_scale_degree = scale_degree self._quality = quality self._extent = extent self._inversion = inversion if suspension is not None and suspension.start is None: suspension = None self._suspension = suspension
def _initialize_by_symbolic_string(self, symbolic_string): from abjad.tools import tonalanalysistools groups = self._symbolic_string_regex.match(symbolic_string).groups() accidental, roman_numeral, quality, figured_bass = groups scale_degree = tonalanalysistools.ScaleDegree(accidental + roman_numeral) figured_bass_parts = figured_bass.split('/') naive_figured_bass = [x for x in figured_bass_parts if not '-' in x] naive_figured_bass = '/'.join(naive_figured_bass) extent = self._figured_bass_string_to_extent[naive_figured_bass] extent = tonalanalysistools.ChordExtent(extent) uppercase = roman_numeral == roman_numeral.upper() quality = self._get_quality_name(uppercase, quality, extent.number) quality = tonalanalysistools.ChordQuality(quality) inversion = self._figured_bass_string_to_inversion[naive_figured_bass] inversion = tonalanalysistools.ChordInversion(inversion) suspension = [x for x in figured_bass_parts if '-' in x] if not suspension: suspension = tonalanalysistools.ChordSuspension() elif 1 < len(suspension): message = 'no multiple suspensions yet.' raise NotImplementedError(message) else: suspension = tonalanalysistools.ChordSuspension(suspension[0]) return scale_degree, quality, extent, inversion, suspension
def _get_quality_symbol(self): from abjad.tools import tonalanalysistools if self.extent == tonalanalysistools.ChordExtent(5): if self.quality == tonalanalysistools.ChordQuality('diminished'): return 'o' elif self.quality == tonalanalysistools.ChordQuality('augmented'): return '+' else: return '' elif self.extent == tonalanalysistools.ChordExtent(7): if self.quality == tonalanalysistools.ChordQuality('dominant'): return '' elif self.quality == tonalanalysistools.ChordQuality('major'): return 'M' elif self.quality == \ tonalanalysistools.ChordQuality('diminished'): return 'o' elif self.quality == \ tonalanalysistools.ChordQuality('half diminished'): return '@' elif self.quality == tonalanalysistools.ChordQuality('augmented'): return '+' else: return '' else: raise NotImplementedError
def _initialize_by_scale_degree_quality_extent_and_inversion(self, *args): from abjad.tools import tonalanalysistools scale_degree, quality, extent, inversion = args scale_degree = tonalanalysistools.ScaleDegree(scale_degree) quality = tonalanalysistools.ChordQuality(quality) extent = tonalanalysistools.ChordExtent(extent) inversion = tonalanalysistools.ChordInversion(inversion) suspension = tonalanalysistools.ChordSuspension() return scale_degree, quality, extent, inversion, suspension
def from_scale_degree_quality_extent_and_inversion( scale_degree, quality, extent, inversion, ): r'''Makes Roman numeral from `scale_degree`, `quality`, `extent` and `inversion`. Returns new Roman numeral. ''' from abjad.tools import tonalanalysistools scale_degree = tonalanalysistools.ScaleDegree(scale_degree) quality = tonalanalysistools.ChordQuality(quality) extent = tonalanalysistools.ChordExtent(extent) inversion = tonalanalysistools.ChordInversion(inversion) roman_numeral = RomanNumeral() roman_numeral._root_scale_degree = scale_degree roman_numeral._quality = quality roman_numeral._extent = extent roman_numeral._inversion = inversion return roman_numeral