Skip to content

feat(analysis-engine): add capo and tuning detection heuristics - #103

Merged
seonghobae merged 3 commits into
mainfrom
feat/capo-tuning-detection
Mar 28, 2026
Merged

feat(analysis-engine): add capo and tuning detection heuristics#103
seonghobae merged 3 commits into
mainfrom
feat/capo-tuning-detection

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator

Goal

Implements initial Capo and alternative tuning (like Drop D) detection heuristics from song chord lists. It enhances the acoustic-guitar role setup note with the recommended configuration.

Changes

  • chords/capo.py: Basic chord-set-based detection heuristics for Capo and Tunings (Standard, Drop D, Capo 1).
  • roles/tuning.py: Determines appropriate setupNote strings.
  • roles/extractor.py: Adds acoustic-guitar role dynamically to the graph and uses the new setup note logic.
  • Updated indices and len assertions in test_roles.py and test_api.py.
  • Achieves 100% test coverage threshold on services/analysis-engine.

Implements initial heuristics to detect Capo and alternative tunings (like Drop D)
from the chord list, and integrates this into the acoustic guitar role setup notes.
Adds robust test coverage to maintain the 100% threshold.
@seonghobae

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 722d50b3-766d-4a75-ab94-baa39594172f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

코드의 코드 분석 기능에 카포와 튜닝 감지 로직을 추가하고, 역할 추출기에 어쿠스틱 기타 역할을 통합하며 설정 노트 기능을 구현했습니다. 관련 테스트 커버리지도 추가되었습니다.

Changes

코호트 / 파일 요약
Chord 분석 기능
services/analysis-engine/src/bandscope_analysis/chords/__init__.py, services/analysis-engine/src/bandscope_analysis/chords/capo.py
카포 및 튜닝 감지 함수 detect_capo_and_tuning 추가. 코드 목록을 기반으로 드롭D, 플랫키 패턴을 감지하여 카포 값과 튜닝 유형을 반환합니다.
역할 설정 노트 통합
services/analysis-engine/src/bandscope_analysis/roles/__init__.py, services/analysis-engine/src/bandscope_analysis/roles/extractor.py, services/analysis-engine/src/bandscope_analysis/roles/tuning.py
새로운 get_setup_note 함수로 기타 역할의 카포/튜닝 정보 조회 기능 추가. 역할 추출기에서 이 함수를 호출하도록 통합하고 어쿠스틱 기타 역할을 추가하며 부분 그래프 인덱싱 업데이트.
테스트 업데이트
services/analysis-engine/tests/test_api.py, services/analysis-engine/tests/test_chords.py, services/analysis-engine/tests/test_roles.py, services/analysis-engine/tests/test_tuning.py
새로운 코드의 테스트 모듈 추가(코드 분석, 튜닝 설정 노트) 및 기존 역할 테스트의 인덱스 업데이트. 어쿠스틱 기타 역할과 부분 그래프 노드 변경사항 반영.

Sequence Diagram

sequenceDiagram
    participant RoleExtractor
    participant get_setup_note
    participant detect_capo_and_tuning
    participant ChordDatabase

    RoleExtractor->>RoleExtractor: create acoustic_guitar_role<br/>with setupNote field
    RoleExtractor->>get_setup_note: call get_setup_note(role_name, chords)
    get_setup_note->>get_setup_note: check if guitar role<br/>(contains "guitar", not "bass")
    get_setup_note->>detect_capo_and_tuning: call detect_capo_and_tuning(chords)
    detect_capo_and_tuning->>detect_capo_and_tuning: analyze chord patterns<br/>for capo and tuning hints
    detect_capo_and_tuning-->>get_setup_note: return {capo, tuning}
    get_setup_note->>get_setup_note: format setup string<br/>e.g., "Setup: Standard tuning, Capo 1"
    get_setup_note-->>RoleExtractor: return setupNote string or None
    RoleExtractor->>RoleExtractor: assign setupNote to role
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 분

Possibly related PRs

Poem

🐰 화음을 파싱하는 토끼의 노래 🎸

카포를 감지하고 튜닝을 찾아내며,
어쿠스틱 기타도 무대에 올려놓고,
설정 노트로 연주자를 도우니,
악보는 이제 더욱 똑똑해졌네! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately describes the main change: adding capo and tuning detection heuristics to the analysis engine.
Description check ✅ Passed The description is directly related to the changeset, explaining the goal, specific file changes, and test coverage improvements in detail.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/capo-tuning-detection

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai

