melihhakanpektas / flutter_midi_pro

MIT License
15 stars 10 forks source link

Instrument metadata #12

Closed KapitanPL closed 7 months ago

KapitanPL commented 7 months ago

How difficult could it be to add some metadata? When loading an instrument? Like what velocities it support? What key-range?

Again, I am willing to offer my help if you point me to where it could be found and what is the structure of the sf2 files.

melihhakanpektas commented 7 months ago

I also don’t have detailed information about .sf2 files for now. I’m just researching. For instance, I learned that instrument names can be extracted, but I haven’t added that functionality. Unfortunately, I couldn’t manage to retrieve instrument names on the Apple side. However, I hadn’t come across anything related to key ranges. Velocity is supported up to 127 for all instruments, which is also mentioned in the explanation of the play method. It might be possible to create a listenable variable that indicates the loading status of the SF2 file. If you’re familiar with writing platform-specific code, I’d appreciate your assistance when I have the time to work on it. 🙂

KapitanPL commented 7 months ago

I made some research as well...

There seems to be a lot of C++ libraries to handle that.

As far as I can say it seems that C++ code can be handled the same way as your kotlin code.

But I have never written anything such platform specific.

I will try to understand how it works for your code, read some manuals... and then maybe fork your repo and try to write c++ backend?

What do you see as better way? As far as I understand it C++ code could be "platform agnostic" with only platform dependent loading/build.

melihhakanpektas commented 7 months ago

In mobile platforms, native languages always offer the best practices. For Android, Java or Kotlin are commonly used. However, as I mentioned before, Java doesn’t have its own MIDI library for Android, whereas it exists in the library written for Windows. I attempted a straightforward copy-paste translation to mobile, but there’s a high likelihood of encountering issues, including latency and loading time problems. I’ve learned the hard way why musicians insist on using macOS and iOS.

In Android, especially latency is quite high. There are more issues related to that. If the solution you found doesn’t increase the latency, why not :) I’d be happy to approve your request.