Commit graph

1401 commits

Author SHA1 Message Date
derselbst
6776569abe Deprecate fluid_event_any_control_change() 2020-09-11 22:22:35 +02:00
derselbst
23b270c08b Merge branch '2.1.x' into master 2020-09-06 14:54:26 +02:00
jjceresa
f94cee0a50
Add multi channels support for audio driver. (#667)
This PR addresses #665.

1) Add new functions for multi channels support: `fluid_synth_write_float_channels()`, `fluid_synth_write_s16_channels()`
2) `dsound` and `waveout` driver make use of this support. tested on 2 audio devices: 
    - creative SB Live! (6 channels).
    - Realtek: ALC889A (8 channels).
2020-09-02 21:31:50 +02:00
jjceresa
57af8803f2
Mapping of fx unit output to dry buffers in mix mode. (#668)
Currently, all fx unit output (in mix mode) are mapped to the `first buffer`.
This is not appropriate for synth.audio-groups > 1

This PR allows the mapping of fx output based on `fx unit index` and `synth.audio-groups` value.
This allows us to get the `fx output `mixed to the respective  `buffer` on which a `MIDI channel` is mapped.
For example: with `synth.audio-groups = 3` and  `synth.effect-groups = 3`:
- MIDI chan 0 (dry + fx0) is mapped to buf 0
- MIDI chan 1 (dry + fx1) is mapped to buf 1
- MIDI chan 2 (dry + fx2) is mapped to buf 2
2020-09-02 21:10:31 +02:00
Tom M
aea6644324
Use a runtime check to detect version of libinstpatch (#666)
It could be that during runtime an older version of libinstpatch is used than the one fluidsynth was compiled against. In this case, libinstpatch will fail to load DLS fonts, because libinstpatch's initialization semantics don't match those compiled into fluidsynth.
2020-08-31 20:35:21 +02:00
jjceresa
c76949e6d3
Limiting audio-channels to audio-groups (#663) 2020-08-22 13:24:41 +02:00
derselbst
fa6f9c3570 Remove unused member variable 2020-08-17 18:23:43 +02:00
derselbst
4b83ee55c0 Merge branch '2.1.x' into master 2020-08-10 20:35:42 +02:00
jjceresa
3ee2bbed96 fix NULL permitted for out and fx pointer buffer
Closes #659
2020-08-10 20:33:42 +02:00
Tom M
31c4e12ac9
Update Travis CI (#658)
* update to Ubuntu Focal
* use clang10
* avoid unintentional fallbacks to  default `/usr/bin/c++` compiler
* fix related compiler warnings
2020-07-28 21:05:01 +02:00
derselbst
3c94f6366d Merge branch '2.1.x' into master 2020-07-12 13:03:59 +02:00
derselbst
2393aef3bd Fix printf format warnings 2020-07-12 12:55:32 +02:00
derselbst
62b715483f Merge branch '2.1.x' into master 2020-07-09 19:39:21 +02:00
derselbst
d7abe8bdfd Fix a possible race condition during midi autoconnect 2020-07-09 19:30:32 +02:00
derselbst
eac0de0345 Fix a NULL deref in jack driver 2020-07-09 19:10:11 +02:00
derselbst
85f94c61c9 Fix passing arguments from incompatible pointer type 2020-07-08 19:20:13 +02:00
derselbst
d73135fc48 Merge branch '2.1.x' into master 2020-07-05 16:32:47 +02:00
derselbst
c5293fc753 Fix an uninitialized memory access
that could possibly trigger an FPE trap for instruments that use the exclusive class generator
2020-06-28 14:58:02 +02:00
derselbst
4261848dd4 Fix regression introduced in a89399476e
Mentioned commit broke fluid_synth_start() when using a DLS soundfont.
2020-06-26 17:38:49 +02:00
Tom M
aa32da0a47
Properly handle overlapping notes when using fluid_event_note() (#637) 2020-06-15 08:38:56 +02:00
Tom M
e16ca05a58
Avoid num_samples from becoming negative (#653)
For Soundfonts bigger 2GiB, num_samples becomes negative. When being passed to safe_fread() it's promoted to long long and when being passed to fread(), it's cast to size_t. Works fine in twos-complement, but still is not nice.
2020-06-08 09:24:23 +02: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
Tom M
9995fd88b2
Support loading SoundFonts >2GiB on Windows (#629)
Since sizeof(long) == 4 even on 64 bit Windose, big files cannot be
loaded natively via the ANSI C file API. This change makes fluidsynth's
file callback API use long long, which is guaranteed to be at least 64
bit wide.
2020-05-26 16:53:59 +02:00
derselbst
19a20eb852 Fix another NULL deref related to #635 2020-05-23 15:31:48 +02:00
derselbst
a865ac33d9 Remove SDL2 not inited warning for upcoming release
Addresses #649
2020-05-19 19:44:47 +02:00
derselbst
9ad2bcaa10 Quote MIDI device names
Addresses #650
2020-05-19 16:39:07 +02:00
derselbst
4f1fdc0df7 Fix unicode string comparison 2020-05-19 16:39:07 +02:00
derselbst
45efbd97c0 Revise log messages in new_fluid_winmidi_driver()
Addresses #650.
2020-05-19 16:39:07 +02:00
derselbst
69e7eca670 Fix notes not being played that start at the value of seek_ticks
Fixes #646
2020-05-17 09:56:35 +02:00
jjceresa
d63524683f
Fix ordering of operations (#647) 2020-05-09 09:31:51 +02:00
derselbst
304096add7 Update API docs about synthesis context 2020-05-02 20:12:01 +02:00
jjceresa
8a3eaf9b18
Make fluidsynth call ipatch_close() (#644) 2020-05-02 14:31:34 +02:00
derselbst
87a6debba0 Replace custom version check by GLIB_CHECK_VERSION 2020-05-02 13:42:10 +02:00
derselbst
87c7599e63 Remove unused variable 2020-05-02 13:24:33 +02:00
jjceresa
6aea18bef4
Allow the reverb to pre allocate delay lines. (#638)
This PR allows the reverb to pre-allocate the memory needed for the maximum sample-rate of the synth. That means that on sample rate change there are no memory allocation and the function fluid_revmodel_samplerate_change() should always return FLUID_OK.

The PR addresses discussion in #608.
2020-05-01 13:26:52 +02:00
jjceresa
791dac6736
Stop dsound properly. (#642)
Stopping `dsound `before stopping `audio thread` avoid dsound playing transient glitches between the time audio task is stopped and dsound will be released. These short trailing glitches are particularly audible when captured by a reverb connected on output.
2020-04-30 19:51:24 +02:00
Tom M
e2d435dad6
Fix a NULL deref in delete_rvoice_mixer_threads() (#641)
The function attempts to lock a mutex that might have not been created yet, due to a previous error.
2020-04-30 19:49:58 +02:00
jjceresa
ff14432cd9
Make chorus capable of sample rate change. (#639) 2020-04-27 18:07:22 +02:00
Tom M
a89399476e
Fix a NULL pointer deref if dynamic-sample-loading is enabled (#636) 2020-04-25 17:26:21 +02:00
derselbst
85cf123d38 Guard against multiple calls to fluid_player_seek()
Addresses #634
2020-04-22 17:28:47 +02:00
derselbst
893f48e4a2 Amend 69cfa781eb
Remove incorrect atomic read from player->seek_ticks. Addresses #634
2020-04-20 15:57:59 +02:00
derselbst
69cfa781eb Fix a race condition while fluid_player is seeking
Fixes #634
2020-04-19 12:08:48 +02:00
derselbst
f15b8e5447 Update API docs
for fluid_get_sysconf() and fluid_get_userconf()
2020-04-18 23:56:59 +02:00
Tom M
85237e4fc8
Fix cross-compilation from Win32 to ARM using vcpkg (#630)
For some reason, the configure command must be specified explicitly in the `gentables` build step. Otherwise, the ARM target compiler will be used to build `make_tables` rather than the host compiler. 

Now that microsoft/vcpkg#10485 has been completed, an ARM CI build can be added to AppVeyor. Also, the build status table in the README has been updated.
2020-04-08 11:13:42 +02:00
derselbst
631c9798cb Update API docs on fluid_player_set_bpm()
Resolves #624
2020-03-20 19:57:43 +01:00
derselbst
eff728753b Update API docs 2020-03-08 09:55:09 +01:00
Tom M
cc85d285b5
Fix a memory leak in Oboe driver (#626) 2020-03-07 14:15:13 +01:00
Tom M
c9d023230a
Add verbose error logging for opensles and oboe (#627) 2020-03-07 14:14:28 +01:00
derselbst
cabb219285 Update API docs 2020-03-07 13:42:09 +01:00
derselbst
ddbd0afcc8 Fix a possible NULL dereference 2020-03-03 16:48:24 +01:00
derselbst
33f687704f Exit with error when invalid commandline arguments are supplied
Resolves #623
2020-03-03 16:46:50 +01:00
derselbst
a359e7f222 Turn SDL2 initialization message into a warning
Resolves #622
2020-03-03 16:15:32 +01:00
derselbst
7ea9e21081 Fix build of OSS driver if soundcard.h is not in sys/ 2020-02-16 16:43:20 +01:00
derselbst
ab15b32656 Bump to 2.1.1 2020-02-16 15:59:11 +01:00
derselbst
d5424462b5 Update documentation of --verbose option 2020-02-14 13:40:50 +01:00
Tom M
aa3f5a52fd
Make printing debug messages runtime configurable (#619)
Supplying --verbose to the fluidsynth executable now prints debug messages to stdout. Debug messages are still being printed by default when fluidsynth was compiled in debug mode.
2020-02-13 17:09:20 +01:00
Tom M
2bbe9272bb
Merge pull request #614 from FluidSynth/sfsampletype
Hardening fluid_sample_validate() against invalid flag combinations
2020-02-13 17:07:57 +01:00
derselbst
b3939138d4 Extend error logging in alsa driver 2020-02-08 18:55:26 +01:00
derselbst
2759d9e087 Remove unused member SFSample::samfile 2020-02-02 15:25:53 +01:00
derselbst
df58a440f2 Warn if ogg sample is not ogg compressed 2020-02-02 15:19:27 +01:00
derselbst
93a170ca58 Minor API doc update 2020-02-01 14:37:35 +01:00
Tom M
af2342ac43
Solve the sequencer client unregistering problem (#610)
Responsibility for calling fluid_sequencer_unregister_client() in case of FLUID_SEQ_UNREGISTERING events has been moved to fluid_sequencer_send_now(). In other words, a FLUID_SEQ_UNREGISTERING event now really unregisters the client, no matter how the client's callback function looks like.

Avoids leaking the sequencer clients if implementations do not unregister them explicitly.

Also fixes another memory leak if fluid_sequencer_register_fluidsynth() clients were unregistered with fluid_sequencer_unregister_client() rather than by sending an unregistering event.
2020-02-01 14:32:35 +01:00
derselbst
dcc9c27acf Hardening fluid_sample_validate() against invalid flag combinations
e.g. unknown compression types, multiple exclusive flags or no flags at all
2020-01-24 15:57:08 +01:00
derselbst
5070fe8419 Attempt to fix double free in jack driver 2020-01-23 14:43:42 +01:00
derselbst
5b3ec92cec Fix a memory leak in the file renderer 2020-01-19 16:17:00 +01:00
Tom M
c85ad53d60
Deprecate usage of the system timer for the sequencer (#599)
Deprecate usage of the system timer for the sequencer and print a warning if the system timer is used.
2020-01-19 15:37:42 +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
7f816029ab Fix a few integer truncation warnings 2020-01-10 17:07:58 +01:00
derselbst
6b42f27724 Remove redundant call to fluid_event_set_time()
It's already done by fluid_sequencer_send_at()
2020-01-02 11:14:25 +01:00
derselbst
68371d382b Update API doc of fluid_sequencer_add_midi_event_to_buffer() 2020-01-02 11:14:04 +01:00
luz.paz
45f8e0a868 Fix various typos
Found via `codespell -q 3 -L uint -S ./ChangeLog -L dur`
2019-12-17 20:11:49 +01:00
derselbst
13c6e98936 Guard the sequencer API 2019-12-14 18:38:27 +01:00
Tom M
cd199cfdc8
Remove unused tracing code from sequencer (#596) 2019-12-14 18:09:29 +01:00
derselbst
4af42bd8ea Update API docs about queuing seq events 2019-12-13 16:02:25 +01:00
derselbst
08848864d2 Elaborate API docs
fluid_synth_all_sounds_off() and fluid_synth_all_notes_off()
2019-12-06 17:24:58 +01:00
Foster McLane
19eacc6b60 Fix undefined behaviour in get_num_outputs in CoreAudio driver (#594)
See discussion in #591 for details. Basically an incorrect size was
being allocated for the CoreAudio buffer list for a device. It was being
allocated by a VLA (which already did not quite fit the semantics of the
list) and the length calculated could be 0 (instead of the size of the
struct with no buffers elements) causing undefined behaviour.

This corrects it to allocate the amount of memory required by the
CoreAudio framework function and adds a check for the size retrieval and
for the dynamic allocation. This change passed UBSan in my test where
before the change it did not.

Fixes #591
2019-11-13 22:13:54 +02:00
jjceresa
bebb5571ae Make Fine Tune destination of default modulator Pitch-Wheel-To-pitch (#590) 2019-11-08 21:26:07 +01:00
Tom M
99268a3e99
FIXME: ensure that the decompressed OGG sample is 16-bit mono (#589) 2019-11-08 16:13:28 +01:00
Tom M
56e0cfd7c1
Merge pull request #586 from FluidSynth/typecheck-fluid-log
Improve type-checking of fluid_log() format specifiers
2019-11-04 16:44:51 +01:00
Tom M
4c980c5860
Remove unused macros from config.h (#588) 2019-11-04 16:44:32 +01:00
derselbst
77ad8c1c87 Replace LASH_ENABLED by HAVE_LASH
As recommended in #587
2019-11-03 12:34:50 +01:00
Carlo Bramini
47e6cdaf50 Remove redundant check on HAVE_LASH (#587) 2019-11-03 12:32:49 +01:00
derselbst
5fbddcecc3 Remove real-time capability from synth.sample-rate setting
Addresses #585
2019-11-03 11:11:02 +01:00
derselbst
60bcdd4457 Add deprecation attribute to fluid_synth_set_sample_rate() 2019-11-03 10:55:29 +01:00
derselbst
0541864628 Fix incorrect printf format specifiers 2019-11-03 09:30:26 +01:00
derselbst
405d4bc48b Move global variable delay_length to inner scope 2019-11-03 09:20:41 +01:00
derselbst
a7162f1ef1 Fix -Wsign-compare in fluid_chorus.c 2019-11-03 08:43:46 +01:00
derselbst
accae4ef82 Add missing header guards 2019-11-03 08:41:20 +01:00
jjceresa
fdbd13e77c Make reverb output independent of sample rate (#584)
Fixes #581
2019-11-01 16:26:46 +01:00
derselbst
56dd87ebf1 Deprecate fluid_synth_set_sample_rate()
Addresses #585
2019-10-31 09:29:55 +01:00
derselbst
f7eb9e0c17 Make fluid_is_soundfont() DLS aware 2019-10-31 08:47:14 +01:00
jjceresa
d4b3a08f53 fix comment in fluid_rvoice_calc_amp() (#583) 2019-10-27 18:05:18 +01:00
derselbst
e739246ef7 Fix broken #ifdef 2019-10-27 17:10:33 +01:00
derselbst
644668a776 Merge branch '2.0.x' into master 2019-10-27 16:52:45 +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
Tom M
59be52ea3b
fluidsynth exec: let option -j connect MIDI devices as well (#578) 2019-10-26 12:28:16 +02:00
derselbst
64d4fe0402 Fix chorus buffer line being partly uninitialized 2019-10-25 15:26:27 +02:00
jjceresa
ee5294c060 move fluid_profile_ref_var() (#577) 2019-10-23 19:56:22 +02:00
jjceresa
0288466f40 Chorus enhancement. (#548)
This adds new LFO modulators:
 - these modulators are computed on the fly, instead of using lfo lookup table. Advantages:
      - Avoiding a lost of 608272 memory bytes when lfo speed is low (0.3Hz).
      - Allows to diminish the lfo speed lower limit to 0.1Hz instead of 0.3Hz.
        A speed of 0.1 is interesting for chorus. Using a lookup table for 0.1Hz
        would require too much memory (1824816 bytes).
      - Make use of first-order all-pass interpolator instead of bandlimited interpolation.
      - Although lfo modulator is computed on the fly, cpu load is lower than using
        lfo lookup table with bandlimited interpolator.

Also adds a stereo unit controlled by WIDTH macro. WIDTH [0..10] value define a stereo separation between left and right.
 - When 0, the output is monophonic.
 - When > 0 , the output is stereophonic.

 WIDTH is currently fixed to maximum value to provide maximum stereo effect.
2019-10-23 16:41:13 +02:00
derselbst
171f3396a4 Format fluid_synth_write_*() 2019-10-23 14:33:34 +02:00
derselbst
988ec6d799 Add proper fluid_ret_val_if_fail checks for rendering functions 2019-10-23 14:33:34 +02:00
Carlo Bramini
8aef0930c6 Speedup rendering functions (#573) 2019-10-23 13:33:22 +02:00
derselbst
eef361eb35 Update API doc of fluid_synth_noteon() 2019-10-22 18:12:50 +02:00
Tom M
64cee5537d
Handle deprecation of GTimeVal (#575)
`GTimeVal` has been deprecated in glib 2.62 . While switching to `g_get_monotonic_time()`, I realized that we could simply reuse `fluid_utime()` for that purpose.
2019-10-22 17:39:08 +02:00
derselbst
dfcf5c019f Add a unit test for fluid_synth_write_float 2019-10-22 16:08:41 +02:00
derselbst
5a42e8147f Extend comment in fluid_ct2hz_real() 2019-10-22 14:37:08 +02:00
Tom M
fa7354a336
More efficient implementation of fluid_ct2hz() (#569)
This provides a less branchy and therefore more instruction-cache-friendly version of fluid_ct2hz(), which also significantly reduces the number of floating-point comparisons.
2019-10-22 13:09:42 +02:00
derselbst
41e77afe84 Merge branch '2.0.x' into master 2019-10-22 11:39:42 +02: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
ca5108d81c Fix "declaration-after-statement" in opensles driver 2019-10-21 14:35:17 +02:00
derselbst
6e45cfc308 Move declaration of fluid_alloc() to fluidsynth_priv.h
Fixes build of opensles, oboe and coreaudio.
2019-10-21 14:27:05 +02:00
Jon Latané
d312def0ce Android CircleCI Build (#574) 2019-10-20 23:09:23 +02:00
Carlo Bramini
6895731df2 Remove GLIB macros for int <=> pointer conversion (#572)
The synthesizer is using stdint types for a long time, perhaps for consistency, it would be worth to get rid of the GLIB macros for integer to pointer conversion and viceversa, and use just a type cast for that purpose.
2019-10-19 18:25:31 +02:00
Tom M
cab46b40c1
Fix incorrect usage of fluid_ct2hz() (#568) 2019-10-18 21:41:43 +02:00
derselbst
bf06638178 Add missing declaration of fluid_alloc to fluid_instpatch 2019-10-05 16:55:26 +02:00
derselbst
d80c704a7b Merge branch '2.0.x' into master 2019-10-05 16:55:10 +02:00
derselbst
a94bc82a3c Initialize allocated memory to garbage
for debug builds.
2019-10-05 16:43:53 +02:00
derselbst
24e7c5090b Minor update to the synth API 2019-10-05 14:43:17 +02:00
derselbst
9ab3e3ab51 Merge branch '2.0.x' into master 2019-09-28 07:38:54 +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
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
jjceresa
22142245ca fix comment in fluid_synth_remove_default_mod() 2019-09-22 16:12:32 +02:00
jjceresa
02134d6959 optimize fluid_delete_synth() 2019-09-22 03:21:09 +02:00
jjceresa
b9421409aa optimize fluid_synth_remove_default_mod() 2019-09-22 02:56:14 +02:00
jjceresa
c4c05533bb check mode param beforehand in fluid_synth_add_default_mod() 2019-09-22 02:53:10 +02:00
derselbst
1e7a5f594d Merge branch '2.0.x' into master 2019-08-19 16:39:36 +02:00
derselbst
f78486a50b Update developer docs 2019-08-17 18:01:01 +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
Marcus Weseloh
bfe954a0fe Supress log messages < PANIC on Windows
As Windows logs to stdout by default.
2019-08-17 11:32:55 +02:00
Marcus Weseloh
1b2e61519a Add quiet mode option to fluidsynth binary
Enabling the option supresses the default welcome message and
some other text output that normally gets printed to stdout.

It also slightly changes the way the welcome message and argument
errors are handled: in case of an argument error, the welcome message
is never printed.
2019-08-17 09:51:28 +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
derselbst
03511aef3a Merge branch '2.0.x' into master 2019-08-08 19:51:44 +02:00
Tom M
5c795791c1
Suppress abort() dialog on windows (#549) 2019-08-06 17:29:49 +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
6a6015f047 Fix build if -Denable-fpe-check=1 on windows 2019-08-02 13:53:14 +02:00
Carlo Bramini
d6c51cd2cc Aid constant folding in fluid_rev.c (#547) 2019-07-16 17:47:25 +02:00
derselbst
bbbb499efd Remove unused member fluid_defpreset_t::defsfont 2019-07-11 20:58:13 +02:00
Carlo Bramini
a02f1379d8 Add support for C99 math functions, if available (#545) 2019-07-07 11:02:31 +02:00
derselbst
2be598b8e9 Amend documentation of fluid_synth_set_gen() 2019-07-02 18:38:19 +02:00
derselbst
db1740b7e9 Avoid conflicts with libinstpatch's default SF2 modulators
By default, libinstpatch silently adds all SF2 default modulators to the
converted DLS voices. Since fluidsynth respects the modulators provided
by libinstpatch, those modulators would conflict with the default
modulator list managed by fluidsynth. This is only noticeable, if the
user used fluidsynth's API to manipulate default modulators.
2019-07-02 14:15:00 +02:00
derselbst
c093b20c31 Fix premature exit of the fluid_shell on WinXP
When compiled with compatibility for WinXP (toolset v141_xp), read() may return 0 (EOF) rather than '\n' which led to an early exit of the shell after a single user input.
2019-06-29 09:10:07 +02:00
Carlo Bramini
0b17a84ced Cleanup floating-point arithmetics (#543)
* avoid unnecessary floating-point promotion to double when compiled `WITH_FLOAT==1`
* remove redundant calculations and reorder floating-point constants to allow better constant folding
2019-06-27 17:20:13 +02:00
Tom M
030a497aa5
fix build with glib < 2.28 (#540)
g_clear_object() was not yet available
2019-06-22 10:22:23 +02:00
Carlo Bramini
580a4d16e0 Make const string really const (#536) 2019-06-09 13:30:43 +03:00
Tom M
e49b5ed201
Support Loading DLS Files (#493)
Fixes #320
2019-05-11 05:31:56 +02:00
derselbst
8c272360fb remove unused variable 2019-05-01 12:56:53 +02:00
derselbst
c9a670d26c Merge branch '2.0.x' into master 2019-04-18 20:21:01 +02:00
derselbst
7f11a9bf5c use a common function for opening regular files
Fixes #514
2019-04-18 19:43:39 +02:00
derselbst
e31bbe3504 Merge branch '2.0.x' into master 2019-04-17 19:14:46 +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
Carlo Bramini
b041fffc44 Remove redundant fclose (#529) 2019-04-17 19:08:45 +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
a5436021a5 fix conditional jump depending on uninitialized variable 2019-04-13 10:45:05 +02:00
Tom M
c04acc653e
Use pkgconfig to find SDL2 (#524) 2019-04-06 09:10:50 +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
Atsushi Eno
daa037b0d3 Add Android audio drivers based on OpenSLES and Oboe (#464)
This set of changes implements audio drivers for Android, OpenSLES and Oboe. The changes in the original sources are kept minimal so that it should be easily maintained.
2019-03-27 18:02:23 +01:00
derselbst
598ec01ce1 revise error logging in sdl2 audio driver 2019-03-17 17:56:06 +01:00
derselbst
5b2b5e6659 initialize sdl2 by the fluidsynth executable 2019-03-17 17:55:53 +01:00
derselbst
c8b455ca7a Merge branch '2.0.x' into master 2019-03-17 16:59:33 +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
derselbst
0cd44d00e1 Merge branch '2.0.x' into master 2019-03-02 10:23: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
5f8fa6f5a0 Merge branch '2.0.x' into master 2019-02-22 10:18:05 +01:00
derselbst
9671e412fe fix build with MinGW 2019-02-22 10:15:18 +01:00
derselbst
bfc03136bb remove duplicate delcarations of fluid_get_std[in|out] 2019-02-17 12:44:06 +01:00
Tom M
46c2857fb0
Merge branch 'master' into cleanup21 2019-02-17 09:02:32 +01:00
derselbst
96e43ec72c Merge branch '2.0.x' into master 2019-02-17 09:00:32 +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
derselbst
5c4ff485c2 log when using the server in a build wihtout network support 2019-02-10 08:53:25 +01:00
derselbst
c096c54cb6 Merge branch '2.0.x' into master 2019-02-09 09:52:53 +01:00
derselbst
e4d30ac61e suppress a few narrowing conversion warnings on windows 2019-02-08 17:28:57 +01:00
derselbst
aa65624f8c Merge branch '2.0.x' into master 2019-02-07 08:55:24 +01:00
derselbst
b6a5c5f570 avoid using g_stat on windows if glib < 2.26
Closes #452.
2019-02-03 19:45:51 +01:00
derselbst
12dd1c7653 reorder calls to fluid_file_test 2019-02-03 14:28:31 +01:00
Yuri
22dd94fc5c FreeBSD compatibility patch upstream from the port 2019-02-03 11:06:17 +01:00
derselbst
06ef8a4e09 fluid_is_midifile(): only accept regular files 2019-02-01 13:10:52 +01:00
derselbst
64c90a6c49 restrict soundfont loading to regular files only
i.e. forbid to load directories, block devices, dangling symlinks, etc.
2019-02-01 11:22:14 +01:00
derselbst
630523ba73 remove fluid_synth_set_gen2()
...and all other absolute NRPN generator leftovers, closes #415
2019-01-27 11:15:14 +01:00
derselbst
70727b2f7a Merge branch 'master' into cleanup21 2019-01-27 10:48:07 +01:00
derselbst
72cb4504bc another cross compilation fix
fixes #501
2019-01-17 17:19:51 +01:00
derselbst
b98ba5bc63 Merge branch '2.0.x'
Closes #500
2019-01-12 16:54:35 +01:00
Marcus Weseloh
caf61baa04 Increase verbosity for fluid_settings_* functions 2019-01-12 14:37:27 +01:00
jjceresa
b462e25ba3 Removing useless preset_zone parameter. 2019-01-03 19:57:27 +01:00
jjceresa
cc3d93b56e Change on prefixe zone name
-Name of an instrument zone shouldn't prefixed by the preset zone
 name.
 This is due to the fact that instrument zone are common to all
 preset zone. Consequently, an instrument zone cannot identfied
 via a preset zone.
-This new change, simply prefixe a zone as this:
 instrument zone name prefixed by iz:
 preset zone name prefixed by pz:
2019-01-03 19:40:55 +01:00
derselbst
8b1820580b Merge branch '2.0.x' 2018-12-30 12:42:30 +01:00
derselbst
1bae9b2fe1 bump to version 2.0.3 2018-12-30 12:42:00 +01:00
derselbst
0f6c40c15e stop adding empty strings to readline's history 2018-12-29 19:58:10 +01:00
derselbst
8634613509 fix incorrect documentation of fluid_sample_sizeof() 2018-12-29 18:27:24 +01:00
derselbst
b7b420617b fix double free in fluid_sample_set_sound_data() 2018-12-29 18:21:43 +01:00
derselbst
15d27b7145 fix inverse logic in fluid_sample_set_sound_data() 2018-12-29 17:34:36 +01:00
derselbst
4d612c22f4 fix segfaults in fluid_is_soundfont() and fluid_is_midifile() 2018-12-29 11:18:36 +01:00
derselbst
488da516cd clarify documentation of fluid_sample_sizeof() 2018-12-28 14:54:13 +01:00
derselbst
c8b18056c6 remove unused fluid_sample_t::userdata 2018-12-28 14:47:55 +01:00
derselbst
6d981aedfe Merge branch '2.0.x' into master 2018-12-22 16:08:54 +01:00
carlo-bramini
828307ff09 Fix error with MSVC (#492)
FLUID_INLINE must be used instead of inline, otherwise MSVC fails to build fluidsynth.
2018-12-22 16:08:09 +01:00
derselbst
d2078e63b4 clarify need for io.h 2018-12-22 16:05:22 +01:00
derselbst
06ec2d4e67 Revert "remove unused io.h include"
This reverts commit cb485806c3. Fixes #491.
2018-12-22 16:04:49 +01:00
derselbst
10ddcc0cd3 Merge branch '2.1-testing' into master 2018-12-21 20:05:32 +01:00
jjceresa
458cea0aff Fix incorrect comment (#488)
Normalized value of MIDI sources (before unipolar or bipolar mapping) is always in the range [0..+1], regardless of MIDI event (even for FLUID_MOD_PITCHWHEEL).
2018-12-21 19:54:15 +01:00
Tom M
d666515c31
Merge pull request #487 from FluidSynth/min-attenuation
Fix minor bug in lower_boundary_for_attenuation()
2018-12-21 19:53:26 +01:00
jjceresa
e9b0f0d24b Add modulators checking at soundfont loading time (#467)
Actually some basic modulators check are done at noteon time (in fluid_voice_add_mod()). That means that we know if a modulator (modx) is invalid only when a MIDI noteon is received and only for a preset modx belongs to. This is not appropriate.

This moves the modulator checking at soundfont loading time. Enhancements are:
1) A better verbose modulator integrity check, for any soundfont loaded at appropriate time.
1.1) All modulators are checked (preset zone (local/global), instrument zone (local/global).
1.2.1) Modulators check are enforced to source src1 and src2  (for non-CC and CC sources) (following SF specs (except for CC LSB) ( see comment in fluid_synth_cc_LOCAL()).
Modulators CC sources checking is coherent with the actual behaviour in fluid_synth_cc_LOCAL() in regard of modulation triggering.
1.2.2) Also, identical modulator in the same zone are detected. 
1.2.3) Any invalid modulator(sources invalid, or modulator identical) is removed at loading time with a warning message displaying the cause and name of the modulators.

2) This fix a bug in noteon, in the case of identical modulators in global preset zone.
Assuming 2 identical modulator (m1 and m2) in a preset global zone, the actual noteon doesn't check this case (the actual code detect identical modulator in all others zones (instrument (local or global), preset(local)) but not preset global).

3) NoteOn is faster.
3.1)There is no more modulators checks at noteon making this more efficient.
3.2) As there are no identical modulator in the same zone, there is no more identity modulator check (i.e local zone against local zone), (i.e global zone against global zone). This result in a faster code and the bug described in (2) is gone.

4) Modulators sources checking as been added in API functions fluid_synth_add_default_mod() and fluid_voice_add_mod(). Please
2018-12-21 19:42:00 +01:00
jjceresa
e8dd6ae389 Import modulator source src1 correctly.
- When primary source input (src1) is set to General Controller
  'No Controller', output will be forced to 0.0 at synthesis time
  (see fluid_mod_get_value()).
  That means that the minimum value of the modulator will be always 0.0.
  We need to force amount value to 0 to ensure a correct evaluation of the
  minimum value later (see fluid_voice_get_lower_boundary_for_attenuation()).
2018-12-21 12:19:37 +01:00
derselbst
54a9f29305 remove public comments about internal details 2018-12-20 17:46:10 +01:00
derselbst
d0813be1c5 add missing getters for lyric and text midi events
fixes #468
2018-12-20 17:45:10 +01:00
jjceresa
b659fd82a5 Import modulator source src2 correctly.
- When secondary source input (src2) is set to General
  Controller 'No Controller', output will be forced to +1.0 at synthesis time
  (see fluid_mod_get_value()).
  That means that this source will behave unipolar only. We need to force the
  unipolar flags to ensure the modulator will behave correctly later in
  fluid_voice_get_lower_boundary_for_attenuation().
2018-12-19 18:12:09 +01:00
derselbst
2cef5b0587 Merge branch 'master' into 2.1-testing 2018-12-19 14:22:40 +01:00
Marcus Weseloh
8da7f11a11 Only retrieve modification time once and remove warning if failed
This change removes the warning message if retrieving the soundfont file
modification time fails in the sample cache loader. The warning made sense
while we didn't have mtime support on all platforms, but after switching
to GLibs g_stat, it's no longer needed.

To reduce the number of calls to fluid_get_file_modification_time and also
get rid of a possible race condition, getting the mtime has been moved to
fluid_samplecache_load.

This change also fixes #483 because it removes the bogus warning messages
if a soundfont was loaded from memory by abusing the filename to store a
pointer.
2018-12-19 14:14:34 +01:00
carlo-bramini
c9b8d40fc2 Fourcc support (#482)
Have a direct comparison to the fourcc code rather than searching through chunk ids all the time with chunkid()
2018-12-19 14:09:29 +01:00
jjceresa
b7af84fbd5 optimizing fluid_voice_modulate() (#486)
This avoids recalculation of the same generator when several modulators have that generator as destination.
2018-12-19 14:07:34 +01:00
jjceresa
06bca9b894 Fix minor bug in lower_boundary_for_attenuation()
- v variable is renamed min_val for clarity.
- This fix a bug when calculating the possible minimun
  value (min_val) of a modulator. min_val should only
  be dependant of:
  - signs of mapped sources (ie bipolar [-1..+1] or unipolar [0..+1])
  - sign of amount.
  - absolute value of amount.
2018-12-16 07:57:51 +01:00
Tom M
ef5739f3ce
Merge pull request #484 from FluidSynth/fix-cross-build
Cross Compilation Fixes
2018-12-15 07:46:53 +01:00
derselbst
a9662bf331 fix gcc8 complaining about stringop-truncation 2018-12-14 19:42:08 +01:00
derselbst
4f1f7349db fix cmake not finding make_tables when cross-compiling
Fixes #477.
2018-12-14 17:50:03 +01:00
derselbst
cb485806c3 remove unused io.h include 2018-12-14 17:50:03 +01:00
carlo-bramini
978283bbf0 Add Sdl2 driver (#478) 2018-12-14 16:43:35 +01:00
jjceresa
ba9092ef98 Reducing defsfont loader code (#480) 2018-12-02 17:42:51 +01:00
carlo-bramini
cfe2d158f4 Add WaveOut driver (#466) 2018-12-01 15:04:26 +01:00
jjceresa
749ce44753 Implement FDN Reverb (#380)
Supersedes the previous Schroeder-Moorer based "Freeverb".
2018-12-01 14:55:18 +01:00
Tom M
b67ecb8b56
Merge pull request #406 from FluidSynth/modenv-convex
Convex shape for modEnv
2018-12-01 14:41:42 +01:00
carlo-bramini
ebb383b47f
Force default device if none is selected 2018-11-25 21:20:18 +01:00
carlo-bramini
26325edb22
Optimize device search
Search of the MIDI device can be done before allocating the struct for the driver.
2018-11-25 21:13:25 +01:00
carlo-bramini
fa924516f0
Max length of device name is MAXPNAMELEN 2018-11-25 21:10:16 +01:00
carlo-bramini
9aeac6ca6e
Unprepare MIDI buffers
This was missing.
2018-11-25 20:14:18 +01:00
carlo-bramini
c57d7fffe8
move fluid_winmidi_callback()
Function fluid_winmidi_callback() has been moved on top of the source and made static.
2018-11-25 20:06:56 +01:00
carlo-bramini
cfa8019a53
Remove old fluid_winmidi_input_error() 2018-11-25 20:05:40 +01:00
carlo-bramini
cea2645530
Makes fluid_winmidi_input_error() thread-safe
The changes are:
1) made the function static
2) implemented UNICODE support
3) made thread-safe
4) delete unused static buffer
2018-11-25 20:03:12 +01:00
carlo-bramini
b8b41f781f Improve chunk id search (#471)
If we move UNKN_ID to the bottom of the enum, in the for() cycle inside chunkid() if the value is not found then the "i" variable will be already UNKN_ID.
2018-11-25 10:02:33 +01:00
jjceresa
36da011191 Avoid redundant dsp parameter updates upon modulation. (#461) 2018-11-25 08:21:51 +01:00
carlo-bramini
98e4046096 Fix handle leak in winmidi driver (#469) 2018-11-23 19:49:20 +01:00
jjceresa
6e9d84f02a Forbid DATA_ENTRY_LSB to modulate (#465)
and document illegal CC modulation
2018-11-18 15:43:03 +01:00
derselbst
c8d1ec3841 Merge branch 'recent-docs' into master 2018-11-18 09:12:22 +01:00
carlo-bramini
fe92a0a655 Introduce enable-threads option to cmake (#463) 2018-11-18 08:55:52 +01:00
carlo-bramini
29c668683f Improve float calculations (#462)
I tried to check the generated ASM code when WITH_FLOAT macro is defined and when it is undefined. In both cases I noticed that there are some points where the math number are converted from float to double and viceversa. Actually this happens whether the FPU is present or not, perhaps for granting the right precision in digits. I also noticed few points that could be simplified a bit by using integer math, so I also included them.

 * Since fluid_voice_get_actual_key() returns an integer value, the value 60 could be subtracted directly as integer, the code generated looks a bit better.
 * FLUID_NOISE_FLOOR needs to be cast to fluid_real_t to generate a bit more efficient code.
 * DC_OFFSET needs a cast to fluid_real_t to generate a bit more efficient code.
 * "last_fres" and "output_rate" are already fluid_real_t, so they do not need type cast.
 * "chan_add", "par1_add" and "par2_add" are integer types, so they can be added without FPU. "chan_mul", "par1_mul" and "par2_mul" are already fluid_real_t, so they do not need type cast. Instead, the constant 0.5 needs cast to fluid_real_t to be more efficient.
2018-11-16 16:52:34 +01:00
carlo-bramini
bd41795263 Remove redundant dependency to readline in fluid_cmd.c
Libreadline is already used into fluid_istream_readline().
In my opinion, there is no need to have this duplicated code, so I would suggest to move the call to add_history() into fluid_sys.h

Closes #460.
2018-11-10 08:25:55 +01:00
carlo-bramini
0bf5c28275 "ready" is unused if ENABLE_MIXER_THREADS=0 2018-11-10 08:09:08 +01:00
Tom M
06bcf8db9f
Fix an incorrectly aligned result when converting between pointer types (#457)
fix alignment issue of idlist
2018-11-10 08:07:30 +01:00
Tom M
edc59ee3b5
Merge pull request #458 from FluidSynth/clang-tidying
Fix clang-tidy warnings
2018-11-10 08:01:10 +01:00
carlo-bramini
d20f6cff66
Use integer math. 2018-11-03 21:07:37 +01:00
carlo-bramini
afbd818f8a
Use M_LN10 macro instead of log(10.) 2018-11-03 17:07:20 +01:00
Tom M
0160543cdd
Compile time constant lookup tables with cmake (#438)
Autogenerate lookup tables with a C helper tool, allowing them to be compile time constant and reduce memory requirements esp. on embedded systems.
2018-11-03 14:38:54 +01:00
derselbst
28edbbfe83 fluid_settings_option_concat: dont count NULL options
should never happen though
2018-11-03 14:17:40 +01:00
derselbst
4d8954ee30 fix mistaken usage of fluid_synth_process in coreaudio driver 2018-11-03 14:11:05 +01:00
derselbst
31ccc6b6a0 fix a NULL deref in coreaudio driver 2018-11-03 14:11:05 +01:00
derselbst
ffdf5b89d7 constify function parameters if possible 2018-11-03 14:11:05 +01:00
derselbst
16d81d50ea remove unused fluid_hz2ct()
Closes #455.
2018-11-03 09:13:56 +01:00
carlo-bramini
2205e4a8fc Use integer math
Since 'data' is an integer value clipped between +/-8192 and 'nrpn_scale' is a char value, this calculation could be done with integers and then return the fluid_real_t value.

Addresses #455.
2018-11-03 08:06:56 +01:00
carlo-bramini
a948f7c5b2 Use integer math
Actually, using an integer division produces the same result.

Addresses #455.
2018-11-03 08:04:16 +01:00
Tom M
3f4c08e34b
Merge pull request #442 from carlo-bramini/float-to-s16-1
Rounded samples do not need to be float.
2018-10-31 13:18:33 +01:00
Colin Kinloch
cf09b654ab jack midi autoconnect (#450) 2018-10-31 13:10:29 +01:00
derselbst
b628115092 optimize rounding and clipping to int16 samples 2018-10-31 10:40:32 +01:00
derselbst
ee5b0ea1c7 remove redundant declarations 2018-10-28 16:42:20 +01:00
derselbst
a4ddc9396c avoid leaking memory in pulse driver 2018-10-28 16:37:44 +01:00
Tom M
804cbf91c9
Merge pull request #449 from carlo-bramini/win-driver-selection
let cmake find WinMidi and DSound
2018-10-27 20:26:18 +02:00
derselbst
e4ab5067f1 fix linker error on win32 without network support
by adding missing #ifdefs
2018-10-27 16:32:54 +02:00
carlo-bramini
e298fefd7f cleanup audio and midi driver instantiation (#448)
Instead of saving the name of the driver, it would be worth to save to pointer to the selected definition instead.
In this way, the function for deleting the driver does not need to search its name by parsing all the list, but it just needs to call the pointer into the saved definition (less code). This fix can be applied to MIDI drivers too. 
I also moved the FLUID_FREE(allnames) inside the "if(allnames != NULL)" block, nothing bad should happen even by keeping that instruction outside, but actually there is no need to call the free if allnames is NULL.
2018-10-27 16:22:44 +02:00
carlo-bramini
30886a3d78
Remove handwritten macros 2018-10-26 19:44:27 +02:00
carlo-bramini
413bcbeb84
Add Windows driver support macro. 2018-10-26 19:43:27 +02:00
carlo-bramini
8ef6ac7dcc
Enable VersionInfo also for MINGW 2018-10-26 19:42:15 +02:00
carlo-bramini
7b6ebbea5b
Add Windows driver selection 2018-10-26 19:41:34 +02:00
Tom M
121ed7124e
Merge pull request #447 from FluidSynth/zero-size-arr
Fix build when no audio drivers are supported
2018-10-23 17:41:35 +02:00
derselbst
e03e2edf8d register settings before adding options 2018-10-23 17:07:34 +02:00
derselbst
f6e70b38c7 clarify log message when no MIDI drivers are available 2018-10-21 20:26:46 +02:00
derselbst
327b3fb45b clarify log message when no audio drivers are available 2018-10-21 20:21:21 +02:00
carlo-bramini
a7c5b66872 Simplify MIDI driver installation 2018-10-21 13:35:41 +02:00
carlo-bramini
70f4551e90 Simplify audio driver installation
In my opionion, it should be possible to simplify the code by installing the drivers with a for() cycle instead of doing tons of #ifdef...#endif.
The size of the binary code is basically the same as before, but the source lines are much less. I think that it could be done also for MIDI input drivers.
2018-10-21 13:35:32 +02:00
carlo-bramini
326c20c0e3 Remove duplicated init_dither() declaration (#446) 2018-10-20 20:06:38 +02:00
derselbst
670cdf1e8f conditionally compile fluid_aufile.c 2018-10-20 15:15:43 +02:00
derselbst
08b5333398 remove macro workaround when no midi drivers are supported 2018-10-20 15:05:18 +02:00
derselbst
5bd07c120c fix build when no audio drivers are supported 2018-10-20 15:04:55 +02:00
carlo-bramini
ebc177f48f Consistently use FLUID_LOG macro (#443) 2018-10-16 18:02:27 +02:00
carlo-bramini
d8890038b6
Rounded samples do not need to be float.
Actually, the function roundi() already returns an "int" type value, so in my opinion there is no need to use a floating point value for saturating the values in the range -32768/+32767. The generated assembly code looks more efficient after that.
2018-10-13 14:37:41 +02:00
derselbst
45e0f94b29 fuse fluid_gen_set_default_values() and fluid_gen_init()
avoids iterating over generators twice
2018-10-12 09:34:42 +02:00
derselbst
f8a55cd10d remove fluid_error() 2018-10-12 09:34:25 +02:00
derselbst
c483ae0f95 make fluid_log() thread safe
by using a local buffer rather than global one, intentionally breaks
the deprecated fluid_synth_error()
2018-10-12 09:34:01 +02:00
derselbst
7517c17524 Revert "make fluid_log() thread safe"
This reverts commit d25cdae17c.
Mistakenly committed too early on the wrong branch.
2018-10-12 09:24:07 +02:00
derselbst
2b563071f6 initialize logging at compile time 2018-10-09 18:11:37 +02:00
derselbst
d25cdae17c make fluid_log() thread safe
by using a local buffer rather than global one, intentionally breaks
fluid_synth_error()
2018-10-09 18:00:19 +02:00
derselbst
f0312c13d3 deprecate fluid_synth_error() 2018-10-09 17:52:33 +02:00
derselbst
c93fdd4b10 avoid chorus depth from spamming the console
on any chorus setting, if the previous depth was out of range
2018-10-07 13:15:05 +02:00
derselbst
0920db6d1f abort 'set' shell command if param not found 2018-10-07 12:56:18 +02:00
derselbst
ce57220d65 dont cast const qualifier away 2018-10-06 14:27:10 +02:00
carlo-bramini
f74f415a69 Avoid duplication of fluid_chorus_sine() call.
Closes #439.
2018-10-06 12:05:10 +02:00
Tom M
b768ad6d14
Merge pull request #437 from FluidSynth/null-fixes
NULL derefs and mem leaks in soundfont loader
2018-10-06 11:55:11 +02:00
derselbst
3ef6af5ade Merge branch 'recent-docs' 2018-10-06 11:45:18 +02:00
derselbst
fd7db023dd set upper chorus depth to 256 ms
upper depth limit (ms) = (MAX_SAMPLES * 1000) / lower sample rate limit

with MAX_SAMPLES==2048 && lowersrate==8000
2018-10-05 18:39:54 +02:00
derselbst
f972fbf1ec remove experimental hint from fluid_synth_set_sample_rate() 2018-10-05 18:12:31 +02:00
derselbst
57ef2dfed8 fix memory leaks in load_phdr() and load_ihdr() 2018-10-02 20:20:22 +02:00
derselbst
7f2d655b9c fix various NULL derefs in fluid_sffile 2018-10-02 20:14:56 +02:00
derselbst
b31afd65a5 fix NULL deref in new_fluid_hashtable_full() 2018-10-02 19:33:50 +02:00
carlo-bramini
6f8a574e36 Various fixes to dsound driver (#435)
- fluid_dsound_audio_run() and fluid_win32_error() are now static functions.

- WAVEFORMATEX is not required by DirectSound during the playback. We do not need it anymore after calling ::SetFormat(), so allocating this structure dynamically inside driver structure is useless.

- Implemented support for float sample type.

- Uses an event object for handling the end of thread, it allows to combine the quit event with the later wait in milliseconds in a single block.

- Calculates the amount of milliseconds to sleep rather than sleeping always for one millisecond.

- Fix an error into a FLUID_LOG() call.

- Fix handle leak of the thread, now it is correctly closed with CloseHandle().

- ExitThread() is a nonsense in that position, since the thread is already exiting.

- Fix error when compiling with WSDK 8.1, by defining NOBITMAP, in case NOGDI macro added somewhere
2018-09-29 10:08:34 +02:00
derselbst
923f5f3544 update API doc of delete_fluid_sequencer() 2018-09-21 19:00:28 +02:00
Tom M
fb684aa5d8
Merge pull request #434 from rncbc/jack_driver-last_client-reuse-fix
jack_driver: last_client reuse fix.
2018-09-20 20:20:55 +02:00
jjceresa
75b77f0186 Remove redundant invalid preset generators checking in fluid_defpreset_noteon() (#430) 2018-09-20 20:11:11 +02:00
rncbc
99e235e279 jack_driver: last_client reuse fix. 2018-09-20 09:04:21 +01:00
Colin Kinloch
f4b88fc747 coremidi input port and autoconnect (#427) 2018-09-15 14:08:55 +02:00
jjceresa
f566f0ef33 Simplify fluid_mod_get_xxx_value() signature. (#429) 2018-09-15 14:01:15 +02:00
Tom M
e4b8e2b44c
Implement fluid_get_userconf() on windows (#425) 2018-09-09 22:34:35 +02:00
derselbst
eb132d8196 correctly typedef fluid_stat_buf_t for glib < 2.26 2018-08-30 22:14:27 +02:00
derselbst
b9dd426046 correctly typedef fluid_stat_buf_t
fixing copy'n paste mistake... excuse me
2018-08-30 19:53:40 +02:00
derselbst
9052bad56c silence MSVC type narrowing warnings in fluid_cmd.c 2018-08-30 18:45:29 +02:00
derselbst
7d9a02d836 replace strlen with FLUID_STRLEN 2018-08-30 18:40:49 +02:00
derselbst
cdc8d38f4e silence MSVC type narrowing warnings in fluid_settings.c 2018-08-30 18:33:05 +02:00
derselbst
70fbabf97c fix incompatible types warning: 'fluid_stat_buf_t *' to '_stat64i32 *'
only occurs on Win64 with glib < 2.26
2018-08-30 17:38:19 +02:00
derselbst
4d8574d38a change fluid_log_* prototypes to const char* 2018-08-23 16:56:22 +02:00
Tom M
55a4bb5597
Merge pull request #421 from FluidSynth/test-flag
Always build unit tests, remove `enable-tests` cmake flag
2018-08-10 16:39:17 +02:00
derselbst
500959701e move fluid_file_renderer_settings() declaration to fluid_adriver.h 2018-08-08 20:55:32 +02:00
derselbst
908aaeb5cc cmake: setup linker directories before creating target 2018-08-07 15:19:05 +02:00
derselbst
39f574942e cmake: remove redundant include and link dir variables
cf. docs of pkg_check_modules()
2018-08-07 15:07:20 +02:00
derselbst
ff1482ec06 fix dll visibility on win32 for unittests 2018-08-06 20:29:50 +02:00
derselbst
521e5451fc remove cmake option enable-tests
Always build unit tests instead and use cmakes OBJECT library to bypass visibility control and the value of BUILD_SHARED_LIBS.
2018-08-05 20:50:41 +02:00
derselbst
063ab5d7d2 remove unused midi driver status functions 2018-07-21 10:43:38 +02:00
derselbst
47c4a5b1c7 remove various redundant audio / midi driver declarations
by moving already existing function declarations to fluid_adriver.h and
fluid_mdriver.h resp.
2018-07-21 10:37:43 +02:00
derselbst
f6f66d53fd make fluid_synth_write_float() safe when called with NULL buffers 2018-07-20 19:30:18 +02:00
derselbst
8afb46515f fix comment for sinc interpolation table
a Hanning window is applied, rather than a Hamming  window
2018-07-19 17:22:44 +02:00
derselbst
bb413011f7 update deprecated note of fluid_synth_nwrite_float() 2018-07-16 12:21:55 +02:00
derselbst
2185194d43 cleanup fluid_synth_process()
remove code duplications
2018-07-15 19:52:48 +02:00
jjceresa
3db36117a1 Adding seamless attack transition for legato notes.
Since v 2.1 ,as recommended by soundfont 2.01/2.4 spec
ATTACK section is convex. So, when skiping from a
section above ATTACK to ATTACK, it is necessary to
correct current modulation envelope value to get
seamless transition.
2018-07-14 23:33:16 +02:00
derselbst
af1fc75717 add fluid_synth_count_effects_groups() 2018-07-12 10:34:02 +02:00
derselbst
7e627c575c fix NULL deref in jack driver 2018-07-11 21:07:37 +02:00
derselbst
b46998ba04 fix alsa driver with custom callback 2018-07-11 21:05:12 +02:00
Tom M
c4f0b19c64
Merge pull request #405 from FluidSynth/fluid-synth-process
Complete implementation of fluid_synth_process() and add support for multi-channel effects rendering.
2018-07-11 17:26:51 +02:00
derselbst
4b5dc36d53 extend the documentation of fluid_synth_process() 2018-07-11 14:44:40 +02:00
derselbst
7f1cdd2acf make fluid_synth_add_default_mod() const correct 2018-07-11 11:52:45 +02:00
derselbst
e6e6c570f6 fix NULL deref in new_fluid_rvoice_mixer() 2018-07-11 10:49:57 +02:00
derselbst
88fda6f99b support multiple effects units
adds a new setting "synth.effects-groups" that allows multiple effects
units, in order to render effects of each midi channel to a separate
audio channel
2018-07-07 12:53:25 +02:00
Tom M
334c752b2a
Merge pull request #409 from FluidSynth/player-reset
Promote player.reset-synth to real-time setting
2018-07-04 12:48:17 +02:00
jjceresa
8d8e7ecd20 noteoff during the attack section of the modulation envelope.
- this insures seamless pitch and filter frequency cutoff transition.
2018-07-01 23:05:24 +02:00
Tom M
5cd99057bf
Merge pull request #407 from FluidSynth/delete-ramsfont
Remove ramsfont
2018-07-01 12:54:51 +02:00
carlo-bramini
4ea94a324f Fix single thread build (#410)
Compilation fails if ENABLE_MIXER_THREADS is set to zero, due to a mismatch of parenthesis.
2018-07-01 12:54:07 +02:00
derselbst
5c99b86234 warn if user provided shell config wasnt found 2018-07-01 07:20:15 +02:00
derselbst
fefb91def9 promote player.reset-synth to real-time setting 2018-07-01 07:12:35 +02:00
derselbst
3ffa6a318e warn if non-realtime settings are set 2018-07-01 06:56:22 +02:00
derselbst
d7609d43f6 remove ramsfont 2018-06-26 08:34:41 +02:00
derselbst
a8be173ba3 fix memory leak in fluid_midi_file_read_event() 2018-06-26 07:55:46 +02:00
derselbst
5e3d5acbdb prefer FLUID_STRNCPY to strcpy 2018-06-26 07:43:54 +02:00
derselbst
d0958c6e35 Merge branch 'master' into modenv-convex 2018-06-26 06:53:02 +02:00