Ejemplo n.º 1
0
    def run_check(self, chorale):
        out = []
        ranges = [
            self.set_range(0),
            self.set_range(1),
            self.set_range(2),
            self.set_range(3)
        ]

        offset_lists = [
            chorale.get_offset_list(Constants.SOPRANO_PART_NUMBER),
            chorale.get_offset_list(Constants.ALTO_PART_NUMBER),
            chorale.get_offset_list(Constants.TENOR_PART_NUMBER),
            chorale.get_offset_list(Constants.BASS_PART_NUMBER)
        ]

        reverse_note_maps = [
            chorale.get_reverse_note_map(Constants.SOPRANO_PART_NUMBER),
            chorale.get_reverse_note_map(Constants.ALTO_PART_NUMBER),
            chorale.get_reverse_note_map(Constants.TENOR_PART_NUMBER),
            chorale.get_reverse_note_map(Constants.BASS_PART_NUMBER)
        ]

        i = 0
        while i < 4:
            for offset in offset_lists[i]:
                note = reverse_note_maps[i][offset]
                pitch = Utils.get_only_element(note.pitches)
                if pitch > ranges[i].max or pitch < ranges[i].min:
                    location = chorale.get_location_from_offset(offset)
                    error = RangeError(note, Constants.PART_NAMES[i], location, [note])
                    out.append(error)
            i += 1

        return out
Ejemplo n.º 2
0
    def run_check(self, chorale):
        out = []
        offset_list = chorale.get_offset_list(Constants.BASS_PART_NUMBER)
        reverse_note_map = chorale.get_reverse_note_map(Constants.BASS_PART_NUMBER)

        first_offset = offset_list[0]
        previous_note = reverse_note_map[first_offset]
        previous_offset = Utils.get_only_element(previous_note.pitches)
        for offset in offset_list[1:]:
            current_note = reverse_note_map[offset]
            current_pitch = Utils.get_only_element(current_note.pitches)
            previous_pitch = Utils.get_only_element(previous_note.pitches)

            if current_pitch == previous_pitch:
                current_location = chorale.get_location_from_offset(offset)
                previous_location = chorale.get_location_from_offset(previous_offset)
                error = RepBassError(current_pitch, previous_location, current_location)
                out.append(error)
            previous_note = current_note
            previous_offset = offset
        return out