Orientação gerada a partir de informações públicas. Apenas para referência.
Uma implementação pura em Dart de um sintetizador Soundfont que reproduz amostras de áudio .sf2, permitindo reprodução de música multiplataforma em aplicativos Flutter. Projetado para desenvolvedores que desejam integrar sons de instrumentos de alta qualidade sem dependências nativas. O pacote suporta múltiplas plataformas, incluindo Android, iOS, macOS, Windows e Linux, tornando-o ideal para aplicações musicais que exigem síntese sonora portátil. Utiliza o poder do Dart para oferecer renderização de áudio em tempo real com configuração mínima.
Casos de uso
Reproduzindo arquivos MIDI com sons de instrumentos personalizados
Construindo aplicativos de educação musical
Criando instrumentos musicais interativos no Flutter
Integração de bibliotecas de instrumentos amostrados
Desenvolvendo aplicativos de áudio multiplataforma
Principais recursos
Implementação pura em Dart
Suporta arquivos de Soundfont .sf2
Compatibilidade multiplataforma
síntese de áudio em tempo real
Leve e fácil de integrar
Nenhum código nativo necessário
Indicado para
Desenvolvedores Flutter construindo aplicativos de música
Software educacional com áudio interativo
Aplicativos que precisam de sons de instrumentos portáteis
Projetos evitando bibliotecas de áudio específicas da plataforma
Desenvolvedores priorizando simplicidade e portabilidade do código
Considerações
O desempenho pode variar em dispositivos de baixa potência
Arquivos .sf2 grandes aumentam o uso de memória
Limitado ao formato SoundFont 2.0
Requer gerenciamento cuidadoso dos recursos de áudio
Não otimizado para polifonia complexa ou efeitos avançados
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
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.
https://github.com/sinshu/meltysynth
Dependencies
This package has no dependencies.
Maintanence
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 indefinitely.
This package was written against Dart SDK 2.16.1.
Example
Synthesize a simple chord:
// Necessary Importsimport'package:dart_melty_soundfont/dart_melty_soundfont.dart';
import'package:flutter/services.dart'show rootBundle;
// load sf2ByteData bytes = await rootBundle.load('assets/akai_steinway.sf2');
// Create the synthesizer.Synthesizer synth = Synthesizer.loadByteData(bytes,
SynthesizerSettings(
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 bufferArrayInt16 buf16 = ArrayInt16.zeros(numShorts: 44100 * 3);
// render the waveform (1 second)
synth.renderMonoInt16(buf16);
// turn off a note
synth.noteOff(channel: 0, key: 72, velocity: 120);
// render another second
synth.renderMonoInt16(buf16);
Polyphone Soundfont Editor
Some of the test cases were generated with Polyphone.
https://www.polyphone-soundfonts.com/
Freeverb by Jezar at Dreampoint
The implementation of the reverb effect is based on Freeverb.
https://music.columbia.edu/pipermail/music-dsp/2001-October/045433.html