Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: FM Composer - A sound & music creation tool  (Read 14269 times)

0 Members and 1 Guest are viewing this topic.

Marukyu

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: FM Composer - A sound & music creation tool
« Reply #15 on: May 15, 2018, 08:21:58 pm »
Submitting a pull request sounds good! I think I should first clean up the hacks I introduced though, and verify that I didn't break anything on the Windows build. I wouldn't want to cause the developer too much additional work, after all.

Phanoo

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Re: FM Composer - A sound & music creation tool
« Reply #16 on: May 20, 2018, 03:59:48 am »
Aww great work !
I looked at bit at your changes, most of them should be harmless, in fact for some of them it's my fault (like the "struct export export" which is ok in my compiler but bad practice).

Are templates better than defines for things like min/max/clamp ?

The only potentially problematic thing is :
/* avoid slow float denormals + round floats down (needed if program compiled with QIfist option (FISTP) fast int/float conversion) */
+               #ifdef _WIN32
                _control87(_RC_DOWN, _MCW_RC);
+               #endif
 

FM Composer is expected to be compiled with the QIfist flag (probably VC++ specific) that allow to speed up float to int conversions by using faster FISTP assembly calls than the slow ftol() from the C library. This method also rounds floats instead of trucating them down as a collateral effect, thus this _control87 force floats to be rounded down again. There are two possible choices :

- Use default C int/float conversions and remove _control87 like you did, which works but worse performance (would be nice to see how much worse it is, maybe it's acceptable)
- Find some way to do it on Linux. I don't know if some compiler flag exists like MSVC's QiFist, but basically it does something like this for conversion :

int convert(float x)
{
    int n;
    __asm {
        fld x
        fistp n
    }
    return n;
}
Then we'd need to find a way to tell the fpu to round down the floats, like _control87 did.


I'd be happy to try your code and integrate it into the main branch once we've tested it !
« Last Edit: May 20, 2018, 10:54:03 am by Phanoo »

Phanoo

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Re: FM Composer - A sound & music creation tool
« Reply #17 on: May 20, 2018, 12:06:42 pm »
Can I link your repo in the project's description and on the website ?

Would be nice to have the compiled binary too, to avoid linux users having to build it manually (however i'm not sure how the compatibility works - If you compile on Ubuntu, will the binary be Ubuntu-compatible only?)

Marukyu

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: FM Composer - A sound & music creation tool
« Reply #18 on: May 21, 2018, 12:26:03 am »
It's very nice to hear that my modifications are appreciated! Feel free to link the forked repository anywhere you'd like, I'd be honored to be mentioned on your website. ^^

The reason I used templates for min/max is because defining macros with those names can break standard library headers that are included afterwards, which is what happened while I was compiling the project. Performance-wise, they should be identical on most modern compilers. I also added explicit min/max macros in fmlib.c to work around a linker issue (undefined references to "min" and "max"), but this might be solvable with a better CMake configuration.

As for _control87, I spent a while looking for a drop-in replacement for Linux, but couldn't find one, so I "temporarily" ifdef'd out the line to see if the program still behaves properly. It appeared to work just fine for me without audio or performance issues, but I'm not enough of a floating point optimization wizard to understand the exact effects this function has on subsequent operations. I'll be sure to let you know and/or update my fork if I stumble upon a cross-platform alternative to this function!

Providing Linux builds that work everywhere is somewhat tricky. Binaries will depend on the exact versions and compiler settings of all dynamically linked libraries (so, to answer your question, yes, Ubuntu builds will pretty much only work on Ubuntu). As a result, applications are usually distributed as packages in an environment where the library versions are predictable (this is what package managers and software repositories do).

There are some ways to work around this issue by bundling binaries and libraries into self-contained packages with tools like AppImage or Snappy, which can be used for universal software distribution on Linux, but my experience with these tools is rather limited. Personally, I'd say that providing source code that compiles successfully on Linux, along with some build instructions, is already a good starting point. :)

Phanoo

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Re: FM Composer - A sound & music creation tool
« Reply #19 on: June 02, 2018, 02:34:45 pm »
I successfully merged your work into the master branch, you're now part of the contributors to the project :)

I saw LAME MP3 was disabled by some ifdef conditions, is it because it wasn't possible to compile LAME on your distrib ?

 

anything