Skip to content

Commit

Permalink
build(pubspec): 🚚 bump Dart SDK 3.7 (#591)
Browse files Browse the repository at this point in the history
* build(pubspec): 🚚 bump Dart SDK 3.7

Signed-off-by: Albert Mañosa <26429103+albertms10@users.noreply.github.com>

* style: 🎨 reformat code using the new formatter

Signed-off-by: Albert Mañosa <26429103+albertms10@users.noreply.github.com>

* style(chord): 🎨 reformat code

Signed-off-by: Albert Mañosa <26429103+albertms10@users.noreply.github.com>

* style: 🎨 reformat code

Signed-off-by: Albert Mañosa <26429103+albertms10@users.noreply.github.com>

---------

Signed-off-by: Albert Mañosa <26429103+albertms10@users.noreply.github.com>
  • Loading branch information
albertms10 authored Feb 22, 2025
1 parent 1bb8b65 commit dc9119e
Show file tree
Hide file tree
Showing 57 changed files with 1,325 additions and 1,358 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/analysis-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
types: [opened, synchronize, reopened]

env:
DART_SDK_VERSION: "3.6"
DART_SDK_VERSION: "3.7"

permissions:
contents: read
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,10 @@ Or know its numeric representation:

```dart
({PitchClass.b, PitchClass.aSharp, PitchClass.d, PitchClass.e})
..numericRepresentation().toSet() // {0, 11, 3, 5}
..numericRepresentation(reference: PitchClass.d).toSet() // {9, 8, 0, 2}
..numericRepresentation()
.toSet() // {0, 11, 3, 5}
..numericRepresentation(reference: PitchClass.d)
.toSet() // {9, 8, 0, 2}
..deltaNumericRepresentation.toList(); // [0, -1, 4, 2]
```

Expand Down Expand Up @@ -494,7 +496,9 @@ TuningFork.c256; // C256
And use it in a `TuningSystem`:

```dart
Note.b.flat.inOctave(4).frequency(
Note.b.flat
.inOctave(4)
.frequency(
tuningSystem: const EqualTemperament.edo12(fork: TuningFork.c256),
); // 456.1401436878537
```
Expand Down Expand Up @@ -541,7 +545,8 @@ ClosestPitch.parse('Eâ™­3-28'); // Eâ™­3-28
### In a nutshell

```dart
ScalePattern.lydian // Lydian (M2 M2 M2 m2 M2 M2 m2)
ScalePattern
.lydian // Lydian (M2 M2 M2 m2 M2 M2 m2)
.on(Note.parse('a')) // A Lydian (A B C♯ D♯ E F♯ G♯ A)
.transposeBy(Interval.M2) // B Lydian (B C♯ D♯ E♯ F♯ G♯ A♯ B)
.degree(ScaleDegree.iii) // D♯
Expand Down
6 changes: 6 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ linter:
- prefer_expression_function_bodies
- prefer_foreach
- prefer_mixin
- strict_top_level_inference
- type_literal_in_constant_pattern
- unintended_html_in_doc_comment
- unnecessary_library_name
- unnecessary_null_aware_operator_on_extension_on_nullable
- unnecessary_underscores
- unreachable_from_main
- unsafe_variance

analyzer:
errors:
# Style decisions
always_use_package_imports: ignore
sort_constructors_first: ignore

# temporarily disabled
require_trailing_commas: ignore
13 changes: 9 additions & 4 deletions example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,10 @@ void main() {
// {{F♯|G♭}, {G}, {D♯|E♭}}

({PitchClass.b, PitchClass.aSharp, PitchClass.d, PitchClass.e})
..numericRepresentation().toSet() // {0, 11, 3, 5}
..numericRepresentation(reference: PitchClass.d).toSet() // {9, 8, 0, 2}
..numericRepresentation()
.toSet() // {0, 11, 3, 5}
..numericRepresentation(reference: PitchClass.d)
.toSet() // {9, 8, 0, 2}
..deltaNumericRepresentation.toList(); // [0, -1, 4, 2]

// Chords
Expand All @@ -259,7 +261,9 @@ void main() {
TuningFork.a440; // A440
TuningFork.c256; // C256

Note.b.flat.inOctave(4).frequency(
Note.b.flat
.inOctave(4)
.frequency(
tuningSystem: const EqualTemperament.edo12(fork: TuningFork.c256),
); // 456.1401436878537

Expand All @@ -282,7 +286,8 @@ void main() {
ClosestPitch.parse('Eâ™­3-28'); // Eâ™­3-28

// In a nutshell
ScalePattern.lydian // Lydian (M2 M2 M2 m2 M2 M2 m2)
ScalePattern
.lydian // Lydian (M2 M2 M2 m2 M2 M2 m2)
.on(Note.parse('a')) // A Lydian (A B C♯ D♯ E F♯ G♯ A)
.transposeBy(Interval.M2) // B Lydian (B C♯ D♯ E♯ F♯ G♯ A♯ B)
.degree(ScaleDegree.iii) // D♯
Expand Down
12 changes: 6 additions & 6 deletions lib/src/harmony/chord.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ class Chord<T extends Scalable<T>>
/// == ChordPattern.majorTriad.add7().add9()
/// ```
ChordPattern get pattern =>
// The pattern is calculated based on the intervals between the notes
// rather than from the root note. This approach helps differentiate
// compound intervals (e.g., [Interval.M9]) from simple intervals
// (e.g., [Interval.M2]) in chords where distance is not explicit
// (so, [Note] based chords rather than [Pitch] based).
ChordPattern.fromIntervalSteps(_items.intervalSteps);
// The pattern is calculated based on the intervals between the notes
// rather than from the root note. This approach helps differentiate
// compound intervals (e.g., [Interval.M9]) from simple intervals
// (e.g., [Interval.M2]) in chords where distance is not explicit
// (so, [Note] based chords rather than [Pitch] based).
ChordPattern.fromIntervalSteps(_items.intervalSteps);

/// The modifier [T]s from the root note.
///
Expand Down
18 changes: 8 additions & 10 deletions lib/src/harmony/chord_pattern.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ class ChordPattern with Chordable<ChordPattern> {
/// ```
factory ChordPattern.fromIntervalSteps(Iterable<Interval> intervalSteps) =>
ChordPattern(
intervalSteps.skip(1).fold(
[intervalSteps.first],
(steps, interval) => [...steps, interval + steps.last],
),
intervalSteps.skip(1).fold([
intervalSteps.first,
], (steps, interval) => [...steps, interval + steps.last]),
);

/// Creates a new [ChordPattern] from the given [quality].
Expand Down Expand Up @@ -79,12 +78,11 @@ class ChordPattern with Chordable<ChordPattern> {
/// == const Chord([Note.c, Note.e, Note.g])
/// ```
Chord<T> on<T extends Scalable<T>>(T scalable) => Chord(
_intervals.fold(
[scalable],
(chordItems, interval) =>
[...chordItems, scalable.transposeBy(interval)],
),
);
_intervals.fold(
[scalable],
(chordItems, interval) => [...chordItems, scalable.transposeBy(interval)],
),
);

/// The root triad of this [ChordPattern].
///
Expand Down
23 changes: 13 additions & 10 deletions lib/src/harmony/harmonic_function.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ class HarmonicFunction {
static const ii = HarmonicFunction([ScaleDegree.ii]);

/// A neapolitan sixth [HarmonicFunction].
static const neapolitanSixth =
HarmonicFunction([ScaleDegree.neapolitanSixth]);
static const neapolitanSixth = HarmonicFunction([
ScaleDegree.neapolitanSixth,
]);

/// A III degree [HarmonicFunction].
static const iii = HarmonicFunction([ScaleDegree.iii]);
Expand All @@ -39,8 +40,9 @@ class HarmonicFunction {
static const iv = HarmonicFunction([ScaleDegree.iv]);

/// A dominant V degree [HarmonicFunction].
static const dominantV =
HarmonicFunction([ScaleDegree(5, quality: ImperfectQuality.major)]);
static const dominantV = HarmonicFunction([
ScaleDegree(5, quality: ImperfectQuality.major),
]);

/// A VI degree [HarmonicFunction].
static const vi = HarmonicFunction([ScaleDegree.vi]);
Expand All @@ -61,10 +63,9 @@ class HarmonicFunction {
@override
String toString({
ScaleDegreeNotation system = ScaleDegreeNotation.standard,
}) =>
_scaleDegrees
.map((scaleDegree) => scaleDegree.toString(system: system))
.join('/');
}) => _scaleDegrees
.map((scaleDegree) => scaleDegree.toString(system: system))
.join('/');

/// Returns a new [HarmonicFunction] relating this [HarmonicFunction] to
/// [other].
Expand All @@ -84,8 +85,10 @@ class HarmonicFunction {
@override
bool operator ==(Object other) =>
other is HarmonicFunction &&
const ListEquality<ScaleDegree>()
.equals(_scaleDegrees, other._scaleDegrees);
const ListEquality<ScaleDegree>().equals(
_scaleDegrees,
other._scaleDegrees,
);

@override
int get hashCode => Object.hashAll(_scaleDegrees);
Expand Down
74 changes: 44 additions & 30 deletions lib/src/interval/interval.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ final class Interval
static const A1 = Interval.perfect(Size.unison, PerfectQuality.augmented);

/// A diminished second [Interval].
static const d2 =
Interval.imperfect(Size.second, ImperfectQuality.diminished);
static const d2 = Interval.imperfect(
Size.second,
ImperfectQuality.diminished,
);

/// A minor second [Interval].
static const m2 = Interval.imperfect(Size.second, ImperfectQuality.minor);
Expand Down Expand Up @@ -100,8 +102,10 @@ final class Interval
static const A6 = Interval.imperfect(Size.sixth, ImperfectQuality.augmented);

/// A diminished seventh [Interval].
static const d7 =
Interval.imperfect(Size.seventh, ImperfectQuality.diminished);
static const d7 = Interval.imperfect(
Size.seventh,
ImperfectQuality.diminished,
);

/// A minor seventh [Interval].
static const m7 = Interval.imperfect(Size.seventh, ImperfectQuality.minor);
Expand All @@ -110,8 +114,10 @@ final class Interval
static const M7 = Interval.imperfect(Size.seventh, ImperfectQuality.major);

/// An augmented seventh [Interval].
static const A7 =
Interval.imperfect(Size.seventh, ImperfectQuality.augmented);
static const A7 = Interval.imperfect(
Size.seventh,
ImperfectQuality.augmented,
);

/// A diminished octave [Interval].
static const d8 = Interval.perfect(Size.octave, PerfectQuality.diminished);
Expand Down Expand Up @@ -144,20 +150,28 @@ final class Interval
static const A11 = Interval.perfect(Size.eleventh, PerfectQuality.augmented);

/// A diminished thirteenth [Interval].
static const d13 =
Interval.imperfect(Size.thirteenth, ImperfectQuality.diminished);
static const d13 = Interval.imperfect(
Size.thirteenth,
ImperfectQuality.diminished,
);

/// A minor thirteenth [Interval].
static const m13 =
Interval.imperfect(Size.thirteenth, ImperfectQuality.minor);
static const m13 = Interval.imperfect(
Size.thirteenth,
ImperfectQuality.minor,
);

/// A major thirteenth [Interval].
static const M13 =
Interval.imperfect(Size.thirteenth, ImperfectQuality.major);
static const M13 = Interval.imperfect(
Size.thirteenth,
ImperfectQuality.major,
);

/// An augmented thirteenth [Interval].
static const A13 =
Interval.imperfect(Size.thirteenth, ImperfectQuality.augmented);
static const A13 = Interval.imperfect(
Size.thirteenth,
ImperfectQuality.augmented,
);

static final _regExp = RegExp(r'(\w+?)(-?\d+)');

Expand All @@ -166,19 +180,19 @@ final class Interval
this.size, [
PerfectQuality this.quality = PerfectQuality.perfect,
])
// Copied from [Size.isPerfect] to allow const.
: assert(
((1 << ((size < 0 ? 0 - size : size) % 7)) & 50) != 0,
'Interval must be perfect.',
);
// Copied from [Size.isPerfect] to allow const.
: assert(
((1 << ((size < 0 ? 0 - size : size) % 7)) & 50) != 0,
'Interval must be perfect.',
);

/// Creates a new [Interval] allowing only imperfect quality [size]s.
const Interval.imperfect(this.size, ImperfectQuality this.quality)
// Copied from [Size.isPerfect] to allow const.
: assert(
((1 << ((size < 0 ? 0 - size : size) % 7)) & 50) == 0,
'Interval must be imperfect.',
);
// Copied from [Size.isPerfect] to allow const.
: assert(
((1 << ((size < 0 ? 0 - size : size) % 7)) & 50) == 0,
'Interval must be imperfect.',
);

/// Creates a new [Interval] from [size] and [Quality.semitones].
factory Interval.fromSizeAndQualitySemitones(Size size, int semitones) {
Expand Down Expand Up @@ -258,9 +272,9 @@ final class Interval
/// ```
// ignore: avoid_positional_boolean_parameters
Interval descending([bool isDescending = true]) => Interval._(
Size(size * (this.isDescending == isDescending ? 1 : -1)),
quality,
);
Size(size * (this.isDescending == isDescending ? 1 : -1)),
quality,
);

/// The inversion of this [Interval], regardless of its direction (ascending
/// or descending).
Expand Down Expand Up @@ -478,9 +492,9 @@ final class Interval

@override
int compareTo(Interval other) => compareMultiple([
() => size.compareTo(other.size),
() => quality.compareTo(other.quality),
]);
() => size.compareTo(other.size),
() => quality.compareTo(other.quality),
]);
}

