chipweinberger / dart_melty_soundfont

A port of Melty Synth by Nobuaki Tanaka (C#) to Dart
Other
35 stars 10 forks source link

Add MIDI file support #29

Closed amuhaimin02 closed 1 week ago

amuhaimin02 commented 1 week ago

Following issue #14, I incorporated MIDI file support on my fork, taken from sinshu's meltysynth, and made necessary adjustments to make it work on Dart.

Example usage:

final sequencer = MidiFileSequencer(synth);
final midiFile = MidiFile.fromByteData(await rootBundle.load('assets/chpn_op23.mid'));
sequencer.play(midiFile);

final buf16 = ArrayInt16.zeros(numShorts: 1000);
sequencer.renderMonoInt16(buf16);

The logic behind it is mostly keep unchanged, so most of the MIDI files out there should work (at least on my case). Tested with single track classical pieces and multi-track GM songs.

I haven't updated the example app code, let me know if you would like those changes as well.

chipweinberger commented 1 week ago

thanks looks pretty good

chipweinberger commented 1 week ago

merged