libfluidsynth  1.1.8
Data Structures | Typedefs | Functions
shell.h File Reference

Command shell interface. More...

Data Structures

struct  fluid_cmd_t
 Shell command information structure. More...
 

Typedefs

typedef int(* fluid_cmd_func_t) (void *data, int ac, char **av, fluid_ostream_t out)
 Command handler function prototype. More...
 
typedef fluid_cmd_handler_t *(* fluid_server_newclient_func_t) (void *data, char *addr)
 Callback function which is executed for new server connections. More...
 

Functions

FLUIDSYNTH_API fluid_istream_t fluid_get_stdin (void)
 Get standard in stream handle. More...
 
FLUIDSYNTH_API fluid_ostream_t fluid_get_stdout (void)
 Get standard output stream handle. More...
 
FLUIDSYNTH_API char * fluid_get_userconf (char *buf, int len)
 Get the user specific FluidSynth command file name. More...
 
FLUIDSYNTH_API char * fluid_get_sysconf (char *buf, int len)
 Get the system FluidSynth command file name. More...
 
FLUIDSYNTH_API fluid_cmd_handler_tnew_fluid_cmd_handler (fluid_synth_t *synth)
 Create a new command handler. More...
 
FLUIDSYNTH_API void delete_fluid_cmd_handler (fluid_cmd_handler_t *handler)
 Delete a command handler. More...
 
FLUIDSYNTH_API int fluid_cmd_handler_register (fluid_cmd_handler_t *handler, fluid_cmd_t *cmd)
 Register a new command to the handler. More...
 
FLUIDSYNTH_API int fluid_cmd_handler_unregister (fluid_cmd_handler_t *handler, const char *cmd)
 Unregister a command from a command handler. More...
 
FLUIDSYNTH_API int fluid_command (fluid_cmd_handler_t *handler, const char *cmd, fluid_ostream_t out)
 Process a string command. More...
 
FLUIDSYNTH_API int fluid_source (fluid_cmd_handler_t *handler, const char *filename)
 Execute shell commands in a file. More...
 
FLUIDSYNTH_API void fluid_usershell (fluid_settings_t *settings, fluid_cmd_handler_t *handler)
 A convenience function to create a shell interfacing to standard input/output console streams. More...
 
FLUIDSYNTH_API fluid_shell_tnew_fluid_shell (fluid_settings_t *settings, fluid_cmd_handler_t *handler, fluid_istream_t in, fluid_ostream_t out, int thread)
 Create a new FluidSynth command shell. More...
 
FLUIDSYNTH_API void delete_fluid_shell (fluid_shell_t *shell)
 Delete a FluidSynth command shell. More...
 
FLUIDSYNTH_API fluid_server_tnew_fluid_server (fluid_settings_t *settings, fluid_server_newclient_func_t func, void *data)
 Create a new TCP/IP command shell server. More...
 
FLUIDSYNTH_API void delete_fluid_server (fluid_server_t *server)
 Delete a TCP/IP shell server. More...
 
FLUIDSYNTH_API int fluid_server_join (fluid_server_t *server)
 Join a shell server thread (wait until it quits). More...
 

Detailed Description

Command shell interface.

The shell interface allows you to send simple textual commands to the synthesizer, to parse a command file, or to read commands from the stdin or other input streams.

Typedef Documentation

◆ fluid_cmd_func_t

typedef int(* fluid_cmd_func_t) (void *data, int ac, char **av, fluid_ostream_t out)

Command handler function prototype.

Parameters
dataUser defined data
acArgument count
avArray of string arguments
outOutput stream to send response to
Returns
Should return FLUID_OK on success, FLUID_FAILED otherwise

◆ fluid_server_newclient_func_t

typedef fluid_cmd_handler_t*(* fluid_server_newclient_func_t) (void *data, char *addr)

Callback function which is executed for new server connections.

Parameters
dataUser defined data supplied in call to new_fluid_server()
addrThe IP address of the client (can be NULL)
Returns
Should return a new command handler for the connection (new_fluid_cmd_handler()).

Function Documentation

◆ fluid_get_stdin()

FLUIDSYNTH_API fluid_istream_t fluid_get_stdin ( void  )

Get standard in stream handle.

Returns
Standard in stream.

Referenced by delete_fluid_shell(), fluid_get_stdout(), and fluid_usershell().

◆ fluid_get_stdout()

FLUIDSYNTH_API fluid_ostream_t fluid_get_stdout ( void  )

Get standard output stream handle.

Returns
Standard out stream.

References FLUID_DBG, FLUID_ERR, fluid_get_stdin(), and FLUID_OK.

Referenced by fluid_source(), and fluid_usershell().

◆ fluid_get_userconf()

FLUIDSYNTH_API char* fluid_get_userconf ( char *  buf,
int  len 
)

Get the user specific FluidSynth command file name.

Parameters
bufCaller supplied string buffer to store file name to.
lenLength of buf
Returns
Returns buf pointer or NULL if no user command file for this system type.

