From 8504e07f060d5c3bd79a7d80c3355ecb36aca4ec Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 16 Sep 2024 09:18:58 -0400 Subject: [PATCH] fix: change default octave for C, F, and G clefs in pitch finding algorithm --- .../jobs/heuristic_pitch_finding/PitchFinding.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/rodan-main/code/rodan/jobs/heuristic_pitch_finding/PitchFinding.py b/rodan-main/code/rodan/jobs/heuristic_pitch_finding/PitchFinding.py index 9254d065a..d79435c20 100644 --- a/rodan-main/code/rodan/jobs/heuristic_pitch_finding/PitchFinding.py +++ b/rodan-main/code/rodan/jobs/heuristic_pitch_finding/PitchFinding.py @@ -1,8 +1,8 @@ from gamera import gamera_xml from gamera.plugins.image_utilities import union_images from operator import itemgetter, attrgetter -import logging -logger = logging.getLogger("__name__") +from celery.utils.log import get_task_logger +logger = get_task_logger(__name__) from math import floor class PitchFinder(object): @@ -497,10 +497,16 @@ def __glyph_type(g): note = SCALE[int((clef_line - my_strt_pos + noteShift) % len(SCALE))] # find octave + clef_octave_map = { + 'c': 4, + 'f': 3, + 'g': 5 + } + base_octave = clef_octave_map.get(clef, 3) if my_strt_pos <= clef_line: - octave = 3 + floor((clef_line - my_strt_pos + noteShift) / len(SCALE)) + octave = base_octave + floor((clef_line - my_strt_pos + noteShift) / len(SCALE)) elif my_strt_pos > clef_line: - octave = 3 - floor((len(SCALE) - clef_line + my_strt_pos - 1 - noteShift) / len(SCALE)) + octave = base_octave - floor((len(SCALE) - clef_line + my_strt_pos - 1 - noteShift) / len(SCALE)) glyph_array.extend([note, octave, clef_line, 'clef.' + clef])