Commit graph

1857 commits

Author SHA1 Message Date
derselbst
56a4507513 Mention fluid_sample_set_sound_data() in API docs 2019-10-27 16:49:04 +01:00
Tom M
38b929e501
Fix broken voice mixing (#582)
This fixes a regression introduced in 907ec27a9e

When rendering a voice, there are 3 cases to consider: silent, playing,
and finished. When optimizing away the memset, I incorrectly assumed that
a voice cannot switch between playing and silence (like crazy) while
rendering FLUID_MIXER_MAX_BUFFERS_DEFAULT. Apparently this does not
hold true, esp. when rendering at sample rates ~96kHz.
2019-10-27 16:45:07 +01:00
derselbst
68c7989d0d Ensure NDEBUG disables assertions 2019-10-27 09:40:37 +01:00
Stefan Westerfeld
50dd443c20 Fix bugs in fluid_sample_set_sound_data with copy enabled
- memset should clear all the memory
- end position should be at the end of sample data

Closes #576

Signed-off-by: Stefan Westerfeld <stefan@space.twc.de>
2019-10-21 21:03:14 +02:00
derselbst
a94bc82a3c Initialize allocated memory to garbage
for debug builds.
2019-10-05 16:43:53 +02:00
derselbst
62b38b1c66 Minor typo in API docs 2019-09-27 16:53:27 +02:00
derselbst
ca7f7047ad Correctly define DEBUG macro 2019-09-27 14:05:13 +02:00
derselbst
44453ff232 Ensure the reverb engine is initialized after synth creation
The parameters (roomsize, level, etc.) of the reverb effects unit are initialized at the very end of `new_fluid_synth()` with `fluid_synth_set_reverb_full_LOCAL()`.
This however only adds an update-event to the `rvoice_mixer` queue.
The call to `fluid_synth_process_event_queue()` in `new_fluid_synth()` should make sure, that this event is dispatched and triggers the actual update.
However, the event is not dispatched immediately, because the rvoice event queue has not been committed yet, that is, a call to `fluid_rvoice_eventhandler_flush()` is missing.

So, although a reverb param initialization event has been queued, the reverb params still are garbage initialized (on Windows to some `-6.2774385622041925e+66`).

The next call to through the synth's public API will flush the queue and finally dispatch the update event, but when will it happen?

1. If the soundfont is specified as command-line argument, this call will happen before the audio driver starts rendering.
2. If the soundfont is loaded via shell command `load`, the audio driver will first start rendering audio, after updating the reverb.

Case 1. is trivial, everything works as it should.
Case 2. is interesting. Since the synth already started rendering audio by using that uninitialized reverb unit, the reverb engine's internal buffer is completely filled up with noise. Before outputting that signal to sound card, the sound is clipped to `1.0f`. That's the click we hear at the beginning. And because the reverb is so loud, the rendered audio signal stays 1.0f for quite a long time (...or always, can't tell).

Why is it not reproducible on Linux? Because GCC and Clang (AFAIK) leave all values uninitialized after allocating memory. And because malloc() often return zero-initialized memory, the reverb params seem to be nicely zero-initialized. MSVC however, always initializes memory with garbage, which is why we "hear" this resonance disaster.

Solution: Just update the reverb params via public API, which implicitly calls `fluid_rvoice_eventhandler_flush()`.

Fixes #563.
2019-09-27 14:01:40 +02:00
derselbst
9793c0def3 bump to 2.0.7 2019-09-24 16:23:55 +02:00
Tom M
17042f4dc1
Add a public wrapper function for free() (#562)
to allow proper deallocation for programming languages other than C.
2019-09-24 16:14:34 +02:00
derselbst
cac2c6bf84 Fix example code in the API docs
order of object creation: audio driver must be last
2019-08-25 10:59:11 +02:00
derselbst
f78486a50b Update developer docs 2019-08-17 18:01:01 +02:00
derselbst
dec5e98f23 Bump version to 2.0.6 2019-08-17 18:00:29 +02:00
derselbst
6d8f338d42 Fix order of object creation in fluidsynth binary
Fixes a use-after-free when the MIDI player is deleted before the audio
driver, because the synthesis thread is still actively making callbacks
on the sample timer, which is deleted by the player though.
2019-08-17 16:17:00 +02:00
derselbst
686556decc Fix documentation of fluid_player_stop()
Addresses #550
2019-08-17 16:04:14 +02:00
derselbst
58022a11fa Regression fix for fluid_player_join()
df893bbfa4 caused to wait for the system timer thread to join for ever.
2019-08-17 16:04:14 +02:00
Tom M
5351d9dcb9
Fix various memory leaks in the fluidsynth binary (#555) 2019-08-17 14:36:35 +02:00
derselbst
81a86e33ab Correctly restart playback after fluid_player_stop()
Fixes #550
2019-08-15 16:21:12 +02:00
derselbst
df893bbfa4 Fix use-after-free in fluid_player_stop()
Previously, sample timers were deleted in fluid_player_stop() which caused a use-after-free when at the same time the sample timers were advanced by the synthesizer thread. This was incorrectly addressed in 5d3f727547 . Deleting sample timers is now done in delete_fluid_player(). A broken application could still crash if it does not respect the order of object creation though. At least now, this issue is properly documented.
2019-08-15 16:18:55 +02:00
Tom M
f70a6321c5 fix build 2019-08-09 09:00:03 +02:00
Tom M
8dae1eebcf enable readline support if header and lib found 2019-08-09 08:59:54 +02:00
derselbst
ac6becea14 Import CI build scripts from master 2019-08-08 21:57:20 +02:00
derselbst
b87d8b96ef Print out version of clang-tidy 2019-08-08 19:50:41 +02:00
derselbst
743601930a Fix two uninitialized memory accesses in new_fluid_synth()
In an out of memory situation, fluid_synth_t::voice and fluid_synth_t::channel may not be fully initialized, causing a NULL dereference and heap corruption in delete_fluid_synth().
2019-08-02 15:09:29 +02:00
derselbst
7f11a9bf5c use a common function for opening regular files
Fixes #514
2019-04-18 19:43:39 +02:00
derselbst
b817232f16 update API docs for 2.0.5 2019-04-17 20:07:40 +02:00
derselbst
8b448ffd4b fix build with MSVC 2019-04-17 19:20:36 +02:00
Marcus Weseloh
a0e91b9878 Fix memory-leak with SF3 samples when dynamic-sample-loading is not active
Vorbis compressed SF3 samples are always loaded individually and stored
in the sample cache in uncompressed form. When dynamic-sample-loading is
not active (the default), then the uncompressed samples did not get
unloaded when unloading the SF3 font.

This fix makes sure that those samples are also freed. For bulk loaded
samples, the sample->data pointer is always the same as the
font->sampledata pointer. For individually loaded samples, the sample->data
pointer always points to a different memory region. So we can use that
information to determine if and when to unload the samples one by one.

Fixes #530
Fixes #528
2019-04-17 19:10:38 +02:00
Stefan Westerfeld
f791162569 Fix buffering bug in fluid_synth_process().
The old buffering code assumes that synth->cur is between 0 and FLUID_BUFSIZE.
However since fluid_synth_process() can render more than one buffer at a time
this isn't always true, and the new code handles other values properly.

Closes #527
2019-04-14 17:25:55 +02:00
derselbst
68db8f4a80 add a unit test for fluid_synth_process()
addresses #527
2019-04-14 17:22:39 +02:00
derselbst
226b411a04 wording docs 2019-04-13 14:52:45 +02:00
derselbst
e5c29cf8b8 bump to 2.0.5 2019-04-13 14:02:01 +02:00
derselbst
a5436021a5 fix conditional jump depending on uninitialized variable 2019-04-13 10:45:05 +02:00
derselbst
33450117e9 another memory leak in jack midi driver 2019-04-05 20:13:17 +02:00
derselbst
faef23f094 fix various NULL derefs and mem leaks in jack driver
closes #416
2019-04-05 20:04:21 +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
f9f826e8e2 fix the default tempo of midi files
the MIDI spec defines it to be 120 BPM, fixes #519
2019-03-17 14:05:06 +01:00
derselbst
9be693d9bc add missing calls to delete_fluid_thread()
even if they are currently a null-op
2019-03-15 20:32:29 +01:00
derselbst
89ffe5881d fix a memory leak in new_fluid_thread() 2019-03-15 20:30:02 +01:00
derselbst
8f3af98a94 prevent fluidsynth_priv.h from being listed by doxygen 2019-03-15 15:59:05 +01:00
derselbst
4bc3ba72cf fix documentation for pitch_bend_range shell command 2019-03-12 18:21:13 +01:00
Florian Léger
099369f8b7 Improve systemd integration
When fluidsynth is run as a service using systemd, make sure
the service is considered started only when it is ready to process events.

In order to do so:
 - Add an optional runtime dependency to libsystemd to the fluidsynth executable
 - Change the systemd service type to "notify"
 - Have fluidsynth notify systemd that the service is started after the server is started
 - Have fluidsynth notify systemd that the service is stopping after joining the server thread
2019-03-02 10:18:32 +01:00
derselbst
9671e412fe fix build with MinGW 2019-02-22 10:15:18 +01:00
Tom M
9ca9a57a1f
add MinGW build badge to ReadMe 2019-02-22 10:10:53 +01:00
Tom M
b2ea8f9870
Add MinGW to AppVeyor CI (#515) 2019-02-22 10:08:02 +01:00
derselbst
bfc03136bb remove duplicate delcarations of fluid_get_std[in|out] 2019-02-17 12:44:06 +01:00
Tom M
24e4d1a963
Merge pull request #513 from FluidSynth/network-darwin
Re-enable Network Support on Mac
2019-02-16 12:39:25 +01:00
Bernhard M. Wiedemann
d25281d447 Generate pow lookup tables with higher precision
possibly due to glibc-2.29 commit 424c4f60ed6190e2ea0e72e0873bf3ebcbbf5448
pow is using fused-multiply-add (fma) if available.
That caused the fluidsynth binaries to differ depending on
the build machine's CPU.

This was visible among others in
grep '7.58577575029183[56]e-04' fluidsynth-2.0.3/build/fluid_conv_tables.c

See https://reproducible-builds.org/ for why this is matters.

Closes #512.
2019-02-16 10:51:53 +01:00
derselbst
cae9e5fdf2 remove orphaned Max/MSP include 2019-02-15 18:06:18 +01:00
derselbst
9ef169cb00 fix building CoreAudio on OSX 10.4
by cleaning up fluidsynth's private includes
2019-02-15 17:55:02 +01:00