atsushieno / fluidsynth-midi-service-j

JNA-based fluidsynth MIDI device service effort
MIT License
26 stars 8 forks source link

Increase sampe rate #11

Closed mlipkovich closed 5 years ago

mlipkovich commented 5 years ago

Hi Atsushi,

Thanks a lot for sharing your work! That's really useful

As I see from your source code you are using 11025 as sample rate https://github.com/atsushieno/fluidsynth-midi-service-j/blob/master/app/src/main/java/name/atsushieno/fluidsynthmidideviceservicej/FluidsynthMidiReceiver.kt#L37 Is it possible to somehow increase it or there are some limitations on fluidsynth part? I tried just to change the value itself but it led me to some artifacts in synthesized sound

Thanks, Mikhail

atsushieno commented 5 years ago

Hi,

Sorry I didn't notice that github defaults to not-Watch my own repo and therefore there was no notification sent to me...!

I believe that changing the sample rate should just work, but only if the target Android device or emulator is powerful enough to generate synthesized buffers for such bigger outputs.It is usually okay for desktop but not for resource-limited mobile devices. I did suffer from that, which is why I set the sample rate to 11k.

mlipkovich commented 5 years ago

Thank you for your response!

I see. That's a pitty. Somehow this application which seems to be using FluidSynth as well has a (subjectively) better sound quality for the same sf2 database
https://play.google.com/store/apps/details?id=org.greh.soundfontmidiplayer&hl=en_US

atsushieno commented 5 years ago

The app description says it uses unmodified fluidsynth which means there is no native audio output for Android.

With that description I can only think of some attempts to use pulseaudio on Android that would make it to happen to connect to pulseaudio driver in fluid_pulse.c.

atsushieno commented 5 years ago

Actually, it does not use FluidR3_GM.sf2. And the app can just use file audio output too. The entire comparison doesn't make sense.

mlipkovich commented 5 years ago

Speaking of FluidR3_GM.sf2, I was using my own sf2 database both for your implementation and for the app. Could you please elaborate a little bit more on "no native audio output for Android"? What are the drawbacks of that for me as a library user who is willing to dynamically generate some midi output as in your example? https://github.com/atsushieno/fluidsynth-midi-service-j/blob/master/app/src/main/java/name/atsushieno/fluidsynthmidideviceservicej/MainActivity.kt#L51 Sorry if I'm asking obvious things - I've just started diving into midi and Android in general

atsushieno commented 5 years ago

fluidsynth comes with "drivers" where each of those implements handling of audio outputs. On Windows it is Win32 API, on MacOS it is CoreAudio, on Linux it is ALSA, Jack, Pulse... kinda. There was no OpenSLES or AAudio support in Android, which is why this fork exists.

If people want to use fluidsynth without audio outputs, they have to use file audio output and play the file as the synthesis results. For playing MIDI songs it would be still okay. For interactive apps where users dynamically give inputs to fluidsynth via MIDI messages, it won't work.

mlipkovich commented 5 years ago

Thanks for the detailed explanation! Actually in the app they have an interactive piano roll but I guess potentially it could be implemented using generation of file for each event?

atsushieno commented 5 years ago

Actually I misread the "About & Help" section, it says modified version. So it is possible that it has own Android driver implementation. Or it can be any other trick. You could directly ask the author for their details as denoted on the dialog:

image

mlipkovich commented 5 years ago

Thank you so much for all the information! No everything is clear :)