-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
do not process more blocks than we can store internally
addresses #192
- Loading branch information
Showing
1 changed file
with
10 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d313db5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diwic Could you perhaps have a look whether this fix makes sense at all or might there be trouble somewhere else? Is my understanding correct so far?
Background:
(assume: parallel render and threadsafe API disabled)
If the user wants to render a whole MIDI with one single call to
fluid_synth_write*()
numerous blocks would be requested fromfluid_synth_render_blocks()
.fluid_sample_timer_process()
would dispatch all the voices immediately, i.e. not queuing them because of non parallel render. And it would do that for all blocks requested, sincefluid_rvoice_eventhandler_dispatch_count()
always stays0
. However we can only render a limited no. of blocks. If we continue to rendering we would hear a huge "bang" at the beginning and silence for the rest of the song. So in this loop we shouldn't render more blocks than we can actually store internally, should we?Note: never experienced this with the
fluidsynth
executable, because it only requests 64 audio frames from the synth.d313db5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm...so I think your fix is about in the right place. You can make it less hacky by
Exposing a
int fluid_rvoice_mixer_get_bufcount(mixer) { return mixer->buffers.buf_blocks }
Above the loop, do
maxblocks = fluid_rvoice_mixer_get_bufcount();
if (blockcount > maxblocks) blockcount = maxblocks;
...now you can skip the condition inside the loop. Correct?
d313db5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: Parallel rendering with more than one thread was mostly a failed experiment, at least for me. FluidSynth rendering is so efficient that only in a few cases was the overhead of starting/stopping threads so low that rendering actually was faster with more threads.
d313db5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, thanks!