FLUTTER ECOSYSTEM

rodydavis/flutter_midi

Midi Playback in Flutter

flutter_midi project cover
Stars
62
Forks
58
Last push (UTC)
Mar 10, 2024
Project status
Active
Rody Davis GitHub avatar
GITHUB User

Rody Davis ↗

Senior Developer Relations Engineer @google @google-deepmind supporting @google-antigravity

@GoogleSan Francisco, CAOfficial website ↗
LanguagesSwiftDartJavaRubyHTMLObjective-C

Technical topics

Packages published by this repository

Dependencies used

Dependency list 7 items
  • flutter{"sdk":"flutter"}
  • flutter_web_plugins{"sdk":"flutter"}
  • js^0.6.3
  • path_provider^2.0.5
  • plugin_platform_interface^2.0.1
  • tonic^0.2.4
  • flutter_testDevelopment{"sdk":"flutter"}

Original README

English project snapshot. Visit GitHub for the latest content.

Expand / collapse project README

Buy Me A Coffee Donate github pages GitHub stars flutter_midi

flutter_midi

A FLutter Plugin to Play midi on iOS and Android. This uses SoundFont (.sf2) Files.

Online Demo: https://rodydavis.github.io/flutter_midi/

Installation

Download a any sound font file, example: sound_font.SF2 file.

Create an /assets folder and store the .sf2 files

Update pubspec.yaml

assets:
   - assets/sf2/Piano.SF2
   - assets/sf2/SmallTimGM6mb.sf2

Load the sound font to prepare to play;

 @override
  void initState() {
    load('assets/sf2/Piano.SF2');
    super.initState();
  }
  
 void load(String asset) async {
    FlutterMidi.unmute(); // Optionally Unmute
    ByteData _byte = await rootBundle.load(asset);
    FlutterMidi.prepare(sf2: _byte);
  }

Play and Stop the Midi Notes

 FlutterMidi.playMidiNote(midi: 60);
 FlutterMidi.playMidiNote(midi: 60, velocity: 120);

 FlutterMidi.stopMidiNote(midi: 60);
 FlutterMidi.stopMidiNote(midi: 60, velocity: 120);