Commit graph

37 commits

Author SHA1 Message Date
derselbst
e04cd572cb Merge branch '2.1.x' into master 2021-01-03 21:37:32 +01:00
Tom M
5c1cfe6a5f
Regression tests for #727 (#735)
This PR adds regression tests for #727, ensuring that soundfonts are correctly unloaded via the lazy-timer-unloading mechanism.
2021-01-03 09:42:42 +01:00
derselbst
03cf8e28f6 Add a unit test for issue 733 2021-01-03 09:41:46 +01:00
getraid-gg
1cdeebef37 Enable the use of UTF-8 filenames under Windows (#718)
While `fopen` (used through the macro `FLUID_FOPEN`) uses UTF-8 on *nix, it's restricted to ANSI on Windows. A change to enable using paths containing non-ANSI characters was suggested before in issue #128 but was rejected due to requiring large parts of both the public API and private implementation to be modified to accommodate Windows.

This PR instead changes the macro definition for `FLUID_FOPEN` from `fopen` to a new wrapper, `fluid_fopen`. This wrapper is defined in `fluidsynth_priv.h` and defined in `fluid_sys.c` (following the pattern of `fluid_alloc`). Under Windows, it converts the `const char*` UTF-8 parameters to Unicode `wchar_t*` strings using the Windows API function `MultiByteToWideChar` and opens the file using the Windows API-specific `_wfopen`. On all other platforms, it simply calls `fopen`.

The public API is unchanged. This solution will require Windows users of the API to convert UTF-16 strings to UTF-8 (which then get converted back into UTF-16 anyway), but that's still an improvement over only being able to use ANSI paths.

This PR also adds a new test, `test_utf8_open`, which tests `FLUID_FOPEN` directly and through `fluid_is_soundfont` and `fluid_synth_sfload` using a new soundfont file, `sf2/â– VintageDreamsWaves-v2â– .sf2`, which is just a copy of `VintageDreamsWaves-v2.sf2` with Unicode characters in the filename.
2020-12-22 11:30:14 +01:00
derselbst
b28c0ed044 Revert "remove VintageDreamsWaves-v2.sf3"
This reverts commit a36c06cff2. We've got
explicit permission from Ian Wilson to convert it to SF3.

Addresses #701.
2020-10-31 15:42:33 +01:00
Marcus Weseloh
109c41c355
Add public API to pin and unpin presets to the sample cache (#698)
Following the discussion about an API to pin and unpin preset samples in the sample cache here:
https://lists.nongnu.org/archive/html/fluid-dev/2020-10/msg00016.html

Short explanation of the change:

Only the default loader currently supports dynamic sample loading, so I thought it might be a good idea to keep the changes for this feature mostly contained in the default loader as well. I've added two new preset notify flags (FLUID_PRESET_PIN and FLUID_PRESET_UNPIN) that are handled by the preset->notify callback and trigger the loading and possibly unloading of the samples.
2020-10-31 13:23:15 +01:00
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
derselbst
27ad0684c6 Add regression test for #635 2020-05-23 15:30:27 +02:00
derselbst
28cde7e867 Reactivate test_preset_sample_loading 2020-05-23 14:40:41 +02:00
derselbst
76f4bc3db3 Add a unit test for fluid_sample_validate() 2020-01-24 15:57:08 +01:00
Tom M
3610372ae5
Workaround for jack sample rate mismatch (#607)
During the creation of a jack audio driver, it is checked whether the sample-rate of the settings object matches jack's rate. If not, it was adjusted previously via fluid_synth_set_sample_rate(). Due to the deprecation of that function and removal of real-time capability of the synth.sample-rate setting, a regression was introduced in 5fbddcecc3 causing the synth's sample-rate to be not updated.

This workaround obtains the synth via the settings instance and for now calls the deprecated sample-rate set function.
2020-01-19 15:36:15 +01:00
derselbst
f979c58e3c Add a unit test for fluid_sequencer_set_time_scale() 2020-01-03 20:30:09 +01:00
derselbst
7898c4f4ab Add a unit test for fluid_sequencer_send_at() 2019-12-27 10:49:25 +01:00
derselbst
3c4861c752 Add a unit test for fluid_ct2hz_real() 2019-10-18 21:03:00 +02:00
derselbst
68db8f4a80 add a unit test for fluid_synth_process()
addresses #527
2019-04-14 17:22:39 +02:00
derselbst
a36c06cff2 remove VintageDreamsWaves-v2.sf3
Converting this soundfont to other formats is forbidden. Suspend
depending unit tests.
2019-03-24 17:25:57 +01:00
derselbst
7b9e8de262 stop cmake from querying for a C++ compiler 2018-08-14 17:14:59 +02:00
Tom M
fcc69471d6
Merge pull request #385 from FluidSynth/issue49
Add reverb and chorus settings
2018-05-18 10:15:11 +02:00
Tom M
7aea42c96f
Merge pull request #374 from FluidSynth/rvoice-align
Enable / Improve vectorizion in rvoice_mixer
2018-05-18 10:14:14 +02:00
Tom M
51252b72b4
Merge branch 'master' into issue49 2018-05-17 22:13:36 +02:00
derselbst
04a5224eb9 add a unit test for C99 compliant FLUID_SNPRINTF 2018-05-17 14:56:55 +02:00
Tom M
f1384f03d9
Merge branch 'master' into rvoice-align 2018-05-11 16:53:42 +02:00
derselbst
cb58583050 add a unit test for reverb and chorus settings 2018-05-09 22:09:23 +02:00
derselbst
34912586f0 add a unit test for manually unregistering via fluid_event_unregistering()
currently results in a double free
2018-05-08 22:19:59 +02:00
derselbst
cdbd508007 add fluid_align_ptr() for aligning pointers 2018-04-26 16:07:19 +02:00
derselbst
044c5e3238 fuse preset iteration tests to preset+sample loading tests 2018-04-24 21:32:49 +02:00
derselbst
c433fc887c simplify dependency handling of unit tests 2018-04-21 23:22:45 +02:00
Marcus Weseloh
7987446fdf Fix tests without libsndfile. Not pretty, welcome a better solution! 2018-04-18 09:14:55 +02:00
Marcus Weseloh
f52bbf53a4 Add VintageDreamsWaves-v2 in SF3 format and some tests for sf3 loading 2018-04-18 09:14:55 +02:00
derselbst
36881f4ba8 add test for sample rate changes 2018-04-11 11:12:01 +02:00
Marcus Weseloh
c6bdc4bc12 Add test for sfont preset iteration 2018-04-08 23:03:14 +02:00
derselbst
9bbd676f4e disable ctest verbose output 2018-04-08 10:04:53 +02:00
derselbst
2cd2c40cd0 add unit test for soundfont [un|re]loading 2018-04-08 10:04:53 +02:00
derselbst
de68492710 add cmake option enable-tests
forces a static build and sets up test env
2018-04-07 10:45:44 +02:00
derselbst
147dbb2aa1 fix build 2018-04-07 10:45:43 +02:00
derselbst
42a6a2153a add a macro to simplify adding unit tests 2018-04-07 10:45:43 +02:00
derselbst
bd5b2f9a9c add unit test for sample cache 2018-04-06 22:15:17 +02:00