Add FLUID_SEQ_SCALE event type (#723)

This commit is contained in:
Tom M 2020-12-27 17:53:36 +01:00 committed by GitHub
parent 0853cac6a3
commit 9a25e71b02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 1 deletions

View file

@ -10,6 +10,7 @@
- The sequencer's queue no longer blocks the synthesizer thread, due to being busy arranging its events internally. - The sequencer's queue no longer blocks the synthesizer thread, due to being busy arranging its events internally.
- Events that share the same tick was given a new, documented order, see fluid_sequencer_send_at(). - Events that share the same tick was given a new, documented order, see fluid_sequencer_send_at().
- The sequencer's scale can now be used for arbitrary tempo changes. Previously, the scale of the sequencer was limited to 1000. The only limitation now is >0. - The sequencer's scale can now be used for arbitrary tempo changes. Previously, the scale of the sequencer was limited to 1000. The only limitation now is >0.
- There is now a dedicated event type for changing the sequencer's time scale, see fluid_event_scale().
- The dynamic-sample-loader has learned support to pin samples, see fluid_synth_pin_preset() and fluid_synth_unpin_preset() - The dynamic-sample-loader has learned support to pin samples, see fluid_synth_pin_preset() and fluid_synth_unpin_preset()
- Added getter and setter functions for individual effect groups - Added getter and setter functions for individual effect groups
- Support for UTF-8 filenames under Windows, see fluid_synth_sfload() - Support for UTF-8 filenames under Windows, see fluid_synth_sfload()

View file

@ -61,6 +61,7 @@ enum fluid_seq_event_type
FLUID_SEQ_KEYPRESSURE, /**< Polyphonic aftertouch event @since 2.0.0 */ FLUID_SEQ_KEYPRESSURE, /**< Polyphonic aftertouch event @since 2.0.0 */
FLUID_SEQ_SYSTEMRESET, /**< System reset event @since 1.1.0 */ FLUID_SEQ_SYSTEMRESET, /**< System reset event @since 1.1.0 */
FLUID_SEQ_UNREGISTERING, /**< Called when a sequencer client is being unregistered. @since 1.1.0 */ FLUID_SEQ_UNREGISTERING, /**< Called when a sequencer client is being unregistered. @since 1.1.0 */
FLUID_SEQ_SCALE, /**< Sets a new time scale for the sequencer @since 2.2.0 */
FLUID_SEQ_LASTEVENT /**< @internal Defines the count of events enums @warning This symbol FLUID_SEQ_LASTEVENT /**< @internal Defines the count of events enums @warning This symbol
is not part of the public API and ABI stability guarantee and is not part of the public API and ABI stability guarantee and
may change at any time! */ may change at any time! */
@ -115,6 +116,8 @@ FLUIDSYNTH_API void fluid_event_system_reset(fluid_event_t *evt);
/* Only when unregistering clients */ /* Only when unregistering clients */
FLUIDSYNTH_API void fluid_event_unregistering(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);
/* Accessing event data */ /* Accessing event data */
FLUIDSYNTH_API int fluid_event_get_type(fluid_event_t *evt); FLUIDSYNTH_API int fluid_event_get_type(fluid_event_t *evt);
FLUIDSYNTH_API fluid_seq_id_t fluid_event_get_source(fluid_event_t *evt); FLUIDSYNTH_API fluid_seq_id_t fluid_event_get_source(fluid_event_t *evt);
@ -129,6 +132,7 @@ FLUIDSYNTH_API void *fluid_event_get_data(fluid_event_t *evt);
FLUIDSYNTH_API unsigned int fluid_event_get_duration(fluid_event_t *evt); FLUIDSYNTH_API unsigned int fluid_event_get_duration(fluid_event_t *evt);
FLUIDSYNTH_API short fluid_event_get_bank(fluid_event_t *evt); FLUIDSYNTH_API short fluid_event_get_bank(fluid_event_t *evt);
FLUIDSYNTH_API int fluid_event_get_pitch(fluid_event_t *evt); FLUIDSYNTH_API int fluid_event_get_pitch(fluid_event_t *evt);
FLUIDSYNTH_API double fluid_event_get_scale(fluid_event_t *evt);
FLUIDSYNTH_API unsigned int fluid_event_get_sfont_id(fluid_event_t *evt); FLUIDSYNTH_API unsigned int fluid_event_get_sfont_id(fluid_event_t *evt);
/* @} */ /* @} */

View file

@ -185,7 +185,6 @@ fluid_seq_fluidsynth_callback(unsigned int time, fluid_event_t *evt, fluid_seque
switch(fluid_event_get_type(evt)) switch(fluid_event_get_type(evt))
{ {
case FLUID_SEQ_NOTEON: case FLUID_SEQ_NOTEON:
fluid_synth_noteon(synth, fluid_event_get_channel(evt), fluid_event_get_key(evt), fluid_event_get_velocity(evt)); fluid_synth_noteon(synth, fluid_event_get_channel(evt), fluid_event_get_key(evt), fluid_event_get_velocity(evt));
break; break;
@ -326,6 +325,10 @@ fluid_seq_fluidsynth_callback(unsigned int time, fluid_event_t *evt, fluid_seque
/* nothing in fluidsynth */ /* nothing in fluidsynth */
break; break;
case FLUID_SEQ_SCALE:
fluid_sequencer_set_time_scale(seq, fluid_event_get_scale(evt));
break;
default: default:
break; break;
} }

View file

@ -479,6 +479,20 @@ fluid_event_unregistering(fluid_event_t *evt)
evt->type = FLUID_SEQ_UNREGISTERING; evt->type = FLUID_SEQ_UNREGISTERING;
} }
/**
* Set a sequencer event to be a scale change event.
* Useful for scheduling tempo changes.
* @param evt Sequencer event structure
* @param new_scale The new time scale to apply to the sequencer, see fluid_sequencer_set_time_scale()
* @since 2.2.0
*/
void
fluid_event_scale(fluid_event_t *evt, double new_scale)
{
evt->type = FLUID_SEQ_SCALE;
evt->scale = new_scale;
}
/** /**
* Set a sequencer event to be a channel-wide aftertouch event. * Set a sequencer event to be a channel-wide aftertouch event.
* @param evt Sequencer event structure * @param evt Sequencer event structure
@ -744,3 +758,15 @@ fluid_event_get_sfont_id(fluid_event_t *evt)
{ {
return evt->duration; return evt->duration;
} }
/**
* Gets time scale field from a sequencer event structure.
* @param evt Sequencer event structure
* @return SoundFont identifier value.
*
* Used by the #FLUID_SEQ_SCALE event type.
*/
double fluid_event_get_scale(fluid_event_t *evt)
{
return evt->scale;
}

View file

@ -46,6 +46,7 @@ struct _fluid_event_t
fluid_note_id_t id; fluid_note_id_t id;
int pitch; int pitch;
unsigned int duration; unsigned int duration;
double scale;
void *data; void *data;
}; };