fluidsynth/doc
Tom M 0d98c47545
Revise the sequencer's event queue (#604)
Proposing a new event queue for the sequencer, based on prior discussion:
https://lists.nongnu.org/archive/html/fluid-dev/2019-12/msg00001.html

With this change fluidsynth will require a C++98 compliant compiler.

Consider this as RFC, feedback is welcome.

The "pain-points" from the discussion:

#### 1. It is slow.

Done (thanks to heap sort), see runtime of `test_seq_event_queue_sort`.

#### 2. A meaningful ordering for events with the same tick has not been considered.

Done, see comments in `fluid_seq_queue.cpp`.

#### 3. Complicated implementation

Now uses one single event queue, which requires C++98. Implemented similarly to std::priority_queue by using heap sort.

The "queue" I use currently is of type `std::deque`. `deque` does not provide preallocation. `std::vector` does provide it. However, `std::deque` has the huge advantage that appending additional elements is cheap. For `std::vector` appending new elements would require to reallocate all the memory and copy it to the new array. So,

* either use `std::deque` with the risk that memory allocation may occur during `fluid_sequencer_send_at()`, or
* use `std::vector` with a preallocated pool of events and make `fluid_sequencer_send_at()` when the `vector` runs out of capacity.

Comments?

#### 4. Events that have been processed are deleted and gone.

After having thought about this more, this is the correct behavior. After events have been dispatched, they must be released to free underlying memory, see point 3. For the very rare case that a client (e.g. fluid_player) may require those events in the future, the client should be responsible for storing the events somewhere.

#### 5. The sequencer supports the system timer as alternative time source.

The conclusion from the mailing list was that the system timer can be removed. This has been done.

#### 6. Time Scaling

Time scaling can now be used for arbitrary tempo changes. The previous implementation was capable of that as well, however, the time-scale was limited to 1000. The only limitation for the scale is now >0, see `test_seq_scale`.

### Other Points

* `fluid_sequencer_remove_events()` turned out to be broken before, as it did not remove all events from the queue. This has been fixed, see `test_seq_event_queue_remove`.

* Consider the following code executed by `threadA`:

```c
fluid_sequencer_send_at(event0);
fluid_sequencer_set_time_scale(); // new scale
fluid_sequencer_send_at(event1);
```

The new scale will be definitely applied to `event1`. However, if another concurrently running `threadB` executes `fluid_sequencer_process()`, it was previously not clear, whether the new scale was also applied to event0. This depends on whether `event0` was still in the `preQueue`, and this depends on `event0.time` and the tick count that `fluid_sequencer_process()` is being called with. This has been changed. As of now, events are queued with their timestamp AS-IS. And only the latest call to `fluid_sequencer_set_time_scale()` is being considered during `fluid_sequencer_process()`. This makes the implementation very simple, i.e. no events need to be changed and the sequencer doesn't have to be locked down. On the other hand, it means that `fluid_sequencer_set_time_scale()` can only be used for tempo changes when called from the sequencer callback. In other words, if `threadA` executes the code above followed by `fluid_sequencer_process()`, `event0` and `event1` will be executed with the same tempo, which is the latest scale provided to the seq. Is this acceptable? The old implementation had the same limitation. And when looking through the internet, I only find users who call `fluid_sequencer_set_time_scale()` from the sequencer callback. Still, this is a point I'm raising for discussion.
2020-05-26 17:16:22 +02:00
..
android Build fluidsynth for Android in RelWithDebInfo 2019-10-21 15:16:35 +02:00
polymono fix typos and grammar in FluidPolyMono-0004.pdf (#440) 2018-10-09 14:57:17 +02:00
CMakeLists.txt Compile suitable demo files from doc/ (#611) 2020-01-24 08:57:20 +01:00
doxy_formula.css update API doc of fluid_synth_process() and add usage example 2018-05-17 14:43:59 +02:00
Doxyfile Bump to 2.1.3 2020-05-23 14:29:17 +02:00
Doxyfile.cmake cleanup 2.0 API docs 2018-05-18 16:28:09 +02:00
example.c Compile suitable demo files from doc/ (#611) 2020-01-24 08:57:20 +01:00
FluidProfile_0004.pdf Add profiling command interface (#345) 2018-03-12 18:25:16 +01:00
fluidsettings.xml Elaborate docs of audio.realtime-prio 2020-04-22 17:28:38 +02:00
fluidsettings.xsl fluidsettings: report boolean settings as int 2018-06-17 20:02:46 +02:00
FluidSostenuto-005.pdf Add Sostenuto PDF documentation (#559) 2019-09-14 17:19:43 +03:00
FluidSynth Thread safety paper for LAC 2011.odt remove fop-level "fluidsynth" directory node 2017-09-03 13:30:26 +02:00
fluidsynth-v20-devdoc.txt Revise the sequencer's event queue (#604) 2020-05-26 17:16:22 +02:00
fluidsynth.1 Bump to 2.1.1 2020-02-16 15:59:11 +01:00
fluidsynth_arpeggio.c Deprecate usage of the system timer for the sequencer (#599) 2020-01-19 15:37:42 +01:00
fluidsynth_fx.c Amend comment in fluidsynth_fx.c 2020-02-16 19:55:28 +01:00
fluidsynth_metronome.c Deprecate usage of the system timer for the sequencer (#599) 2020-01-19 15:37:42 +01:00
fluidsynth_process.c extend documentation on multi-channel rendering 2018-07-16 12:10:07 +02:00
fluidsynth_register_adriver.c Compile suitable demo files from doc/ (#611) 2020-01-24 08:57:20 +01:00
fluidsynth_sfload_mem.c Fix the sfload_mem example to actually read back the pointer address 2018-09-19 01:18:42 +02:00
fluidsynth_simple.c enforce coding style guide 2018-06-24 13:13:18 +02:00
ladspa.md Information about LADSPA on non-Linux platforms and some reformatting 2017-11-19 21:12:49 +01:00
README update doc/README 2017-12-15 19:29:12 +01:00

To build FluidSynth API reference documentation, make sure you have Doxygen
installed.

If you are using the cmake build system, change to the build directory and
execute the following command in this doc/ directory:

$ make doxygen

The latest generated API HTML docs can also be found at:
http://www.fluidsynth.org/api/

Even more documentation references are provided on our wiki page:
https://github.com/FluidSynth/fluidsynth/wiki/Documentation