dart_melty_soundfont is a SoundFont synthesizer (i.e. '.sf2' player) written in pure Dart.

It is a port of MeltySynth (C#, MIT License) written by Nobuaki Tanaka, to Dart.



This package has no dependencies.


This project was specifically designed to not require maintanence, in large part by not having any dependencies. Apart from breaking changes to the Dart language (rare), it should be solid code that works for decades. It will work on any Dart SDK sdk>=2.12 && sdk<4.0 indefinitely.

This package was written against Dart SDK 2.16.1.


Synthesize a simple chord:

// Necessary Imports
import 'package:dart_melty_soundfont/dart_melty_soundfont.dart';
import 'package:flutter/services.dart' show rootBundle;

// load sf2
ByteData bytes = await rootBundle.load('assets/akai_steinway.sf2');

// Create the synthesizer.
Synthesizer synth = Synthesizer.loadByteData(bytes, 
        sampleRate: 44100, 
        blockSize: 64, 
        maximumPolyphony: 64, 
        enableReverbAndChorus: true,

// optional: print available instruments (aka presets)
List<Preset> p = synth.soundFont.presets;
for (int i = 0; i < p.length; i++) {
  String instrumentName = p[i].regions.isNotEmpty ? p[i].regions[0].instrument.name : "N/A";
  print('[preset $i] name: ${p[i].name} instrument: $instrumentName');

//  optional: select first instrument (aka preset)
synth.selectPreset(channel: 0, preset: 0);

// Turn on some notes
synth.noteOn(channel: 0, key: 72, velocity: 120);
synth.noteOn(channel: 0, key: 76, velocity: 120);
synth.noteOn(channel: 0, key: 79, velocity: 120);
synth.noteOn(channel: 0, key: 82, velocity: 120);

// create a pcm buffer
ArrayInt16 buf16 = ArrayInt16.zeros(numShorts: 44100 * 3);

// Render the waveform (3 seconds)

Playing Sound

This library does not audibly make sound, it only generates the PCM waveform.

To actually hear something, you need to pass the generated PCM waveform to your device's speakers using PCM.

See the Example App for a flutter_pcm_sound + dart_melty_soundfont example.


  • No memory allocation in the rendering process.

  • Wave synthesis

    • x SoundFont reader
    • x Waveform generator
    • x Envelope generator
    • x Low-pass filter
    • x Vibrato LFO
    • x Modulation LFO
  • MIDI message processing

    • x Note on/off
    • x Bank selection
    • x Modulation
    • x Volume control
    • x Pan
    • x Expression
    • x Hold pedal
    • x Program change
    • x Pitch bend
    • x Tuning
  • Effects

    • x Reverb
    • x Chorus
  • Other things

    • x Loop extension support
    • x Performace optimization


DartMeltySoundFont is available under the MIT license.