dart_midi 1.0.1

pub package GitHub license GitHub issues

dart_midi #

A dart package that provides a parser and writer implementation for midi data.

The byte decoding and writing code is based on javascript library midi-file

Example #

// Open a file containing midi data
var file = File('sample_midi.mid');

// Construct a midi parser
var parser = MidiParser();

// Parse midi directly from file. You can also use parseMidiFromBuffer to directly parse List<int>
MidiFile parsedMidi = parser.parseMidiFromFile(file);

// You can now access your parsed [MidiFile]
print(parsedMidi.tracks.length.toString());

// Construct a midi writer
var writer = MidiWriter();

// Let's write and encode our midi data again
// You can also control `running` flag to compress file and  `useByte9ForNoteOff` to use 0x09 for noteOff when velocity is zero
writer.writeMidiToFile(parsedMidi, File('output.mid'));

[1.0.1] - 04.06.2019.

  • Codestyle fixes

[1.0.0] - 04.06.2019.

  • Initial implementation of MidiWriter and MidiParser

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dart_midi: ^1.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dart_midi/dart_midi.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
45
Health:
Code health derived from static analysis. [more]
93
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
68
Learn more about scoring.

We analyzed this package on Aug 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, other

Primary library: package:dart_midi/dart_midi.dart with components: io.

Health suggestions

Fix lib/src/midi_parser.dart. (-5.36 points)

Analysis of lib/src/midi_parser.dart reported 11 hints, including:

line 21 col 7: DO use curly braces for all flow control structures.

line 28 col 9: DO use curly braces for all flow control structures.

line 86 col 15: DO use curly braces for all flow control structures.

line 136 col 15: DO use curly braces for all flow control structures.

line 146 col 15: DO use curly braces for all flow control structures.

Fix lib/src/byte_reader.dart. (-1.49 points)

Analysis of lib/src/byte_reader.dart reported 3 hints:

line 21 col 7: DO use curly braces for all flow control structures.

line 35 col 7: DO use curly braces for all flow control structures.

line 50 col 7: DO use curly braces for all flow control structures.

Fix lib/src/midi_writer.dart. (-0.50 points)

Analysis of lib/src/midi_writer.dart reported 1 hint:

line 46 col 9: DO use curly braces for all flow control structures.

Fix additional 6 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/dart_midi.dart (Run dartfmt to format lib/dart_midi.dart.)
  • lib/src/byte_writer.dart (Run dartfmt to format lib/src/byte_writer.dart.)
  • lib/src/data_chunk.dart (Run dartfmt to format lib/src/data_chunk.dart.)
  • lib/src/midi_events.dart (Run dartfmt to format lib/src/midi_events.dart.)
  • lib/src/midi_file.dart (Run dartfmt to format lib/src/midi_file.dart.)
  • lib/src/midi_header.dart (Run dartfmt to format lib/src/midi_header.dart.)

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and dart_midi.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
Dev dependencies
test ^1.6.4