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

패키지 상세v4.0.4

flutter_midi_pro

`flutter_midi_pro` 플러그인은 SoundFont (.sf2) 파일을 로드하고, 악기 변경 및 MIDI 명령으로 노트를 재생하는 기능을 제공합니다.

AndroidiOSmacOS
30일 다운로드
2.7천
좋아요
33
Pub 점수
150

패키지 설치

flutter pub add flutter_midi_pro

패키지 개요

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

flutter_midi_pro는 SoundFont(.sf2) 파일을 통해 오디오 합성을 가능하게 하는 플러터 플러그인으로, 사용자가 악기를 로드하고 전환하며 MIDI 노트를 재생할 수 있도록 합니다. 안드로이드, iOS, macOS를 지원하여 고품질의 악기 재생이 필요한 음악 애플리케이션에 적합합니다. 이 플러그인은 플러터의 UI 프레임워크와 원활하게 통합되어 개발자들이 앱에 상호작용 가능한 음악 기능을 쉽게 추가할 수 있도록 합니다. 특히 교육 도구, 가상 악기 또는 음악 작곡 앱에 유용합니다.

사용 사례

  • 가상 피아노 애플리케이션
  • 음악 교육 도구
  • 인터랙티브 사운드 효과
  • MIDI 기반 게임 오디오
  • 앱에서 장비 전환

주요 기능

  • .sf2 SoundFont 파일을 지원합니다
  • 실시간 MIDI 노트 재생
  • 장비 전환
  • 다중 플랫폼 호환성 (Android, iOS, macOS)
  • 사운드를 로드하고 재생하기 위한 간단한 API

적합한 대상

  • 음악 앱을 개발하는 개발자
  • 교육 소프트웨어 제작자
  • MIDI 오디오가 필요한 게임 개발자
  • Flutter를 사용하는 오디오 애호가

고려 사항

  • 악기 데이터용 .sf2 파일이 필요합니다
  • 큰 SoundFont 사용 시 메모리 사용량 증가
  • MIDI 노트 이벤트에 한정
  • 성능은 장치의 오디오 기능에 따라 달라집니다
  • 복잡한 오디오 처리에 적합하지 않습니다

원본 README

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

flutter_midi_pro

pub packageGitHub stars GitHub issues

A SoundFont (.sf2) synthesizer plugin for Flutter, powered by FluidSynth on Android and AVFoundation on iOS/macOS.

  • Load multiple SoundFonts at once and play notes on 16 MIDI channels per soundfont
  • Full expression surface: pitch bend (+ bend range), channel/key aftertouch, any MIDI CC, sustain, master gain, panic
  • List the instruments inside an SF2 (getPresets) and switch presets per channel
  • MIDI file (.mid) playback with pitch-preserving tempo control, seek and loop (Android)
  • Built-in effects: reverb & chorus (FluidSynth), equalizer / delay / distortion (iOS/macOS)
  • Explicit init/dispose lifecycle, pop-free audio, automatic recovery from interruptions and route changes

Windows, Linux and Web support may be added in the future.

Android

The native (FluidSynth) part of the plugin is built with CMake, but no specific CMake version is required. The Android Gradle Plugin automatically downloads and uses its bundled CMake version from the Android SDK — no manual installation is needed. Any CMake from 3.18 up to and including 4.x works.

If you prefer to use your own CMake installation (e.g. the system CMake on Linux), you can optionally point cmake.dir in your project's local.properties to it. In that case make sure ninja is available on your PATH.

The official FluidSynth Android binaries (~40 MB) are downloaded automatically on the first build, checksum-verified and cached in the Gradle user home — later builds are offline. For fully offline environments, download fluidsynth-vX.Y.Z-android24.zip from the FluidSynth releases and unpack it to <plugin>/android/src/main/cpp/fluidsynth/ (so that include/ and lib/<abi>/ sit directly under it); a vendored copy takes precedence over the download.

Installation

To use this plugin, add flutter_midi_pro using terminal or pubspec.yaml file.

flutter pub add flutter_midi_pro

Usage

Import flutter_midi_pro.dart and use the MidiPro class to access the plugin's functions. MidiPro class is a singleton class, so you can use the same instance of the class in your application.

import 'package:flutter_midi_pro/flutter_midi_pro.dart';
Initialize

The package does nothing until it is initialized: no audio engine is created and no audio stream is opened. Call init before using any other method.

final midiPro = MidiPro();
await midiPro.init();
// Optional tuning knobs (defaults shown):
// await midiPro.init(sampleRate: 44100, bufferSize: 64, polyphony: 64);

Calling init while already initialized throws a StateError (call dispose first to re-initialize), and calling any other method before init also throws a StateError. You can check the current state with midiPro.isInitialized.

Load SoundFont File

Use the loadSoundfontAsset, loadSoundfontFile or loadSoundfontData functions to load a SoundFont file. These functions return an integer value that represents the soundfont ID. You can use this ID to load instruments from the SoundFont file and play MIDI notes. These functions load the instrument at the given bank and program number to all channels (0-15). If you want to load a specific instrument, you can use the selectInstrument function. Up to 16 soundfonts can be loaded at the same time; call unloadSoundfont(sfId) to release one.

