Skip to content

Detect a twelve-bar blues by bars, not chord count [patch] - #428

Merged
matt-edmondson merged 2 commits into
mainfrom
fix/317-blues-by-bars
Oct 14, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
fix/317-blues-by-bars

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #317

What changed

Form.IsTwelveBarBlues required exactly 12 chord events and never looked at their durations. Three bars of quarter-note chords were therefore called a blues, while a real 12-bar blues with held chords was not.

The detector now works bar by bar:

  • The section must last exactly 12 bars of its time signature. The comparison uses exact Duration fractions, not TotalBars doubles.
  • Each bar is represented by the chord sounding on its downbeat. This is the rule triage proposed. A chord held across several bars counts for each of them, and a chord that starts after a downbeat does not count for that bar.
  • The rule is documented in a comment on the method, and the altered-degree rejection is unchanged.

Tests

  • The existing Of_RecognizesTwelveBarBlues used "C7 | C7 | …". A chart cell is one beat, so that chart is three bars long and was the false positive from the issue. It now writes each chord as a full bar (C7 / / /).
  • New: the issue's held-chord chart is recognised, and so is a blues with a passing chord after the downbeat. The issue's 3-bar quarter-note chart is not.

The three new tests fail on main. All 354 Music tests pass on this branch, and the local Sonar build reports nothing in Form.cs.

This touches the same file as #427 (#314), but a different method, so the two should merge independently.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SWJoWcEC3BuVS7pSPco7mA


Generated by Claude Code

IsTwelveBarBlues required exactly twelve chord events and ignored their
durations, so three bars of quarter-note chords were called a blues and
a real twelve-bar blues with held chords was not. The section must now
last exactly twelve bars, and each bar is represented by the chord
sounding on its downbeat.

The existing blues test used twelve one-beat cells, the three-bar false
positive itself, so it now writes each chord as a full bar.

Fixes #317

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SWJoWcEC3BuVS7pSPco7mA
Keeps them clear of the #314 tests so the two PRs merge independently.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SWJoWcEC3BuVS7pSPco7mA
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit bf31322 into main Oct 14, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the fix/317-blues-by-bars branch October 14, 2026 01:14
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.

Form.Of detects a 12-bar blues by counting chord events, not bars: 3 bars of quarter notes match and a real blues with held chords doesn't

2 participants