fluid-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [fluid-dev] Fluidsynth questions: 2.0.5 release / threading


From: Ceresa Jean-Jacques
Subject: Re: [fluid-dev] Fluidsynth questions: 2.0.5 release / threading
Date: Fri, 19 Apr 2019 14:43:43 +0200 (CEST)

> > Another question I have is related to threading. I'd like to use two fluid_synth_t* instances in two different threads with two different soundfonts to render two different midi tracks.

 

As explained by Tom, you don't need to create two fluid_synth_t* instances in two different thread to just to increase rendering speed. Creating  synth(s) in one thread is sufficient.

And the only reason one could need to create 2 synths would be to render more than 16 MIDI channels (i.g 16 MIDI channels per synth).

 

If one need multiple synths, remember that each synth's instance must have its own audio driver instance. This case is complicated when different audio driver instance are using the same device (audio adapter). It should works only if the OS audio driver accepts this. Of course Alsa or Dsound will accept this, but the cpu load will be augmented.

jjc.

> Message du 19/04/19 09:34
> De : "Tom M." <address@hidden>
> A : "Stefan Westerfeld" <address@hidden>
> Copie à : address@hidden, "Tim Janik" <address@hidden>
> Objet : Re: [fluid-dev] Fluidsynth questions: 2.0.5 release / threading
>
> Hi Stefan,
>
> pls. also send a copy to our mailing list the next time.
>
> > I've seen that my fixes should be in 2.0.5. Do you have an approximate idea when this fluidsynth release will be available?
>
> Today.
>
> > Another question I have is related to threading. I'd like to use two fluid_synth_t* instances in two different threads with two different soundfonts to render two different midi tracks. I'm assuming that I can call fluid_synth_process() independently on these two instances from two threads and they will not interfere in any way, right?
>
> Yes. Each synth has it's own mutex, which is used if the setting "synth.threadsafe-api" is true (the default). Apart from that all synths share a sample cache as global ressource, which is always mutex protected.
>
> > And if I do so, the processing speed would effectively be doubled if I have 2 cores, because the rendering would be fully parallel?
>
> It should, I haven't tested it. However I cannot recommend to create multiple synths just to increase rendering speed. You should instead create only one synth. Before creation, set the setting "synth.cpu-cores" to the number of cores you want to use for rendering [1]. Load all soundfonts you want to use into the synth. Make sure every MIDI track you want to render is playing on its own MIDI channel. Then you can use fluid_synth_sfont_select() to select the soundfont for each MIDI channel [2]. And by using multichannel rendering, you will also be able to render each MIDI channel to its own audio channel, if required, see [3].
>
>
> [1] http://www.fluidsynth.org/api/fluidsettings.xml#synth.cpu-cores
> [2] http://www.fluidsynth.org/api/synth_8h.html#af66d59e942a14ee9f2d28444885bd27b
> [3] http://www.fluidsynth.org/api/fluidsynth_process_8c-example.html
>
>
> Tom
>
>
>
> _______________________________________________
> fluid-dev mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/fluid-dev
>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]