Git Product home page Git Product logo

flutter_midi's Introduction

Buy Me A Coffee Donate github pages GitHub stars flutter_midi

flutter_midi

A FLutter Plugin to Play midi on iOS and Android. This uses SoundFont (.sf2) Files.

Online Demo: https://rodydavis.github.io/flutter_midi/

Installation

Download a any sound font file, example: sound_font.SF2 file.

Create an /assets folder and store the .sf2 files

Update pubspec.yaml

assets:
   - assets/sf2/Piano.SF2
   - assets/sf2/SmallTimGM6mb.sf2

Load the sound font to prepare to play;

 @override
  void initState() {
    load('assets/sf2/Piano.SF2');
    super.initState();
  }
  
 void load(String asset) async {
    FlutterMidi.unmute(); // Optionally Unmute
    ByteData _byte = await rootBundle.load(asset);
    FlutterMidi.prepare(sf2: _byte);
  }

Play and Stop the Midi Notes

 FlutterMidi.playMidiNote(midi: 60);
 FlutterMidi.playMidiNote(midi: 60, velocity: 120);

 FlutterMidi.stopMidiNote(midi: 60);
 FlutterMidi.stopMidiNote(midi: 60, velocity: 120);

flutter_midi's People

Contributors

canastro avatar knoapp avatar rodydavis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flutter_midi's Issues

Broken link to sf2 file on README of flutter_midi

The link to sound_font.SF2 on the README of flutter_midi leads to Google Drive which says the requested file is not found.
FYI just in case the issue has something to do with my location, I accessed it from Japan.

macos support?

Are there any plans to build in support for flutter apps running on macos?

Thannks

[flutter_midi] Lag

There's a significant delay on my Android between pressing a button and hearing the sound. How can I try to make it faster?

How to properly close and release resource?

Hello, good day!

I have been developing a little app (for Android) which uses flutter_midi. Basically the app will allow the user to input notes and play them back,similar to an audio sequencer.

Then one night after developing and testing, I left the app minimized from background (Pressing the home button). The next day, the phone battery level dropped hard and the phone overheats a little. Ultimately I found that the problem is caused by my app.

Upon further research, and by checking the battery graph, I found that my phone is awake at all times. I used Wakelock Detector app to confirm what caused the phone to be in that state, and found that my app is responsible for that. The app has been in CPU Wakelock overnight, consuming and battery.

Then I found that the app process that caused that is called "AudioMix", I suspect that the app is not closed properly due to the audio playback. Even the audio have been stopped playing, the process still keeps running until I eventually closed my app either by force stopping or swiping up from recent apps.

I tried to find a way to make the app to release all possible resource programmatically. However I cannot find that in the flutter_midi documentation. Can only find play_midi_note and stop_midi_note function. Even the stop function cannot completely stop the playback from running

Is there a way to completely close flutter_midi to free up the resource?

TIA

Can't play multiple notes

Hello!

First of all, thank you for this amazing plugin! I'm trying to play 3 notes in a row (same SF2 file, no need to load any other). But it does not seem to work :(

I'm using version 1.0.1 of the plugin from pub.dev. This is the code i trued (It's basically your example + subsequent calls to playMidiNote()):

Scaffold(
      appBar: AppBar(
        title: Text('Example'),
      ),
      body: Center(
          child: RaisedButton(
            child: Text("Test"),
            onPressed: () async {
              await _flutterMidi.playMidiNote(midi: 70);
              await Future.delayed(Duration(seconds: 1), () async {
                await _flutterMidi.stopMidiNote(midi: 70);
                await _flutterMidi.playMidiNote(midi: 61);
              });
              await Future.delayed(Duration(seconds: 1), () async {
                await _flutterMidi.playMidiNote(midi: 65);
              });
            },
          )
      ),
    );

When i run this on my Android 10 device (real device, not emulator) it seems that it only plays the first note.

Any ideas why this may be happening?

Here you have my flutter doctor:

[✓] Flutter (Channel dev, 1.19.0-4.0.pre, on Mac OS X 10.15.4 19E287, locale es-ES)
    • Flutter version 1.19.0-4.0.pre at /Users/ja2375/flutter
    • Framework revision 2f7a59a8da (2 days ago), 2020-06-05 03:44:02 -0700
    • Engine revision d17c84e7af
    • Dart version 2.9.0 (build 2.9.0-13.0.dev 02915ec5ce)


