dart_melty_soundfont 1.0.9 copy "dart_melty_soundfont: ^1.0.9" to clipboard
dart_melty_soundfont: ^1.0.9 copied to clipboard

outdated

A Soundfont synthesizer (i.e. '.sf2' player) written in pure Dart.

DartMeltySoundFont #

DartMeltySoundFont 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.

https://github.com/sinshu/meltysynth

Dependencies #

This package has no dependencies.

Maintanence #

Apart from breaking changes to the Dart language (rare), this package has no external dependencies and should work on any Dart SDK >=2.12 indefinitely. This package was written against Dart SDK 2.16.1.

Example #

Ssynthesize a simple chord:


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

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

Synthesizer synth = Synthesizer.loadByteData(bytes, 
    SynthesizerSettings(
        sampleRate: 44100, 
        blockSize: 64, 
        maximumPolyphony: 64, 
        enableReverbAndChorus: true,
    ));

int instruments = synth.soundFont.presets.length;

// you might need to select the instrument, like so:
for (int i = 0; i < instruments; i++){
  Preset p = synth.soundFont.presets[i];
  synth.processMidiMessage(
     channel:i % 16, 
     command:0xB0, // control change
     data1: 0, //bank select
     data2:p.bankNumber, 
   );
  synth.processMidiMessage(
     channel:i % 16, 
     command:0xC0, //program change
     data1:p.patchNumber, 
     data2:0
   );
}

// Turn on some notes
for (int i = 0; i < instruments; i++ {
   synth.noteOn(channel: i % 16, key: 72, velocity: 120);
   synth.noteOn(channel: i % 16, key: 76, velocity: 120);
   synth.noteOn(channel: i % 16, key: 79, velocity: 120);
   synth.noteOn(channel: i % 16, key: 82, velocity: 120);
}

// Render the waveform (3 seconds)
ArrayInt16 buf16 = ArrayInt16.zeros(numShorts: 44100 * 3);

synth.renderMonoInt16(buf16);

Features #

  • No memory allocation in the rendering process.

  • Wave synthesis

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

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

    • ✅ Reverb
    • ✅ Chorus
  • Other things

    • ✅ Loop extension support
    • ✅ Performace optimization

Todo #

  • MIDI file support.

Feel free to port MIDI file support to Dart and make a pull request.

Its usage would look like this when implemented:

// Create the synthesizer.
var sampleRate = 44100;
var synthesizer = new Synthesizer("TimGM6mb.sf2", sampleRate);

// Read the MIDI file.
var midiFile = MidiFile("flourish.mid");
var sequencer = MidiFileSequencer(synthesizer);
sequencer.play(midiFile, false);

// Render the waveform (3 seconds)
ArrayInt16 buf16 = ArrayInt16.zeros(numShorts: 44100 * 3);

sequencer.renderMonoInt16(buf16);

License #

DartMeltySoundFont is available under the MIT license.

References #

35
likes
0
pub points
73%
popularity

Publisher

verified publisherjamcorder.com

A Soundfont synthesizer (i.e. '.sf2' player) written in pure Dart.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on dart_melty_soundfont