add missing getters for lyric and text midi events

fixes #468
This commit is contained in:
derselbst 2018-12-20 17:44:08 +01:00
parent 8da7f11a11
commit d0813be1c5
3 changed files with 63 additions and 0 deletions

View file

@ -21,6 +21,7 @@ All the source code examples in this document are in the public domain; you can
- \ref Disclaimer
- \ref Introduction
- \ref NewIn2_0_3
- \ref NewIn2_0_2
- \ref NewIn2_0_0
- \ref CreatingSettings
@ -61,6 +62,12 @@ What is FluidSynth?
- FluidSynth is open source, in active development. For more details, take a look at http://www.fluidsynth.org
\section NewIn2_0_3 Whats new in 2.0.3?
- add missing getters for midi events:
- fluid_midi_event_get_text()
- fluid_midi_event_get_lyrics()
\section NewIn2_0_2 Whats new in 2.0.2?

View file

@ -53,8 +53,12 @@ FLUIDSYNTH_API int fluid_midi_event_set_sysex(fluid_midi_event_t *evt, void *dat
int size, int dynamic);
FLUIDSYNTH_API int fluid_midi_event_set_text(fluid_midi_event_t *evt,
void *data, int size, int dynamic);
FLUIDSYNTH_API int fluid_midi_event_get_text(fluid_midi_event_t *evt,
void **data, int *size);
FLUIDSYNTH_API int fluid_midi_event_set_lyrics(fluid_midi_event_t *evt,
void *data, int size, int dynamic);
FLUIDSYNTH_API int fluid_midi_event_get_lyrics(fluid_midi_event_t *evt,
void **data, int *size);
/**
* MIDI router rule type.

View file

@ -36,6 +36,7 @@ static long fluid_getlength(unsigned char *s);
*/
static char *fluid_file_read_full(fluid_file fp, size_t *length);
static void fluid_midi_event_set_sysex_LOCAL(fluid_midi_event_t *evt, int type, void *data, int size, int dynamic);
static void fluid_midi_event_get_sysex_LOCAL(fluid_midi_event_t *evt, void **data, int *size);
#define READ_FULL_INITIAL_BUFLEN 1024
static fluid_track_t *new_fluid_track(int num);
@ -1334,6 +1335,25 @@ fluid_midi_event_set_text(fluid_midi_event_t *evt, void *data, int size, int dyn
return FLUID_OK;
}
/**
* Get the text of a MIDI event structure.
* @param evt MIDI event structure
* @param data Pointer to return text data on.
* @param size Pointer to return text size on.
* @return Returns #FLUID_OK if \p data and \p size previously set by
* fluid_midi_event_set_text() have been successfully retrieved.
* Else #FLUID_FAILED is returned and \p data and \p size are not changed.
* @since 2.0.3
*/
int fluid_midi_event_get_text(fluid_midi_event_t *evt, void **data, int *size)
{
fluid_return_val_if_fail(evt != NULL, FLUID_FAILED);
fluid_return_val_if_fail(evt->type == MIDI_TEXT, FLUID_FAILED);
fluid_midi_event_get_sysex_LOCAL(evt, data, size);
return FLUID_OK;
}
/**
* Assign lyric data to a MIDI event structure.
* @param evt MIDI event structure
@ -1353,6 +1373,25 @@ fluid_midi_event_set_lyrics(fluid_midi_event_t *evt, void *data, int size, int d
return FLUID_OK;
}
/**
* Get the lyric of a MIDI event structure.
* @param evt MIDI event structure
* @param data Pointer to return lyric data on.
* @param size Pointer to return lyric size on.
* @return Returns #FLUID_OK if \p data and \p size previously set by
* fluid_midi_event_set_lyrics() have been successfully retrieved.
* Else #FLUID_FAILED is returned and \p data and \p size are not changed.
* @since 2.0.3
*/
int fluid_midi_event_get_lyrics(fluid_midi_event_t *evt, void **data, int *size)
{
fluid_return_val_if_fail(evt != NULL, FLUID_FAILED);
fluid_return_val_if_fail(evt->type == MIDI_LYRIC, FLUID_FAILED);
fluid_midi_event_get_sysex_LOCAL(evt, data, size);
return FLUID_OK;
}
static void fluid_midi_event_set_sysex_LOCAL(fluid_midi_event_t *evt, int type, void *data, int size, int dynamic)
{
evt->type = type;
@ -1361,6 +1400,19 @@ static void fluid_midi_event_set_sysex_LOCAL(fluid_midi_event_t *evt, int type,
evt->param2 = dynamic;
}
static void fluid_midi_event_get_sysex_LOCAL(fluid_midi_event_t *evt, void **data, int *size)
{
if(data)
{
*data = evt->paramptr;
}
if(size)
{
*size = evt->param1;
}
}
/******************************************************
*
* fluid_track_t