Commit Graph

1401 Commits

Author SHA1 Message Date
derselbst 57f40ea91c Fix heap-use-after free 2021-01-03 09:41:46 +01:00
derselbst 03cf8e28f6 Add a unit test for issue 733 2021-01-03 09:41:46 +01:00
Tom M 4bfeff5764
Elaborate API docs on voice state 2021-01-01 22:27:25 +01:00
derselbst 26710f1076 Bump to 2.1.6 2021-01-01 21:26:12 +01:00
jjceresa 0ae16f6a2b
Check first MIDI files then Soundfonts files in fluidsynth.c (#731) 2020-12-31 10:28:12 +01:00
Tom M a14c70cbbd
Fix the fluid_synth_set_sample_rate() change problem for jack driver (#722) 2020-12-31 10:25:53 +01:00
derselbst 1be0e5ae7c Log error when audio callback function fails
Addresses #724
2020-12-28 18:08:38 +01:00
Tom M 9a25e71b02
Add FLUID_SEQ_SCALE event type (#723) 2020-12-27 17:53:36 +01:00
derselbst 0853cac6a3 Fix doxygen warnings 2020-12-27 10:48:07 +01:00
derselbst bc056b576b Print error if fluid_is_soundfont() fails 2020-12-22 13:16:30 +01:00
derselbst 3c84dcc816 Update API docs about UTF8 filenames 2020-12-22 11:30:14 +01:00
derselbst ed34742824 Add log messages to fluid_fopen() 2020-12-22 11:30:14 +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
Carlo Bramini f15147d43a
Replace g_ascii_strtoll() with FLUID_STRTOL() (#717) 2020-12-16 09:15:04 +01:00
Carlo Bramini 3719c58246
Make some strings const (#716) 2020-12-16 00:05:28 +01:00
Chris Xiong 9b485fad7c
Handle GS SysEx messages for setting whether a channel is used for rhythm part. (#708)
Some MIDI files that uses the GS standard uses channels other than channel 10 as percussion channel. Currently FluidSynth ignores the messages setting that up, causing notes meant to be played with a drum instrument played with a melodic instrument or vice versa. This patch will partially fix the issue.

Currently the implementation in this patch doesn't cover a specific "quirk" in Roland GS Modules: they seem to remember the last used instrument in the selected mode. This patch simply sets the instrument number to 0 instead.

A test file is attached. If played correctly (with `-o synth.device-id=16`) no out of place drum or piano sounds should be heard.

[wikipedia_MIDI_sample_gstest.mid.gz](https://github.com/FluidSynth/fluidsynth/files/5610727/wikipedia_MIDI_sample_gstest.mid.gz)
2020-11-29 00:20:04 +01:00
Nathan Umali 33c147402b
Update owner of the SoundFont registered trademark. (#706)
As of the time of this PR, the SoundFont registered trademark is owned by Creative Technology Ltd.
http://tmsearch.uspto.gov/bin/showfield?f=doc&state=4803:rj74xq.2.1
http://assignments.uspto.gov/assignments/q?db=tm&qt=sno&reel=&frame=&sno=74325965
2020-11-25 12:31:16 +01:00
jjceresa c9b187bd85
Fx unit api (#673)
This PR addresses #669 point 2.1.
It proposes set/get API functions to change/read fx unit parameters.
The deprecated shell commands are updated. Now the commands line have 2 parameters:
- first parameter is the fx unit index.
- second parameter is the value to apply to the fx unit.
2020-11-22 21:02:06 +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 7f1ac22869 Miscellaneous group 2020-11-12 21:27:00 +01:00
Marcus Weseloh 4a40695541 Settings documentation 2020-11-12 21:27:00 +01:00
Marcus Weseloh 39ae70793a MIDI Seqencer documentation 2020-11-12 21:27:00 +01:00
Marcus Weseloh 4185b25d6f MIDI input group
Contains MIDI Driver, MIDI Router, MIDI Player and MIDI Events
2020-11-12 21:27:00 +01:00
Marcus Weseloh 66b7c19893 Audio output group
With subgroups Audio Driver and File Renderer
2020-11-12 21:27:00 +01:00
Marcus Weseloh af68288628 Command Shell group for all shell related commands
With subgroups for command handler, shell and server.
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
jjceresa 032700f4e1
Add hint message when compiled without getopt support (#697) 2020-10-27 17:57:21 +01:00
jjceresa 42819d3e40 avoid an unlikely race condition 2020-10-27 14:01:37 +01:00
Marcus Weseloh c8fea77528 Fix possible uninitialized use of dry_idx variable 2020-10-26 21:01:59 +01:00
Marcus Weseloh 7fc56567ca Remove unused variable 2020-10-26 20:59:44 +01:00
jjceresa 5b8f3cbbc2
Ensure WaveOut compatibility with Win9X/NT (#687) 2020-10-14 17:54:56 +02:00
Tom M 97615ef2cf
Promote Controller/Pressure/Bend event functions to 32bits (#670) 2020-10-08 16:33:52 +02:00
derselbst d64ab70709 Fix build on Windows 9x/ME
Addresses #679
2020-10-04 20:42:08 +02:00
derselbst 94dbb9601e Add proper unicode support to Windows error reporting 2020-10-04 13:40:26 +02:00
derselbst 66d916a34a Fix Windows build 2020-10-04 13:32:38 +02:00
derselbst abc89d7d6c Improve error reporting in Waveout and DSound drivers 2020-10-04 13:21:15 +02:00
jjceresa b5da68393c
Fix minor bug in windows audio driver (#680) 2020-10-04 12:39:54 +02:00
jjceresa b55884b273
Make winmidi driver multi devices capable. (#677) 2020-09-27 14:22:56 +02:00
derselbst 90ba627794 Remove a FIXME 2020-09-13 13:38:38 +02:00
derselbst e48e48121b Remove a FIXME
Not aware of any problems caused by the old glib thread API. It will be removed sooner or later anyway.
2020-09-13 13:38:38 +02:00
derselbst f6038ea194 Add comment into empty block 2020-09-13 13:38:38 +02:00
derselbst dceb6e9835 Remove a FIXME
I have no clue what it refers to or what it's meant by that.
2020-09-13 13:38:38 +02:00
derselbst c94ccdfed1 Remove a FIXME
I don't see any 'allocation' of preset. And ALL public synth functions have a mutex lock which might potentially block when called from synth context, but only then if the client app pessimizes this situation by extensively calling the synth from outside the synth context.
2020-09-13 13:38:38 +02:00
derselbst 0b8fa2e386 Remove a FIXME
I don't see any problem calling fluid_channel_init() from within synth context
2020-09-13 13:38:38 +02:00
derselbst 18fdafe37f Fix another NULL dereference
Access to field 'zone' results in a dereference of a null pointer (loaded from variable 'pr'), if size is negative. However, size should be unsigned.
2020-09-13 13:38:38 +02:00
derselbst c4cd8bfc24 Fix a NULL dereference
Access to field 'zone' results in a dereference of a null pointer (loaded from variable 'prev_preset'), if `size` is negative. Problem is: Parameter `size` is `chunk.size` and should be unsigned.
2020-09-13 13:38:38 +02:00
derselbst ec74ed905b Fix an impossible NULL deref 2020-09-13 13:38:38 +02:00
derselbst 7ff98227c6 Remove dead code 2020-09-13 13:38:38 +02:00
Tom M 4c1292d8ab
Remove fluid_event_any_control_change() from public API (#674)
Originally, I have only marked it deprecated. But since we have an SOVERSION bump next release and because this function was only meant for internal usage, I think it's safe to remove it right now.
2020-09-12 10:40:57 +02:00
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