final soundfontId = await midiPro.loadSoundfontAsset(assetPath: 'assets/soundfont.sf2', bank: 0, program: 0);
List and Select Instruments

getPresets lists every instrument inside a loaded soundfont — ready to feed an instrument picker — and selectInstrument binds an instrument at the given bank and program to a specific channel.

final presets = await midiPro.getPresets(soundfontId); // [(bank, program, name), ...]
await midiPro.selectInstrument(sfId: soundfontId, channel: 0, bank: 0, program: 0);
Play and Stop Notes

Use the playNote function to play a MIDI note. The key is the MIDI note number (0-127) and the velocity is the volume of the note (0-127). stopNote stops it on the same channel.

midiPro.playNote(sfId: soundfontId, channel: 0, key: 60, velocity: 127);
midiPro.stopNote(sfId: soundfontId, channel: 0, key: 60);
Expression and Control
await midiPro.pitchBend(value: 12000, channel: 0, sfId: soundfontId); // 0-16383, 8192 = center
await midiPro.setPitchBendRange(semitones: 12, channel: 0, sfId: soundfontId);
await midiPro.channelPressure(pressure: 90, channel: 0, sfId: soundfontId); // aftertouch
await midiPro.setSustain(enabled: true, channel: 0, sfId: soundfontId);
await midiPro.controlChange(controller: 10, value: 30, channel: 0, sfId: soundfontId); // any MIDI CC
await midiPro.setMasterGain(1.5); // global volume, 1.0 = default
await midiPro.panic();            // instantly silence everything

sendMidiEvent accepts raw MIDI channel messages, which makes it easy to bridge hardware MIDI input straight into the synthesizer.

MIDI File Player (Android)

Play Standard MIDI Files through a loaded soundfont — with pitch-preserving tempo scaling for practice, seeking and looping. File channels 0-15 play on the target soundfont's channels, so instrument selection and expression controls apply to playback too.

await midiPro.loadMidiAsset(assetPath: 'assets/song.mid', sfId: soundfontId);
await midiPro.setMidiTempo(0.5); // half speed, same pitch
await midiPro.setMidiLoop(-1);   // loop forever
await midiPro.playMidi();        // pauseMidi() / stopMidi() / seekMidi(tick)
final state = await midiPro.getMidiPlayerState(); // status, position, BPM, PPQ

Currently Android-only; iOS/macOS throw an UNSUPPORTED error for these methods.

Dispose

Use the dispose function to shut the synthesizer down: it stops all notes, unloads all soundfonts and releases the audio engine. After disposing you can call init again to start a fresh session; this cycle can be repeated any number of times.

await midiPro.dispose();
Audio session (iOS)

On iOS you can control how the synthesizer coexists with other audio — keep background music playing, survive video/ad audio session takeovers, and play regardless of the ring/mute switch:

await midiPro.configureAudioSession(
  category: AudioSessionCategory.playback,
  mixWithOthers: true,
);

This is iOS-only and a no-op on Android/macOS. The plugin also recovers automatically from audio interruptions (calls, Siri, ads), route changes (headphones/Bluetooth) and media services resets on iOS/macOS.

Effects
await midiPro.setReverb(enabled: true, roomSize: 0.6, level: 0.9); // all platforms
await midiPro.setChorus(enabled: true);                            // Android only
await midiPro.setEqualizer(enabled: true, bassGain: 6, trebleGain: 3); // iOS/macOS only
await midiPro.setDelay(enabled: true, time: 0.3, wetDryMix: 30);       // iOS/macOS only
await midiPro.setDistortion(enabled: true, preset: DistortionPreset.multiDistortedFunk); // iOS/macOS only
Platform support
Feature Android iOS macOS
Notes, control change, pitch bend, aftertouch, master gain, panic ✅ ✅ ✅
Preset listing (getPresets) ✅ ✅ ✅
Reverb (setReverb) ✅ full parameters ✅ preset + level ✅ preset + level
Chorus (setChorus) ✅ — —
Equalizer / Delay / Distortion — ✅ ✅
Audio session config (configureAudioSession) — ✅ —
MIDI file player (loadMidiFile, playMidi, …) ✅ planned planned
init sampleRate/bufferSize/polyphony ✅ synth settings ✅ session preferences (no polyphony) —

Example

You can find a complete example in the example directory — an interactive playground covering the full lifecycle (init/dispose), soundfont loading, an instrument picker built on getPresets, a piano with pitch bend, master gain, effects and the MIDI file player.

Contributions

Contributions are welcome! Please feel free to submit a PR or open an issue.

Contact

If you have any questions or suggestions, feel free to contact the package maintainer, Melih Hakan Pektas, via email or through GitHub.

Melih Hakan Pektas

Thank you for contributing to flutter_midi_pro!

License

This project is licensed under the MIT License. See the LICENSE file for details.

카테고리

의존성

의존성 목록 2 개

소스 저장소

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

아직 데이터가 없습니다.