make fluid_midi_parser_parse() public

to enable realtime byte to fluid_midi_event_t parsing

fixes #108
addresses #150
This commit is contained in:
derselbst 2017-12-16 15:08:47 +01:00
parent 07a167c737
commit 4568e551b9
5 changed files with 32 additions and 14 deletions

View file

@ -121,6 +121,7 @@ Changes in FluidSynth 2.0.0 concerning developers:
Changes in FluidSynth 1.1.9 concerning developers:
- add a function for registering audio drivers based on acutal needs: fluid_audio_driver_register()
- make fluid_midi_parser_parse() public to enable realtime byte to #fluid_midi_event_t parsing
- implement handling of #FLUID_SEQ_ALLSOUNDSOFF events in fluid_seq_fluidsynth_callback()
- fix return value of fluid_file_set_encoding_quality()

View file

@ -146,7 +146,11 @@ FLUIDSYNTH_API int fluid_player_get_bpm(fluid_player_t * player);
FLUIDSYNTH_API int fluid_player_get_midi_tempo(fluid_player_t * player);
FLUIDSYNTH_API int fluid_player_seek(fluid_player_t *player, int ticks);
///
FLUIDSYNTH_API fluid_midi_parser_t* new_fluid_midi_parser(void);
FLUIDSYNTH_API void delete_fluid_midi_parser(fluid_midi_parser_t* parser);
FLUIDSYNTH_API fluid_midi_event_t* fluid_midi_parser_parse(fluid_midi_parser_t* parser, unsigned char c);
#ifdef __cplusplus
}

View file

@ -58,6 +58,7 @@ typedef struct _fluid_rampreset_t fluid_rampreset_t; /**< RAM SoundFo
typedef struct _fluid_cmd_handler_t fluid_cmd_handler_t; /**< Shell Command Handler */
typedef struct _fluid_ladspa_fx_t fluid_ladspa_fx_t; /**< LADSPA effects instance */
typedef struct _fluid_file_callbacks_t fluid_file_callbacks_t; /**< Callback struct to perform custom file loading of soundfonts */
typedef struct _fluid_midi_parser_t fluid_midi_parser_t;
typedef int fluid_istream_t; /**< Input stream descriptor */
typedef int fluid_ostream_t; /**< Output stream descriptor */

View file

@ -1891,8 +1891,10 @@ int fluid_player_get_midi_tempo(fluid_player_t * player)
*
*/
/*
* new_fluid_midi_parser
/**
* Create a MIDI parser.
* @return New MIDI parser or NULL when out of memory.
* @since 1.1.9
*/
fluid_midi_parser_t *
new_fluid_midi_parser ()
@ -1907,8 +1909,10 @@ new_fluid_midi_parser ()
return parser;
}
/*
* delete_fluid_midi_parser
/**
* Delete a MIDI parser.
* @param parser The MIDI parser to delete
* @since 1.1.9
*/
void
delete_fluid_midi_parser(fluid_midi_parser_t *parser)
@ -1919,11 +1923,25 @@ delete_fluid_midi_parser(fluid_midi_parser_t *parser)
}
/**
* Parse a MIDI stream one character at a time.
* Parse one character of a MIDI byte stream at a time.
* @param parser Parser instance
* @param c Next character in MIDI stream
* @return A parsed MIDI event or NULL if none. Event is internal and should
* @return A parsed MIDI event or NULL if more data required. Event is owned internally, should
* not be modified or freed and is only valid until next call to this function.
* @since 1.1.9
*
* Usage example:
* @code
* int ret=FLUID_OK;
* for (i = 0; i < length_of_byte_stream && ret == FLUID_OK; i++)
* {
* fluid_midi_event_t* event = fluid_midi_parser_parse(parser, my_byte_stream[i]);
* if (event != NULL)
* {
* ret = fluid_sequencer_add_midi_event_to_buffer(seq, event);
* }
* }
* @endcode
*/
fluid_midi_event_t *
fluid_midi_parser_parse(fluid_midi_parser_t *parser, unsigned char c)

View file

@ -25,12 +25,6 @@
#include "fluid_sys.h"
#include "fluid_list.h"
typedef struct _fluid_midi_parser_t fluid_midi_parser_t;
fluid_midi_parser_t* new_fluid_midi_parser(void);
void delete_fluid_midi_parser(fluid_midi_parser_t* parser);
fluid_midi_event_t* fluid_midi_parser_parse(fluid_midi_parser_t* parser, unsigned char c);
/***************************************************************
*