Skip to content
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

Plans to add Windows support for the VST? #2

Closed
Archer6621 opened this issue Jun 12, 2018 · 25 comments
Closed

Plans to add Windows support for the VST? #2

Archer6621 opened this issue Jun 12, 2018 · 25 comments

Comments

@Archer6621
Copy link

As the title says, just wondering.

I've been looking for a working soundfont playing VST for a while now, and it seems that anything out there is either flawed in following the soundfont specification (the "fake" soundfont players), broken, or very outdated.

@Birch-san
Copy link
Owner

Birch-san commented Jun 14, 2018

I had a crack at it today.

image

I got the standalone .exe working just now.

.vst3 is complaining about some missing factory function (or a 32-bit/64-bit mismatch somewhere).
.vst and VSTi may not be possible since Projucer didn't give me a project template for building those.

So, soon I'll see if I can get VST3 working, and revisit Projucer to see if I missed any project targets.
I haven't checked whether this .exe works on other people's computers, but run-time linking on Windows is much easier than on macOS, so worst-case I can make it work by just throwing dlls at it.

I can't yet publish the .exe I built, since I need to track down licenses for all files that I release. I have most of them already from the Mac version, but Windows adds a few more libraries.

Btw, is VST3 fine for you? It's probably the easiest one for me to get working.

@Birch-san
Copy link
Owner

I got VST and VST3 working.

image

Now just need to check whether this release is portable (and fix it otherwise), figure out where to put the dlls (or consider statically-linking), and include the licenses.

@Birch-san
Copy link
Owner

licenses written.
proof-of-concept installer written for dynamic dependencies.
working as VST3 inside FL Studio:

image

Pretty close now. Just need to make the installer setup the exe and plug-ins (which should be trivial), confirm whether installer is portable, confirm whether the exe and plug-ins themselves are portable, then put it all in a zip with licenses.

@Birch-san
Copy link
Owner

@Archer6621
Finished. Please tell me whether it works for you:

https://github.com/Birch-san/juicysfplugin/releases/tag/1.0.8

@Archer6621
Copy link
Author

Wow, that is awesome, I will try it right away!

@Archer6621
Copy link
Author

Archer6621 commented Jun 16, 2018

It works great @Birch-san , thank you so much for doing this!

The VST2 version was indeed the one I needed, since Ableton Live is a bit behind on their VST3 support, which is rather unfortunate.

Would a 32-bit version also be possible? This would ease up the compatibility between other older 32-bit plugins (effects etc) and this one without the necessity of having to use a bridge (again, Ableton Live quirk). It's not a huge deal though, just a nice-to-have.

One additional little thing: are there plans to support additional MIDI commands that can control the attack/release times of instruments (MIDI CC 73 and 72)? And the filter cutoff/resonance (MIDI CC 74 and 71)? I think this belongs to certain MIDI feature set (XG?), but I'm not sure how Fluidsynth interprets these or whether it needs a specific configuration for it.

Regardless, I'll be using this actively the coming few weeks, mostly for just playing on my keyboard and trying out various soundfonts, I'll report back to you if I run into any serious issues.

@Birch-san
Copy link
Owner

Birch-san commented Jun 16, 2018

@Archer6621 phew; glad it works.

The main reason that it's difficult for me to do 32-bit is that I don't have a 32-bit fluidsynth.dll. I compiled fluidsynth using this MinGW package, which is 64-bit only. Making a 32-bit package would require also having 32-bit libraries for all its dependencies (and their dependencies…).

How problematic is Ableton's 64-to-32-bit bridge? Is it easy-to configure (or automatic)? I think FL Studio does it automatically, and they said that the performance penalty is just 1% extra CPU usage.

I don't quite know how to add support for those MIDI commands, but potentially it's easy. Probably only a couple of lines of code. Need some help understanding it.

Here's how fluidsynth is configured:

http://www.fluidsynth.org/api/index.html#CreatingSettings

I notice synth.midi-bank-select can be used to select banks. Not quite what you specified, but it mentions XG ("xg: CC32 becomes the bank number, CC0 is ignored").

I suspect this is done on a per-voice level. Probably something to do with the generators or modulators, but not sure exactly what to call and when:

http://www.fluidsynth.org/api/voice_8h.html

