def _is_neighbor_note(note): from abjad.tools import scoretools from abjad.tools import tonalanalysistools if not isinstance(note, scoretools.Note): message = 'must be note: {!r}.' message = message.format(note) raise TypeError(message) previous_note = note._get_in_my_logical_voice( -1, prototype=scoretools.Note) next_note = note._get_in_my_logical_voice( 1, prototype=scoretools.Note) if previous_note is None: return False if next_note is None: return False notes = [previous_note, note, next_note] selection = tonalanalysistools.select(notes) preceding_interval = note.written_pitch - previous_note.written_pitch preceding_interval_direction = \ mathtools.sign(preceding_interval.direction_number) following_interval = next_note.written_pitch - note.written_pitch following_interval_direction = \ mathtools.sign(following_interval.direction_number) if selection.are_stepwise_notes(): if preceding_interval_direction != following_interval_direction: return True return False
def _is_neighbor_note(note): from abjad.tools import scoretools from abjad.tools import tonalanalysistools if not isinstance(note, scoretools.Note): message = 'must be note: {!r}.' message = message.format(note) raise TypeError(message) previous_note = note._get_in_my_logical_voice( -1, component_class=scoretools.Note) next_note = note._get_in_my_logical_voice( 1, component_class=scoretools.Note) if previous_note is None: return False if next_note is None: return False notes = [previous_note, note, next_note] selection = tonalanalysistools.select(notes) preceding_interval = note.written_pitch - previous_note.written_pitch preceding_interval_direction = \ mathtools.sign(preceding_interval.direction_number) following_interval = next_note.written_pitch - note.written_pitch following_interval_direction = \ mathtools.sign(following_interval.direction_number) if selection.are_stepwise_notes(): if preceding_interval_direction != following_interval_direction: return True return False
def _is_passing_tone(note): from abjad.tools import scoretools from abjad.tools import tonalanalysistools if not isinstance(note, scoretools.Note): message = 'must be note: {!r}.' message = message.format(note) raise TypeError(message) previous_note = note._get_in_my_logical_voice( -1, prototype=scoretools.Note) next_note = note._get_in_my_logical_voice( 1, prototype=scoretools.Note) if previous_note is None or next_note is None: return False notes = [previous_note, note, next_note] selection = tonalanalysistools.select(notes) return selection.are_scalar_notes()
def _is_passing_tone(note): from abjad.tools import scoretools from abjad.tools import tonalanalysistools if not isinstance(note, scoretools.Note): message = 'must be note: {!r}.' message = message.format(note) raise TypeError(message) previous_note = note._get_in_my_logical_voice( -1, component_class=scoretools.Note) next_note = note._get_in_my_logical_voice( 1, component_class=scoretools.Note) if previous_note is None or next_note is None: return False notes = [previous_note, note, next_note] selection = tonalanalysistools.select(notes) return selection.are_scalar_notes()
def _analyze_incomplete_tonal_function(expr, key_signature): from abjad.tools import tonalanalysistools if isinstance(expr, tonalanalysistools.RootedChordClass): chord_class = expr else: selection = tonalanalysistools.select(expr) chord_classes = selection.analyze_incomplete_chords() assert len(chord_classes) == 1 chord_class = chord_classes[0] root = chord_class.root scale = tonalanalysistools.Scale(key_signature) scale_degree = scale.named_pitch_class_to_scale_degree(root) quality = chord_class.chord_quality.quality_string extent = chord_class.extent inversion = chord_class.inversion return tonalanalysistools.RomanNumeral( scale_degree, quality, extent, inversion, )