/// The abstraction for [Interval] notation systems.
Expand Down
13 changes: 7 additions & 6 deletions lib/src/interval/interval_class.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ final class IntervalClass

/// Creates an [IntervalClass] from [semitones].
const IntervalClass(int semitones)
: semitones = (semitones % chromaticDivisions) > (chromaticDivisions ~/ 2)
? chromaticDivisions - (semitones % chromaticDivisions)
: semitones % chromaticDivisions;
: semitones =
(semitones % chromaticDivisions) > (chromaticDivisions ~/ 2)
? chromaticDivisions - (semitones % chromaticDivisions)
: semitones % chromaticDivisions;

/// A distance of 0 semitones [IntervalClass], which corresponds to
/// [Interval.P1] or [Interval.P8].
Expand Down Expand Up @@ -125,9 +126,9 @@ final class IntervalClass
/// ```
Interval resolveClosestSpelling([Quality? preferredQuality]) {
if (preferredQuality != null) {
final interval = spellings(distance: 1).firstWhereOrNull(
(interval) => interval.quality == preferredQuality,
);
final interval = spellings(
distance: 1,
).firstWhereOrNull((interval) => interval.quality == preferredQuality);
if (interval != null) return interval;
}

Expand Down
Loading

0 comments on commit dc9119e

Please sign in to comment.