From 8b00644751578ba67b709a827cbe5133d849d339 Mon Sep 17 00:00:00 2001 From: derselbst Date: Sat, 19 Mar 2022 12:49:15 +0100 Subject: [PATCH 1/9] Bump to 2.2.6 --- CMakeLists.txt | 4 ++-- doc/fluidsynth-v20-devdoc.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93000f71..cfef8b3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ set ( PACKAGE "fluidsynth" ) # FluidSynth package version set ( FLUIDSYNTH_VERSION_MAJOR 2 ) set ( FLUIDSYNTH_VERSION_MINOR 2 ) -set ( FLUIDSYNTH_VERSION_MICRO 5 ) +set ( FLUIDSYNTH_VERSION_MICRO 6 ) set ( VERSION "${FLUIDSYNTH_VERSION_MAJOR}.${FLUIDSYNTH_VERSION_MINOR}.${FLUIDSYNTH_VERSION_MICRO}" ) set ( FLUIDSYNTH_VERSION "\"${VERSION}\"" ) @@ -53,7 +53,7 @@ set ( FLUIDSYNTH_VERSION "\"${VERSION}\"" ) # This is not exactly the same algorithm as the libtool one, but the results are the same. set ( LIB_VERSION_CURRENT 3 ) set ( LIB_VERSION_AGE 0 ) -set ( LIB_VERSION_REVISION 5 ) +set ( LIB_VERSION_REVISION 6 ) set ( LIB_VERSION_INFO "${LIB_VERSION_CURRENT}.${LIB_VERSION_AGE}.${LIB_VERSION_REVISION}" ) diff --git a/doc/fluidsynth-v20-devdoc.txt b/doc/fluidsynth-v20-devdoc.txt index 636d8e31..0bf7ca17 100644 --- a/doc/fluidsynth-v20-devdoc.txt +++ b/doc/fluidsynth-v20-devdoc.txt @@ -8,8 +8,8 @@ \author David Henningsson \author Tom Moebert \author Copyright © 2003-2022 Peter Hanappe, Conrad Berhörster, Antoine Schmitt, Pedro López-Cabanillas, Josh Green, David Henningsson, Tom Moebert -\version Revision 2.2.5 -\date 2022-01-16 +\version Revision 2.2.6 +\date 2022-03-19 All the source code examples in this document are in the public domain; you can use them as you please. This document is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License. To view a copy of this license, visit https://creativecommons.org/licenses/by-sa/3.0/ . The FluidSynth library is distributed under the GNU Lesser General Public License. A copy of the GNU Lesser General Public License is contained in the FluidSynth package; if not, visit https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. From 88e039efeb53391afe098af03576c48b1c513255 Mon Sep 17 00:00:00 2001 From: Tom M Date: Tue, 5 Apr 2022 22:10:39 +0200 Subject: [PATCH 2/9] Fix fluid_curtime() returning very incorrect timings (#1076) --- src/drivers/fluid_aufile.c | 8 +++----- src/utils/fluid_sys.c | 10 +++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/drivers/fluid_aufile.c b/src/drivers/fluid_aufile.c index ab6a2586..6ca33d1f 100644 --- a/src/drivers/fluid_aufile.c +++ b/src/drivers/fluid_aufile.c @@ -39,7 +39,6 @@ typedef struct { fluid_audio_driver_t driver; - fluid_audio_func_t callback; void *data; fluid_file_renderer_t *renderer; int period_size; @@ -49,7 +48,7 @@ typedef struct } fluid_file_audio_driver_t; -static int fluid_file_audio_run_s16(void *d, unsigned int msec); +static int fluid_file_audio_run(void *d, unsigned int msec); /************************************************************** * @@ -78,7 +77,6 @@ new_fluid_file_audio_driver(fluid_settings_t *settings, fluid_settings_getnum(settings, "synth.sample-rate", &dev->sample_rate); dev->data = synth; - dev->callback = (fluid_audio_func_t) fluid_synth_process; dev->samples = 0; dev->renderer = new_fluid_file_renderer(synth); @@ -89,7 +87,7 @@ new_fluid_file_audio_driver(fluid_settings_t *settings, } msec = (int)(0.5 + dev->period_size / dev->sample_rate * 1000.0); - dev->timer = new_fluid_timer(msec, fluid_file_audio_run_s16, (void *) dev, TRUE, FALSE, TRUE); + dev->timer = new_fluid_timer(msec, fluid_file_audio_run, (void *) dev, TRUE, FALSE, TRUE); if(dev->timer == NULL) { @@ -115,7 +113,7 @@ void delete_fluid_file_audio_driver(fluid_audio_driver_t *p) FLUID_FREE(dev); } -static int fluid_file_audio_run_s16(void *d, unsigned int clock_time) +static int fluid_file_audio_run(void *d, unsigned int clock_time) { fluid_file_audio_driver_t *dev = (fluid_file_audio_driver_t *) d; unsigned int sample_time; diff --git a/src/utils/fluid_sys.c b/src/utils/fluid_sys.c index e3c0ea4d..08f41200 100644 --- a/src/utils/fluid_sys.c +++ b/src/utils/fluid_sys.c @@ -387,17 +387,17 @@ void fluid_msleep(unsigned int msecs) */ unsigned int fluid_curtime(void) { - float now; - static float initial_time = 0; + double now; + static double initial_time = 0; if(initial_time == 0) { - initial_time = (float)fluid_utime(); + initial_time = fluid_utime(); } - now = (float)fluid_utime(); + now = fluid_utime(); - return (unsigned int)((now - initial_time) / 1000.0f); + return (unsigned int)((now - initial_time) / 1000.0); } /** From b1a28624ba6d41c880efebc44c52749de94d708f Mon Sep 17 00:00:00 2001 From: JimHenry Date: Sat, 9 Apr 2022 00:27:53 -0500 Subject: [PATCH 3/9] Add fluid_event_from_midi_event(fluid_event_t *evt, const fluid_midi_event_t *event) to create a sequencer event from a midi event. Issue #1078 --- include/fluidsynth/seqbind.h | 6 +- src/midi/fluid_seqbind.c | 116 +++++++++++++++++++++-------------- 2 files changed, 73 insertions(+), 49 deletions(-) diff --git a/include/fluidsynth/seqbind.h b/include/fluidsynth/seqbind.h index ddf1cb9d..085f807d 100644 --- a/include/fluidsynth/seqbind.h +++ b/include/fluidsynth/seqbind.h @@ -34,8 +34,10 @@ extern "C" { */ FLUIDSYNTH_API fluid_seq_id_t fluid_sequencer_register_fluidsynth(fluid_sequencer_t *seq, fluid_synth_t *synth); -FLUIDSYNTH_API int -fluid_sequencer_add_midi_event_to_buffer(void *data, fluid_midi_event_t *event); +FLUIDSYNTH_API +int fluid_event_from_midi_event(fluid_event_t *, const fluid_midi_event_t *); +FLUIDSYNTH_API +int fluid_sequencer_add_midi_event_to_buffer(void *data, fluid_midi_event_t *event); /* @} */ #ifdef __cplusplus diff --git a/src/midi/fluid_seqbind.c b/src/midi/fluid_seqbind.c index eb922297..f80f4534 100644 --- a/src/midi/fluid_seqbind.c +++ b/src/midi/fluid_seqbind.c @@ -355,6 +355,72 @@ static fluid_seq_id_t get_fluidsynth_dest(fluid_sequencer_t *seq) return -1; } +/** + * Transforms an incoming MIDI event (from a MIDI driver or MIDI router) to a + * sequencer event. + * + * @param evt returned sequencer event + * @param event MIDI event + * @return #FLUID_OK or #FLUID_FAILED + * + * @since 2.2.X + */ +int fluid_event_from_midi_event(fluid_event_t *evt, const fluid_midi_event_t *event) +{ + fluid_return_val_if_fail(event != NULL, FLUID_FAILED); + + int chan = fluid_midi_event_get_channel(event); + + switch (fluid_midi_event_get_type(event)) + { + case NOTE_OFF: + fluid_event_noteoff(evt, chan, (short)fluid_midi_event_get_key(event)); + break; + + case NOTE_ON: + fluid_event_noteon(evt, + fluid_midi_event_get_channel(event), + (short)fluid_midi_event_get_key(event), + (short)fluid_midi_event_get_velocity(event)); + break; + + case CONTROL_CHANGE: + fluid_event_control_change(evt, + chan, + (short)fluid_midi_event_get_control(event), + (short)fluid_midi_event_get_value(event)); + break; + + case PROGRAM_CHANGE: + fluid_event_program_change(evt, chan, (short)fluid_midi_event_get_program(event)); + break; + + case PITCH_BEND: + fluid_event_pitch_bend(evt, chan, fluid_midi_event_get_pitch(event)); + break; + + case CHANNEL_PRESSURE: + fluid_event_channel_pressure(evt, chan, (short)fluid_midi_event_get_program(event)); + break; + + case KEY_PRESSURE: + fluid_event_key_pressure(evt, + chan, + (short)fluid_midi_event_get_key(event), + (short)fluid_midi_event_get_value(event)); + break; + + case MIDI_SYSTEM_RESET: + fluid_event_system_reset(evt); + break; + + default: /* Not yet implemented */ + return FLUID_FAILED; + } + + return FLUID_OK; +} + /** * Transforms an incoming MIDI event (from a MIDI driver or MIDI router) to a * sequencer event and adds it to the sequencer queue for sending as soon as possible. @@ -367,64 +433,20 @@ static fluid_seq_id_t get_fluidsynth_dest(fluid_sequencer_t *seq) * * @since 1.1.0 */ -int -fluid_sequencer_add_midi_event_to_buffer(void *data, fluid_midi_event_t *event) +int fluid_sequencer_add_midi_event_to_buffer(void *data, fluid_midi_event_t *event) { fluid_event_t evt; fluid_sequencer_t *seq; - int chan; fluid_return_val_if_fail(data != NULL, FLUID_FAILED); fluid_return_val_if_fail(event != NULL, FLUID_FAILED); - seq = (fluid_sequencer_t *) data; - chan = fluid_midi_event_get_channel(event); + seq = (fluid_sequencer_t *)data; fluid_event_clear(&evt); + fluid_event_from_midi_event(&evt, event); fluid_event_set_dest(&evt, get_fluidsynth_dest(seq)); - switch(fluid_midi_event_get_type(event)) - { - case NOTE_OFF: - fluid_event_noteoff(&evt, chan, (short)fluid_midi_event_get_key(event)); - break; - - case NOTE_ON: - fluid_event_noteon(&evt, fluid_midi_event_get_channel(event), - (short)fluid_midi_event_get_key(event), (short)fluid_midi_event_get_velocity(event)); - break; - - case CONTROL_CHANGE: - fluid_event_control_change(&evt, chan, (short)fluid_midi_event_get_control(event), - (short)fluid_midi_event_get_value(event)); - break; - - case PROGRAM_CHANGE: - fluid_event_program_change(&evt, chan, (short)fluid_midi_event_get_program(event)); - break; - - case PITCH_BEND: - fluid_event_pitch_bend(&evt, chan, fluid_midi_event_get_pitch(event)); - break; - - case CHANNEL_PRESSURE: - fluid_event_channel_pressure(&evt, chan, (short)fluid_midi_event_get_program(event)); - break; - - case KEY_PRESSURE: - fluid_event_key_pressure(&evt, chan, - (short)fluid_midi_event_get_key(event), - (short)fluid_midi_event_get_value(event)); - break; - - case MIDI_SYSTEM_RESET: - fluid_event_system_reset(&evt); - break; - - default: /* Not yet implemented */ - return FLUID_FAILED; - } - /* Schedule for sending at next call to fluid_sequencer_process */ return fluid_sequencer_send_at(seq, &evt, 0, 0); } From 719b525e2b8e018ce3b361881c363424aa295b43 Mon Sep 17 00:00:00 2001 From: JimHenry Date: Sun, 10 Apr 2022 23:52:18 -0500 Subject: [PATCH 4/9] Add @note and @code to fluid_event_from_midi_event() documentation block. --- src/midi/fluid_seqbind.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/midi/fluid_seqbind.c b/src/midi/fluid_seqbind.c index f80f4534..b0f62591 100644 --- a/src/midi/fluid_seqbind.c +++ b/src/midi/fluid_seqbind.c @@ -363,7 +363,23 @@ static fluid_seq_id_t get_fluidsynth_dest(fluid_sequencer_t *seq) * @param event MIDI event * @return #FLUID_OK or #FLUID_FAILED * - * @since 2.2.X + * @note This function copies the fields of the MIDI event into the provided + * sequencer event. Calling applications must create the sequencer event and set + * additional fields such as the source and destination of the sequencer event. + * + * @code{.cpp} + * // ... get MIDI event, e.g. using player_callback() + * + * // Send MIDI event to sequencer to play + * fluid_event_t *evt = new_fluid_event(); + * fluid_event_set_source(evt, -1); + * fluid_event_set_dest(evt, seqid); + * fluid_event_from_midi_event(evt, event); + * fluid_sequencer_send_at(sequencer, evt, 50, 0); // relative time + * delete_fluid_event(evt); + * @endcode + * + * @since 2.2.7 */ int fluid_event_from_midi_event(fluid_event_t *evt, const fluid_midi_event_t *event) { From 757b151601696e3c00ec0cca20b9246668fdfcff Mon Sep 17 00:00:00 2001 From: derselbst Date: Tue, 12 Apr 2022 10:47:00 +0200 Subject: [PATCH 5/9] Move fluid_event_from_midi_event() to fluid_event.c --- include/fluidsynth/event.h | 1 + include/fluidsynth/seqbind.h | 2 - src/midi/fluid_seqbind.c | 82 ------------------------------------ src/synth/fluid_event.c | 81 +++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 84 deletions(-) diff --git a/include/fluidsynth/event.h b/include/fluidsynth/event.h index e50f974f..643f6c52 100644 --- a/include/fluidsynth/event.h +++ b/include/fluidsynth/event.h @@ -117,6 +117,7 @@ FLUIDSYNTH_API void fluid_event_system_reset(fluid_event_t *evt); FLUIDSYNTH_API void fluid_event_unregistering(fluid_event_t *evt); FLUIDSYNTH_API void fluid_event_scale(fluid_event_t *evt, double new_scale); +FLUIDSYNTH_API int fluid_event_from_midi_event(fluid_event_t *, const fluid_midi_event_t *); /* Accessing event data */ FLUIDSYNTH_API int fluid_event_get_type(fluid_event_t *evt); diff --git a/include/fluidsynth/seqbind.h b/include/fluidsynth/seqbind.h index 085f807d..b8fd1a40 100644 --- a/include/fluidsynth/seqbind.h +++ b/include/fluidsynth/seqbind.h @@ -35,8 +35,6 @@ extern "C" { FLUIDSYNTH_API fluid_seq_id_t fluid_sequencer_register_fluidsynth(fluid_sequencer_t *seq, fluid_synth_t *synth); FLUIDSYNTH_API -int fluid_event_from_midi_event(fluid_event_t *, const fluid_midi_event_t *); -FLUIDSYNTH_API int fluid_sequencer_add_midi_event_to_buffer(void *data, fluid_midi_event_t *event); /* @} */ diff --git a/src/midi/fluid_seqbind.c b/src/midi/fluid_seqbind.c index b0f62591..9ec06f20 100644 --- a/src/midi/fluid_seqbind.c +++ b/src/midi/fluid_seqbind.c @@ -355,88 +355,6 @@ static fluid_seq_id_t get_fluidsynth_dest(fluid_sequencer_t *seq) return -1; } -/** - * Transforms an incoming MIDI event (from a MIDI driver or MIDI router) to a - * sequencer event. - * - * @param evt returned sequencer event - * @param event MIDI event - * @return #FLUID_OK or #FLUID_FAILED - * - * @note This function copies the fields of the MIDI event into the provided - * sequencer event. Calling applications must create the sequencer event and set - * additional fields such as the source and destination of the sequencer event. - * - * @code{.cpp} - * // ... get MIDI event, e.g. using player_callback() - * - * // Send MIDI event to sequencer to play - * fluid_event_t *evt = new_fluid_event(); - * fluid_event_set_source(evt, -1); - * fluid_event_set_dest(evt, seqid); - * fluid_event_from_midi_event(evt, event); - * fluid_sequencer_send_at(sequencer, evt, 50, 0); // relative time - * delete_fluid_event(evt); - * @endcode - * - * @since 2.2.7 - */ -int fluid_event_from_midi_event(fluid_event_t *evt, const fluid_midi_event_t *event) -{ - fluid_return_val_if_fail(event != NULL, FLUID_FAILED); - - int chan = fluid_midi_event_get_channel(event); - - switch (fluid_midi_event_get_type(event)) - { - case NOTE_OFF: - fluid_event_noteoff(evt, chan, (short)fluid_midi_event_get_key(event)); - break; - - case NOTE_ON: - fluid_event_noteon(evt, - fluid_midi_event_get_channel(event), - (short)fluid_midi_event_get_key(event), - (short)fluid_midi_event_get_velocity(event)); - break; - - case CONTROL_CHANGE: - fluid_event_control_change(evt, - chan, - (short)fluid_midi_event_get_control(event), - (short)fluid_midi_event_get_value(event)); - break; - - case PROGRAM_CHANGE: - fluid_event_program_change(evt, chan, (short)fluid_midi_event_get_program(event)); - break; - - case PITCH_BEND: - fluid_event_pitch_bend(evt, chan, fluid_midi_event_get_pitch(event)); - break; - - case CHANNEL_PRESSURE: - fluid_event_channel_pressure(evt, chan, (short)fluid_midi_event_get_program(event)); - break; - - case KEY_PRESSURE: - fluid_event_key_pressure(evt, - chan, - (short)fluid_midi_event_get_key(event), - (short)fluid_midi_event_get_value(event)); - break; - - case MIDI_SYSTEM_RESET: - fluid_event_system_reset(evt); - break; - - default: /* Not yet implemented */ - return FLUID_FAILED; - } - - return FLUID_OK; -} - /** * Transforms an incoming MIDI event (from a MIDI driver or MIDI router) to a * sequencer event and adds it to the sequencer queue for sending as soon as possible. diff --git a/src/synth/fluid_event.c b/src/synth/fluid_event.c index ddc6aa8b..ff8d9f79 100644 --- a/src/synth/fluid_event.c +++ b/src/synth/fluid_event.c @@ -30,6 +30,7 @@ #include "fluid_event.h" #include "fluidsynth_priv.h" +#include "fluid_midi.h" /*************************************************************** * @@ -577,7 +578,87 @@ fluid_event_system_reset(fluid_event_t *evt) evt->type = FLUID_SEQ_SYSTEMRESET; } +/** + * Transforms an incoming MIDI event (from a MIDI driver or MIDI router) to a + * sequencer event. + * + * @param evt returned sequencer event + * @param event MIDI event + * @return #FLUID_OK or #FLUID_FAILED + * + * @note This function copies the fields of the MIDI event into the provided + * sequencer event. Calling applications must create the sequencer event and set + * additional fields such as the source and destination of the sequencer event. + * + * @code{.cpp} + * // ... get MIDI event, e.g. using player_callback() + * + * // Send MIDI event to sequencer to play + * fluid_event_t *evt = new_fluid_event(); + * fluid_event_set_source(evt, -1); + * fluid_event_set_dest(evt, seqid); + * fluid_event_from_midi_event(evt, event); + * fluid_sequencer_send_at(sequencer, evt, 50, 0); // relative time + * delete_fluid_event(evt); + * @endcode + * + * @since 2.2.7 + */ +int fluid_event_from_midi_event(fluid_event_t *evt, const fluid_midi_event_t *event) +{ + fluid_return_val_if_fail(event != NULL, FLUID_FAILED); + int chan = fluid_midi_event_get_channel(event); + + switch (fluid_midi_event_get_type(event)) + { + case NOTE_OFF: + fluid_event_noteoff(evt, chan, (short)fluid_midi_event_get_key(event)); + break; + + case NOTE_ON: + fluid_event_noteon(evt, + fluid_midi_event_get_channel(event), + (short)fluid_midi_event_get_key(event), + (short)fluid_midi_event_get_velocity(event)); + break; + + case CONTROL_CHANGE: + fluid_event_control_change(evt, + chan, + (short)fluid_midi_event_get_control(event), + (short)fluid_midi_event_get_value(event)); + break; + + case PROGRAM_CHANGE: + fluid_event_program_change(evt, chan, (short)fluid_midi_event_get_program(event)); + break; + + case PITCH_BEND: + fluid_event_pitch_bend(evt, chan, fluid_midi_event_get_pitch(event)); + break; + + case CHANNEL_PRESSURE: + fluid_event_channel_pressure(evt, chan, (short)fluid_midi_event_get_program(event)); + break; + + case KEY_PRESSURE: + fluid_event_key_pressure(evt, + chan, + (short)fluid_midi_event_get_key(event), + (short)fluid_midi_event_get_value(event)); + break; + + case MIDI_SYSTEM_RESET: + fluid_event_system_reset(evt); + break; + + default: /* Not yet implemented */ + return FLUID_FAILED; + } + + return FLUID_OK; +} /* * Accessing event data From a9d555ff501b358e3017494762939b335ea1580b Mon Sep 17 00:00:00 2001 From: Tom M Date: Tue, 19 Apr 2022 22:00:47 +0200 Subject: [PATCH 6/9] WinXP CI build: use x87 FPU (#1083) --- .azure/azure-pipelines-win.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.azure/azure-pipelines-win.yml b/.azure/azure-pipelines-win.yml index dc7b4f16..8c9aca7a 100644 --- a/.azure/azure-pipelines-win.yml +++ b/.azure/azure-pipelines-win.yml @@ -24,11 +24,15 @@ jobs: gtk-bundle: $(gtk-bundle-x86) libsndfile-url: $(libsndfile-url-x86) artifact-prefix: "fluidsynth" + CFLAGS: "/arch:IA32" + CXXFLAGS: "/arch:IA32" x64: platform: x64 gtk-bundle: $(gtk-bundle-x64) libsndfile-url: $(libsndfile-url-x64) artifact-prefix: "fluidsynth" + CFLAGS: "" + CXXFLAGS: "" pool: vmImage: 'windows-2019' steps: @@ -38,7 +42,7 @@ jobs: # https://dev.azure.com/tommbrt/_apis/projects?api-version=5.0 project: 'd3638885-de4a-4ce7-afe7-f237ae461c07' pipeline: 1 - artifactName: libinstpatch-$(platform) + artifactName: libinstpatch-XP-$(platform) downloadPath: '$(Build.ArtifactStagingDirectory)' displayName: 'Get libinstpatch' - script: | @@ -52,11 +56,11 @@ jobs: REM need to fix the naming of libsndfile otherwise the linker won't find it mv lib\libsndfile-1.lib lib\sndfile.lib || exit -1 mv lib\libsndfile-1.def lib\sndfile.def || exit -1 - cd $(Build.ArtifactStagingDirectory)\libinstpatch-$(platform) + cd $(Build.ArtifactStagingDirectory)\libinstpatch-XP-$(platform) cp -rf * d:\deps\ mv -f * .. cd .. - rmdir $(Build.ArtifactStagingDirectory)\libinstpatch-$(platform)\ + rmdir $(Build.ArtifactStagingDirectory)\libinstpatch-XP-$(platform)\ DEL /F C:\Strawberry\perl\bin\pkg-config.bat displayName: 'Prerequisites' - script: | From 2acb06807540ad54311ff55d5057675e67188555 Mon Sep 17 00:00:00 2001 From: derselbst Date: Tue, 19 Apr 2022 22:15:03 +0200 Subject: [PATCH 7/9] Fix C90 build --- src/synth/fluid_event.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/synth/fluid_event.c b/src/synth/fluid_event.c index ff8d9f79..48b781bd 100644 --- a/src/synth/fluid_event.c +++ b/src/synth/fluid_event.c @@ -582,7 +582,7 @@ fluid_event_system_reset(fluid_event_t *evt) * Transforms an incoming MIDI event (from a MIDI driver or MIDI router) to a * sequencer event. * - * @param evt returned sequencer event + * @param evt Sequencer event structure * @param event MIDI event * @return #FLUID_OK or #FLUID_FAILED * @@ -606,9 +606,10 @@ fluid_event_system_reset(fluid_event_t *evt) */ int fluid_event_from_midi_event(fluid_event_t *evt, const fluid_midi_event_t *event) { + int chan; fluid_return_val_if_fail(event != NULL, FLUID_FAILED); - int chan = fluid_midi_event_get_channel(event); + chan = fluid_midi_event_get_channel(event); switch (fluid_midi_event_get_type(event)) { From 15529d50a82738a802e4b1840150c8a4ef11e3d1 Mon Sep 17 00:00:00 2001 From: derselbst Date: Tue, 19 Apr 2022 22:15:18 +0200 Subject: [PATCH 8/9] Make MIDI Event API const correct --- doc/recent_changes.txt | 6 ++++++ include/fluidsynth/midi.h | 16 ++++++++-------- src/midi/fluid_midi.c | 16 ++++++++-------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/doc/recent_changes.txt b/doc/recent_changes.txt index 33c7a12c..c564db83 100644 --- a/doc/recent_changes.txt +++ b/doc/recent_changes.txt @@ -1,6 +1,12 @@ /*! \page RecentChanges Recent Changes +\section NewIn2_2_7 What's new in 2.2.7? + +- Most getter functions of the MIDI event API are now const correct +- fluid_event_from_midi_event() has been added + + \section NewIn2_2_0 What's new in 2.2.0? - #fluid_file_callbacks_t now uses long long as file-offset type (see #fluid_long_long_t).This is a breaking change, which allows to load SoundFonts bigger than 2GiB on Windows. This change required to bump fluidsynth's SOVERSION. diff --git a/include/fluidsynth/midi.h b/include/fluidsynth/midi.h index 067db84e..cc3e435b 100644 --- a/include/fluidsynth/midi.h +++ b/include/fluidsynth/midi.h @@ -114,20 +114,20 @@ FLUIDSYNTH_API void delete_fluid_midi_event(fluid_midi_event_t *event); /** @endlifecycle */ FLUIDSYNTH_API int fluid_midi_event_set_type(fluid_midi_event_t *evt, int type); -FLUIDSYNTH_API int fluid_midi_event_get_type(fluid_midi_event_t *evt); +FLUIDSYNTH_API int fluid_midi_event_get_type(const fluid_midi_event_t *evt); FLUIDSYNTH_API int fluid_midi_event_set_channel(fluid_midi_event_t *evt, int chan); -FLUIDSYNTH_API int fluid_midi_event_get_channel(fluid_midi_event_t *evt); -FLUIDSYNTH_API int fluid_midi_event_get_key(fluid_midi_event_t *evt); +FLUIDSYNTH_API int fluid_midi_event_get_channel(const fluid_midi_event_t *evt); +FLUIDSYNTH_API int fluid_midi_event_get_key(const fluid_midi_event_t *evt); FLUIDSYNTH_API int fluid_midi_event_set_key(fluid_midi_event_t *evt, int key); -FLUIDSYNTH_API int fluid_midi_event_get_velocity(fluid_midi_event_t *evt); +FLUIDSYNTH_API int fluid_midi_event_get_velocity(const fluid_midi_event_t *evt); FLUIDSYNTH_API int fluid_midi_event_set_velocity(fluid_midi_event_t *evt, int vel); -FLUIDSYNTH_API int fluid_midi_event_get_control(fluid_midi_event_t *evt); +FLUIDSYNTH_API int fluid_midi_event_get_control(const fluid_midi_event_t *evt); FLUIDSYNTH_API int fluid_midi_event_set_control(fluid_midi_event_t *evt, int ctrl); -FLUIDSYNTH_API int fluid_midi_event_get_value(fluid_midi_event_t *evt); +FLUIDSYNTH_API int fluid_midi_event_get_value(const fluid_midi_event_t *evt); FLUIDSYNTH_API int fluid_midi_event_set_value(fluid_midi_event_t *evt, int val); -FLUIDSYNTH_API int fluid_midi_event_get_program(fluid_midi_event_t *evt); +FLUIDSYNTH_API int fluid_midi_event_get_program(const fluid_midi_event_t *evt); FLUIDSYNTH_API int fluid_midi_event_set_program(fluid_midi_event_t *evt, int val); -FLUIDSYNTH_API int fluid_midi_event_get_pitch(fluid_midi_event_t *evt); +FLUIDSYNTH_API int fluid_midi_event_get_pitch(const fluid_midi_event_t *evt); FLUIDSYNTH_API int fluid_midi_event_set_pitch(fluid_midi_event_t *evt, int val); FLUIDSYNTH_API int fluid_midi_event_set_sysex(fluid_midi_event_t *evt, void *data, int size, int dynamic); diff --git a/src/midi/fluid_midi.c b/src/midi/fluid_midi.c index cab651b8..89271cf3 100644 --- a/src/midi/fluid_midi.c +++ b/src/midi/fluid_midi.c @@ -1106,7 +1106,7 @@ delete_fluid_midi_event(fluid_midi_event_t *evt) * @return Event type field (MIDI status byte without channel) */ int -fluid_midi_event_get_type(fluid_midi_event_t *evt) +fluid_midi_event_get_type(const fluid_midi_event_t *evt) { return evt->type; } @@ -1130,7 +1130,7 @@ fluid_midi_event_set_type(fluid_midi_event_t *evt, int type) * @return Channel field */ int -fluid_midi_event_get_channel(fluid_midi_event_t *evt) +fluid_midi_event_get_channel(const fluid_midi_event_t *evt) { return evt->channel; } @@ -1154,7 +1154,7 @@ fluid_midi_event_set_channel(fluid_midi_event_t *evt, int chan) * @return MIDI note number (0-127) */ int -fluid_midi_event_get_key(fluid_midi_event_t *evt) +fluid_midi_event_get_key(const fluid_midi_event_t *evt) { return evt->param1; } @@ -1178,7 +1178,7 @@ fluid_midi_event_set_key(fluid_midi_event_t *evt, int v) * @return MIDI velocity number (0-127) */ int -fluid_midi_event_get_velocity(fluid_midi_event_t *evt) +fluid_midi_event_get_velocity(const fluid_midi_event_t *evt) { return evt->param2; } @@ -1202,7 +1202,7 @@ fluid_midi_event_set_velocity(fluid_midi_event_t *evt, int v) * @return MIDI control number */ int -fluid_midi_event_get_control(fluid_midi_event_t *evt) +fluid_midi_event_get_control(const fluid_midi_event_t *evt) { return evt->param1; } @@ -1226,7 +1226,7 @@ fluid_midi_event_set_control(fluid_midi_event_t *evt, int v) * @return Value field */ int -fluid_midi_event_get_value(fluid_midi_event_t *evt) +fluid_midi_event_get_value(const fluid_midi_event_t *evt) { return evt->param2; } @@ -1250,7 +1250,7 @@ fluid_midi_event_set_value(fluid_midi_event_t *evt, int v) * @return MIDI program number (0-127) */ int -fluid_midi_event_get_program(fluid_midi_event_t *evt) +fluid_midi_event_get_program(const fluid_midi_event_t *evt) { return evt->param1; } @@ -1274,7 +1274,7 @@ fluid_midi_event_set_program(fluid_midi_event_t *evt, int val) * @return Pitch value (14 bit value, 0-16383, 8192 is center) */ int -fluid_midi_event_get_pitch(fluid_midi_event_t *evt) +fluid_midi_event_get_pitch(const fluid_midi_event_t *evt) { return evt->param1; } From 0771899e3f18101ac4f6d7bdd4d6833bd4bc87d1 Mon Sep 17 00:00:00 2001 From: derselbst Date: Thu, 21 Apr 2022 14:15:24 +0200 Subject: [PATCH 9/9] Update vcpkg ref to fix CI pipeline --- .azure/azure-pipelines-vcpkg.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure/azure-pipelines-vcpkg.yml b/.azure/azure-pipelines-vcpkg.yml index b730d4d5..3b51f787 100644 --- a/.azure/azure-pipelines-vcpkg.yml +++ b/.azure/azure-pipelines-vcpkg.yml @@ -31,7 +31,7 @@ variables: toolset: 'v142' generator: 'Visual Studio 16 2019' configuration: 'RelWithDebInfo' - VCPKG_REVISION: 'e6dcc079c81161786eb7b052209a2047e79f2c6c' + VCPKG_REVISION: 'e809a42f87565e803b2178a0c11263f462d1800a' jobs: - job: vcpkg