Skip to content

Commit

Permalink
Merge pull request #1208 from DDMAL/fix-default-octave
Browse files Browse the repository at this point in the history
Change default octave for clefs in heuristic pitch finding
  • Loading branch information
lucasmarchd01 authored Sep 23, 2024
2 parents 4c7f761 + 4e5e799 commit a851c6f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 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': 4
}
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

Large diffs are not rendered by default.

0 comments on commit a851c6f

Please sign in to comment.