◆ fluid_get_sysconf()

FLUIDSYNTH_API char* fluid_get_sysconf ( char *  buf,
int  len 
)

◆ new_fluid_cmd_handler()

FLUIDSYNTH_API fluid_cmd_handler_t* new_fluid_cmd_handler ( fluid_synth_t synth)

Create a new command handler.

Parameters
synthIf not NULL, all the default synthesizer commands will be added to the new handler.
Returns
New command handler

References fluid_cmd_t::data, fluid_cmd_handler_register(), and fluid_cmd_t::name.

◆ delete_fluid_cmd_handler()

FLUIDSYNTH_API void delete_fluid_cmd_handler ( fluid_cmd_handler_t handler)

Delete a command handler.

Parameters
handlerCommand handler to delete

◆ fluid_cmd_handler_register()

FLUIDSYNTH_API int fluid_cmd_handler_register ( fluid_cmd_handler_t handler,
fluid_cmd_t cmd 
)

Register a new command to the handler.

Parameters
handlerCommand handler instance
cmdCommand info (gets copied)
Returns
FLUID_OK if command was inserted, FLUID_FAILED otherwise

References FLUID_OK, and fluid_cmd_t::name.

Referenced by new_fluid_cmd_handler().

◆ fluid_cmd_handler_unregister()

FLUIDSYNTH_API int fluid_cmd_handler_unregister ( fluid_cmd_handler_t handler,
const char *  cmd 
)

Unregister a command from a command handler.

Parameters
handlerCommand handler instance
cmdName of the command
Returns
TRUE if command was found and unregistered, FALSE otherwise

References fluid_cmd_t::data, and fluid_cmd_t::handler.

◆ fluid_command()

FLUIDSYNTH_API int fluid_command ( fluid_cmd_handler_t handler,
const char *  cmd,
fluid_ostream_t  out 
)

Process a string command.

NOTE: FluidSynth 1.0.8 and above no longer modifies the 'cmd' string.

Parameters
handlerFluidSynth command handler
cmdCommand string (NOTE: Gets modified by FluidSynth prior to 1.0.8)
outOutput stream to display command response to
Returns
Integer value corresponding to: -1 on command error, 0 on success, 1 if 'cmd' is a comment or is empty and -2 if quit was issued

Referenced by delete_fluid_shell().

◆ fluid_source()

FLUIDSYNTH_API int fluid_source ( fluid_cmd_handler_t handler,
const char *  filename 
)

Execute shell commands in a file.

Parameters
handlerCommand handler callback
filenameFile name
Returns
0 on success, a value >1 on error

References fluid_get_stdout().

◆ fluid_usershell()

FLUIDSYNTH_API void fluid_usershell ( fluid_settings_t settings,
fluid_cmd_handler_t handler 
)

A convenience function to create a shell interfacing to standard input/output console streams.

Parameters
settingsSettings instance for the shell
handlerCommand handler callback

References fluid_get_stdin(), and fluid_get_stdout().

◆ new_fluid_shell()

FLUIDSYNTH_API fluid_shell_t* new_fluid_shell ( fluid_settings_t settings,
fluid_cmd_handler_t handler,
fluid_istream_t  in,
fluid_ostream_t  out,
int  thread 
)

Create a new FluidSynth command shell.

Parameters
settingsSetting parameters to use with the shell
handlerCommand handler
inInput stream
outOutput stream
threadTRUE if shell should be run in a separate thread, FALSE to run it in the current thread (function blocks until "quit")
Returns
New shell instance or NULL on error

References delete_fluid_shell(), and FLUID_PANIC.

◆ delete_fluid_shell()

FLUIDSYNTH_API void delete_fluid_shell ( fluid_shell_t shell)

Delete a FluidSynth command shell.

Parameters
shellCommand shell instance

References fluid_command(), fluid_get_stdin(), and fluid_settings_dupstr().

Referenced by new_fluid_shell().

◆ new_fluid_server()

FLUIDSYNTH_API fluid_server_t* new_fluid_server ( fluid_settings_t settings,
fluid_server_newclient_func_t  newclient,
void *  data 
)

Create a new TCP/IP command shell server.

Parameters
settingsSettings instance to use for the shell
newclientCallback function to call for each new client connection
dataUser defined data to pass to newclient callback
Returns
New shell server instance or NULL on error

References FLUID_ERR, and fluid_settings_getint().

◆ delete_fluid_server()

FLUIDSYNTH_API void delete_fluid_server ( fluid_server_t server)

Delete a TCP/IP shell server.

Parameters
serverShell server instance

◆ fluid_server_join()

FLUIDSYNTH_API int fluid_server_join ( fluid_server_t server)

Join a shell server thread (wait until it quits).

Parameters
serverShell server instance
Returns
FLUID_OK on success, FLUID_FAILED otherwise

References FLUID_DBG, and FLUID_ERR.