On 2014-05-02 02:31, sqweek wrote:
On 30 April 2014 23:38, David Henningsson <di...@ubuntu.com> wrote:
I have it working, but I haven't quite grasped _which_ samples the
fluid_synth_write call returns.
Well, if you first call fluid_synth_note_on, and after that call
fluid_synth_write_s16, then the note you added will sound from the
beginning. Does that answer your question?
Secondly, my crude implementation results in some midi events being
triggered up to 4095 frames too early or too late; the plan is to use
fluid-synth's sequencer API to fix this.
Right, you can do this because the sequencer supports "sample timers" which
is an internal concept that makes it possible for the sequencer to insert
note events "in the middle" of calls to fluid_synth_write_*.
However, it's probably easier for you to just call fluid_synth_write_* with
just 64 samples at a time, and start your notes between the right two calls
to fluid_synth_write_*. That would give you the same granularity as is being
used internally in fluidsynth.
Ah, very interesting! Does this imply that the samples aren't
synthesized until fluid_synth_write is called?
Is 64 samples just an example number or is there something special
about this block size? If so, is that 64 total samples including both
channels (ie. 32 frames) or 64 samples per channel?
Thanks for the suggestion, I would never have thought of this approach!
Yes, calls to fluid_synth_write is what synthesizes the samples. It does
so by calling an internal function that always render 64 samples (per
channel, so 64 frames in ALSA terms).
Fluid_synth_write compensates for you asking for more than 64 frames, or
non-multiples of 64, by calling this internal function as many times as
necessary, and by doing internal buffering of up to 64 frames.
The constant that is normally set to 64 is called FLUID_BUFSIZE in
FluidSynths code, and I've never seen anyone change it.
// David
_______________________________________________
fluid-dev mailing list
fluid-dev@nongnu.org
https://lists.nongnu.org/mailman/listinfo/fluid-dev