Skip to content

Commit

Permalink
fix: change default octave for C, F, and G clefs in pitch finding alg…
Browse files Browse the repository at this point in the history
…orithm
  • Loading branch information
lucasmarchd01 committed Sep 16, 2024
1 parent 4c7f761 commit 8504e07
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions rodan-main/code/rodan/jobs/heuristic_pitch_finding/PitchFinding.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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])

Expand Down

0 comments on commit 8504e07

Please sign in to comment.