Discussion:
[fluid-dev] Integration of FluidSynth in Polyphone
Davy Triponney
2018-09-19 09:06:50 UTC
Permalink
Dear FluidSynth team,

I should have done this from the beginning but I'm now considering
integrating FluidSynth directly inside Polyphone, which will assure a
correct and complete rendering of the soundfonts. I have always considered
FluidSynth as the reference for playing a soundfont.

Loading a soundfont from a file with FluidSynth is well documented but,
Polyphone being an editor, I'm now requiring some help or "hints" to know
how parameters of a sample, instrument or preset can be changed / added /
deleted without requiring loading a file. The goal is to test the effect of
a change within Polyphone without having to save and load the file between
two operations.

I imagined two possibilities:
* loading an existing soundfont and synchronizing all following changes
made in Polyphone with the internal structure of the FluidSynth data, or
* loading an existing soundfont and creating small temporary files
containing a modified version of presets.

Can someone advice on the best way to update parameters?

Best regards,
Davy
Ceresa Jean-Jacques
2018-09-20 16:53:54 UTC
Permalink
Hello Davy

 

Following some hints.
1) loading an existing soundfont and synchronizing all following changes made in Polyphone with the internal structure of the FluidSynth data
This solution should be possible via the concept of possible multiple "soundfont loader" (fluid_sfloader_t) inside Fluidsynth.

When an application creates a Fluidsynth instance, a default internal fluid_sfloader_t is built. Of course this default loader is for Soundfont 2.1 loading.

Then when the application call fluid_synth_noteon(), Fluidsynth call fluid_defpreset_noteon() which is the default noteon function provided by the default loader.

The application can also add others soundfont loader (fluid_synth_add_sfloader()) owned by this application. These new loader is added in the internal loader list.

Then when the application call fluid_synth_sfload() (or fluid_synth_sfreload()) , the internal loader list is used until the load is successful.

This means that if the application call fluid_synth_noteon(), now the noteon function provided by the application loader could be called.

Whatever this solution avoid to save and load a file between two operations, it is complex to implement.

 

1.2) May be an other solution could be making use of those APIs to play a preset coming from the application (without any soundfont loading):

FLUIDSYNTH_API fluid_sample_t *new_fluid_sample(void)

FLUIDSYNTH_API int fluid_sample_set_name()

FLUIDSYNTH_API int fluid_sample_set_sound_data()

FLUIDSYNTH_API int fluid_sample_set_loop()

FLUIDSYNTH_API int fluid_sample_set_pitch()

FLUIDSYNTH_API fluid_voice_t *fluid_synth_alloc_voice()

FLUIDSYNTH_API void fluid_voice_gen_set()

FLUIDSYNTH_API void fluid_voice_add_mod()

FLUIDSYNTH_API void fluid_voice_start()

Note this solution (1.2) is a subset of solution (1.1), anyway it is still a bit complex.

 
2) loading an existing soundfont and creating small temporary files containing a modified version of presets.
Probably the easier way. Making use of fluid_synth_sfload(), fluid_synth_sfunload(), fluid_synth_sfreload() should be convenient.

Using a very small file should not produce a boring latency.

Regards.

jjc

 

 

 
Message du 19/09/18 14:46
De : "Davy Triponney"
Objet : [fluid-dev] Integration of FluidSynth in Polyphone
Dear FluidSynth team,
I should have done this from the beginning but I'm now considering integrating FluidSynth directly inside Polyphone, which will assure a correct and complete rendering of the soundfonts. I have always considered FluidSynth as the reference for playing a soundfont.
Loading a soundfont from a file with FluidSynth is well documented but, Polyphone being an editor, I'm now requiring some help or "hints" to know how parameters of a sample, instrument or preset can be changed / added / deleted without requiring loading a file. The goal is to test the effect of a change within Polyphone without having to save and load the file between two operations.
I imagined two possibilities:
* loading an existing soundfont and synchronizing all following changes made in Polyphone with the internal structure of the FluidSynth data, or
* loading an existing soundfont and creating small temporary files containing a modified version of presets.
Can someone advice on the best way to update parameters?
Best regards,
Davy
Tom M.
2018-09-20 18:08:11 UTC
Permalink
The proper solution is to use the soundfont loader API, as pointed out by jjc:

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

That way you are in full control of what preset, instruments... are contained in your "virtual soundfont" and how they trigger a noteon. For a usage example, see SWAMI:

https://sourceforge.net/projects/swami/

It still uses fluidsynth 1.x API though. Find a bunch of patches attached that port SWAMI to fluidsynth 2.0 API (untested, probably buggy and for demonstration only).

Also note that fluidsynth provides functions for allocating and manipulating single voices, mentioned by jjc in 1.2).

Tom

Loading...