coderabbitai Bot commented Mar 28, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@seonghobae
seonghobae enabled auto-merge (squash) March 28, 2026 11:09

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@services/analysis-engine/src/bandscope_analysis/chords/capo.py`:
- Line 1: 이 파일(src/bandscope_analysis/chords/capo.py)의 Ruff 포맷팅 오류를 고치려면 ruff
포맷터를 실행하여 코드 스타일을 자동으로 정리하세요: 터미널에서 ruff format
src/bandscope_analysis/chords/capo.py를 실행한 뒤 변경사항을 검토하고 커밋합니다; 모듈명 capo.py와 관련된
함수/클래스(예: capo 관련 함수들)가 있다면 포맷팅 후 임포트 정렬, 공백, 줄바꿈 규칙이 올바른지 확인하여 린트가 통과하도록 합니다.
- Around line 20-24: Remove the dead if-block that checks for drop D indicators:
the conditional "if 'D5' in chords_set or 'Eb' in chords_set and 'D' in
chords_set" is a no-op (contains only pass), has an operator-precedence bug (and
vs or), and duplicates the simpler drop-D logic implemented later; delete this
entire if block referencing chords_set so only the later, intended logic
remains.

In `@services/analysis-engine/src/bandscope_analysis/roles/extractor.py`:
- Around line 236-237: The two lines that mutate part_graph using hardcoded
indices (part_graph[0]["handoff_to"].append("lead-vocal") and
part_graph[4]["handoff_from"].append("bass-guitar")) are fragile; instead locate
nodes by their role_id (e.g., "lead-vocal", "bass-guitar") and update their
handoff lists. Implement or use a helper like find_node_by_role(graph, role_id)
that returns the node (or None) and then append to node["handoff_to"] or
node["handoff_from"] accordingly, and guard against missing nodes before
appending.

In `@services/analysis-engine/src/bandscope_analysis/roles/tuning.py`:
- Around line 22-23: The assignment capo = result["tuning"] if result["capo"] ==
0 else f"Capo {result['capo']} is dead and confusing because later code only
uses capo when result["capo"] > 0; remove the unnecessary branch and only assign
capo when needed (e.g., set capo = f"Capo {result['capo']}" inside the block
guarded by result["capo"] > 0), keeping tuning = result["tuning"] unchanged so
there is no redundant or unused assignment.

In `@services/analysis-engine/tests/test_chords.py`:
- Around line 1-28: The file ends without a trailing newline which causes ruff
format --check to fail; open the test file containing the tests that call
detect_capo_and_tuning (e.g., functions test_detect_capo_standard,
test_detect_capo_fret1, test_detect_capo_empty, test_detect_drop_d) and add a
single newline character at EOF so the file ends with a blank line.

In `@services/analysis-engine/tests/test_tuning.py`:
- Around line 1-30: The ruff formatting check failed because the test file
tests/test_tuning.py is missing a trailing newline at EOF; open the file
(contains functions like test_get_setup_note_acoustic_guitar,
test_get_setup_note_drop_d) and add a single blank line/newline character at the
end of the file so the file ends with a newline, then re-run ruff format/check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d135a3e9-116b-406b-88d4-cd16ef6ced42

📥 Commits

Reviewing files that changed from the base of the PR and between b36b56e and a1e6e04.

📒 Files selected for processing (9)
  • services/analysis-engine/src/bandscope_analysis/chords/__init__.py
  • services/analysis-engine/src/bandscope_analysis/chords/capo.py
  • services/analysis-engine/src/bandscope_analysis/roles/__init__.py
  • services/analysis-engine/src/bandscope_analysis/roles/extractor.py
  • services/analysis-engine/src/bandscope_analysis/roles/tuning.py
  • services/analysis-engine/tests/test_api.py
  • services/analysis-engine/tests/test_chords.py
  • services/analysis-engine/tests/test_roles.py
  • services/analysis-engine/tests/test_tuning.py

Comment thread services/analysis-engine/src/bandscope_analysis/chords/capo.py
Comment thread services/analysis-engine/src/bandscope_analysis/chords/capo.py Outdated
Comment thread services/analysis-engine/src/bandscope_analysis/roles/extractor.py Outdated
Comment thread services/analysis-engine/src/bandscope_analysis/roles/tuning.py Outdated
Comment thread services/analysis-engine/tests/test_chords.py
Comment thread services/analysis-engine/tests/test_tuning.py
- Remove dead if block in chords/capo.py
- Refactor fragile hardcoded index graph mutation in roles/extractor.py
- Remove unused assignment in roles/tuning.py
- Remove accidentally tracked agent JSON files and update .gitignore
@seonghobae

Copy link
Copy Markdown
Collaborator Author

@coderabbitai resolve

@coderabbitai

coderabbitai Bot commented Mar 28, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Comments resolved and changes approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant