mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-02-23 04:10:59 +00:00
Merge pull request #222 from FluidSynth/cmd-handler
shell command handler decoupled
This commit is contained in:
commit
cb036d2023
11 changed files with 532 additions and 470 deletions
|
@ -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?
|
||||
|
|
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
@ -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);
|
||||
|
|
|
@ -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 */
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "fluidsynth_priv.h"
|
||||
|
||||
|
||||
void fluid_shell_settings(fluid_settings_t* settings);
|
||||
|
||||
|
||||
|
@ -32,50 +33,58 @@ int fluid_is_empty(char* a);
|
|||
char* fluid_expand_path(char* path, char* new_path, int len);
|
||||
|
||||
/** the handlers for the command lines */
|
||||
int fluid_handle_help(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_quit(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_noteon(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_noteoff(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_pitch_bend(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_pitch_bend_range(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_cc(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_prog(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_select(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_inst(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_channels(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_load(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_unload(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_reload(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_fonts(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_mstat(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_reverbpreset(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_reverbsetroomsize(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_reverbsetdamp(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_reverbsetwidth(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_reverbsetlevel(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_chorusnr(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_choruslevel(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_chorusspeed(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_chorusdepth(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_chorus(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_reverb(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_gain(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_interp(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_interpc(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_tuning(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_tune(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_settuning(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_resettuning(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_tunings(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_dumptuning(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_reset(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_help(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_quit(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_noteon(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_noteoff(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_pitch_bend(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_pitch_bend_range(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_cc(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_prog(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_select(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_inst(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_channels(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_load(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_unload(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_reload(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_fonts(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_mstat(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_reverbpreset(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_reverbsetroomsize(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_reverbsetdamp(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_reverbsetwidth(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_reverbsetlevel(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_chorusnr(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_choruslevel(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_chorusspeed(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_chorusdepth(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_chorus(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_reverb(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_gain(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_interp(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_interpc(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_tuning(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_tune(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_settuning(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_resettuning(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_tunings(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_dumptuning(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_reset(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_source(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_echo(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
|
||||
int fluid_handle_set(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_get(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_info(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_settings(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_set(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_get(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_info(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_settings(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
|
||||
int fluid_handle_router_clear(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_router_default(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_router_begin(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_router_end(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_router_chan(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_router_par1(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_handle_router_par2(fluid_cmd_handler_t* handler, int ac, char** av, fluid_ostream_t out);
|
||||
|
||||
|
||||
fluid_cmd_t* fluid_cmd_copy(fluid_cmd_t* cmd);
|
||||
|
|
|
@ -52,10 +52,6 @@ void print_usage(void);
|
|||
void print_help(fluid_settings_t *settings);
|
||||
void print_welcome(void);
|
||||
|
||||
#if !defined(MACINTOSH)
|
||||
static fluid_cmd_handler_t* newclient(void* data, char* addr);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* the globals
|
||||
*/
|
||||
|
@ -604,12 +600,6 @@ int main(int argc, char** argv)
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
cmd_handler = new_fluid_cmd_handler(synth);
|
||||
if (cmd_handler == NULL) {
|
||||
fprintf(stderr, "Failed to create the command handler\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* load the soundfonts (check that all non options are SoundFont or MIDI files) */
|
||||
for (i = arg1; i < argc; i++) {
|
||||
if (fluid_is_soundfont(argv[i]))
|
||||
|
@ -650,8 +640,6 @@ int main(int argc, char** argv)
|
|||
"will be available. You can access the synthesizer \n"
|
||||
"through the console.\n");
|
||||
} else {
|
||||
fluid_synth_set_midi_router(synth, router); /* Fixme, needed for command handler */
|
||||
// fluid_sequencer_register_fluidsynth(sequencer, synth);
|
||||
mdriver = new_fluid_midi_driver(
|
||||
settings,
|
||||
dump ? fluid_midi_dump_prerouter : fluid_midi_router_handle_midi_event,
|
||||
|
@ -665,17 +653,6 @@ int main(int argc, char** argv)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* run commands specified in config file */
|
||||
if (config_file != NULL) {
|
||||
fluid_source(cmd_handler, config_file);
|
||||
} else if (fluid_get_userconf(buf, sizeof(buf)*sizeof(buf[0])) != NULL) {
|
||||
fluid_source(cmd_handler, buf);
|
||||
} else if (fluid_get_sysconf(buf, sizeof(buf)*sizeof(buf[0])) != NULL) {
|
||||
fluid_source(cmd_handler, buf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* play the midi files, if any */
|
||||
for (i = arg1; i < argc; i++) {
|
||||
if ((argv[i][0] != '-') && fluid_is_midifile(argv[i])) {
|
||||
|
@ -709,10 +686,25 @@ int main(int argc, char** argv)
|
|||
fluid_player_play(player);
|
||||
}
|
||||
|
||||
cmd_handler = new_fluid_cmd_handler(synth, router);
|
||||
if (cmd_handler == NULL) {
|
||||
fprintf(stderr, "Failed to create the command handler\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* try to load the user or system configuration */
|
||||
if (config_file != NULL) {
|
||||
fluid_source(cmd_handler, config_file);
|
||||
} else if (fluid_get_userconf(buf, sizeof(buf)*sizeof(buf[0])) != NULL) {
|
||||
fluid_source(cmd_handler, buf);
|
||||
} else if (fluid_get_sysconf(buf, sizeof(buf)*sizeof(buf[0])) != NULL) {
|
||||
fluid_source(cmd_handler, buf);
|
||||
}
|
||||
|
||||
/* run the server, if requested */
|
||||
#if !defined(MACINTOSH)
|
||||
if (with_server) {
|
||||
server = new_fluid_server(settings, newclient, synth);
|
||||
server = new_fluid_server(settings, cmd_handler);
|
||||
if (server == NULL) {
|
||||
fprintf(stderr, "Failed to create the server.\n"
|
||||
"Continuing without it.\n");
|
||||
|
@ -720,7 +712,6 @@ int main(int argc, char** argv)
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef LASH_ENABLED
|
||||
if (enabled_lash)
|
||||
fluid_lash_create_thread (synth);
|
||||
|
@ -810,14 +801,6 @@ int main(int argc, char** argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if !defined(MACINTOSH)
|
||||
static fluid_cmd_handler_t* newclient(void* data, char* addr)
|
||||
{
|
||||
fluid_synth_t* synth = (fluid_synth_t*) data;
|
||||
return new_fluid_cmd_handler(synth);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* print_usage
|
||||
*/
|
||||
|
|
|
@ -42,10 +42,6 @@ struct _fluid_midi_router_t {
|
|||
void* event_handler_data; /* One arg for the callback */
|
||||
|
||||
int nr_midi_channels; /* For clipping the midi channel */
|
||||
|
||||
/* FIXME - If there are multiple command handlers, they will conflict! */
|
||||
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) */
|
||||
};
|
||||
|
||||
struct _fluid_midi_router_rule_t {
|
||||
|
@ -742,194 +738,6 @@ send_event:
|
|||
return ret_val;
|
||||
}
|
||||
|
||||
#define CHECK_VALID_ROUTER(_router, _out) \
|
||||
if (router == NULL) { \
|
||||
fluid_ostream_printf(out, "cannot execute router command without a midi router.\n"); \
|
||||
return FLUID_FAILED; \
|
||||
}
|
||||
|
||||
/* Command handler for "router_clear" command */
|
||||
int
|
||||
fluid_midi_router_handle_clear (fluid_synth_t* synth, int ac, char** av,
|
||||
fluid_ostream_t out)
|
||||
{
|
||||
fluid_midi_router_t *router = synth->midi_router;
|
||||
|
||||
if (ac != 0) {
|
||||
fluid_ostream_printf (out, "router_clear needs no arguments.\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
CHECK_VALID_ROUTER (router, out);
|
||||
|
||||
fluid_midi_router_clear_rules (router);
|
||||
|
||||
return FLUID_OK;
|
||||
}
|
||||
|
||||
/* Command handler for "router_default" command */
|
||||
int
|
||||
fluid_midi_router_handle_default(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out)
|
||||
{
|
||||
fluid_midi_router_t *router = synth->midi_router;
|
||||
|
||||
if (ac != 0) {
|
||||
fluid_ostream_printf(out, "router_default needs no arguments.\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
CHECK_VALID_ROUTER (router, out);
|
||||
|
||||
fluid_midi_router_set_default_rules (router);
|
||||
|
||||
return FLUID_OK;
|
||||
}
|
||||
|
||||
/* Command handler for "router_begin" command */
|
||||
int
|
||||
fluid_midi_router_handle_begin (fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out)
|
||||
{
|
||||
fluid_midi_router_t* router = synth->midi_router;
|
||||
|
||||
if (ac != 1) {
|
||||
fluid_ostream_printf (out, "router_begin requires [note|cc|prog|pbend|cpress|kpress]\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
CHECK_VALID_ROUTER (router, out);
|
||||
|
||||
if (FLUID_STRCMP (av[0], "note") == 0)
|
||||
router->cmd_rule_type = FLUID_MIDI_ROUTER_RULE_NOTE;
|
||||
else if (FLUID_STRCMP (av[0], "cc") == 0)
|
||||
router->cmd_rule_type = FLUID_MIDI_ROUTER_RULE_CC;
|
||||
else if (FLUID_STRCMP (av[0], "prog") == 0)
|
||||
router->cmd_rule_type = FLUID_MIDI_ROUTER_RULE_PROG_CHANGE;
|
||||
else if (FLUID_STRCMP (av[0], "pbend") == 0)
|
||||
router->cmd_rule_type = FLUID_MIDI_ROUTER_RULE_PITCH_BEND;
|
||||
else if (FLUID_STRCMP (av[0], "cpress") == 0)
|
||||
router->cmd_rule_type = FLUID_MIDI_ROUTER_RULE_CHANNEL_PRESSURE;
|
||||
else if (FLUID_STRCMP (av[0], "kpress") == 0)
|
||||
router->cmd_rule_type = FLUID_MIDI_ROUTER_RULE_KEY_PRESSURE;
|
||||
else
|
||||
{
|
||||
fluid_ostream_printf (out, "router_begin requires [note|cc|prog|pbend|cpress|kpress]\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
if (router->cmd_rule)
|
||||
delete_fluid_midi_router_rule (router->cmd_rule);
|
||||
|
||||
router->cmd_rule = new_fluid_midi_router_rule ();
|
||||
|
||||
if (!router->cmd_rule)
|
||||
return FLUID_FAILED;
|
||||
|
||||
return FLUID_OK;
|
||||
}
|
||||
|
||||
/* Command handler for "router_end" command */
|
||||
int
|
||||
fluid_midi_router_handle_end (fluid_synth_t* synth, int ac, char** av,
|
||||
fluid_ostream_t out)
|
||||
{
|
||||
fluid_midi_router_t* router = synth->midi_router;
|
||||
|
||||
if (ac != 0) {
|
||||
fluid_ostream_printf (out, "router_end needs no arguments.\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
CHECK_VALID_ROUTER (router, out);
|
||||
|
||||
if (!router->cmd_rule)
|
||||
{
|
||||
fluid_ostream_printf (out, "No active router_begin command.\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
/* Add the rule */
|
||||
if (fluid_midi_router_add_rule (router, router->cmd_rule, router->cmd_rule_type) != FLUID_OK)
|
||||
delete_fluid_midi_router_rule (router->cmd_rule); /* Free on failure */
|
||||
|
||||
router->cmd_rule = NULL;
|
||||
|
||||
return FLUID_OK;
|
||||
}
|
||||
|
||||
/* Command handler for "router_chan" command */
|
||||
int
|
||||
fluid_midi_router_handle_chan (fluid_synth_t* synth, int ac, char** av,
|
||||
fluid_ostream_t out)
|
||||
{
|
||||
fluid_midi_router_t* router = synth->midi_router;
|
||||
|
||||
if (ac != 4) {
|
||||
fluid_ostream_printf(out, "router_chan needs four args: min, max, mul, add.");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
CHECK_VALID_ROUTER (router, out);
|
||||
|
||||
if (!router->cmd_rule)
|
||||
{
|
||||
fluid_ostream_printf (out, "No active router_begin command.\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
fluid_midi_router_rule_set_chan (router->cmd_rule, atoi (av[0]), atoi (av[1]),
|
||||
atof (av[2]), atoi (av[3]));
|
||||
return FLUID_OK;
|
||||
}
|
||||
|
||||
/* Command handler for "router_par1" command */
|
||||
int
|
||||
fluid_midi_router_handle_par1 (fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out)
|
||||
{
|
||||
fluid_midi_router_t* router = synth->midi_router;
|
||||
|
||||
if (ac != 4) {
|
||||
fluid_ostream_printf(out, "router_par1 needs four args: min, max, mul, add.");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
CHECK_VALID_ROUTER (router, out);
|
||||
|
||||
if (!router->cmd_rule)
|
||||
{
|
||||
fluid_ostream_printf (out, "No active router_begin command.\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
fluid_midi_router_rule_set_param1 (router->cmd_rule, atoi (av[0]), atoi (av[1]),
|
||||
atof (av[2]), atoi (av[3]));
|
||||
return FLUID_OK;
|
||||
}
|
||||
|
||||
/* Command handler for "router_par2" command */
|
||||
int
|
||||
fluid_midi_router_handle_par2 (fluid_synth_t* synth, int ac, char** av,
|
||||
fluid_ostream_t out)
|
||||
{
|
||||
fluid_midi_router_t* router = synth->midi_router;
|
||||
|
||||
if (ac != 4) {
|
||||
fluid_ostream_printf(out, "router_par2 needs four args: min, max, mul, add.");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
CHECK_VALID_ROUTER (router, out);
|
||||
|
||||
if (!router->cmd_rule)
|
||||
{
|
||||
fluid_ostream_printf (out, "No active router_begin command.\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
fluid_midi_router_rule_set_param2 (router->cmd_rule, atoi (av[0]), atoi (av[1]),
|
||||
atof (av[2]), atoi (av[3]));
|
||||
return FLUID_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* MIDI event callback function to display event information to stdout
|
||||
* @param data MIDI router instance
|
||||
|
|
|
@ -28,12 +28,5 @@
|
|||
#include "fluid_midi.h"
|
||||
#include "fluid_sys.h"
|
||||
|
||||
int fluid_midi_router_handle_clear(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_midi_router_handle_default(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_midi_router_handle_begin(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_midi_router_handle_chan(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_midi_router_handle_par1(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_midi_router_handle_par2(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
int fluid_midi_router_handle_end(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3851,18 +3851,55 @@ fluid_synth_set_reverb_preset(fluid_synth_t* synth, int num)
|
|||
* @param damping Reverb damping value (0.0-1.0)
|
||||
* @param width Reverb width value (0.0-100.0)
|
||||
* @param level Reverb level value (0.0-1.0)
|
||||
* @return FLUID_OK on success, FLUID_FAILED otherwise
|
||||
*
|
||||
* @note Not realtime safe and therefore should not be called from synthesis
|
||||
* context at the risk of stalling audio output.
|
||||
*/
|
||||
void
|
||||
int
|
||||
fluid_synth_set_reverb(fluid_synth_t* synth, double roomsize, double damping,
|
||||
double width, double level)
|
||||
{
|
||||
fluid_synth_set_reverb_full (synth, FLUID_REVMODEL_SET_ALL,
|
||||
return fluid_synth_set_reverb_full (synth, FLUID_REVMODEL_SET_ALL,
|
||||
roomsize, damping, width, level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set reverb roomsize. See fluid_synth_set_reverb() for further info.
|
||||
* @return FLUID_OK on success, FLUID_FAILED otherwise
|
||||
*/
|
||||
int fluid_synth_set_reverb_roomsize(fluid_synth_t* synth, double roomsize)
|
||||
{
|
||||
return fluid_synth_set_reverb_full(synth, FLUID_REVMODEL_SET_ROOMSIZE, roomsize, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set reverb damping. See fluid_synth_set_reverb() for further info.
|
||||
* @return FLUID_OK on success, FLUID_FAILED otherwise
|
||||
*/
|
||||
int fluid_synth_set_reverb_damp(fluid_synth_t* synth, double damping)
|
||||
{
|
||||
return fluid_synth_set_reverb_full(synth, FLUID_REVMODEL_SET_DAMPING, 0, damping, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set reverb width. See fluid_synth_set_reverb() for further info.
|
||||
* @return FLUID_OK on success, FLUID_FAILED otherwise
|
||||
*/
|
||||
int fluid_synth_set_reverb_width(fluid_synth_t* synth, double width)
|
||||
{
|
||||
return fluid_synth_set_reverb_full(synth, FLUID_REVMODEL_SET_WIDTH, 0, 0, width, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set reverb level. See fluid_synth_set_reverb() for further info.
|
||||
* @return FLUID_OK on success, FLUID_FAILED otherwise
|
||||
*/
|
||||
int fluid_synth_set_reverb_level(fluid_synth_t* synth, double level)
|
||||
{
|
||||
return fluid_synth_set_reverb_full(synth, FLUID_REVMODEL_SET_LEVEL, 0, 0, 0, level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set one or more reverb parameters.
|
||||
* @param synth FluidSynth instance
|
||||
|
@ -3880,10 +3917,10 @@ int
|
|||
fluid_synth_set_reverb_full(fluid_synth_t* synth, int set, double roomsize,
|
||||
double damping, double width, double level)
|
||||
{
|
||||
int ret;
|
||||
fluid_return_val_if_fail (synth != NULL, FLUID_FAILED);
|
||||
|
||||
if (!(set & FLUID_REVMODEL_SET_ALL))
|
||||
set = FLUID_REVMODEL_SET_ALL;
|
||||
/* if non of the flags is set, fail */
|
||||
fluid_return_val_if_fail (set & FLUID_REVMODEL_SET_ALL, FLUID_FAILED);
|
||||
|
||||
/* Synth shadow values are set here so that they will be returned if querried */
|
||||
|
||||
|
@ -3901,12 +3938,13 @@ fluid_synth_set_reverb_full(fluid_synth_t* synth, int set, double roomsize,
|
|||
if (set & FLUID_REVMODEL_SET_LEVEL)
|
||||
fluid_atomic_float_set (&synth->reverb_level, level);
|
||||
|
||||
fluid_rvoice_eventhandler_push5(synth->eventhandler,
|
||||
/* finally enqueue an rvoice event to the mixer to actual update reverb */
|
||||
ret = fluid_rvoice_eventhandler_push5(synth->eventhandler,
|
||||
fluid_rvoice_mixer_set_reverb_params,
|
||||
synth->eventhandler->mixer, set,
|
||||
roomsize, damping, width, level, 0.0f);
|
||||
|
||||
FLUID_API_RETURN(FLUID_OK);
|
||||
FLUID_API_RETURN(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3990,7 +4028,8 @@ fluid_synth_set_chorus_on(fluid_synth_t* synth, int on)
|
|||
}
|
||||
|
||||
/**
|
||||
* Set chorus parameters.
|
||||
* Set chorus parameters. It should be turned on with fluid_synth_set_chorus_on().
|
||||
* Keep in mind, that the needed CPU time is proportional to 'nr'.
|
||||
* @param synth FluidSynth instance
|
||||
* @param nr Chorus voice count (0-99, CPU time consumption proportional to
|
||||
* this value)
|
||||
|
@ -3999,15 +4038,60 @@ fluid_synth_set_chorus_on(fluid_synth_t* synth, int on)
|
|||
* @param depth_ms Chorus depth (max value depends on synth sample rate,
|
||||
* 0.0-21.0 is safe for sample rate values up to 96KHz)
|
||||
* @param type Chorus waveform type (#fluid_chorus_mod)
|
||||
* @return FLUID_OK on success, FLUID_FAILED otherwise
|
||||
*/
|
||||
void
|
||||
fluid_synth_set_chorus(fluid_synth_t* synth, int nr, double level,
|
||||
int fluid_synth_set_chorus(fluid_synth_t* synth, int nr, double level,
|
||||
double speed, double depth_ms, int type)
|
||||
{
|
||||
fluid_synth_set_chorus_full (synth, FLUID_CHORUS_SET_ALL, nr, level, speed,
|
||||
return fluid_synth_set_chorus_full (synth, FLUID_CHORUS_SET_ALL, nr, level, speed,
|
||||
depth_ms, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the chorus voice count. See fluid_synth_set_chorus() for further info.
|
||||
* @return FLUID_OK on success, FLUID_FAILED otherwise
|
||||
*/
|
||||
int fluid_synth_set_chorus_nr(fluid_synth_t* synth, int nr)
|
||||
{
|
||||
return fluid_synth_set_chorus_full (synth, FLUID_CHORUS_SET_NR, nr, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the chorus level. See fluid_synth_set_chorus() for further info.
|
||||
* @return FLUID_OK on success, FLUID_FAILED otherwise
|
||||
*/
|
||||
int fluid_synth_set_chorus_level(fluid_synth_t* synth, double level)
|
||||
{
|
||||
return fluid_synth_set_chorus_full (synth, FLUID_CHORUS_SET_LEVEL, 0, level, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the chorus speed. See fluid_synth_set_chorus() for further info.
|
||||
* @return FLUID_OK on success, FLUID_FAILED otherwise
|
||||
*/
|
||||
int fluid_synth_set_chorus_speed(fluid_synth_t* synth, double speed)
|
||||
{
|
||||
return fluid_synth_set_chorus_full (synth, FLUID_CHORUS_SET_SPEED, 0, 0, speed, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the chorus depth. See fluid_synth_set_chorus() for further info.
|
||||
* @return FLUID_OK on success, FLUID_FAILED otherwise
|
||||
*/
|
||||
int fluid_synth_set_chorus_depth(fluid_synth_t* synth, double depth_ms)
|
||||
{
|
||||
return fluid_synth_set_chorus_full (synth, FLUID_CHORUS_SET_DEPTH, 0, 0, 0, depth_ms, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the chorus type. See fluid_synth_set_chorus() for further info.
|
||||
* @return FLUID_OK on success, FLUID_FAILED otherwise
|
||||
*/
|
||||
int fluid_synth_set_chorus_type(fluid_synth_t* synth, int type)
|
||||
{
|
||||
return fluid_synth_set_chorus_full (synth, FLUID_CHORUS_SET_TYPE, 0, 0, 0, 0, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set one or more chorus parameters.
|
||||
* @param synth FluidSynth instance
|
||||
|
@ -4019,15 +4103,16 @@ fluid_synth_set_chorus(fluid_synth_t* synth, int nr, double level,
|
|||
* @param depth_ms Chorus depth (max value depends on synth sample rate,
|
||||
* 0.0-21.0 is safe for sample rate values up to 96KHz)
|
||||
* @param type Chorus waveform type (#fluid_chorus_mod)
|
||||
* @return FLUID_OK on success, FLUID_FAILED otherwise
|
||||
*/
|
||||
int
|
||||
fluid_synth_set_chorus_full(fluid_synth_t* synth, int set, int nr, double level,
|
||||
double speed, double depth_ms, int type)
|
||||
{
|
||||
int ret;
|
||||
fluid_return_val_if_fail (synth != NULL, FLUID_FAILED);
|
||||
|
||||
if (!(set & FLUID_CHORUS_SET_ALL))
|
||||
set = FLUID_CHORUS_SET_ALL;
|
||||
/* if non of the flags is set, fail */
|
||||
fluid_return_val_if_fail (set & FLUID_CHORUS_SET_ALL, FLUID_FAILED);
|
||||
|
||||
/* Synth shadow values are set here so that they will be returned if queried */
|
||||
fluid_synth_api_enter(synth);
|
||||
|
@ -4047,12 +4132,12 @@ fluid_synth_set_chorus_full(fluid_synth_t* synth, int set, int nr, double level,
|
|||
if (set & FLUID_CHORUS_SET_TYPE)
|
||||
fluid_atomic_int_set (&synth->chorus_type, type);
|
||||
|
||||
fluid_rvoice_eventhandler_push5(synth->eventhandler,
|
||||
ret = fluid_rvoice_eventhandler_push5(synth->eventhandler,
|
||||
fluid_rvoice_mixer_set_chorus_params,
|
||||
synth->eventhandler->mixer, set,
|
||||
nr, level, speed, depth_ms, type);
|
||||
|
||||
FLUID_API_RETURN(FLUID_OK);
|
||||
FLUID_API_RETURN(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4878,23 +4963,6 @@ fluid_synth_get_gen(fluid_synth_t* synth, int chan, int param)
|
|||
FLUID_API_RETURN(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign a MIDI router to a synth.
|
||||
* @param synth FluidSynth instance
|
||||
* @param router MIDI router to assign to the synth
|
||||
*
|
||||
* @note This should only be done once and prior to using the synth.
|
||||
*/
|
||||
void
|
||||
fluid_synth_set_midi_router(fluid_synth_t* synth, fluid_midi_router_t* router)
|
||||
{
|
||||
fluid_return_if_fail (synth != NULL);
|
||||
fluid_synth_api_enter(synth);
|
||||
|
||||
synth->midi_router = router;
|
||||
fluid_synth_api_exit(synth);
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle MIDI event from MIDI router, used as a callback function.
|
||||
* @param data FluidSynth instance
|
||||
|
|
|
@ -162,7 +162,6 @@ struct _fluid_synth_t
|
|||
fluid_tuning_t*** tuning; /**< 128 banks of 128 programs for the tunings */
|
||||
fluid_private_t tuning_iter; /**< Tuning iterators per each thread */
|
||||
|
||||
fluid_midi_router_t* midi_router; /**< The midi router. Could be done nicer. */
|
||||
fluid_sample_timer_t* sample_timers; /**< List of timers triggered before a block is processed */
|
||||
unsigned int min_note_length_ticks; /**< If note-offs are triggered just after a note-on, they will be delayed */
|
||||
|
||||
|
|
Loading…
Reference in a new issue