Commit graph

249 commits

Author SHA1 Message Date
Tom M
e3d8b3f2c3
Prevent samples accidentally having their loops disabled (#1018)
If a SoundFont sets `loopstart == loopend` and then uses loop-offset-modulators to fix up those loops assigning them with a valid position, the sample was previously switched to unlooped mode erroneously.

For the long story, see #1017.
2022-01-16 14:35:53 +01:00
Tamás Korodi
e096919477
Select soundfont samples by frequency instead of midi note numbers (#932)
For detuned channels it might be better to use another key for Soundfont sample selection
giving better approximations for the pitch than the original key.
Example: play key 60 on 6370 Hz => use tuned key 64 for sample selection

This feature is only enabled for melodic channels.
For drum channels we always select Soundfont samples by key numbers.
2021-07-05 00:47:47 +02:00
Tom M
7b3c2b87f7
Address clang-tidy10 warnings (#860) 2021-04-27 20:28:32 +02:00
Tom M
f69a47081a
Fix MinGW warnings (#861) 2021-04-27 20:27:56 +02:00
Tom M
00806600b6
fluid_compare_func_t const correctness (#858)
fluid_compare_func_t should receive const args.
2021-04-25 13:44:40 +02:00
derselbst
d2754028b4 Merge branch 'master' into refactor-and-fix-sffile-defsfont 2021-04-10 16:30:05 +02:00
Tom M
8a39c5aea4
Zone Validation Test (#826)
This is my implementation of a unit test to verify the preset and instrument zone validation behaviour.
2021-04-10 15:33:12 +02:00
Marcus Weseloh
5ebd4d3d26 Speedup SF2 loading by using prepend instead of append on samples
Using prepend both in sffile and defsfont reduces insert complexity
to O(1) and does not affect the final order of the sample list, as
the reversed order of the samples in sffile is reversed again in
defsfont.
2021-03-28 15:00:43 +02:00
Marcus Weseloh
0f8e2c7fde Refactor load_igen and load_pgen
Cleanup of the code structure and fix of the ineffective
check for global zones that are not first in list.

Fixes #813
2021-03-27 22:42:57 +01:00
Marcus Weseloh
dfbef11da0 Remove instsamp hack
This change removes the need for the instsamp hack in instrument
and preset zones. The sampleid and instrument generators are
treated as any other generator and simply passed to the defsfont
import functions. Those read the two generators and use the
index to look up valid samples and instruments.

Both generators are then reset to GEN_UNUSED again, just to make
sure that the rest of FluidSynth doesn't get confused. But that might
not be necessary.
2021-03-27 22:42:57 +01:00
Marcus Weseloh
6ca9b21740 Add more invalid generators for presets and instruments
Presets should not contain sampleid generators, instruments
should not contain instrument generators.
2021-03-27 22:42:57 +01:00
Marcus Weseloh
6b63c80d3d Remove code duplication by re-using enum from fluid_gen.h
We already have an enum for all generator values, so there is
no need to define another list in the loader code.
2021-03-27 22:42:57 +01:00
Marcus Weseloh
c4d38a7125 Fix preset generator validity checks
The previous implementation used 0 as end-of-list sentinel
value. But 0 is also the id of the first generator in the
invalid_preset_gen list. This effectively prevented checks
for invalid preset generators.

Also contains some code cleanup to make the check for invalid
instrument generators similar to invalid preset generators.

Fixes #821
2021-03-27 22:42:57 +01:00
Marcus Weseloh
259aecedf2 Remove unused macros 2021-03-27 22:42:57 +01:00
Marcus Weseloh
84704ea440 Remove Gen_MaxValid macro
Not really necessary, checking against Gen_Last is just as
understandable and removes a macro.
2021-03-27 22:42:57 +01:00
Marcus Weseloh
359af770a3 Rename Gen_Dummy to Gen_last to clarify the purpose 2021-03-27 22:42:57 +01:00
Marcus Weseloh
b61abdd907 Remove unused structs in sffile code 2021-03-27 22:42:57 +01:00
Marcus Weseloh
16d2f43509 Remove unused library, genre and morphology fields
Those fields are not used anywhere, so let's simply remove them.
2021-03-27 22:42:57 +01:00
Tom M
c32faa7b17
Parallelize SF2 loading (#812)
The loading of SF2 samples can be parallelized as well, at least for bigger soundfonts like the Stgiga 4GB monster.

The following test is performed with hot-caches:

`time src/fluidsynth -i -a alsa Stgiga\'s\ HiDef\ Soundfont\ \(2019-05-25\).sf2`

Serial version:
```
real    0m15,460s
user    0m14,163s
sys     0m1,192s
```

Parallelized version proposed by this PR:
```
real    0m5,851s
user    0m14,089s
sys     0m1,194s
```
2021-03-17 19:41:33 +01:00
Tom M
5ae72f8c74
Merge branch 'master' into fluid-sffile-variable-renaming 2021-03-15 21:40:16 +01:00
derselbst
9ea6c75724 Merge branch '2.1.x' into master 2021-03-15 21:27:42 +01:00
Tom M
005719628a
Invalid generators were not removed from zone list (#810)
fluid_list_remove() should receive the beginning of a list, so it can adjust the predecessor of the element to be removed. Otherwise the element would remain in the list, which in this case led to a use-after-free afterwards.
2021-03-15 20:12:51 +01:00
Marcus Weseloh
e3d95cb854 Rename p in load_igen to inst_list 2021-03-14 21:33:46 +01:00
Marcus Weseloh
552b1c4aa6 Rename p in load_imod to inst_list 2021-03-14 21:32:08 +01:00
Marcus Weseloh
dd037c725e Rename p in load_ibag to inst_list 2021-03-14 21:31:27 +01:00
Marcus Weseloh
93a74ff3bd Rename pr in load_ihdr to prev_inst 2021-03-14 21:29:28 +01:00
Marcus Weseloh
c545766ea6 Rename p in load_ihdr to inst 2021-03-14 21:27:40 +01:00
Marcus Weseloh
8df5abf903 Rename p in load_pgen to preset_list 2021-03-14 21:24:25 +01:00
Marcus Weseloh
9e7c108f4c Rename p in load_pmod to preset_list 2021-03-14 21:12:04 +01:00
Marcus Weseloh
f1baa556a6 Rename p in load_pbag to preset_list 2021-03-14 21:11:07 +01:00
Marcus Weseloh
edc99ebc24 Rename p2 in fixup_igen to zone_list 2021-03-14 21:03:10 +01:00
Marcus Weseloh
06145d2139 Rename p2 in fixup_pgen to zone_list 2021-03-14 21:02:29 +01:00
Marcus Weseloh
e254c56373 Rename p2 in load_igen to zone_list 2021-03-14 21:00:15 +01:00
Marcus Weseloh
0c363cc574 Rename p2 in load_imod to zone_list 2021-03-14 20:59:32 +01:00
Marcus Weseloh
355c50631d Rename p2 in load_ibag to zone_list 2021-03-14 20:58:55 +01:00
Marcus Weseloh
b5d80a1248 Rename p2 in load_pgen to zone_list 2021-03-14 20:58:03 +01:00
Marcus Weseloh
a044835cf5 Rename p2 in load_pmod to zone_list 2021-03-14 20:56:58 +01:00
Marcus Weseloh
0e761da102 Rename p2 in load_pbag to zone_list 2021-03-14 20:55:52 +01:00
Marcus Weseloh
f694d41a0e Rename p3 in fixup_igen to inst_list 2021-03-14 20:54:27 +01:00
Marcus Weseloh
fd3e9bdc21 Rename p3 in fixup_pgen to inst_list 2021-03-14 20:54:14 +01:00
Marcus Weseloh
bc2afb682b Rename p3 in load_igen to gen_list 2021-03-14 20:51:10 +01:00
Marcus Weseloh
b506304bef Rename p3 in load_imod to mod_list 2021-03-14 20:50:18 +01:00
Marcus Weseloh
5bf9cf545f Rename p3 in load_pmod to gen_list 2021-03-14 20:49:45 +01:00
Marcus Weseloh
2c3caafcdf Rename p3 in load_pmod to mod_list 2021-03-14 20:48:58 +01:00
Tom M
8a778e0c0e
Add warning if soundfont bigger 2GB (#811)
Advice the user to use fluidsynth 2.2.0 or later when loading soundfonts > 2GB
2021-03-14 17:20:09 +01:00
Tom M
0d76403f9f
Parallelize SF3 loading (#746) 2021-02-06 20:32:17 +01:00
derselbst
bc056b576b Print error if fluid_is_soundfont() fails 2020-12-22 13:16:30 +01:00
Marcus Weseloh
a9135faf70 Structure the large synth header into subgroups
Also include version.h and ladspa.h in the Synthesizer group.
2020-11-12 21:27:00 +01:00
Marcus Weseloh
9248032feb SoundFont API
Includes Generators, Modulators, Loader etc
2020-11-12 21:27:00 +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