Skip to content

Commit

Permalink
Add double harmonic major scale pattern
Browse files Browse the repository at this point in the history
With documentation, Wikipedia diagram, and unit tests for the scale notes, name and toString()
  • Loading branch information
JulioJamon54 committed Apr 19, 2024
1 parent 3a2dcc0 commit 55f1867
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/src/scale/scale_pattern.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,19 @@ final class ScalePattern {
Interval.m2,
]);

/// See [Double harmonic scale](https://en.wikipedia.org/wiki/Double_harmonic_scale).
///
/// ![C Double harmonic scale](https://upload.wikimedia.org/score/r/f/rf4xfu7bhu0k9n0ccidte6yjngjswnm/rf4xfu7b.png).
static const doubleHarmonicMajor = ScalePattern([
Interval.m2,
Interval.A2,
Interval.m2,
Interval.M2,
Interval.m2,
Interval.A2,
Interval.m2,
]);

/// Creates a new [ScalePattern] from the given [chordPattern].
///
/// Example:
Expand Down Expand Up @@ -447,6 +460,7 @@ final class ScalePattern {
majorPentatonic => 'Major pentatonic',
minorPentatonic => 'Minor pentatonic',
octatonic => 'Octatonic',
doubleHarmonicMajor => 'Double harmonic major',
_ => null,
};

Expand Down
34 changes: 34 additions & 0 deletions test/src/scale/scale_pattern_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,35 @@ void main() {
Scale([Note.g, Note.b.flat, Note.c, Note.d, Note.f, Note.g]),
);
});

test('returns the double harmonic major Scale on Note', () {
expect(
ScalePattern.doubleHarmonicMajor.on(Note.c),
Scale([
Note.c,
Note.d.flat,
Note.e,
Note.f,
Note.g,
Note.a.flat,
Note.b,
Note.c,
]),
);
expect(
ScalePattern.doubleHarmonicMajor.on(Note.f.sharp),
Scale([
Note.f.sharp,
Note.g,
Note.a.sharp,
Note.b,
Note.c.sharp,
Note.d,
Note.e.sharp,
Note.f.sharp,
]),
);
});
});

group('.mirrored', () {
Expand Down Expand Up @@ -573,6 +602,7 @@ void main() {
expect(ScalePattern.majorPentatonic.name, 'Major pentatonic');
expect(ScalePattern.minorPentatonic.name, 'Minor pentatonic');
expect(ScalePattern.octatonic.name, 'Octatonic');
expect(ScalePattern.doubleHarmonicMajor.name, 'Double harmonic major');
});
});

Expand Down Expand Up @@ -606,6 +636,10 @@ void main() {
ScalePattern.octatonic.toString(),
'Octatonic (M2 m2 M2 m2 M2 m2 M2 m2)',
);
expect(
ScalePattern.doubleHarmonicMajor.toString(),
'Double harmonic major (m2 A2 m2 M2 m2 A2 m2)',
);
});
});

Expand Down

0 comments on commit 55f1867

Please sign in to comment.