Skip to content

Commit

Permalink
Fix multiple uses of the same finger in fingering
Browse files Browse the repository at this point in the history
  • Loading branch information
noeddl committed Dec 5, 2021
1 parent 47677f8 commit 21e4f29
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/voicing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl Voicing {
if f == fret_id {
fingering[i] = finger as u8;
used_strings += 1;
if !self.has_barre() && finger < FINGER_COUNT {
if (!self.has_barre() || finger > 1) && finger < FINGER_COUNT {
finger += 1;
}
}
Expand Down Expand Up @@ -435,10 +435,12 @@ mod tests {
case([1, 1, 1, 4], true),
case([1, 1, 2, 1], true),
case([1, 2, 1, 1], true),
case([1, 3, 3, 1], true),
case([2, 1, 1, 1], true),
case([3, 1, 1, 1], true),
case([3, 2, 1, 1], true),
case([3, 1, 2, 1], true),
case([3, 1, 1, 3], true),
)]
fn test_has_barre(frets: [FretID; STRING_COUNT], has_barre: bool) {
let voicing = Voicing::new(frets, Tuning::C);
Expand Down Expand Up @@ -482,6 +484,8 @@ mod tests {
case([1, 1, 1, 4], [1, 1, 1, 4]),
case([3, 2, 1, 1], [3, 2, 1, 1]),
case([4, 3, 2, 2], [3, 2, 1, 1]),
case([3, 1, 1, 3], [3, 1, 1, 4]),
case([1, 3, 3, 1], [1, 3, 4, 1]),
// Fingering across a span of five frets.
case([0, 0, 1, 5], [0, 0, 1, 4]),
case([3, 0, 1, 5], [3, 0, 1, 4]),
Expand Down

0 comments on commit 21e4f29

Please sign in to comment.