패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.0.0

dart_melty_soundfont

순수한 Dart로 작성된 사운드포트 싱เธ사이저(즉 '.sf2' 플레이어).

AndroidiOSmacOSWindowsLinux
30일 다운로드
2.1천
좋아요
51
Pub 점수
140

패키지 설치

flutter pub add dart_melty_soundfont

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

.sf2 오디오 샘플을 재생하는 순수 Dart 구현의 사운드포트 싱เธ사이저로, Flutter 앱에서 크로스 플랫폼 음악 재생을 가능하게 합니다. 네이티브 종속성 없이 고품질 악기 사운드를 통합하고자 하는 개발자를 위한 것입니다. Android, iOS, macOS, Windows, Linux 등 여러 플랫폼을 지원하여 포터블 사운드 합성 요구가 있는 음악 애플리케이션에 적합합니다. Dart의 강력한 기능을 활용해 최소한의 설정으로 실시간 오디오 렌더링을 제공합니다.

사용 사례

  • 사용자 지정 악기 사운드로 MIDI 파일 재생
  • 음악 교육 앱 만들기
  • Flutter에서 상호작용형 악기를 만들기
  • 샘플링된 악기 라이브러리 통합
  • 크로스 플랫폼 오디오 애플리케이션 개발

주요 기능

  • 순수한 다트 구현
  • .sf2 사운드폰트 파일을 지원합니다
  • 크로스 플랫폼 호환성
  • 실시간 오디오 합성
  • 경량이며 통합이 쉬움
  • 네이티브 코드가 필요하지 않습니다

적합한 대상

  • 음악 앱을 개발하는 Flutter 개발자
  • 인터랙티브 오디오를 갖춘 교육 소프트웨어
  • 이동식 악기 사운드가 필요한 앱
  • 플랫폼 고유의 오디오 라이브러리를 피하는 프로젝트
  • 코드의 단순성과 이식성을 우선시하는 개발자

고려 사항

  • 저사양 기기에서는 성능이 다를 수 있습니다
  • 큰 .sf2 파일은 메모리 사용량을 증가시킵니다
  • 사운드포트 2.0 형식만 가능
  • 오디오 리소스를 신중하게 관리해야 합니다
  • 복잡한 폴리포니 또는 고급 효과를 위한 최적화되지 않음

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

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 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, 
    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 buffer
ArrayInt16 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);

Synthesize notes from a MIDI file playback:

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

// Load the soundfont file
ByteData bytes = await rootBundle.load('assets/akai_steinway.sf2');

// Create the synthesizer
Synthesizer synth = Synthesizer.loadByteData(bytes);

// Load MIDI file from asset
ByteData midiBytes = await rootBundle.load('assets/arabesque.mid');
MidiFile midiFile = MidiFile.fromByteData(midiBytes);

// Start MIDI playback
MidiFileSequencer sequencer = MidiFileSequencer(synth);
sequencer.play(midiFile, loop: false);

// Change the playback speed.
sequencer.speed = 1.5;

// Render 10 seconds of playback into PCM buffer
ArrayInt16 buf16 = ArrayInt16.zeros(numShorts: 44100 * 10);
sequencer.renderMonoInt16(buf16);

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.

Isolates

It is recommended to do your audio rendering in isolates or using compute. This will keep your UI fast & prevent audio stuttering.

Features

  • 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] Standard MIDI file support
    • [x] Loop extension support
    • [x] Performance optimization

License

DartMeltySoundFont is available under the MIT license.

References

  • SoundFont® Technical Specification
    http://www.synthfont.com/SFSPEC21.PDF

  • 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

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트