dart-tonic icon indicating copy to clipboard operation
dart-tonic copied to clipboard

PitchClass octave

Open razvangeangu opened this issue 5 years ago • 1 comments

In the example, passing the octave does not seem to be an option anymore.

════════ Exception caught by widgets library ═══════════════════════════════════
E4 is not a pitch class name

The relevant error-causing widget was

https://github.com/osteele/dart-tonic/blob/4454afd1ddb03f83fd3d8ee1e43dca7f6ae52563/example/tonic_example.dart#L75

razvangeangu avatar Dec 01 '20 00:12 razvangeangu

For anyone looking for this functionality, this is what I am currently using:

import 'package:tonic/tonic.dart';

List<Pitch> toPitch(List<PitchClass> pitchClasses, int octave) {
  var _octave = octave ?? 0;

  return pitchClasses
      .asMap()
      .map((i, e) {
        if (i > 0 && pitchClasses[i - 1].integer > e.integer) {
          _octave += 1;
        }

        return MapEntry(i, e.toPitch(octave: _octave));
      })
      .values
      .toList();
}

razvangeangu avatar Dec 07 '20 01:12 razvangeangu