[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
    • Android SDK at /Users/ja2375/Library/Android/sdk
    • Platform android-29, build-tools 29.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    • CocoaPods version 1.8.4

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 46.0.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.45.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.10.2


[✓] Connected device (3 available)
    • GM1913     • 192.168.5.11:5555 • android-arm64  • Android 10 (API 29)
    • Web Server • web-server        • web-javascript • Flutter Tools
    • Chrome     • chrome            • web-javascript • Google Chrome 83.0.4103.61

• No issues found!

Thanks again!

The plugin `flutter_midi` uses a deprecated version of the Android embedding.

The plugin flutter_midi uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

How to play a note with specific speed in flutter_midi ?

static Future playMidiNote({
@required int midi,
}) async {
final Map<dynamic, dynamic> mapData = <dynamic, dynamic>{};
print("Pressed: $midi");
mapData["note"] = midi;
return await _channel.invokeMethod('play_midi_note', mapData);
}

Are there others parameters that can be added in mapData in order to change de default note behavior, like speed for example?

[Android] FlutterMidi.stopMidiNote isn't working on Android.

The following snippet only seams to work on iOS, but on Android, the midi notes start, but never stop playing.

// Init.
final _flutterMidi = FlutterMidi();
final file = await rootBundle.load("assets/Test File.sf2");
_flutterMidi.prepare(sf2: file, name: "Test File.sf2");

await _flutterMidi.playMidiNote(midi: x); // Play.
await Future<void>.delayed(...); // Wait.
await _flutterMidi.stopMidiNote(x); // Stop. <-- This line doesn't seem to work.

[flutter_midi] "java.util.prefs: Couldn't create user preferences directory. User preferences are unusable."

When I run the example app it prints the following error:

W/java.util.prefs(11715): Couldn't create user preferences directory. User preferences are unusable.               
W/java.util.prefs(11715): java.io.IOException: No such file or directory

This is not a bug per se because the app works regardless. I'm just wondering what this means.

Moreover, I find it odd that in the log I can see the line Path => ... but not the Result: .... As if the prepare_midi never returns. The code that prints those is here:

https://github.com/AppleEducate/plugins/blob/8f5c0064d4e169135c101a88d097b60648e41a15/packages/flutter_midi/lib/flutter_midi.dart#L20-L22

Steps to Reproduce

Run the example app in packages/flutter_midi/example with flutter run

Logs

❯ flutter run
Launching lib/main.dart on F5321 in debug mode...
Initializing gradle...                                              5.0s
Resolving dependencies...                                          20.9s
Running Gradle task 'assembleDebug'...                                  
Running Gradle task 'assembleDebug'... Done                         9.0s
Built build/app/outputs/apk/debug/app-debug.apk.
I/flutter (11715): Loading File...
Syncing files to device F5321...                                        
I/flutter (11715): Path => /mnt/expand/e2e52c2a-20c5-4027-a28a-5c867197d67d/user/0/com.appleeducate.fluttermidiexample/app_flutter/SmallTimGM6mb.sf2
I/zygote64(11715): Do partial code cache collection, code=30KB, data=27KB                                          
I/zygote64(11715): After code cache collection, code=30KB, data=27KB                                               
I/zygote64(11715): Increasing code cache capacity to 128KB                                                         
W/java.util.prefs(11715): Couldn't create user preferences directory. User preferences are unusable.               
W/java.util.prefs(11715): java.io.IOException: No such file or directory                                           
I/zygote64(11715): Do partial code cache collection, code=61KB, data=42KB                                          
I/zygote64(11715): After code cache collection, code=43KB, data=32KB                                               
I/zygote64(11715): Increasing code cache capacity to 256KB                                                         
D/AudioTrack(11715): Client defaulted notificationFrames to 1768 for frameCount 5304                               
W/AudioTrack(11715): Use of stream types is deprecated for operations other than volume control                    
W/AudioTrack(11715): See the documentation of AudioTrack() for what to use instead with android.media.AudioAttributes to qualify your playback use case
I/zygote64(11715): Compiler allocated 5MB to compile cn.sherlock.com.sun.media.sound.ModelPerformer[] cn.sherlock.com.sun.media.sound.SF2Instrument.getPerformers()
I/zygote64(11715): Do full code cache collection, code=124KB, data=88KB                                            
I/zygote64(11715): After code cache collection, code=75KB, data=54KB                                               
I/Choreographer(11715): Skipped 73 frames!  The application may be doing too much work on its main thread.         
Syncing files to device F5321...                                 6,528ms (!)                                       

🔥  To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
An Observatory debugger and profiler on F5321 is available at: http://127.0.0.1:46217/
For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".
I/flutter (11715): Pressed: 60
I/zygote64(11715): Do partial code cache collection, code=110KB, data=79KB
I/zygote64(11715): After code cache collection, code=110KB, data=79KB
I/zygote64(11715): Increasing code cache capacity to 512KB

flutter doctor -v

❯ flutter doctor -v
[✓] Flutter (Channel beta, v1.4.9-hotfix.1, on Linux, locale en_US.UTF-8)
    • Flutter version 1.4.9-hotfix.1 at /home/antti/tools/flutter
    • Framework revision 88fa7ea403 (13 days ago), 2019-04-11 14:01:46 -0700
    • Engine revision 4737fc5cd8
    • Dart version 2.2.1 (build 2.2.1-dev.4.0 None)

[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /home/antti/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /home/antti/Android/Sdk
    • Java binary at: /usr/lib/jvm/java-8-openjdk-amd64/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.18.04.1-b12)
    ✗ Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit https://flutter.io/setup/#android-setup for detailed instructions.

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.io/setup/#android-setup for detailed instructions).

[✓] VS Code (version 1.33.1)
    • VS Code at /usr/share/code
    • Flutter extension version 2.25.1

[✓] Connected device (1 available)
    • F5321 • BH9035L55P • android-arm64 • Android 8.0.0 (API 26)

! Doctor found issues in 2 categories.

package build method

I'm going to modify a few things after I fork this project.

After modifying the FlutterMidiPlugin.java file,
which command should I build and push?

flutter build apk -t lib/flutter_midi.dart
this command should not have this error.
[!] Your app is using an unsupported Gradle project. To fix this problem, create a new project by running flutter create -t app and then move the dart code, assets and pubspec.yaml to the new project.

If you give me a help to build,
I want to modify the part of Velocity and programChange.

Support for M1 Macbooks?

Hi.

i've been trying to use the flutter_midi package to build a simple flutter app. If i try to build the app i get following error message:

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require': dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle, 0x0009): tried: '/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/lib/ffi_c.bundle' (no such file) - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle (LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require'
from /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi.rb:5:in rescue in <top (required)>' from /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi.rb:2:in <top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require'
from /Library/Ruby/Gems/2.6.0/gems/ethon-0.15.0/lib/ethon.rb:3:in <top (required)>' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' from /Library/Ruby/Gems/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in <top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:440:in download_typhoeus_impl_async' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:372:in download_and_save_with_retries_async'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:365:in download_file_async' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:338:in download_file'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:53:in refresh_metadata' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source.rb:31:in initialize'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:30:in initialize' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:315:in new'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:315:in block in source_from_path' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:322:in source_from_path'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:331:in block in aggregate_with_repos' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:331:in map'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:331:in aggregate_with_repos' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:26:in aggregate'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:60:in all' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface/error_report.rb:173:in repo_information'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface/error_report.rb:77:in stack' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface/error_report.rb:24:in report'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:66:in report_error' from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:396:in handle_exception'
from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:337:in rescue in run' from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:324:in run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:52:in run' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/bin/pod:55:in <top (required)>'
from /usr/local/bin/pod:23:in load' from /usr/local/bin/pod:23:in

'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require': cannot load such file -- 2.6/ffi_c (LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require'
from /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi.rb:3:in <top (required)>' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' from /Library/Ruby/Gems/2.6.0/gems/ethon-0.15.0/lib/ethon.rb:3:in <top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require'
from /Library/Ruby/Gems/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in <top (required)>' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:440:in download_typhoeus_impl_async'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:372:in download_and_save_with_retries_async' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:365:in download_file_async'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:338:in download_file' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:53:in refresh_metadata'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source.rb:31:in initialize' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:30:in initialize'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:315:in new' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:315:in block in source_from_path'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:322:in source_from_path' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:331:in block in aggregate_with_repos'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:331:in map' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:331:in aggregate_with_repos'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:26:in aggregate' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:60:in all'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface/error_report.rb:173:in repo_information' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface/error_report.rb:77:in stack'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface/error_report.rb:24:in report' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:66:in report_error'
from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:396:in handle_exception' from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:337:in rescue in run'
from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:324:in run' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:52:in run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/bin/pod:55:in <top (required)>' from /usr/local/bin/pod:23:in load'
from /usr/local/bin/pod:23:in <main>' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require': dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle, 0x0009): tried: '/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/lib/ffi_c.bundle' (no such file) - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' from /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi.rb:5:in rescue in <top (required)>'
from /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi.rb:2:in <top (required)>' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' from /Library/Ruby/Gems/2.6.0/gems/ethon-0.15.0/lib/ethon.rb:3:in <top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require'
from /Library/Ruby/Gems/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in <top (required)>' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:440:in download_typhoeus_impl_async'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:372:in download_and_save_with_retries_async' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:365:in download_file_async'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:338:in download_file' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:53:in refresh_metadata'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source.rb:31:in initialize' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:30:in initialize'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:315:in new' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:315:in block in source_from_path'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:322:in source_from_path' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:331:in block in aggregate_with_repos'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source/manager.rb:331:in `map'

if i run the app without the package everything works fine. Is there a way to resolve this issue on my side?

Unhandled Exception: MissingPluginException(

Dear Sir

Any idea for...

E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(171)] Unhandled Exception: MissingPluginException(No implementation found for method play_midi_note on channel flutter_midi)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158)

#1 FlutterMidi.playMidiNote (package:flutter_midi/flutter_midi.dart:69)

#2 _MyAppState._play (package:melody/main.dart:552)

iOS voice memo recording stops

I have using flutter_midi to play sound in one of my flutter mobile app project.
and I noticed that when I open iOS app its stop Voice memo recoding.

I want recording should continue when Open aiOs pp, ( in Android build , voice recording continue )

Steps : 1 open Voice memo recoding apps ,
2 start recording
3. open app which has flutter_midi added
recording is stoped automatically when open app.

Thanks,
Rushiraj

flutter_midi can't integrated into an existing app as a module

hi,
when i use flutter_midi in a flutter module about my ios app, i get a crash.

in xcode error like this:
2020-11-19 14:53:14.142725+0800 piano_demo[3130:923294] [VERBOSE0:callback_cache.cc(133)] Could not parse callback cache, aborting restore
(lldb)

image

how can i fix it

Xcode 11.2.1 AVAudioSessionCategoryPlayback

Xcode
Classes -> SwiftFlutterMidiPlugin.swift
Line 40

From
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)

to
try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback)

Stop sound

I simply want a method to stop playing the sound. I'm thinking on making my own change and then do a PR but what are your thoughts on this?

Support for macOS

I wonder if there is any possibility of bringing the compatibility to macOS.

I don't know how different is the architecture to run this project on both iOS and macOS, but many projects don't have many difficulties to bring compatibility to macOS from iOS because they both use Swift and have some things in common.

Thank you.

Switching instruments in sf2 file

Hi, I have a sf2 file w/ multiple instruments:
image

How do I select the instrument? Right now I only see note select...does that default to first instrument in file?

Await of unmute() blocks the program

If we call unmute() method using await feature, it'll just block a program execution:

  void _load(String asset) async {
    await f.unmute(); // <--- HERE IS A BLOCKING METHOD
    //So, this code will not be executed:
    ByteData _byte = await rootBundle.load(asset);
    await f.prepare(sf2: _byte);
  }

Is it possible to call prepare to load a second .sf2 file?

Hi,

First, thanks for the great library!

I'm trying to have two different modes in my app, one using a percussion .sf2 file and another for bass with a different sf2 file. I tried calling the prepare method a second time with the second sf2 file name, but it still seems to use the first. Is there a way to "unload" the first sf2 file and then load a second?

Thanks,

Jim

Unhandled Exception: MissingPluginException on MacOS

I added the plugin and decided to follow the example, but i get this error:

#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:7)
<asynchronous suspension>
#1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:334:12)
#2      FlutterMidi.unmute (package:flutter_midi/flutter_midi.dart:47:42)
#3      MotivateViewModel.load (package:motivate/core/viewmodels/motivate_vm.dart:60:17)
#4      MotivateViewModel.loadData (package:motivate/core/viewmodels/motivate_vm.dart:42:5)
#5      _HomeState.afterFirstLayout (package:motivate/views/home.dart:31:14)
#6      AfterLayoutMixin.initState.<anonymous closure> (package:after_layout/after_layout.dart:10:38)
#7      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1117:15)
#8      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1064:9)
#9      SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:865:7)
#10     _rootRun (dart:async/zone.dart:1182:47)
#11     _CustomZone.run (dart:async/zone.dart:1093:19)
#12     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
#13     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
#14     _rootRun (dart:async/zone.dart:1190:13)
#15     _CustomZone.run (dart:async/zone.dart:1093:19)
#16     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1021:23)
#17     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
#18     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:397:19)
#19     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:428:5)
#20     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

[ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: MissingPluginException(No implementation found for method prepare_midi on channel flutter_midi)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:7)
<asynchronous suspension>
#1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:334:12)
#2      FlutterMidi.prepare (package:flutter_midi/flutter_midi.dart:23:24)
<asynchronous suspension>
#3      MotivateViewModel.load (package:motivate/core/viewmodels/motivate_vm.dart:62:17)
<asynchronous suspension>
#4      MotivateViewModel.loadData (package:motivate/core/viewmodels/motivate_vm.dart:42:5)
#5      _HomeState.afterFirstLayout (package:motivate/views/home.dart:31:14)
#6      AfterLayoutMixin.initState.<anonymous closure> (package:after_layout/after_layout.dart:10:38)
#7      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1117:15)
#8      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1064:9)
#9      SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:865:7)
#10     _rootRun (dart:async/zone.dart:1182:47)
#11     _CustomZone.run (dart:async/zone.dart:1093:19)
#12     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
#13     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
#14     _rootRun (dart:async/zone.dart:1190:13)
#15     _CustomZone.run (dart:async/zone.dart:1093:19)
#16     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1021:23)
#17     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
#18     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:397:19)
#19     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:428:5)
#20     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

Android build.gradle needs updating to version 29

Running Flutter 1.26.0-2.0.pre-406 together with the latest Android tools, the flutter_midi app won't compile as the build.gradle is set to 28. When manually changing it to 29 my app compiles. Please update the build version to 29.

no reproduce notes on iOS

getflutterMidi.unmute();
ByteData _sound = await rootBundle.load('assets/sf2/Wurlitzer_EP-Hedsound-V2_2.sf2');
getflutterMidi.prepare(sf2: _sound, name: "Piano");
notifyListeners();

playNote(60);

this example run perfect on Android and no works on iOS, version flutter_midi: ^1.1.0, no show any error.

Dependency to old version of plugin_platform_interface

flutter_midi depends on plugin_platform_interface 1.0.1 and that breaks the apps with dependency on version 2.0.0. An example is when I add "file_picker" library to flutter_piano, I get this error:

And because no versions of flutter_midi match >1.0.2 <2.0.0, file_picker >=3.0.0-nullsafety.3 is incompatible with flutter_midi ^1.0.2.
So, because flutter_piano depends on both flutter_midi ^1.0.2 and file_picker ^3.0.0, version solving failed.
pub get failed (1; So, because flutter_piano depends on both flutter_midi ^1.0.2 and file_picker ^3.0.0, version solving failed.)```

flutter_midi/AudioUnitMIDISynth.swift:148: Fatal error: initialize graph first

I'm having this error "flutter_midi/AudioUnitMIDISynth.swift:148: Fatal error: initialize graph first", and I really don't know what to do to solve it, thanks

final ByteData _sound = await rootBundle.load('assets/sf2/Wurlitzer_EP-Hedsound-V2_2.sf2');
getflutterMidi.prepare(sf2: _sound, name: "Piano");
notifyListeners();

Velocity parameter

Hi,
First, great library!
Is there any way of adding velocity (or volume) to the notes played?

thanks

Midi note play/stop note not working if inside of Future.Delayed

I can't seem to schedule notes on/off using Future.delayed. Am I doing something wrong?

Future load(String asset, FlutterMidi midiPlayer) async {
  midiPlayer.unmute(); // Optionally Unmute
  ByteData _byte = await rootBundle.load(asset);
  await midiPlayer.prepare(sf2: _byte);
}

void playNotes(String asset) async {
  FlutterMidi midiPlayer = FlutterMidi();
  await load(asset, midiPlayer).then((value) {
    midiPlayer.playMidiNote(midi: 60);
    Future.delayed(Duration(seconds: 1), () {
      print ('stops now'); // this prints, but the note continues playing as if there were no noteOff 
      midiPlayer.stopMidiNote(midi: 60);
    });
     
    // if we comment out the previous Future.delayed and uncomment the next two lines, 
    // the noteOff comes at the correct time (but of course sleep blocks the main isolate,
    // breaking the UI; so we can't use this method) 

    // sleep(Duration(seconds: 1));
    // midiPlayer.stopMidiNote(midi: 60);
  });
}

I have tried spawning a new isolate so I could use sleep, but there were many error logs and then neither notes on nor notes off would work at all.

Support for Android V2 embedding

Are there any plans to update your plug-in to support Android V2 embedding? When compiling my app, I now get the warning:

"The plugin flutter_midi uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future
release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration."

Thanks

[flutter_midi]Playing midi notes in background on iOS

I try to write simple app which playing random notes while device stays in background mode. As I can see this could be done by calling unmute method. But unfortunately it still mutes all notes as soon as app enters background mode. In generated XCode project all capabilities set correct.

I believe that implementation of unmute method may be the source of problem

case "unmute":
        do {
            try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
        }...

May be it should be

case "unmute":
        do {
            try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
            try AVAudioSession.sharedInstance().setActive(true)
        } ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.