However, I'm aware that they're about to drastically change the API (FluidSynth 2.0 is coming soon):

https://lists.nongnu.org/archive/html/fluid-dev/2018-05/msg00019.html

Maybe it's easier to do this stuff in FluidSynth 2. Or at least more futureproof.

Admittedly, I don't currently have a MinGW package definition to let me build FluidSynth 2.0 on Windows (maybe I can make one myself with some small changes to the existing one… unless the dependencies have changed radically).

And we can probably stay on FluidSynth 1 forever. But nevertheless: would be nice to not be stuck. At the very least I'd like to know whether there's a big difference in how we'd implement these features in v1 versus v2.

Here's the new API:

https://github.com/FluidSynth/fluidsynth/tree/v2.0.0.beta1/include/fluidsynth
https://github.com/FluidSynth/fluidsynth/blob/v2.0.0.beta1/include/fluidsynth/settings.h
https://github.com/FluidSynth/fluidsynth/blob/v2.0.0.beta1/include/fluidsynth/voice.h

We'd need a plan for how to do this in v1, and check if it has any incompatibilities that stop us upgrading to v2.

@Archer6621
Copy link
Author

@Birch-san Understandable about the 32-bit version, that's only going to be pain yeah.

Bridging in Ableton Live is unfortunately not offered by the DAW itself, users need to make use of something like Jbridge (https://jstuff.wordpress.com/jbridge/) to get 32-bit and 64-bit plugins work together, which I'm trying to avoid for as long as possible but is probably going to be inevitable :P

I might also research a bit on how something like this can be implemented, I know that some other VSTs (such as the old SFZ plugin from Cakewalk, and a recent bassmidi implementation, do listen to these MIDI commands and use them to control things like attack/release/filter etc, but I don't know how Fluidsynth handles all this. Maybe I can take a look at how the bassmidi library does it and see whether there's something equivalent for Fluidsynth.. I'll let you know when I find something!

Fluidsynth v2 looks promising with all the new stuff that's gonna be in it, it could very well be that the functionality I requested is something that's coming in FS2 (support for default modulators maybe).

@Archer6621
Copy link
Author

Archer6621 commented Jun 17, 2018

I might've found something, not sure if relevant: https://musescore.org/en/user/527826/blog/2016/05/23/volume-fluidsynth

EDIT: According to something from 2016 it seems that filters are unsupported: https://lists.gnu.org/archive/html/fluid-dev/2016-03/msg00013.html

@Birch-san
Copy link
Owner

Birch-san commented Jun 17, 2018

Bridging in Ableton Live is unfortunately not offered by the DAW itself

that's a downer.

the release notes for Fluidsynth 2 showed something interesting:

Windows users may directly download the CI build artifacts:
Win32:
https://ci.appveyor.com/project/derselbst/fluidsynth/build/1037/job/5nj9yl7v74126be5/artifacts
Win64:
https://ci.appveyor.com/project/derselbst/fluidsynth/build/1037/job/xfp58vxf904ou3e9/artifacts

so, their continuous integration system builds 32-bit fluidsynth.dlls and includes some 32-bit libraries. sadly: I see that libsndfile and friends are absent, so those builds don't have support for SF3 soundfonts.

but maybe by reading the build log I can work out how they setup their Windows build environment, then consider doing my own build with libsndfile and friends enabled (the hard part would be finding or building zero-dependency 32-bit versions of all those dlls [libsndfile-1.dll, libogg-0.dll, libvorbis-0.dll, libvorbisenc-2.dll, libFLAC-8.dll])

@Archer6621
Copy link
Author

Well it's something, haha. I must say that I personally haven't ever used SF3 soundfonts, most of what is out there is SF2. It seems that the main difference is support for sample compression compared to SF2 soundfonts: https://musescore.org/en/node/151611

@Archer6621
Copy link
Author

Archer6621 commented Jun 17, 2018

This whole thread seems to be about the envelope thing I mentioned, for controlling attack/release: https://lists.nongnu.org/archive/html/fluid-dev/2018-04/msg00025.html

EDIT: according to this it seems that they haven't implemented these messages yet, which is unfortunate: https://lists.nongnu.org/archive/html/fluid-dev/2018-04/msg00035.html

Though according to this it seems to be possible to implement this: https://lists.nongnu.org/archive/html/fluid-dev/2018-04/msg00037.html

Corresponding pull request: FluidSynth/fluidsynth#164

@Birch-san
Copy link
Owner

Birch-san commented Jun 17, 2018

I might've found something, not sure if relevant:
https://musescore.org/en/user/527826/blog/2016/05/23/volume-fluidsynth

okay, so every voice has generators for certain aspects (for example an attentuation generator). and each generator is influenced by a set of modulators.

Soundfont 2.1 generators are defined here (don't know whether that implies that all are hooked up to implementations):

https://github.com/FluidSynth/fluidsynth/blob/master/src/synth/fluid_gen.c#L27
https://github.com/FluidSynth/fluidsynth/blob/master/src/synth/fluid_voice.c#L506

I personally haven't ever used SF3 soundfonts, most of what is out there is SF2

likewise, but I found that if you want to use soundfonts with a specific license, the only resource that actually shows licenses is MuseScore's list, and that uses SF3 quite a lot.

@Birch-san
Copy link
Owner

Birch-san commented Jun 17, 2018

according to this it seems to be possible to implement this:
https://lists.nongnu.org/archive/html/fluid-dev/2018-04/msg00037.html

okay, so "use the new API for manipulating default modulators". Looks like we'll definitely be needing FluidSynth 2 (which will be annoying for the Windows release, since I don't have the dlls — unless I ditch SF3 support).

Maybe something like this?

...
settings = new_fluid_settings();
...
synth = new_fluid_synth(settings);
// Add a Key Pressure to Initial Attenuation modulator
mod = fluid_mod_new();

// modulator's primary source controller and flags
// fluid_mod_src:
// https://github.com/FluidSynth/fluidsynth/blob/master/include/fluidsynth/mod.h#L61
// fluid_mod_flags:
// https://github.com/FluidSynth/fluidsynth/blob/master/include/fluidsynth/mod.h#L41
// diagrams showing what negative and concave mean:
// https://musescore.org/en/user/527826/blog/2016/05/23/volume-fluidsynth
// fluid_gen_type:
// https://github.com/FluidSynth/fluidsynth/blob/master/include/fluidsynth/gen.h#L36
// https://github.com/FluidSynth/fluidsynth/blob/master/src/synth/fluid_gen.c#L27
fluid_mod_set_source1(mod,
        FLUID_MOD_KEYPRESSURE,
        FLUID_MOD_CC |
        FLUID_MOD_NEGATIVE |
        FLUID_MOD_UNIPOLAR |
        FLUID_MOD_CONCAVE);
// modulator's secondary source controller and flags
// MIDI CC 74
fluid_mod_set_source2(mod, 74, FLUID_MOD_CC);
// generator for filter cutoff
fluid_mod_set_dest(mod, GEN_FILTERFC);
fluid_mod_set_amount(mod, 13500.0f);

fluid_synth_add_default_mod(synth, mod, FLUID_SYNTH_ADD);
adriver = new_fluid_audio_driver(settings, synth);
...

There's a lot of guesses here. GEN_FILTERFC's min, max and def are all different to GEN_ATTENUATION's (which was the example provided).
https://github.com/FluidSynth/fluidsynth/blob/master/src/synth/fluid_gen.c#L27

static const fluid_gen_info_t fluid_gen_info[] = {
        /* number/name             init  scale         min        max         def */
        { GEN_FILTERFC,               1,     2,    1500.0f,  13500.0f,   13500.0f },
        { GEN_ATTENUATION,            1,     1,       0.0f,   1440.0f,       0.0f },

Their example was a FLUID_MOD_NEGATIVE | FLUID_MOD_UNIPOLAR on GEN_ATTENUATION with 960.0 amount.

Any thoughts on what I should set it to?

What should a modulated filter cutoff sound like?

How do I test this? Is there a MIDI file you can give me? Or better: you could get the FL Studio 20 trial and save out a project.

@Birch-san
Copy link
Owner

Birch-san commented Jun 17, 2018

I may be able to test it with my M-Audio Keystation 49 II, but I lost found the manual; not sure how to configure it.

@Birch-san
Copy link
Owner

Birch-san commented Jun 17, 2018

I've had a crack at updating to FluidSynth 2 on macOS, but it seems broken; no sound comes out. Even if I run directly (i.e. not using the VST).

Edit: they fixed it. FluidSynth 2 working on macOS. now I can do things like try out default modulators.

@Archer6621
Copy link
Author

I suppose I can make a couple of MIDI test files for you. As far as I know the modulation is relative, meaning that for certain instruments in soundfonts it may have no effect at all. I'll put something together in an hour or so and attach it here, along with a link to a soundfont/instrument from which I know it should respond to the modulators.

@Archer6621
Copy link
Author

Archer6621 commented Jun 17, 2018

So here are four midi files, all essentially doing the same thing: playing a note every bar, for 8 bars, starting at level 0 for the specified modulator, and ending at level 127 just before the final note strikes, while increasing in a smooth linear fashion inbetween. For the one demonstrating the release time, the notes are shortened to 1/16th notes, but still played at 1 bar interval, to be able to hear the longer release time.

I've tested this on Virtual Midi Synth, which can be configured as default MIDI device on Windows, and you can hear the difference there given the right soundfont. But indeed you can also just import the MIDI in any DAW, or just play it back somehow, and the CC data should be there.

I tried to find a small soundfont that showed the difference clearly, and found this one, which I used for creating the midi clips: ChoriumRevA. While the piano worked fine for hearing the difference, I recommend using an instrument with more sustain to it, such as strings/flute/etc. I found that the "synth brass 1" instrument works decently for demonstration.

I used that bassmidi VST I linked earlier as a representative implementation for creating the clips, you could also compare with that one to see whether it works as intended, which might be handier than me describing what should happen, but I'll do that anyway (for the midi clips):

  • For CC74 (filter): Sounds should start dull without high frequencies, and slowly become brighter/more normal sounding
  • For CC71 (resonance): Sounds should start normal, and slowly get a sharp timbre/tone to them
  • For CC73 (attack): Sounds should start normal, and then slowly start more softly, taking time to reach their max loudness
  • For CC72 (release): Sounds should start very short, and slowly take longer before stopping

EDIT: I didn't read that last bit about Fruity Loops. I think you can import MIDI files in that though, just let me know if you run into issues with that and I'll try to make a FL Studio 20 arrangement for you.

@Birch-san
Copy link
Owner

Thanks very much for the test files! I'll have a play.

Though, my long holiday ends about now, so progress will be slower from here on out.

@Archer6621
Copy link
Author

No problem, thanks again for the Windows VST, I'll keep an eye on this!

@KJinx101
Copy link

Can't wait to use 2.3.0! Genuine thanks for your hard work. Can't wait to play around with it with the windows release

@Birch-san
Copy link
Owner

@KJinx101 thanks for the support. I've now released for Windows:

https://github.com/Birch-san/juicysfplugin/releases/tag/2.3.1.win

Please tell me whether it works for you.

  • Would a 32-bit version also be possible?
  • are there plans to support additional MIDI commands that can control the attack/release times of instruments (MIDI CC 73 and 72)?
  • And the filter cutoff/resonance (MIDI CC 74 and 71)?

@Archer6621 all of these are now finished. could you tell me whether it's all working for you (in particular the 32-bit release)?

@KJinx101
Copy link

KJinx101 commented Aug 5, 2019

Works flawlessly! Mod/Pitch work perfectly with hardware, ASDR is doing exactly what I need and cut-res will definitely be useful! (I can see myself automating cut with the scroll wheel for automating brightness/expressiveness). This is 100% what I was looking for. No real bugs or anything when using it. (Using 64 bit btw)

Something you may want to know but isn't necessarily much of a problem, (happened 2x) if you leave the plug in up/unattended for 30 mins or more and interact with it right upon waking up the computer, it may crash FL. Maybe Juce or Fluid has some usage timer or something built in? FL? Either way not a big problem tho. Genuine thanks for your work! 🙏🙏

@Birch-san
Copy link
Owner

Birch-san commented Aug 5, 2019

:) glad to hear it's working for you. At some point I need to try making some music with it myself.

Thanks for the bug report. I've opened an issue regarding the wake-from-sleep problem (#10) and have documented my initial thoughts on what the cause might be.

@Birch-san
Copy link
Owner

Closing since my own testing indicates that juicysfplugin works on Windows x86 and x64. the various other feature requests in this issue were implemented also. any bugs that are found can be considered separate issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants