Commit graph

130 commits

Author SHA1 Message Date
Marcus Weseloh
df3bab0b40 Only import instruments once from Soundfont
This changes the way instruments and their related information is imported
from a Soundfont. Previously, each preset zone got a complete copy of the
instrument and related information, wasting a lot of precious memory.

After this change, an instrument and related information is only
imported once and then linked into all preset zones that use this
instrument.
2018-04-22 19:09:23 +02:00
Marcus Weseloh
c4003bef39 Store mutable information about inst zones in new fluid_voice_zone_t struct
This change separates the static instrument zone information read from
the Soundfont from the information that gets modified on import and
later via the legato handling. It opens opens up the possibility of
having unique instruments that only get imported once and then linked
into the individual preset zones.
2018-04-22 19:08:09 +02:00
Marcus Weseloh
3603a34a77 Also load 46 zero words area after sample for uncompressed samples 2018-04-22 12:20:37 +02:00
Marcus Weseloh
3ce3575269 Ensure that loops are sanitized and sample is optimized for dynamically loaded samples 2018-04-22 10:37:14 +02:00
Marcus Weseloh
7240461e5b Merge branch 'master' into dynamic-sample-loading 2018-04-21 23:34:20 +02:00
Marcus Weseloh
9dcb4148cb Only open the Soundfont for sample reading if necessary 2018-04-21 23:22:45 +02:00
derselbst
02de830043 fix dangling pointer on inst_zone sample lookup
fixes #369
2018-04-21 23:17:19 +02:00
derselbst
323b9b8cbf avoid assigning incompatible pointers 2018-04-21 22:31:18 +02:00
derselbst
17dded3700 avoid NULL deref in fluid_rampreset_preset_delete() 2018-04-21 16:55:08 +02:00
derselbst
71592ec679 fix memory leaks during sfont loading 2018-04-21 16:48:56 +02:00
derselbst
08147cc3d6 avoid double free in fluid_sample_set_sound_data() 2018-04-21 16:33:27 +02:00
Marcus Weseloh
073da2141c Implement dynamic sample loading
This change adds a new feature that enables loading and unloading of
sample data on demand. As soon as a preset is selected for a channel, all
of it's samples are loaded into memory. When a preset is unselected, all
of it's samples are unloaded from memory (unless they are being used by
another selected preset).

This feature is disabled by default and can be switched on with the
"synth.dynamic-sample-loading" setting.
2018-04-18 09:14:55 +02:00
Marcus Weseloh
a985c68a13 Enable decompressed Ogg Vorbis samples to be stored in sample cache
This change moves the Ogg Vorbis decompression to fluid_sffile, so that
this is the only place where we have to deal with compressed audio.

It also changes the way the samples are loaded for SF3 files: previously,
the compressed data was copied into memory, then the individual samples
were decompressed (resulting in both compressed and decompressed data to
stay in memory). Also, decompressed data wasn't cached, so previous loads
of the same file ran the decompressed again for each sample.

After this change, the vorbis decompression is changed so that it reads the
compressed data directly from the Soundfont file. And the resulting WAV
data is stored in the sample cache.
2018-04-18 09:14:55 +02:00
Marcus Weseloh
3d05360f33 Split preset parsing from Soundfont file open 2018-04-18 09:14:55 +02:00
Marcus Weseloh
839f62f89d Remove unused variable 2018-04-10 22:09:33 +02:00
Marcus Weseloh
1a1bf7d0ea Remove now obsolete preset stack code and struct members 2018-04-08 23:03:14 +02:00
Marcus Weseloh
66610abcb9 Refactor fluid_preset_t handling in defsfont and ramsfont
Removes the need for a pre-allocated stack of fluid_preset_t's. Upon
adding a loader specific preset, a fluid_preset_t is automatically
created. defsfont and ramsfont now keep track of the fluid_preset_t's,
not the loader specific ones.

Also changes the sfont::iteration_next signature to directly return
the next preset. This is possible as presets are now only created once
and returned as a pointer.
2018-04-08 22:59:55 +02:00
derselbst
5698106dde fix various doxygen warnings 2018-04-08 10:36:52 +02:00
Marcus Weseloh
fa0d103907 Remove unnecessary debug warnings for equal sample loopstart and loopend 2018-04-08 00:07:25 +02:00
derselbst
4ede11e71f remove redundant struct _fluid_sfont_info_t
integrate its members into fluid_sfont_t
2018-04-07 22:17:08 +02:00
derselbst
6ab1c7fde3 avoid memory leak during sample import 2018-04-07 18:21:25 +02:00
derselbst
19587d343a dont exit sample processing early
when a single sample is broken
2018-04-07 18:14:09 +02:00
derselbst
b1b870049b fix return value on sample validation 2018-04-07 18:09:37 +02:00
Marcus Weseloh
9c1f3bd53e Return FLUID_OK instead if TRUE to be consistent with other return values 2018-04-05 19:20:47 +02:00
Marcus Weseloh
362a3f2a81 Fix bug in removing element from samplecache_list 2018-04-05 19:20:17 +02:00
Marcus Weseloh
f8bc376392 Use glib's g_stat to get file modification time 2018-04-04 11:11:41 +02:00
Marcus Weseloh
7e36bcf058 Rename parameters and variables to better reflect their contents / use
As fluid_defsfont contains code that deals with fluid_sfont_t and
fluid_defsfont_t, fluid_preset_t and fluid_defpreset_t, it sometimes gets
very confusion to know which type is currently being accessed by "sfont"
or "preset".

Also clarify some preset zone / inst zone ambiguities.
2018-04-04 11:11:41 +02:00
Marcus Weseloh
d1c620f998 Use fluid_list_get to access list entry data 2018-04-04 11:11:41 +02:00
Marcus Weseloh
109e8990b8 Use FLUID_STRDUP instead of manual allocate and copy for strings in defsfont loader 2018-04-04 11:11:41 +02:00
Marcus Weseloh
cf04a4ff73 Use FLUID_ARRAY instead of FLUID_MALLOC for sample buffers 2018-04-04 11:11:41 +02:00
Marcus Weseloh
312459eaf1 Treat failures while loading 24-bit sample data as not fatal 2018-04-04 11:11:41 +02:00
Marcus Weseloh
352bdef533 Properly free memory on error 2018-04-04 11:11:41 +02:00
Marcus Weseloh
e8717e5b40 Remove explicit cast of FLUID_MALLOC return value 2018-04-04 11:11:41 +02:00
Marcus Weseloh
c7e579aa75 Remove redundant error messages 2018-04-04 11:11:41 +02:00
Marcus Weseloh
29296b0e20 Ensure that sample_data memory is unlocked even if sample_data_24 mlock fails 2018-04-04 11:11:41 +02:00
Marcus Weseloh
d5407742a6 Always release the mutex when exiting fluid_samplecache_load
And change fluid_samplecache_unload to use the same style.
2018-04-04 11:11:41 +02:00
Marcus Weseloh
8024907610 No need for fluid_sample_* functions in fluid_sfont to be public 2018-04-04 11:11:41 +02:00
Marcus Weseloh
4932b4af90 Refactor sample cache loader
- move sample reading to fluid_sffile
- refactor sample cache to use fluid_list and separate long functions into
  smaller ones
- include sample start and count in cache key, in preparation for lazy loading
- make defsfont use new sample cache loader interface
2018-04-04 11:11:41 +02:00
Marcus Weseloh
5bc2d33bb9 Differences in sample chunk sizes are not an error but simply an indication of a changed file 2018-04-04 11:11:41 +02:00
Marcus Weseloh
870fc56d6a Code cleanup and formatting in fluid_samplecache 2018-04-04 11:11:41 +02:00
Marcus Weseloh
a274a394e0 Clang-format fluid_samplecache 2018-04-04 11:11:41 +02:00
Marcus Weseloh
4ec1cfe73e Move sample caching code to own file fluid_samplecache.c/h 2018-04-04 11:11:41 +02:00
Marcus Weseloh
76102f2009 Remove unnecessary fluid_sample_t::valid flag 2018-04-04 11:11:41 +02:00
Marcus Weseloh
963a5e98b4 Move sample and loop validation to fluid_sfont
Makes it possible to use the same validation logic for both SF2 and SF3
samples.
2018-04-04 11:11:41 +02:00
Marcus Weseloh
987d8a5f17 Move vorbis decompression to fluid_sfont 2018-04-04 11:11:41 +02:00
Marcus Weseloh
0a664e0797 Remove unnecessary conversion of sample pointers to offsets
SFSample should provide the sample pointers as specified in the Soundfont
file. If any mangling of the pointers is required, it should happen in the
defsfont loader.
2018-04-04 11:11:34 +02:00
Marcus Weseloh
9341059b24 Remove underscore functions for log messages
They were only used in soundfont loading code, so are probably a remnant
from Smurf. The rest of the FluidSynth code doesn't use underscore
functions, so remove them here as well for consistency.

Also use single quotes in double quoted string, to remove the need for
escaping chars.
2018-04-04 11:08:45 +02:00
Marcus Weseloh
1bc69be41b Rename fluid_sf2_* functions to fluid_sffile_* 2018-04-04 11:08:45 +02:00
Marcus Weseloh
b6bdb6b059 Cleanup delete_* functions 2018-04-04 11:08:45 +02:00
Marcus Weseloh
7f09321714 Make size macro names easier to read 2018-04-04 11:08:45 +02:00