MidiPro class

The FlutterMidiPro class provides functions for writing to and loading soundfont files, as well as playing and stopping MIDI notes.

To use this class, you must first call the init method. Then, you can load a soundfont file using the loadSoundfont method. After loading a soundfont file, you can select an instrument using the selectInstrument method. Finally, you can play and stop notes using the playNote and stopNote methods.

To stop all notes on a channel, you can use the stopAllNotes method.

To dispose of the FlutterMidiPro instance, you can use the dispose method.

Constructors

MidiPro()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() Future<void>
Disposes of the FlutterMidiPro instance. This should be called when the instance is no longer needed. This will stop all notes and unload all soundfonts. This will also release all resources used by the instance. After disposing of the instance, the instance should not be used again.
loadSoundfont({required String path, required int bank, required int program}) Future<int>
Loads a soundfont file from the specified path. Returns the sfId (SoundfontSamplerId).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
playNote({int channel = 0, required int key, required int velocity, required int sfId}) Future<void>
Plays a note on the specified channel. The channel is a number from 0 to 15. The key is the MIDI note number. This is a number from 0 to 127. The velocity is the velocity of the note. This is a number from 0 to 127. A velocity of 127 is the maximum velocity. The note will continue to play until it is stopped. To stop the note, use the stopNote method.
selectInstrument({required int sfId, required int program, int channel = 0, int bank = 0}) Future<void>
Selects an instrument on the specified soundfont. The soundfont ID is the ID returned by the loadSoundfont method. The channel is a number from 1 to 16. The bank number is the bank number of the instrument on the soundfont. The program number is the program number of the instrument on the soundfont. This is the same as the patch number. If the soundfont does not have banks, set the bank number to 0.
stopNote({int channel = 0, required int key, required int sfId}) Future<void>
Stops a note on the specified channel. The channel is a number from 0 to 15. The key is the MIDI note number. This is a number from 0 to 127. The note will stop playing. To play the note again, use the playNote method. To stop all notes on a channel, use the stopAllNotes method.
toString() String
A string representation of this object.
inherited
unloadSoundfont(int sfId) Future<void>
Unloads a soundfont from memory. The soundfont ID is the ID returned by the loadSoundfont method. If resetPresets is true, the presets will be reset to the default values.

Operators

operator ==(Object other) bool
The equality operator.
inherited