Replies: 22 comments 71 replies
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
-
@komh seems to maintain an OS/2 fork of Fluidsynth here: https://github.com/komh/fluidsynth-os2 Compiled versions seem to be published here: https://ecsoft2.org/fluidsynth |
Beta Was this translation helpful? Give feedback.
-
Language Standard10 years ago, the MSVC compiler didn't accept many C99 features which were available in GCC, so people coding on Linux often contributed code that didn't compile in MSVC. That's why additional strict diagnostics were introduced when configuring for GCC (or compatible) compilers like By the way, whatever the language(s) standard adopted, it should be prominently documented in CONTRIBUTING.md in addition to the wiki and other developer documentation. CMakeIn addition to Tom's list, my favorite request would be exported targets. Why? because right now the only way for a client project using CMake to configure/search Fluidsynth as a dependency is using pkg-config. There is an option With modern CMake versions, you can already import pkg-config targets into your project , and Fluidsynth installs pkg-config support (fluidsynth.pc) but it would be nice to also provide support for |
Beta Was this translation helpful? Give feedback.
-
Regarding my threading patch... It was a terrible patch. It was a thing only because back then I wasn't able to figure out a "painless" way to build glib for Windows and Android. Now that we have stuff like msys2 and mxe, building for Windows is no longer that a mess to deal with. There are also folks providing Android binaries. So the patch isn't really needed anymore. I'm still occasionally maintaining it because I have the legacy setup still in use. And the patch itself has a lot of issues. It breaks LADSPA because I didn't do anything about GModule. It has a completely broken I also personally don't like the idea of mixing C++ code into a code base that's mostly C. I have considered using C11 threading, but no major libc implementation has it back then (CRT on Windows still doesn't have it to this day afaik). A better alternative in my opinion is just using pthread (minimal dependency, won't randomly introduce a file in another language to the code base, and has decent support for legacy platforms as well). Atomic types in C11 can still be used (if we ignore msvc for a moment). GCC comes with C11 atomic types since 4.9, and mingw 4.9 definitely can target Windows 9x (I'm not sure whether atomic types would work with mingw of that age though). If support for certain (very) legacy platforms is an absolute must, and there's a real need to remove glib as a dependency, adding multiple threading implementations and let the user decide which to use at compile time is potentially an option. (I'd say using glib only for concurrency is wasteful though.) And I'm definitely a backer for adding exported targets to the CMake project file. |
Beta Was this translation helpful? Give feedback.
-
I would like to summarize the recent comments: When talking about removing glib, it should be possible to compile fluidsynth with all features without having to compile glib at all. I.e. glib is currently used by fluidsynth and libinstpatch (which provides DLS support). Thus the answer cannot be to move solely fluidsynth to another dlib, xlib, whateverlib. Doing so would simply add yet another dependency and glib would still be required through libinstpatch. To truly remove glib, native DLS support should be added to fluidsynth (alternatively libinstpatch should be glib-free, very difficult). Then, glib should be replaced with a standardized API. Since many of C11's features we require are optional, I'm proposing to move to C++11 instead. Also, using C++11 maintains good compatibilty to old platforms (Solaris, OS/2, WinXP should work fine, only Win9x support is questionable). This is a big effort and will take time. And before going into the implementation details, my questions to all stakeholders are:
@paulsapps @sykhro @komh @pedrolcl @d3nwah @midi-pascal @carlo-bramini @jjceresa @chirs241097 |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
I would like to reiterate my proposal for a less intrusive approach with regards to glib-replacement and the modernization in general. Let me first explain where I'm coming from. Sorry, this is going to be a little longer, but I really wanted to get this off my chest. Skip to "Proposal" below if you don't want to read my whole sermon. Motivationglib ist great :-)In my opinion, glib does a great job at abstracting away (most of) the hardware differences for FluidSynth. It's very actively maintained and extremely well tested due to it being the basis for GTK and Gnome, especially the low-level bits that we mostly use. And it has served us very well for the last few years, we have experience in using it. What does glib provide us?Please extend if I'm missing something, but to my knowledge, we use the following bits from glib:
Reasons for removing glibSo far I've seen the following (good) reasons why we should remove glib or at least make it replaceable:
Who wants to remove glib?Given the reasons above, I see users on the following platforms wanting to remove glib:
C or C++?FluidSynth is written in C. The API design, the internal data structures, data flow, the whole architecture... everything is heavily influenced by the possibilities and limits of the C language. Personally I feel comfortable in C. But in C++ I have only basic knowledge of the syntax. I know next to nothing about design patterns, data-flows, conventions for API design or data structures. And I have exactly zero experience writing C++ myself. I love learning new stuff, so I would be willing to start learning C++... but it would take me while until I would be confident enough to actually help reviewing patches again, let alone contributing new code. But what really drives me to oppose a move to C++ is that I think such a move would only make sense if we are not just changing syntax and replacing some data structures, but actually make good use of that new language. That includes taking advantage of the great tools, patterns and data structures that C++ probably offers (so I've heard). Changing the architecture of FluidSynth to fit into the C++ world. Only then would a move to C++ provide enough benefits to be worthwhile, in my opinion. But that would also probably mean rewriting FluidSynth from scratch. And that in turn would not only be a huge amount of work, it's also a lot of work for an unclear gain. And it would be a project with huge risks... just look at the jack/jack2 mess as an example of what could happen. Yes, using C++ just for a platform interface would be much less intrusive. But even C++11 doesn't offer everything we need as built-ins, so that platform interface would contain a fair amount of C++ code. And I think that is the wrong direction for a C project. ProposalSo, with that all said, I would like to propose to think about this differently. Rather than us providing a solution to the glib problem, let our users experiment with good alternatives to glib. Restructure the FluidSynth code so that all calls and Macros used by our platform interface (glib) can be easily replaced. A little bit like what @paulsapps has proposed in #901, but with documentation, and a clear explanations on how users can write their own wrapper. Then let that simmer for a few months, maybe a year. Watch what interfaces people are writing and how they are using them. Notice how well they maintain their interfaces, how much work it is to keep up with upstream. Then, when the dust has settled, decide if any of those wrappers should make it into FluidSynth. Some of the benefits of this approach:
How exactly this platform interface and glib-replacement could work on a technical level would obviously need to be discussed. Ok, that's it. Sorry again for this wall of text, but I needed to get this out of my system. :-) |
Beta Was this translation helpful? Give feedback.
-
Although FluidSynth depends on GLib, I have to say that it is not an impossible task to make the synthesizer working without it. It tooks less than 20 minutes to change I did several tests and I was able to run FluidSynth natively on:
So, I must say that the current code is highly configurable... at the moment, it's true that the code needs GLib but it is not too difficult to adjust it for your favourite system or if you want something different. Talking about my version for Windows, later I did more changes to the code:
When doing my DJGPP and Embedded ARM ports, I had added also 8bit sample output. It is true that you could easily obtain the same thing by converting a 16bit buffer to 8 bit, but this allowed to save some bandwidth especially on the second port. More or less, this is what I did in my FluidSynth build: I created an abstraction layer that works with posix, winapi, or none (no threads and no atomics). However, we should note that:
but GLib is not: today, a function exists and tomorrow it could be deprecated or it could disappear. |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
Ok, here's a propsal how to proceed regarding C++: Towards the end of the year I will port the sequencer to C++11. We already have lot's of C++ in the sequencer, so getting the rest ported seems like the natural way to go. I hope that by doing so we get a better understanding of what we can expect from such a step, what effort it takes, and what approach is best (PIMPL?, exception and error handling), etc. Also it's gonna be interesting how to set up the C API from the C++ sequencer class: Ideally, one would come up with a clever template or macro which generates the In the meantime, I welcome anybody to work on the CMake modernization points listed above. During this work it will probably become necessary to raise the minimum required CMake version. I would say that 3.13.3 is a reasonable minimum version, as it's the last version to officially support WinXP (and at least one of our contributors is a WinXP guy). |
Beta Was this translation helpful? Give feedback.
-
The reasons I am using Win XP are to maintain compatibility (hardware, software) with my legacy silent hardware.
Concerning WinXP, MSVC 2010 is the only one that can be installed on XP. Unfortunately MSVC 2010 doesn't support all C++11 features (for example, constexpr C++ isn't supported). That means that future fluidsynth with C++11 code build will probably fail when compiled on Win XP.
My applications (calling fluidsynth API and Windows GUI API) are actually pure C code. I am not interested by moving to C++ for calling fluidsynth library.
As explained by Marcus (@mawe42 ) and Carlo (@carlo-bramini), I am rather favorable to define an C API that allows glib functions substitution by user custom functions (the interface selection could be a cmake option). I would say that even I am not fan of C++, I understand Tom's motivations (as a maintainer). However, if any future version of fluidsynth shouldn't support compilation on Win XP, then this should be clearly documented in the Wiki. |
Beta Was this translation helpful? Give feedback.
-
libinstpatch internal is complex and hugely based on GObject, so libinstpatch cannot be glib-free. |
Beta Was this translation helpful? Give feedback.
-
Was asked to comment on this in #942 I'm in favor of using C++11 here. When you put all the C++11 code in a cpp-file the external interface can still be C-only. You can also invent a rule that only this "glib-replacement" is allowed to use C++11 and everything else must stay C. There could be also a ifdef here that still uses glib to make the WinXP users happy. The problem for me is that glib is hard to compile on some platforms and bloated (too huge increase in binary size). I'm a maintainer of https://github.com/EasyRPG/Player . Thats a game engine compatible to RPG Maker 2000 and a lot of games use MIDI for there music so we need good support for this. The engine is available for Windows, Linux, macOS, Android, Wii*, 3DS*, Switch*, PS Vita* and Emscripten (WASM). We currently are about to move from FluidLite (https://github.com/divideconcept/FluidLite) to FluidSynth because we got many reports about incorrect instruments. To achieve this I had to patch out glib because it is close to impossible to compile. Most of these homebrew SDK are only "kinda POSIX" and certain functions are broken. *: Homebrew only About Windows: We ship a single binary (static linking) everywhere and static linking of glib is broken on Windows since 8 years! https://gitlab.gnome.org/GNOME/glib/-/issues/692 Also std::thread does not work on Emscripten due to technical reasons, but this is not something you should worry about (it will still compile and not all parts of fluidsynth use threads). Note that my glib patching is extremely rudimentary: I simply removed the entire thread/atomic/mutex code because we only use FluidSynth as a synthesizer (load soundfont, send midi messages to it, sample into a buffer) on a single thread. MIDI processing and so on is done by us directly because RPG Maker 2000 has some non-standard features (e.g. looping and skipping of silence) that we must handle. |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
Modernizing
|
Beta Was this translation helpful? Give feedback.
-
Sequencer C++ Port availableAn MVP-like example of a C++ port of fluidsynth is now available, see #1011. Feedback is highly welcome! |
Beta Was this translation helpful? Give feedback.
-
As of recently, glib can be linked statically on Windows. This means we've lost one argument for removing glib. As described initially, removing glib is a huge amount of work. And the feedback for #1011 was less than I expected, which makes me think that it's not worth spending even more time on this in the future. If one day somebody would come up with a full-featured C++11 port, which doesn't even require glib for DLS support, I would take it. Do bare in mind though, that there are nasty pit-falls that will break the build, e.g. https://stackoverflow.com/a/17986785 . |
Beta Was this translation helpful? Give feedback.
-
For what it's worth, I flat out "ported" an earlier fork that did away with GLib. By no means perfect, of course doesn't fix the GLib dependency of libinstpatch (no DLS support) and probably some dubios changes (e.g. JACK audio driver changes). My main gripe with Glib is that it is hard to bundle and likely to just pull in more and more dependencies in the future which seems an overkill to me for the limited use FluidSynth gets out of it. But I'm certain you have a much better overview and know the pros and cons much much better than me :) |
Beta Was this translation helpful? Give feedback.
-
HarfBuzz https://github.com/harfbuzz/harfbuzz is an important text related library used in different places including browsers, has an optional glib dependency which most embedders including Chrome and Firefox just don't use it, it's written in C++ and actually needs a C++11 compiler to compile but doesn't use C++'s standard libraries (STL) runtime dependency but uses C++11's atomics but with a compiler definition as described in CONFIG.md can go even without threading. So my suggestion is to remove or make glib dependency optional for the ease of embedders, use C11 or C++11 atomic operations but don't switch to C++ or at least don't use C++'s standard libraries at all for the rest of the project now that you didn't need them all these years. And maybe provide a compiler configuration just like HB_NO_MT for non multithreaded environment if you want to support C11 builds without atomics. Or maybe just adopt this file from HarfBuzz. My own use case: I wanted to build fluidsynth for web using Emscripten, while compiling glib2 for Emscripten emscripten-core/emscripten#11066 isn't impossible https://gist.github.com/VitoVan/92ba4f2b68fec31cda803119686295e5 but it's hard and it most likely bloats resulting .wasm file and in web projects reducing .wasm result is beneficial so I wanted also to have fluidsynth without or with optional glib2 dependency. And here is result of my work based on Ghabry's work https://github.com/ebraminio/fluidsynth-no-glib-meson-wasm which builds with |
Beta Was this translation helpful? Give feedback.
-
Language Standard: C89
Being bound to C89 is getting more and more annoying. The most recent issue was the introduction of
fluid_long_long_t
. Now, MinGW complains about issues like that:C89 doesn't know about
%lld
. But C99 does. Ofc, you can always find ways to make it work: Use non-standard%I64d
or cast down tounsigned long
. Which decreases maintainability and increases technical debts. And it's no fun either.The effort for checking if certain C99 math functions or headers exist would also become redundant when upgrading to a newer C standard. Resulting in faster compilation on Windows.
Glib Dependency
Glib is a huge dependency. And it's becoming a pain when cross-compiling for e.g. Android.
Nowadays, the standard provides portable means that could replace glib. @chirs241097 has done some nice work to replace glib-threads with C++11 threading. His patch is basically only missing
try / catch
clauses around the C++ code and then would be instantly ready to use for fluidsynth. On the other hand, using C++ as OSAL in a project that is mainly written in C feels somewhat unclean. Using C11 threads feels better. Unfortunately MShas just started to support them in their recent VS 16.8, so, it's not a realistic optionstill doesn't support threading.Yes, I know. Even once fluidsynth would be free of glib, glib wouldn't simply disappear. We still have libinstpatch which is using much more of glib's internals with much less abstraction than fluidsynth does. It might be even easier to adopt the DLS loading code from libinstpatch, rather than getting libinstpatch glib-free.
And dropping glib would also mean to drop support for ancient OSes like Win9x,
OS/2, Solaris... WinXP might still work...Auto-generated loookup tables
Having compile-time const lookup tables is really nice. The way we produce them is not. Again, we are using a sophisticated CMake-workaround to access the host compiler. Recently, someone has pointed out that Meson provides easier access to the host compiler. I don't want to access the host compiler at all. I don't want to generate any tables myself. I want to solve the problem rather than curing the symptom. Why can't we just use a C++11/14
constexpr
lookup table? There is a nice project that provides constexpr C++ math functions, so no need to implement our own Newton iteration as we thought before.fluid_long_long_t
Define it as
int64
rather thanlong long
, see related discussion in #1057.CMake
EDIT: CMake modernization has been incorporated into fluidsynth 2.3.0!
Currently, the minimum required cmake version is 3.1.0. Bumping the minimum cmake version would allow for
CMAKE_MSVC_RUNTIME_LIBRARY
.Again: yes, to some extent it is possible to achieve this without bumping the minimum version, by injecting a bunch of
if ( CMAKE_VERSION )
into the build system. Doesn't makes things easier...Unrelated to the cmake version there are a few more TODOs to refurbish the build system a little:
GnuInstallDirs
(requested already a few years ago, cannot find the issue anymore)link_directories
,include_libraries
, etc)enable-debug
enable-fpe-check
andenable-trap-on-fpe
The goals listed here are some huge milestones, which no one should expect to be achievable within a few weeks. I would be very happy, if we find a compromise that could be applied to fluidsynth 2.3.0 or so.
How do we find the best compromise between modernizing the tools and retaining backward compatibility? How to figure out which OSes are used out there? An answer to the latter question is essential for deciding on a technical implementation of the points above.
[This disussion will stay for a while. Please upvote it so it's attracting people's attention.]
Beta Was this translation helpful? Give feedback.
All reactions