-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to play sound ? #22
Comments
Playing sound to the speakers is beyond the scope of FluidLite, as described in the README: You can use the RtAudio library to output sound for instance: https://github.com/thestk/rtaudio |
Hey @divideconcept, thanks for your quick response. Yes, I know that audio output is beyond the scope of this project. In fact, I didn't want to open an issue because this is not an issue, but I didn't find anywhere else to post the question. May I do a suggestion for your project? I am looking to play midi notes in an Android app. I have looked for Midi synthesizers around the web and found these projects: https://github.com/billthefarmer/mididriver - this one works great, there's a sample app ready to go, but there's no way to change the default soundbank I think that your project might do the job: a lite version of FluidSynth with ability to change soundbanks and without performance issues. However, I don't have experience in building and compiling C application, so I am kind of stuck. If you could provide a sample Android app that plays a simple midi note (like in BillTheFramer's repo), I think more people would gravitate towards your repo, since it will offer user friendliness, relief to the developer of having to know how to compile, build and link C code, and flexibility to change soundbanks. Just my two cents, I really thank you for having this project! |
There are ports of fluidsynth to Android, you probably want one of them as they are more feature complete (they support MIDI playing and audio output - Both stuff that is out of scope in fluidlite) Audio output is highly platform dependent and a complex topic so I can understand why there are zero examples about this. For using Fludlite I recommend that you look at SDL2 Audio example code. In SDL_OpenAudioDevice register a callback function. This callback function is called when the audio buffer is exhausted. In that callback ask fluidlite to write audio in the buffer. For just targeting Android without SDL2 you likely have to do something like exporting fluidlite API through JNI, copying the audio buffer to Java and playing it through the Android Audio API (no idea how to do this). This is also annoying and hard to get right. |
I succesfully got it to work using SOKOL (https://github.com/floooh/sokol) which can also compile to ANDROID:
My AHA moment was that there's many ways to forward audio inside C, but in the end it boils down to understanding the audiobuffer (sizes) of the parent process and the child process (fluid). |
would be nice to have an alsa example of the same or sdl sound |
ALSA-example.zip working great :) |
openaldemo.c.zip -- needs work still in the buffer converter |
sdldemo.cpp.zip -- still needs work |
qFluidlite.zip |
sdldemo.cpp.zip |
OpenalDemo.cpp.zip working now too |
might make a plugin for cAudio next. also raycasted reverb |
https://github.com/netpipe/cAudio my fork of caudio that can play fluidlite in 3d check examples folder for example 10 |
@netpipe Do you have a tutorial for putting it all together? I'm interested in combining fluidlite with realtime audio playback on a Raspberry Pi Pico, or SAMD51 or something. |
you will need a microchip that supports linux or windows. |
@netpipe Do you think it can run on a microcontroller (Raspberry Pi Pico or SAMD51) that have no OS, just bare metal? Since this variant of FluidSynth has few dependencies and is all static, I was hoping to run it on one of those minimal chips. |
its not designed to because you'll need sd card library and other stuff to make filesystem work. |
Co you have an example where there is actual sound output from the synthesizer?
If I am not wrong, the code in example/main.c produces an output file of float32output.pcm . I am guessing this is the output raw data. How can I play this sound ?
I am on Windows 10, and I compiled and ran the example/main.c with Cygwin.
Thanks
The text was updated successfully, but these errors were encountered: