Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #222 from FluidSynth/cmd-handler
shell command handler decoupled
  • Loading branch information
derselbst committed Oct 6, 2017
2 parents 87fdc38 + 5ae6279 commit cb036d2
Show file tree
Hide file tree
Showing 11 changed files with 528 additions and 466 deletions.
5 changes: 4 additions & 1 deletion doc/fluidsynth-v11-devdoc.txt
Expand Up @@ -74,17 +74,20 @@ Changes in FluidSynth @NEXT_RELEASE@ concerning developers:

- remove deprecated fluid_synth_get_program() and fluid_synth_get_channel_preset(), use fluid_synth_get_channel_info() instead
- remove deprecated fluid_settings_getstr()
- remove deprecated fluid_synth_set_midi_router()
- remove deprecated FLUID_HINT_INTEGER
- remove misspelled FLUID_SEQ_PITCHWHHELSENS macro
- remove obsolete "audio.[out|in]put-channels" settings
- remove unimplemented "synth.dump" setting
- remove fluid_synth_set_gen2(), fluid_synth_set_gen() now behaves as fluid_synth_set_gen2()
- all public \c fluid_settings_* functions that return an int that shall not be interpreted as a bool consistently return either FLUID_OK or FLUID_FAILED
- all public \c fluid_settings_* functions that return an integer which is not meant to be interpreted as bool consistently return either FLUID_OK or FLUID_FAILED
- struct fluid_mod_t was removed from public API
- struct _fluid_gen_t, fluid_gen_set_default_values() and enum fluid_gen_flags were removed from public API
- add "synth.volenv" a setting for volume envelope processing
- add support for polyonic key pressure events, see fluid_event_key_pressure()
- add fluid_synth_add_default_mod() for manipulating default modulators
- add individual reverb setters: fluid_synth_set_reverb_roomsize(), fluid_synth_set_reverb_damp(), fluid_synth_set_reverb_width(), fluid_synth_set_reverb_level()
- add individual chorus setters: fluid_synth_set_chorus_nr(), fluid_synth_set_chorus_level(), fluid_synth_set_chorus_speed(), fluid_synth_set_chorus_depth(), fluid_synth_set_chorus_type()


\section NewIn1_1_7 Whats new in 1.1.7?
Expand Down
16 changes: 12 additions & 4 deletions include/fluidsynth/shell.h
Expand Up @@ -63,11 +63,20 @@ typedef struct {
char* help; /**< A help string */
} fluid_cmd_t;

/* the shell cmd handler struct */
typedef struct {
fluid_synth_t* synth;
fluid_midi_router_t* router;
fluid_cmd_hash_t* commands;

fluid_midi_router_rule_t *cmd_rule; /* Rule currently being processed by shell command handler */
int cmd_rule_type; /* Type of the rule (#fluid_midi_router_rule_type) */
} fluid_cmd_handler_t;

/* The command handler */

FLUIDSYNTH_API
fluid_cmd_handler_t* new_fluid_cmd_handler(fluid_synth_t* synth);
fluid_cmd_handler_t* new_fluid_cmd_handler(fluid_synth_t* synth, fluid_midi_router_t* router);

FLUIDSYNTH_API
void delete_fluid_cmd_handler(fluid_cmd_handler_t* handler);
Expand Down Expand Up @@ -112,12 +121,11 @@ FLUIDSYNTH_API void delete_fluid_shell(fluid_shell_t* shell);
* @param addr The IP address of the client (can be NULL)
* @return Should return a new command handler for the connection (new_fluid_cmd_handler()).
*/
typedef fluid_cmd_handler_t* (*fluid_server_newclient_func_t)(void* data, char* addr);
typedef fluid_cmd_handler_t* (*fluid_server_newclient_func_t)(void* data, char* addr, char* addr2);

FLUIDSYNTH_API
fluid_server_t* new_fluid_server(fluid_settings_t* settings,
fluid_server_newclient_func_t func,
void* data);
fluid_cmd_handler_t* handler);

FLUIDSYNTH_API void delete_fluid_server(fluid_server_t* server);

Expand Down
23 changes: 20 additions & 3 deletions include/fluidsynth/synth.h
Expand Up @@ -139,8 +139,19 @@ FLUIDSYNTH_API int fluid_synth_get_bank_offset(fluid_synth_t* synth, int sfont_i

/* Reverb */

FLUIDSYNTH_API void fluid_synth_set_reverb(fluid_synth_t* synth, double roomsize,
double damping, double width, double level);
/*
*
* Reverb
*
*/

FLUIDSYNTH_API int fluid_synth_set_reverb(fluid_synth_t* synth, double roomsize,
double damping, double width, double level);
FLUIDSYNTH_API int fluid_synth_set_reverb_roomsize(fluid_synth_t* synth, double roomsize);
FLUIDSYNTH_API int fluid_synth_set_reverb_damp(fluid_synth_t* synth, double damping);
FLUIDSYNTH_API int fluid_synth_set_reverb_width(fluid_synth_t* synth, double width);
FLUIDSYNTH_API int fluid_synth_set_reverb_level(fluid_synth_t* synth, double level);

FLUIDSYNTH_API void fluid_synth_set_reverb_on(fluid_synth_t* synth, int on);
FLUIDSYNTH_API double fluid_synth_get_reverb_roomsize(fluid_synth_t* synth);
FLUIDSYNTH_API double fluid_synth_get_reverb_damp(fluid_synth_t* synth);
Expand All @@ -163,8 +174,14 @@ enum fluid_chorus_mod {
FLUID_CHORUS_MOD_TRIANGLE = 1 /**< Triangle wave chorus modulation */
};

FLUIDSYNTH_API void fluid_synth_set_chorus(fluid_synth_t* synth, int nr, double level,
FLUIDSYNTH_API int fluid_synth_set_chorus(fluid_synth_t* synth, int nr, double level,
double speed, double depth_ms, int type);
FLUIDSYNTH_API int fluid_synth_set_chorus_nr(fluid_synth_t* synth, int nr);
FLUIDSYNTH_API int fluid_synth_set_chorus_level(fluid_synth_t* synth, double level);
FLUIDSYNTH_API int fluid_synth_set_chorus_speed(fluid_synth_t* synth, double speed);
FLUIDSYNTH_API int fluid_synth_set_chorus_depth(fluid_synth_t* synth, double depth_ms);
FLUIDSYNTH_API int fluid_synth_set_chorus_type(fluid_synth_t* synth, int type);

FLUIDSYNTH_API void fluid_synth_set_chorus_on(fluid_synth_t* synth, int on);
FLUIDSYNTH_API int fluid_synth_get_chorus_nr(fluid_synth_t* synth);
FLUIDSYNTH_API double fluid_synth_get_chorus_level(fluid_synth_t* synth);
Expand Down
2 changes: 1 addition & 1 deletion include/fluidsynth/types.h
Expand Up @@ -49,7 +49,7 @@ typedef struct _fluid_midi_event_t fluid_midi_event_t; /**< MIDI event
typedef struct _fluid_midi_driver_t fluid_midi_driver_t; /**< MIDI driver instance */
typedef struct _fluid_midi_router_t fluid_midi_router_t; /**< MIDI router instance */
typedef struct _fluid_midi_router_rule_t fluid_midi_router_rule_t; /**< MIDI router rule */
typedef struct _fluid_hashtable_t fluid_cmd_handler_t; /**< Command handler */
typedef struct _fluid_hashtable_t fluid_cmd_hash_t; /**< Command handler hash table */
typedef struct _fluid_shell_t fluid_shell_t; /**< Command shell */
typedef struct _fluid_server_t fluid_server_t; /**< TCP/IP shell server instance */
typedef struct _fluid_event_t fluid_event_t; /**< Sequencer event */
Expand Down

5 comments on commit cb036d2

@mawe42
Copy link
Member

@mawe42 mawe42 commented on cb036d2 Oct 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derselbst a quick question: as I'm currently doing the LADSPA cleanup and refactor, I also have to fix the 5 ladspa command handlers to use this new interface. I'm thinking of moving the command handling stuff to fluid_cmd.c, calling into functions in fluid_ladspa.c for the real work. Does that sound good to you?

@derselbst
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good point. Yes please do so. Also it seems that adjusting their signature was completely forgotten by this commit due to that error hiding cast in fluid_commands[]. Highly appreciated.

@mawe42
Copy link
Member

@mawe42 mawe42 commented on cb036d2 Oct 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll leave the source formatting for later after all, doing more of a refactor now. I guess it would be good to get this fixed sooner rather than later.

@derselbst
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No hurry, this commit is only on master, this has time until next major release (not this year, maybe next).

@mawe42
Copy link
Member

@mawe42 mawe42 commented on cb036d2 Oct 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's good to know, thanks! I'll take more time then and (try to) do it properly.

Please sign in to comment.