Lots of code cleanup, bug fixes, added friendliness and release

worthiness.
This commit is contained in:
Element Green 2006-02-19 10:01:58 +00:00
parent c9193d8f81
commit 569ebd158c
21 changed files with 812 additions and 526 deletions

View File

@ -8,18 +8,21 @@
Many people contributed to FluidSynth, send suggestions or bug
fixes. The project was started by Peter Hanappe who is the main
author. Below you'll find a summery of contributions.
author. Josh Green is the current maintainer. Below you'll find a
summery of contributions.
* Peter Hanappe. Initiated the project. files: sticked his nose in all
files.
* Josh Green contributed a lot of code directly or indirectly through
the Swami and Smurf code base. The soundfont loader is
completely based on his code. He also wrote the alsa sequencer
driver. He made many changes and bug fixes, but above all, he's one
of the driver forces behind the synthesizer. files:
iiwu_defsfont.{c,h}, iiwu_alsa{c,h}.
* Josh Green is the current maintainer and contributed a lot of code
directly or indirectly through the Swami and Smurf code base.
The SoundFont loader is completely based on his code. He also wrote
the alsa sequencer driver. He made many changes and bug fixes,
but above all, he's one of the driver forces behind the synthesizer.
He also created the current FluidSynth graphic logo with Blender
(the blue waves with FluidSynth letters partially submerged).
files: iiwu_defsfont.{c,h}, iiwu_alsa{c,h} and others.
* Stephane Letz from Grame wrote most of the MidiShare driver, all of
the PortAudio driver, ported iiwusynth to MacOS X, and sent in many
@ -59,7 +62,7 @@ author. Below you'll find a summery of contributions.
(http://www.ircam.fr/jmax). The jMax code was based upon Ardour's
alsa_device.cc by Paul Barton-Davis. file: iiwu_alsa.c
* I copied code from the glib library to the smurf files. The goal was
* Code was borrowed from the glib library to the smurf files. The goal was
to make iiwusynth independent from any library for maximum
portability.
@ -79,7 +82,7 @@ author. Below you'll find a summery of contributions.
* Ebrahim Mayat made big efforts for compiling and running FluidSynth
on MacOS X. He also wrote the README-OSX file.
* I used Martin Uddén's midi package. His files are integrated into
* Martin Uddén's midi package was used. His files are integrated into
the iiwu_midi file. Martin Uddén <nanook@lysator.liu.se> file:
iiwu_midi.c
@ -87,17 +90,27 @@ author. Below you'll find a summery of contributions.
adapted version was integrated in the source code. files:
fluid_cmd.c, fluidsynth/synth.h, fluid_synth.c.
* I copied some interpolation algorihms that I found in the music-dsp
archives (http://www.smartelectronix.com/musicdsp). They were
written by Joshua Scholar and others. file: iiwu_synth.c
* Some interpolation algorihms were used that were found in
the music-dsp archives (http://www.smartelectronix.com/musicdsp).
They were written by Joshua Scholar and others. file: iiwu_synth.c
* Bug fixes and corrections where sent in by: Werner Schweer, Dave
Philips, Anthony
Green, Jake Commander, Fernando Pablo Lopez-Lezcano, Raoul
Bonisch, Sergey Pavlishin, Eric Van Buggenhaut, Ken Ellinwood,
Takashi Iwai, Bob Ham, Gerald Pye, Rui Nuno Capela
* I copied the macros to {increment,decrement} the 64-bit fixed point
phase from Mozilla's macros to handle the Long-long type (64-bit
* Macros to {increment,decrement} the 64-bit fixed point phase were
borrowed from Mozilla's macros to handle the Long-long type (64-bit
signed integer type). Mozilla NSPR library, www.mozilla.org. file:
iiwu_phase.h
* Growing list of individuals who contributed bug fixes and corrections:
Werner Schweer
Dave Philips
Anthony Green
Jake Commander
Fernando Pablo Lopez-Lezcano
Raoul Bonisch
Sergey Pavlishin
Eric Van Buggenhaut
Ken Ellinwood
Takashi Iwai
Bob Ham
Gerald Pye
Rui Nuno Capela
Frieder Bürzele

View File

@ -1,3 +1,30 @@
2006-02-18 Josh Green <jgreen@users.sourceforge.net>
* FluidSynth release 1.0.7 "Increasing Fluidity.."
* Removed spurious newlines from FLUID_LOG statements throughout.
* AUTHORS: Some cleanup and additions.
* src/fluid_lash.[ch]: Moved LADCCA related code from fluidsynth.c here
and added new LASH support (both old LADCCA and LASH are supported
exclusively). Used patches sent by Frieder Bürzele as a guide.
* src/fluidsynth.c: Removed LADCCA code (now in fluid_lash.c),
re-organized command line parsing and removed duplicate WIN32 switch
statement, re-organized help output and added missing entries, added
"-o help" switch for listing settings, welcome message now printed
whenever FluidSynth is run and simplified,
(print_usage): hard coded application name as "fluidsynth".
* src/configure.ac: Changed --enable-SSE option to --enable-broken-SSE
and --enable-SSE now just displays a fat warning about not using it.
* src/fluid_jack.c: Warning is now displayed if synth sample rate
doesn't match jackd.
* src/fluid_alsa.c: Added detection for ALSA sequencer buffer overrun
(-ENOSPC) and interrupted poll() call (-1??).
* src/fluid_voice.c: Applied patch from Henri Manson which adds a
fluid_ct2hz_real() function which does not have the filter cutoff
limits that fluid_ct2hz() does, new function being used for
calculations that may include non-audible frequencies.
* src/fluid_dsound.c: Applied patch from Henri Manson which
only creates the directsound window once.
2005-09-04 Josh Green <jgreen@users.sourceforge.net>
* src/fluid_ramsfont.c (fluid_ramsfont_remove_izone): Applied crash bug

View File

@ -8,7 +8,7 @@ dnl *** NOTE *** Don't forget to update library version below also
FLUIDSYNTH_VERSION_MAJOR=1
FLUIDSYNTH_VERSION_MINOR=0
FLUIDSYNTH_VERSION_MICRO=6
FLUIDSYNTH_VERSION_MICRO=7
FLUIDSYNTH_VERSION=$FLUIDSYNTH_VERSION_MAJOR.$FLUIDSYNTH_VERSION_MINOR.$FLUIDSYNTH_VERSION_MICRO
AC_SUBST(FLUIDSYNTH_VERSION_MAJOR)
@ -29,7 +29,7 @@ dnl if any interfaces have been added: LT_AGE++
dnl if any interfaces have been removed/changed (compatibility broken): LT_AGE=0
LT_CURRENT=2
LT_REVISION=0
LT_REVISION=1
LT_AGE=1
LT_VERSION_INFO="${LT_CURRENT}:${LT_REVISION}:${LT_AGE}"
@ -107,14 +107,19 @@ if test "x$longlong" = "xyes" ; then
AC_DEFINE(USE_LONGLONG, 1, [Define to use long long type, where appropriate])
fi
AC_ARG_ENABLE(SSE, AS_HELP_STRING([--enable-SSE],
[Use SSE instructions of Pentium3+ (not recommended)]),
AC_ARG_ENABLE(broken-SSE, AS_HELP_STRING([--enable-broken-SSE],
[Use SSE instructions (not recommended and probably broken)]),
SSE=$enableval,
SSE=no)
if test "x$SSE" = "xyes" ; then
AC_DEFINE(ENABLE_SSE, 1, [Use the SSE instructions of Pentium3+ (not recommended)])
fi
AC_ARG_ENABLE(SSE, AS_HELP_STRING([--enable-SSE],
[Does nothing currently but tell you that this option is no more.]),
DUMMY_SSE=$enableval,
DUMMY_SSE=no)
AC_ARG_ENABLE(ladspa, AS_HELP_STRING([--enable-ladspa],
[Include LADSPA effect unit (default=no)]),
ENABLE_LADSPA=$enableval,
@ -291,14 +296,35 @@ if test "x${have_termcap}" = "xtrue"; then
fi
dnl
dnl ladcca stuff
dnl lash stuff
dnl
AC_ARG_ENABLE(lash, AS_HELP_STRING([--disable-lash],
[disable LASH support (default=auto)]),
fluid_enable_lash=$enableval,
fluid_enable_lash="yes")
if test "$fluid_enable_lash" = "yes"; then
PKG_CHECK_MODULES(LASH, lash-1.0 >= 0.3, LASH_FOUND="yes", LASH_FOUND="no")
AC_SUBST(LASH_CFLAGS)
AC_SUBST(LASH_LIBS)
if test "$LASH_FOUND" = "yes"; then
AC_DEFINE(HAVE_LASH, 1, [whether or not we are supporting lash])
fi
else
LASH_FOUND="no"
fi
AM_CONDITIONAL(LASH_SUPPORT, test "$LASH_FOUND" = "yes")
dnl
dnl ladcca stuff (depricated by lash and will be removed in the future)
dnl
AC_ARG_ENABLE(ladcca, AS_HELP_STRING([--disable-ladcca],
[disable LADCCA support (default=auto)]),
fluid_enable_ladcca=$enableval,
fluid_enable_ladcca="yes")
if test "$fluid_enable_ladcca" = "yes"; then
if test "$fluid_enable_ladcca" = "yes" -a "$LASH_FOUND" = "no"; then
PKG_CHECK_MODULES(LADCCA, ladcca-1.0 >= 0.3, LADCCA_FOUND="yes", LADCCA_FOUND="no")
AC_SUBST(LADCCA_CFLAGS)
AC_SUBST(LADCCA_LIBS)
@ -309,9 +335,7 @@ if test "$fluid_enable_ladcca" = "yes"; then
else
LADCCA_FOUND="no"
fi
AM_CONDITIONAL(LADCCA, test "$LADCCA_FOUND" = "yes")
AM_CONDITIONAL(LADCCA_SUPPORT, test "$LADCCA_FOUND" = "yes")
@ -371,6 +395,12 @@ else
echo "LADSPA support: no"
fi
if test "${LASH_FOUND}" = "yes"; then
echo "LASH support: yes"
else
echo "LASH support: no"
fi
if test "${LADCCA_FOUND}" = "yes"; then
echo "LADCCA support: yes"
else
@ -414,9 +444,14 @@ else
fi
if test "${SSE}" = "yes"; then
echo "Pentium 3+ SSE: yes (experimental and may actually decrease performance!)"
else
echo "Pentium 3+ SSE: no"
echo "Pentium 3+ SSE: yes (broken and may actually DECREASE performance!)"
fi
if test "${DUMMY_SSE}" = "yes"; then
echo "!!! --enable-SSE is no longer valid since the SSE implementation in !!!"
echo "!!! FluidSynth is currently rather broken. If you are a package !!!"
echo "!!! maintainer, please remove this switch! (Use --enable-broken-SSE !!!"
echo "!!! if you really want to end up with a broken FluidSynth :) !!!"
fi
echo "**************************************************************"

View File

@ -21,6 +21,16 @@ if OSS_SUPPORT
fluid_oss = fluid_oss.c
endif
# if LASH_SUPPORT || LADCCA_SUPPORT (Makefile supports OR?)
if LASH_SUPPORT
fluid_lash = fluid_lash.c
else
if LADCCA_SUPPORT
fluid_lash = fluid_lash.c
endif
endif
# Extra files and optional drivers
EXTRA_DIST = fluid_dll.c fluid_dsound.c fluid_winmidi.c fluid_portaudio.c \
fluid_coreaudio.c fluid_alsa.c fluid_oss.c fluid_dsp_core.c \
@ -35,6 +45,7 @@ libfluidsynth_la_SOURCES = \
$(fluid_alsa) \
$(fluid_coreaudio) \
$(fluid_jack) \
$(fluid_lash) \
$(fluid_oss) \
$(fluid_windows) \
fluid_adriver.c \
@ -59,6 +70,7 @@ libfluidsynth_la_SOURCES = \
fluid_io.h \
fluid_ladspa.c \
fluid_ladspa.h \
fluid_lash.h \
fluid_list.c \
fluid_list.h \
fluid_mdriver.c \
@ -93,11 +105,11 @@ libfluidsynth_la_SOURCES = \
fluid_voice.h \
fluid_aufile.c
INCLUDES = -I$(top_srcdir)/include $(LADCCA_CFLAGS) $(READLINE_CFLAGS) \
$(JACK_CFLAGS) $(ALSA_CFLAGS)
INCLUDES = -I$(top_srcdir)/include $(LASH_CFLAGS) $(LADCCA_CFLAGS) \
$(READLINE_CFLAGS) $(JACK_CFLAGS) $(ALSA_CFLAGS)
libfluidsynth_la_LIBADD = $(LIBFLUID_LIBS) $(LADCCA_LIBS) $(READLINE_LIBS) \
$(COREAUDIO_LIBS) $(JACK_LIBS) $(ALSA_LIBS)
libfluidsynth_la_LIBADD = $(LIBFLUID_LIBS) $(LASH_LIBS) $(LADCCA_LIBS) \
$(READLINE_LIBS) $(COREAUDIO_LIBS) $(JACK_LIBS) $(ALSA_LIBS)
libfluidsynth_la_LDFLAGS = \
-version-info @LT_VERSION_INFO@ \
-export-dynamic @FCLDFLAGS@ $(LIBFLUID_LDFLAGS)

View File

@ -33,6 +33,9 @@
/* whether or not we are supporting ladcca */
#undef HAVE_LADCCA
/* whether or not we are supporting lash */
#undef HAVE_LASH
/* Define to 1 if you have the `dl' library (-ldl). */
#undef HAVE_LIBDL

View File

@ -256,7 +256,7 @@ new_fluid_audio_driver(fluid_settings_t* settings, fluid_synth_t* synth)
for (i = 0; fluid_audio_drivers[i].name != NULL; i++) {
if (fluid_settings_str_equal(settings, "audio.driver", fluid_audio_drivers[i].name)) {
FLUID_LOG(FLUID_DBG, "Using '%s' audio driver\n", fluid_audio_drivers[i].name);
FLUID_LOG(FLUID_DBG, "Using '%s' audio driver", fluid_audio_drivers[i].name);
driver = (*fluid_audio_drivers[i].new)(settings, synth);
if (driver) {
driver->name = fluid_audio_drivers[i].name;
@ -281,7 +281,7 @@ new_fluid_audio_driver2(fluid_settings_t* settings, fluid_audio_func_t func, voi
for (i = 0; fluid_audio_drivers[i].name != NULL; i++) {
if (fluid_settings_str_equal(settings, "audio.driver", fluid_audio_drivers[i].name) &&
(fluid_audio_drivers[i].new2 != NULL)) {
FLUID_LOG(FLUID_DBG, "Using '%s' audio driver\n", fluid_audio_drivers[i].name);
FLUID_LOG(FLUID_DBG, "Using '%s' audio driver", fluid_audio_drivers[i].name);
driver = (*fluid_audio_drivers[i].new2)(settings, func, data);
if (driver) {
driver->name = fluid_audio_drivers[i].name;

View File

@ -42,12 +42,7 @@
#include "config.h"
#ifdef HAVE_LADCCA
#include <ladcca/ladcca.h>
extern cca_client_t * fluid_cca_client;
#endif /* HAVE_LADCCA */
#include "fluid_lash.h"
#define FLUID_ALSA_DEFAULT_MIDI_DEVICE "default"
#define FLUID_ALSA_DEFAULT_SEQ_DEVICE "default"
@ -290,7 +285,7 @@ new_fluid_alsa_audio_driver2(fluid_settings_t* settings,
goto error_recovery;
}
FLUID_LOG(FLUID_INFO, "ALSA driver: Using format %s\n", fluid_alsa_formats[i].name);
FLUID_LOG(FLUID_INFO, "ALSA driver: Using format %s", fluid_alsa_formats[i].name);
/* Set the software params */
snd_pcm_sw_params_current(dev->pcm, swparams);
@ -964,17 +959,15 @@ new_fluid_alsa_seq_driver(fluid_settings_t* settings,
}
}
/* tell the ladcca server our client id */
#ifdef HAVE_LADCCA
/* tell the lash server our client id */
#ifdef LASH_ENABLED
{
int enable_ladcca = 0;
fluid_settings_getint (settings, "ladcca.enable", &enable_ladcca);
if (enable_ladcca)
cca_alsa_client_id (fluid_cca_client, snd_seq_client_id (dev->seq_handle));
int enable_lash = 0;
fluid_settings_getint (settings, "lash.enable", &enable_lash);
if (enable_lash)
fluid_lash_alsa_client_id (fluid_lash_client, snd_seq_client_id (dev->seq_handle));
}
#endif /* HAVE_LADCCA */
#endif /* LASH_ENABLED */
dev->status = FLUID_MIDI_READY;
@ -1141,9 +1134,17 @@ fluid_alsa_seq_run(void* d)
}
}
if ((n < 0) && (n != -EAGAIN)) {
FLUID_LOG(FLUID_ERR, "Error occured while reading ALSA sequencer events");
dev->status = FLUID_MIDI_DONE;
if (n < 0) /* Negative value indicates an error */
{
if (n == -EPERM) /* interrupted system call? */
;
else if (n != -ENOSPC) /* input event buffer overrun? */
FLUID_LOG(FLUID_WARN, "ALSA sequencer buffer overrun, lost events");
else
{
FLUID_LOG(FLUID_ERR, "Error occured while reading ALSA sequencer events (code=%d)", n);
dev->status = FLUID_MIDI_DONE;
}
}
}
pthread_exit(NULL);

View File

@ -104,7 +104,7 @@ new_fluid_file_audio_driver(fluid_settings_t* settings,
dev->file = fopen(filename, "wb");
if (dev->file == NULL) {
FLUID_LOG(FLUID_ERR, "Failed to open the file '%s'\n", filename);
FLUID_LOG(FLUID_ERR, "Failed to open the file '%s'", filename);
goto error_recovery;
}

View File

@ -49,7 +49,7 @@ void fluid_shell_settings(fluid_settings_t* settings)
fluid_cmd_t fluid_commands[] = {
{ "help", "general", (fluid_cmd_func_t) fluid_handle_help, NULL,
"help Print command summary. 'help help': Show more help topics" },
"help Command summary. 'help help' for more help topics" },
{ "quit", "general", (fluid_cmd_func_t) fluid_handle_quit, NULL,
"quit Quit the synthesizer" },
{ "noteon", "event", (fluid_cmd_func_t) fluid_handle_noteon, NULL,
@ -63,9 +63,9 @@ fluid_cmd_t fluid_commands[] = {
{ "select", "event", (fluid_cmd_func_t) fluid_handle_select, NULL,
"select chan sfont bank prog Combination of bank-select and program-change" },
{ "load", "general", (fluid_cmd_func_t) fluid_handle_load, NULL,
"load file [reset] [bank_offset] Load a SoundFont (reset=0|1, default 1; bank_offset=n, default 0)" },
"load file [reset] [bankofs] Load SoundFont (reset=0|1, def 1; bankofs=n, def 0)" },
{ "unload", "general", (fluid_cmd_func_t) fluid_handle_unload, NULL,
"unload id [reset] Unload the SoundFont with the specified ID (reset=0|1, default 1)"},
"unload id [reset] Unload SoundFont by ID (reset=0|1, default 1)"},
{ "reload", "general", (fluid_cmd_func_t) fluid_handle_reload, NULL,
"reload id Reload the SoundFont with the specified ID" },
{ "fonts", "general", (fluid_cmd_func_t) fluid_handle_fonts, NULL,
@ -116,7 +116,7 @@ fluid_cmd_t fluid_commands[] = {
{ "dumptuning", "tuning", (fluid_cmd_func_t) fluid_handle_dumptuning, NULL,
"dumptuning bank prog Print the pitch details of the tuning" },
{ "reset", "general", (fluid_cmd_func_t) fluid_handle_reset, NULL,
"reset Send a system reset (all notes off, reset controllers)" },
"reset System reset (all notes off, reset controllers)" },
{ "set", "settings", (fluid_cmd_func_t) fluid_handle_set, NULL,
"set name value Set the value of a controller or settings" },
{ "get", "settings", (fluid_cmd_func_t) fluid_handle_get, NULL,

View File

@ -31,7 +31,7 @@ int fluid_win32_create_window(void);
#ifndef FLUIDSYNTH_NOT_A_DLL
BOOL WINAPI DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
FLUID_LOG(FLUID_DBG, "DllMain\n");
FLUID_LOG(FLUID_DBG, "DllMain");
fluid_set_hinstance((void*) hModule);
fluid_win32_create_window();
return TRUE;
@ -42,7 +42,7 @@ void fluid_set_hinstance(void* hinstance)
{
if (fluid_hinstance == NULL) {
fluid_hinstance = (HINSTANCE) hinstance;
FLUID_LOG(FLUID_DBG, "DLL instance = %d\n", (int) fluid_hinstance);
FLUID_LOG(FLUID_DBG, "DLL instance = %d", (int) fluid_hinstance);
}
}
@ -96,4 +96,3 @@ HWND fluid_win32_get_window(void)
return fluid_wnd;
}
#endif

View File

@ -186,7 +186,7 @@ new_fluid_dsound_audio_driver(fluid_settings_t* settings, fluid_synth_t* synth)
print a warning. */
hr = IDirectSoundBuffer_SetFormat(dev->prim_buffer, dev->format);
if (hr != DS_OK) {
FLUID_LOG(FLUID_WARN, "Can't set format of primary sound buffer\n", fluid_win32_error(hr));
FLUID_LOG(FLUID_WARN, "Can't set format of primary sound buffer", fluid_win32_error(hr));
}
/* initialize the buffer description */
@ -215,7 +215,7 @@ new_fluid_dsound_audio_driver(fluid_settings_t* settings, fluid_synth_t* synth)
hr = IDirectSoundBuffer_Lock(dev->sec_buffer, 0, 0, (void*) &buf1, &bytes1, 0, 0, DSBLOCK_ENTIREBUFFER);
if ((hr != DS_OK) || (buf1 == NULL)) {
FLUID_LOG(FLUID_PANIC, "Failed to lock the audio buffer. Exiting.\n");
FLUID_LOG(FLUID_PANIC, "Failed to lock the audio buffer. Exiting.");
goto error_recovery;
}
@ -318,7 +318,7 @@ DWORD WINAPI fluid_dsound_audio_run(LPVOID lpParameter)
res = IDirectSoundBuffer_Lock(dev->sec_buffer, cur_position, bytes, (void*) &buf1, &bytes1, (void*) &buf2, &bytes2, 0);
if ((res != DS_OK) || (buf1 == NULL)) {
FLUID_LOG(FLUID_PANIC, "Failed to lock the audio buffer. System lockup might follow. Exiting.\n");
FLUID_LOG(FLUID_PANIC, "Failed to lock the audio buffer. System lockup might follow. Exiting.");
ExitProcess(0);
}

View File

@ -38,12 +38,7 @@
#include <jack/jack.h>
#include "config.h"
#ifdef HAVE_LADCCA
#include <ladcca/ladcca.h>
extern cca_client_t * fluid_cca_client;
#endif /* HAVE_LADCCA */
#include "fluid_lash.h"
/**************************************************************
@ -105,8 +100,9 @@ new_fluid_jack_audio_driver(fluid_settings_t* settings, fluid_synth_t* synth)
const char ** jack_ports;
char* client_name;
int autoconnect = 0;
int jack_srate;
double sample_rate;
dev = FLUID_NEW(fluid_jack_audio_driver_t);
if (dev == NULL) {
FLUID_LOG(FLUID_ERR, "Out of memory");
@ -141,7 +137,17 @@ new_fluid_jack_audio_driver(fluid_settings_t* settings, fluid_synth_t* synth)
(see below), you should rely on your own sample rate
callback (see above) for this value.
*/
FLUID_LOG(FLUID_DBG, "Jack engine sample rate: %lu\n", jack_get_sample_rate(dev->client));
jack_srate = jack_get_sample_rate(dev->client);
FLUID_LOG(FLUID_DBG, "Jack engine sample rate: %lu", jack_srate);
fluid_settings_getnum(settings, "synth.sample-rate", &sample_rate);
if ((int)sample_rate != jack_srate) {
/* There's currently no way to change the sampling rate of the
synthesizer after it's been created. */
FLUID_LOG(FLUID_WARN, "Jack sample rate mismatch, expect tuning issues"
" (synth.sample-rate=%lu, jackd=%lu)", (int)sample_rate, jack_srate);
}
if (!fluid_settings_str_equal(settings, "audio.jack.multi", "yes")) {
@ -228,15 +234,15 @@ new_fluid_jack_audio_driver(fluid_settings_t* settings, fluid_synth_t* synth)
goto error_recovery;
}
/* tell the ladcca server our client name */
#ifdef HAVE_LADCCA
/* tell the lash server our client name */
#ifdef LASH_ENABLED
{
int enable_ladcca = 0;
fluid_settings_getint (settings, "ladcca.enable", &enable_ladcca);
if (enable_ladcca)
cca_jack_client_name (fluid_cca_client, name);
int enable_lash = 0;
fluid_settings_getint (settings, "lash.enable", &enable_lash);
if (enable_lash)
fluid_lash_jack_client_name (fluid_lash_client, name);
}
#endif /* HAVE_LADCCA */
#endif /* LASH_ENABLED */
/* connect the ports. */
@ -326,7 +332,7 @@ new_fluid_jack_audio_driver2(fluid_settings_t* settings, fluid_audio_func_t func
(see below), you should rely on your own sample rate
callback (see above) for this value.
*/
FLUID_LOG(FLUID_DBG, "Jack engine sample rate: %lu\n", jack_get_sample_rate(dev->client));
FLUID_LOG(FLUID_DBG, "Jack engine sample rate: %lu", jack_get_sample_rate(dev->client));
fluid_settings_getint(settings, "audio.output-channels", &dev->num_output_ports);
fluid_settings_getint(settings, "audio.input-channels", &dev->num_input_ports);

300
fluidsynth/src/fluid_lash.c Normal file
View File

@ -0,0 +1,300 @@
/* FluidSynth - A Software Synthesizer
*
* Copyright (C) 2003 Peter Hanappe and others.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307, USA
*/
#include "fluid_lash.h"
#include "fluid_synth.h"
#include <unistd.h> /* for usleep() */
#include <sys/types.h>
#include <signal.h>
#include <string.h>
#include <errno.h>
#include <pthread.h>
static void fluid_lash_save (fluid_synth_t * synth);
static void fluid_lash_load (fluid_synth_t * synth, const char * filename);
static void *fluid_lash_run (void * data);
/*
* lash client - this symbol needs to be in the library else
* all clients would need a fluid_lash_client symbol.
*/
#ifdef HAVE_LASH
lash_client_t * fluid_lash_client;
#else
cca_client_t * fluid_lash_client;
#endif
static pthread_t fluid_lash_thread;
#ifdef HAVE_LASH
fluid_lash_args_t *
fluid_lash_extract_args (int * pargc, char *** pargv)
{
return lash_extract_args (pargc, pargv);
}
int
fluid_lash_connect (fluid_lash_args_t * args)
{
fluid_lash_client = lash_init (args, PACKAGE, LASH_Config_Data_Set | LASH_Terminal, LASH_PROTOCOL (2,0));
return fluid_lash_client && lash_enabled (fluid_lash_client);
}
void
fluid_lash_create_thread (fluid_synth_t * synth)
{
pthread_create (&fluid_lash_thread, NULL, fluid_lash_run, synth);
}
static void
fluid_lash_save (fluid_synth_t * synth)
{
int i;
int sfcount;
fluid_sfont_t * sfont;
lash_config_t * config;
char num[32];
sfcount = fluid_synth_sfcount (synth);
config = lash_config_new ();
lash_config_set_key (config, "soundfont count");
lash_config_set_value_int (config, sfcount);
lash_send_config (fluid_lash_client, config);
for (i = sfcount - 1; i >= 0; i--)
{
sfont = fluid_synth_get_sfont (synth, i);
config = lash_config_new ();
sprintf (num, "%d", i);
lash_config_set_key (config, num);
lash_config_set_value_string (config, sfont->get_name (sfont));
lash_send_config (fluid_lash_client, config);
}
}
static void
fluid_lash_load (fluid_synth_t * synth, const char * filename)
{
fluid_synth_sfload (synth, filename, 1);
}
static void *
fluid_lash_run (void * data)
{
lash_event_t * event;
lash_config_t * config;
fluid_synth_t * synth;
int done = 0;
int err;
int pending_restores = 0;
synth = (fluid_synth_t *) data;
while (!done)
{
while ( (event = lash_get_event (fluid_lash_client)) )
{
switch (lash_event_get_type (event))
{
case LASH_Save_Data_Set:
fluid_lash_save (synth);
lash_send_event (fluid_lash_client, event);
break;
case LASH_Restore_Data_Set:
lash_event_destroy (event);
break;
case LASH_Quit:
err = kill (getpid(), SIGQUIT);
if (err)
fprintf (stderr, "%s: error sending signal: %s",
__FUNCTION__, strerror (errno));
lash_event_destroy (event);
done = 1;
break;
case LASH_Server_Lost:
lash_event_destroy (event);
done = 1;
break;
default:
fprintf (stderr, "Recieved unknown LASH event of type %d\n", lash_event_get_type (event));
lash_event_destroy (event);
break;
}
}
while ( (config = lash_get_config (fluid_lash_client)) )
{
if (strcmp (lash_config_get_key (config), "soundfont count") == 0)
pending_restores = lash_config_get_value_int (config);
else
{
fluid_lash_load (synth, lash_config_get_value_string (config));
pending_restores--;
}
lash_config_destroy (config);
if (!pending_restores)
{
event = lash_event_new_with_type (LASH_Restore_Data_Set);
lash_send_event (fluid_lash_client, event);
}
}
usleep (10000);
}
return NULL;
}
#else /* depricated LADCCA support, will remove someday */
fluid_lash_args_t *
fluid_lash_extract_args (int * pargc, char *** pargv)
{
return cca_extract_args (pargc, pargv);
}
int
fluid_lash_connect (fluid_lash_args_t * args)
{
fluid_lash_client = cca_init (args, PACKAGE, CCA_Config_Data_Set | CCA_Terminal, CCA_PROTOCOL (2,0));
return fluid_lash_client && cca_enabled (fluid_lash_client);
}
void
fluid_lash_create_thread (fluid_synth_t * synth)
{
pthread_create (&fluid_lash_thread, NULL, fluid_lash_run, synth);
}
static void
fluid_lash_save (fluid_synth_t * synth)
{
int i;
int sfcount;
fluid_sfont_t * sfont;
cca_config_t * config;
char num[32];
sfcount = fluid_synth_sfcount (synth);
config = cca_config_new ();
cca_config_set_key (config, "soundfont count");
cca_config_set_value_int (config, sfcount);
cca_send_config (fluid_lash_client, config);
for (i = sfcount - 1; i >= 0; i--)
{
sfont = fluid_synth_get_sfont (synth, i);
config = cca_config_new ();
sprintf (num, "%d", i);
cca_config_set_key (config, num);
cca_config_set_value_string (config, sfont->get_name (sfont));
cca_send_config (fluid_lash_client, config);
}
}
static void
fluid_lash_load (fluid_synth_t * synth, const char * filename)
{
fluid_synth_sfload (synth, filename, 1);
}
/* LADCCA thread */
static void *
fluid_lash_run (void * data)
{
cca_event_t * event;
cca_config_t * config;
fluid_synth_t * synth;
int done = 0;
int err;
int pending_restores = 0;
synth = (fluid_synth_t *) data;
while (!done)
{
while ( (event = cca_get_event (fluid_lash_client)) )
{
switch (cca_event_get_type (event))
{
case CCA_Save_Data_Set:
fluid_lash_save (synth);
cca_send_event (fluid_lash_client, event);
break;
case CCA_Restore_Data_Set:
cca_event_destroy (event);
break;
case CCA_Quit:
err = kill (getpid(), SIGQUIT);
if (err)
fprintf (stderr, "%s: error sending signal: %s",
__FUNCTION__, strerror (errno));
cca_event_destroy (event);
done = 1;
break;
case CCA_Server_Lost:
cca_event_destroy (event);
done = 1;
break;
default:
fprintf (stderr, "Recieved unknown LADCCA event of type %d\n", cca_event_get_type (event));
cca_event_destroy (event);
break;
}
}
while ( (config = cca_get_config (fluid_lash_client)) )
{
if (strcmp (cca_config_get_key (config), "soundfont count") == 0)
pending_restores = cca_config_get_value_int (config);
else
{
fluid_lash_load (synth, cca_config_get_value_string (config));
pending_restores--;
}
cca_config_destroy (config);
if (!pending_restores)
{
event = cca_event_new_with_type (CCA_Restore_Data_Set);
cca_send_event (fluid_lash_client, event);
}
}
usleep (10000);
}
return NULL;
}
#endif /* #if HAVE_LASH #else */

View File

@ -0,0 +1,51 @@
/* FluidSynth - A Software Synthesizer
*
* Copyright (C) 2003 Peter Hanappe and others.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307, USA
*/
#include "config.h"
#if defined(HAVE_LASH) || defined(HAVE_LADCCA)
#include "fluid_synth.h"
#define LASH_ENABLED 1
#ifdef HAVE_LASH
#include <lash/lash.h>
extern lash_client_t * fluid_lash_client;
#define fluid_lash_args_t lash_args_t
#define fluid_lash_alsa_client_id lash_alsa_client_id
#define fluid_lash_jack_client_name lash_jack_client_name
#else /* old depricated LADCCA support which will be removed someday */
#include <ladcca/ladcca.h>
extern cca_client_t * fluid_lash_client;
#define fluid_lash_args_t cca_args_t
#define fluid_lash_alsa_client_id cca_alsa_client_id
#define fluid_lash_jack_client_name cca_jack_client_name
#endif
fluid_lash_args_t *fluid_lash_extract_args (int * pargc, char *** pargv);
int fluid_lash_connect (fluid_lash_args_t * args);
void fluid_lash_create_thread (fluid_synth_t * synth);
#endif /* defined(HAVE_LASH) || defined(HAVE_LADCCA) */

View File

@ -158,7 +158,7 @@ fluid_midi_driver_t* new_fluid_midi_driver(fluid_settings_t* settings, handle_mi
fluid_midi_driver_t* driver = NULL;
for (i = 0; fluid_midi_drivers[i].name != NULL; i++) {
if (fluid_settings_str_equal(settings, "midi.driver", fluid_midi_drivers[i].name)) {
FLUID_LOG(FLUID_DBG, "Using '%s' midi driver\n", fluid_midi_drivers[i].name);
FLUID_LOG(FLUID_DBG, "Using '%s' midi driver", fluid_midi_drivers[i].name);
driver = fluid_midi_drivers[i].new(settings, handler, event_handler_data);
if (driver) {
driver->name = fluid_midi_drivers[i].name;
@ -182,5 +182,3 @@ void delete_fluid_midi_driver(fluid_midi_driver_t* driver)
}
}
}

View File

@ -76,7 +76,7 @@ start_fluid_sndmgr_audio_driver(fluid_settings_t* settings,
dev->doubleCallbackProc = NewSndDoubleBackProc(fluid_sndmgr_callback);
/* the channel */
FLUID_LOG(FLUID_DBG, "FLUID-SndManager@2\n");
FLUID_LOG(FLUID_DBG, "FLUID-SndManager@2");
err = SndNewChannel(&channel, sampledSynth, initStereo, NULL);
if ((err != noErr) || (channel == NULL)) {
FLUID_LOG(FLUID_ERR, "Failed to allocate a sound channel (error %i)", err);
@ -84,7 +84,7 @@ start_fluid_sndmgr_audio_driver(fluid_settings_t* settings,
}
/* the double buffer struct */
FLUID_LOG(FLUID_DBG, "FLUID-SndManager@3\n");
FLUID_LOG(FLUID_DBG, "FLUID-SndManager@3");
doubleHeader = FLUID_NEW(SndDoubleBufferHeader2);
if (doubleHeader == NULL) {
FLUID_LOG(FLUID_PANIC, "Out of memory");
@ -101,14 +101,14 @@ start_fluid_sndmgr_audio_driver(fluid_settings_t* settings,
doubleHeader->dbhFormat = 0;
/* prepare dev */
FLUID_LOG(FLUID_DBG, "FLUID-SndManager@4\n");
FLUID_LOG(FLUID_DBG, "FLUID-SndManager@4");
dev->doubleHeader = doubleHeader;
dev->channel = channel;
dev->bufferFrameSize = buffer_size;
dev->bufferByteSize = buffer_size * 2 * 2;
/* the 2 doublebuffers */
FLUID_LOG(FLUID_DBG, "FLUID-SndManager@5\n");
FLUID_LOG(FLUID_DBG, "FLUID-SndManager@5");
for (i = 0; i < 2; i++) {
doubleBuffer = (SndDoubleBufferPtr) FLUID_MALLOC(sizeof(SndDoubleBuffer)
+ dev->bufferByteSize);
@ -124,7 +124,7 @@ start_fluid_sndmgr_audio_driver(fluid_settings_t* settings,
}
/* start */
FLUID_LOG(FLUID_DBG, "FLUID-SndManager@6\n");
FLUID_LOG(FLUID_DBG, "FLUID-SndManager@6");
err = SndPlayDoubleBuffer(channel, (SndDoubleBufferHeader *)doubleHeader);
if (err != noErr) {
@ -132,7 +132,7 @@ start_fluid_sndmgr_audio_driver(fluid_settings_t* settings,
return err;
}
FLUID_LOG(FLUID_DBG, "FLUID-SndManager@7\n");
FLUID_LOG(FLUID_DBG, "FLUID-SndManager@7");
return 0;
}

View File

@ -88,14 +88,6 @@ static fluid_revmodel_presets_t revmodel_preset[] = {
{ NULL, 0.0f, 0.0f, 0.0f, 0.0f }
};
/*
* ladcca client - this symbol needs to be in the library else
* all clients would need a fluid_cca_client symbol.
*/
#ifdef HAVE_LADCCA
cca_client_t * fluid_cca_client;
#endif
/***************************************************************
*
@ -2084,7 +2076,7 @@ void fluid_synth_kill_by_exclusive_class(fluid_synth_t* synth, fluid_voice_t* ne
return;
}
// FLUID_LOG(FLUID_INFO, "Voice belongs to exclusive class (class=%d, ignore_id=%d)\n", excl_class, ignore_ID);
// FLUID_LOG(FLUID_INFO, "Voice belongs to exclusive class (class=%d, ignore_id=%d)", excl_class, ignore_ID);
/* Kill all notes on the same channel with the same exclusive class */
@ -2113,7 +2105,7 @@ void fluid_synth_kill_by_exclusive_class(fluid_synth_t* synth, fluid_voice_t* ne
continue;
}
// FLUID_LOG(FLUID_INFO, "Releasing previous voice of exclusive class (class=%d, id=%d)\n",
// FLUID_LOG(FLUID_INFO, "Releasing previous voice of exclusive class (class=%d, id=%d)",
// (int)_GEN(existing_voice, GEN_EXCLUSIVECLASS), (int)fluid_voice_get_id(existing_voice));
fluid_voice_kill_excl(existing_voice);
@ -2162,7 +2154,7 @@ fluid_synth_sfload(fluid_synth_t* synth, const char* filename, int reset_presets
#endif
if (filename == NULL) {
FLUID_LOG(FLUID_ERR, "Invalid filename\n");
FLUID_LOG(FLUID_ERR, "Invalid filename");
return FLUID_FAILED;
}
@ -2187,7 +2179,7 @@ fluid_synth_sfload(fluid_synth_t* synth, const char* filename, int reset_presets
}
}
FLUID_LOG(FLUID_ERR, "Failed to load SoundFont \"%s\"\n", filename);
FLUID_LOG(FLUID_ERR, "Failed to load SoundFont \"%s\"", filename);
return -1;
}
@ -2199,7 +2191,7 @@ static int fluid_synth_sfunload_callback(void* data, unsigned int msec)
fluid_sfont_t* sfont = (fluid_sfont_t*) data;
int r = delete_fluid_sfont(sfont);
if (r == 0) {
printf("%s: %d: Deleted SoundFont\n", __FILE__, __LINE__);
FLUID_LOG(FLUID_DBG,"Unloaded SoundFont");
}
return r != 0;
}
@ -2238,7 +2230,7 @@ fluid_synth_sfunload(fluid_synth_t* synth, unsigned int id, int reset_presets)
#endif
if (!sfont) {
FLUID_LOG(FLUID_ERR, "No SoundFont with id = %d\n", id);
FLUID_LOG(FLUID_ERR, "No SoundFont with id = %d", id);
return FLUID_FAILED;
}
@ -2278,7 +2270,7 @@ int fluid_synth_sfreload(fluid_synth_t* synth, unsigned int id)
sfont = fluid_synth_get_sfont_by_id(synth, id);
if (!sfont) {
FLUID_LOG(FLUID_ERR, "No SoundFont with id = %d\n", id);
FLUID_LOG(FLUID_ERR, "No SoundFont with id = %d", id);
return FLUID_FAILED;
}
@ -2318,7 +2310,7 @@ int fluid_synth_sfreload(fluid_synth_t* synth, unsigned int id)
}
}
FLUID_LOG(FLUID_ERR, "Failed to load SoundFont \"%s\"\n", filename);
FLUID_LOG(FLUID_ERR, "Failed to load SoundFont \"%s\"", filename);
return -1;
}

View File

@ -219,11 +219,3 @@ void fluid_synth_remove_bank_offset(fluid_synth_t* synth, int sfont_id);
void fluid_synth_settings(fluid_settings_t* settings);
#endif /* _FLUID_SYNTH_H */
/*
* ladcca stuff
*/
#ifdef HAVE_LADCCA
#include <ladcca/ladcca.h>
extern cca_client_t * cca_client;
#endif

View File

@ -870,18 +870,18 @@ void fluid_profiling_print(void)
printf("fluid_profiling_print\n");
FLUID_LOG(FLUID_INFO, "Estimated CPU frequency: %.0f MHz\n", fluid_cpu_frequency);
FLUID_LOG(FLUID_INFO, "Estimated times: min/avg/max (micro seconds)\n");
FLUID_LOG(FLUID_INFO, "Estimated CPU frequency: %.0f MHz", fluid_cpu_frequency);
FLUID_LOG(FLUID_INFO, "Estimated times: min/avg/max (micro seconds)");
for (i = 0; i < FLUID_PROF_LAST; i++) {
if (fluid_profile_data[i].count > 0) {
FLUID_LOG(FLUID_INFO, "%s: %.3f/%.3f/%.3f\n",
FLUID_LOG(FLUID_INFO, "%s: %.3f/%.3f/%.3f",
fluid_profile_data[i].description,
fluid_profile_data[i].min,
fluid_profile_data[i].total / fluid_profile_data[i].count,
fluid_profile_data[i].max);
} else {
FLUID_LOG(FLUID_DBG, "%s: no profiling available\n", fluid_profile_data[i].description);
FLUID_LOG(FLUID_DBG, "%s: no profiling available", fluid_profile_data[i].description);
}
}
}

View File

@ -104,13 +104,13 @@ new_fluid_winmidi_driver(fluid_settings_t* settings,
(DWORD) fluid_winmidi_callback,
(DWORD) dev, CALLBACK_FUNCTION);
if (err != MMSYSERR_NOERROR) {
FLUID_LOG(FLUID_WARN, "Couldn't open MIDI input: %s (error %d)\n",
FLUID_LOG(FLUID_WARN, "Couldn't open MIDI input: %s (error %d)",
fluid_winmidi_input_error(err), err);
goto error_recovery;
}
if (midiInStart(dev->hmidiin) != MMSYSERR_NOERROR) {
FLUID_LOG(FLUID_ERR, "Failed to start the MIDI input. MIDI input not available.\n");
FLUID_LOG(FLUID_ERR, "Failed to start the MIDI input. MIDI input not available.");
goto error_recovery;
}

View File

@ -49,12 +49,7 @@
#include "signal.h"
#endif
#ifdef HAVE_LADCCA
#include <pthread.h>
#include <ladcca/ladcca.h>
static void * cca_run (void * data);
extern cca_client_t * fluid_cca_client;
#endif /* HAVE_LADCCA */
#include "fluid_lash.h"
#ifndef WITH_MIDI
#define WITH_MIDI 1
@ -70,24 +65,20 @@ extern cca_client_t * fluid_cca_client;
void print_usage(void);
void print_help(void);
void print_welcome(void);
void print_version(void);
static fluid_cmd_handler_t* newclient(void* data, char* addr);
/*
* the globals
*/
char* appname = NULL;
fluid_cmd_handler_t* cmd_handler = NULL;
/*
* macros to wrap readline functions
*/
int option_help = 0; /* set to 1 if "-o help" is specified */
/*
* support for the getopt function
*/
#if !defined(WIN32) && !defined(MACINTOSH)
#define GETOPT_SUPPORT 1
int getopt(int argc, char * const argv[], const char *optstring);
extern char *optarg;
extern int optind, opterr, optopt;
@ -108,7 +99,14 @@ void process_o_cmd_line_option(fluid_settings_t* settings, char* optarg){
break;
}
}
/* did user request list of settings */
if (strcmp (optarg, "help") == 0)
{
option_help = 1;
return;
}
/* At this point:
* optarg => "synth.polyphony"
* val => "16"
@ -132,6 +130,54 @@ void process_o_cmd_line_option(fluid_settings_t* settings, char* optarg){
}
}
static void
print_pretty_int (int i)
{
if (i == INT_MAX) printf ("MAXINT");
else if (i == INT_MIN) printf ("MININT");
else printf ("%d", i);
}
/* fluid_settings_foreach function for displaying option help "-o help" */
static void
settings_foreach_func (void *data, char *name, int type)
{
fluid_settings_t *settings = (fluid_settings_t *)data;
double dmin, dmax, ddef;
int imin, imax, idef;
char *defstr;
switch (type)
{
case FLUID_NUM_TYPE:
fluid_settings_getnum_range (settings, name, &dmin, &dmax);
ddef = fluid_settings_getnum_default (settings, name);
printf ("%-24s FLOAT [min=%0.3f, max=%0.3f, def=%0.3f]\n",
name, dmin, dmax, ddef);
break;
case FLUID_INT_TYPE:
fluid_settings_getint_range (settings, name, &imin, &imax);
idef = fluid_settings_getint_default (settings, name);
printf ("%-24s INT [min=", name);
print_pretty_int (imin);
printf (", max=");
print_pretty_int (imax);
printf (", def=");
print_pretty_int (idef);
printf ("]\n");
break;
case FLUID_STR_TYPE:
defstr = fluid_settings_getstr_default (settings, name);
printf ("%-24s STR", name);
if (defstr) printf (" [def='%s']\n", defstr);
else printf ("\n");
break;
case FLUID_SET_TYPE:
printf ("%-24s SET\n", name);
break;
}
}
#ifdef HAVE_SIGNAL_H
/*
@ -163,121 +209,103 @@ int main(int argc, char** argv)
char* midi_id = NULL;
char* midi_driver = NULL;
char* midi_device = NULL;
char* file = NULL;
char* config_file = NULL;
int audio_groups = 0;
int audio_channels = 0;
int with_server = 0;
int dump = 0;
int ladcca_connect = 1;
#ifdef HAVE_LADCCA
cca_args_t * cca_args;
pthread_t cca_thread;
int connect_lash = 1;
char *optchars = "a:C:c:df:G:g:hijK:L:lm:no:R:r:sVvz:";
#ifdef LASH_ENABLED
int enabled_lash = 0; /* set to TRUE if lash gets enabled */
fluid_lash_args_t *lash_args;
cca_args = cca_extract_args (&argc, &argv);
lash_args = fluid_lash_extract_args (&argc, &argv);
#endif
appname = argv[0];
settings = new_fluid_settings();
#if !defined(WIN32) && !defined(MACINTOSH)
/* handle command options. on posix machines only */
#ifdef GETOPT_SUPPORT /* pre section of GETOPT supported argument handling */
opterr = 0;
while (1) {
int option_index = 0;
static struct option long_options[] = {
{"no-midi-in", 0, 0, 'n'},
{"midi-driver", 1, 0, 'm'},
{"midi-channels", 1, 0, 'K'},
{"audio-driver", 1, 0, 'a'},
{"connect-jack-outputs", 0, 0, 'j'},
{"audio-channels", 1, 0, 'L'},
{"audio-groups", 1, 0, 'G'},
{"audio-bufsize", 1, 0, 'z'},
{"audio-bufcount", 1, 0, 'c'},
{"sample-rate", 1, 0, 'r'},
{"disable-ladcca", 1, 0, 'f'},
{"disable-ladcca", 0, 0, 'l'},
{"verbose", 0, 0, 'v'},
{"reverb", 1, 0, 'R'},
{"audio-bufsize", 1, 0, 'z'},
{"audio-channels", 1, 0, 'L'},
{"audio-driver", 1, 0, 'a'},
{"audio-groups", 1, 0, 'G'},
{"chorus", 1, 0, 'C'},
{"gain", 1, 0, 'g'},
{"server", 0, 0, 's'},
{"help", 0, 0, 'h'},
{"connect-jack-outputs", 0, 0, 'j'},
{"disable-lash", 0, 0, 'l'},
{"dump", 0, 0, 'd'},
{"gain", 1, 0, 'g'},
{"help", 0, 0, 'h'},
{"load-config", 1, 0, 'f'},
{"midi-channels", 1, 0, 'K'},
{"midi-driver", 1, 0, 'm'},
{"no-midi-in", 0, 0, 'n'},
{"no-shell", 0, 0, 'i'},
{"version", 0, 0, 'V'},
{"option", 1, 0, 'o'},
{"reverb", 1, 0, 'R'},
{"sample-rate", 1, 0, 'r'},
{"server", 0, 0, 's'},
{"verbose", 0, 0, 'v'},
{"version", 0, 0, 'V'},
{0, 0, 0, 0}
};
c = getopt_long(argc, argv, "vnixdhVsplf:m:K:L:M:a:A:s:z:c:R:C:r:G:o:g:j",
long_options, &option_index);
c = getopt_long(argc, argv, optchars, long_options, &option_index);
if (c == -1) {
break;
}
#else /* "pre" section to non getopt argument handling */
for (i = 1; i < argc; i++) {
char *optarg;
/* Skip non switch arguments (assume they are file names) */
if ((argv[i][0] != '-') || (argv[i][1] == '\0')) continue;
c = argv[i][1];
optarg = strchr (optchars, c); /* find the option character in optchars */
if (optarg && optarg[1] == ':') /* colon follows if switch argument expected */
{
if (++i >= argc)
{
printf ("Option -%c requires an argument\n", c);
print_usage();
exit(0);
}
else
{
optarg = argv[i];
if (optarg[0] == '-')
{
printf ("Expected argument to option -%c found switch instead\n", c);
print_usage();
exit(0);
}
}
}
else optarg = "";
#endif
switch (c) {
case 0:
#ifdef GETOPT_SUPPORT
case 0: /* shouldn't normally happen, a long option's flag is set to NULL */
printf ("option %s", long_options[option_index].name);
if (optarg) {
printf (" with arg %s", optarg);
}
printf ("\n");
break;
case 'm':
fluid_settings_setstr(settings, "midi.driver", optarg);
break;
#endif
case 'a':
fluid_settings_setstr(settings, "audio.driver", optarg);
break;
case 'j':
fluid_settings_setint(settings, "audio.jack.autoconnect", 1);
break;
case 'z':
fluid_settings_setint(settings, "audio.period-size", atoi(optarg));
break;
case 'c':
fluid_settings_setint(settings, "audio.periods", atoi(optarg));
break;
case 'g':
fluid_settings_setnum(settings, "synth.gain", atof(optarg));
break;
case 'r':
fluid_settings_setnum(settings, "synth.sample-rate", atof(optarg));
break;
case 'f':
file = optarg;
break;
case 'l': /* disable LADCCA */
ladcca_connect = 0;
break;
case 'L':
audio_channels = atoi(optarg);
fluid_settings_setint(settings, "synth.audio-channels", audio_channels);
break;
case 'G':
audio_groups = atoi(optarg);
break;
case 'K':
fluid_settings_setint(settings, "synth.midi-channels", atoi(optarg));
break;
case 'v':
fluid_settings_setstr(settings, "synth.verbose", "yes");
break;
case 'd':
fluid_settings_setstr(settings, "synth.dump", "yes");
dump = 1;
break;
case 'R':
if ((optarg != NULL) && ((strcmp(optarg, "0") == 0) || (strcmp(optarg, "no") == 0))) {
fluid_settings_setstr(settings, "synth.reverb.active", "no");
} else {
fluid_settings_setstr(settings, "synth.reverb.active", "yes");
}
break;
case 'C':
if ((optarg != NULL) && ((strcmp(optarg, "0") == 0) || (strcmp(optarg, "no") == 0))) {
fluid_settings_setstr(settings, "synth.chorus.active", "no");
@ -285,24 +313,74 @@ int main(int argc, char** argv)
fluid_settings_setstr(settings, "synth.chorus.active", "yes");
}
break;
case 'o':
process_o_cmd_line_option(settings, optarg);
case 'c':
fluid_settings_setint(settings, "audio.periods", atoi(optarg));
break;
case 'd':
fluid_settings_setstr(settings, "synth.dump", "yes");
dump = 1;
break;
case 'f':
config_file = optarg;
break;
case 'G':
audio_groups = atoi(optarg);
break;
case 'g':
fluid_settings_setnum(settings, "synth.gain", atof(optarg));
break;
case 'h':
print_help();
break;
case 'i':
interactive = 0;
break;
case 'j':
fluid_settings_setint(settings, "audio.jack.autoconnect", 1);
break;
case 'K':
fluid_settings_setint(settings, "synth.midi-channels", atoi(optarg));
break;
case 'L':
audio_channels = atoi(optarg);
fluid_settings_setint(settings, "synth.audio-channels", audio_channels);
break;
case 'l': /* disable LASH */
connect_lash = 0;
break;
case 'm':
fluid_settings_setstr(settings, "midi.driver", optarg);
break;
case 'n':
midi_in = 0;
break;
case 'i':
interactive = 0;
case 'o':
process_o_cmd_line_option(settings, optarg);
break;
case 'R':
if ((optarg != NULL) && ((strcmp(optarg, "0") == 0) || (strcmp(optarg, "no") == 0))) {
fluid_settings_setstr(settings, "synth.reverb.active", "no");
} else {
fluid_settings_setstr(settings, "synth.reverb.active", "yes");
}
break;
case 'r':
fluid_settings_setnum(settings, "synth.sample-rate", atof(optarg));
break;
case 's':
with_server = 1;
break;
case 'V':
print_version(); /* and don't come back */
printf("FluidSynth %s\n", VERSION);
exit (0);
break;
case 'h':
print_help();
case 'v':
fluid_settings_setstr(settings, "synth.verbose", "yes");
break;
case 'z':
fluid_settings_setint(settings, "audio.period-size", atoi(optarg));
break;
#ifdef GETOPT_SUPPORT
case '?':
printf ("Unknown option %c\n", optopt);
print_usage();
@ -310,147 +388,43 @@ int main(int argc, char** argv)
break;
default:
printf ("?? getopt returned character code 0%o ??\n", c);
}
}
break;
#else /* Non getopt default case */
default:
printf ("Unknown switch '%c'\n", c);
print_usage();
exit(0);
break;
#endif
} /* end of switch statement */
} /* end of loop */
#ifdef GETOPT_SUPPORT
arg1 = optind;
#else
for (i = 1; i < argc; i++) {
char *optarg;
if ((argv[i][0] == '-') && (argv[i][1] != '\0')) {
switch (argv[i][1]) {
case 'm':
if (++i < argc) {
fluid_settings_setstr(settings, "midi.driver", argv[i]);
} else {
printf ("Option -m requires an argument\n");
}
break;
case 'a':
if (++i < argc) {
fluid_settings_setstr(settings, "audio.driver", argv[i]);
} else {
printf ("Option -a requires an argument\n");
}
break;
case 'j':
fluid_settings_setint(settings, "audio.jack.autoconnect", 1);
break;
case 'z':
if (++i < argc) {
fluid_settings_setnum(settings, "audio.period-size", atof(argv[i]));
} else {
printf ("Option -z requires an argument\n");
}
break;
case 'c':
if (++i < argc) {
fluid_settings_setnum(settings, "audio.periods", atof(argv[i]));
} else {
printf ("Option -c requires an argument\n");
}
break;
case 'g':
if (++i < argc) {
fluid_settings_setnum(settings, "synth.gain", atof(argv[i]));
} else {
printf ("Option -g requires an argument\n");
}
break;
case 'r':
if (++i < argc) {
fluid_settings_setnum(settings, "synth.sample-rate", atof(argv[i]));
} else {
printf ("Option -r requires an argument\n");
}
break;
case 'f':
if (++i < argc) {
file = argv[i];
}
break;
case 'l': /* disable LADCCA */
ladcca_connect = 0;
break;
case 'L':
if (++i < argc) {
audio_channels = atoi(argv[i]);
fluid_settings_setint(settings, "synth.audio-channels", audio_channels);
} else {
printf ("Option -L requires an argument\n");
}
break;
case 'G':
audio_groups = atoi(optarg);
break;
case 'K':
if (++i < argc) {
fluid_settings_setint(settings, "synth.midi-channels", atoi(argv[i]));
} else {
printf ("Option -K requires an argument\n");
}
break;
case 'v':
fluid_settings_setstr(settings, "synth.verbose", "yes");
break;
case 'R':
optarg = (++i < argc)? argv[i] : NULL;
if ((optarg != NULL) && ((strcmp(optarg, "0") == 0) || (strcmp(optarg, "no") == 0))) {
fluid_settings_setstr(settings, "synth.reverb.active", "no");
} else {
fluid_settings_setstr(settings, "synth.reverb.active", "yes");
}
break;
case 'C':
optarg = (++i < argc)? argv[i] : NULL;
if ((optarg != NULL) && ((strcmp(optarg, "0") == 0) || (strcmp(optarg, "no") == 0))) {
fluid_settings_setstr(settings, "synth.chorus.active", "no");
} else {
fluid_settings_setstr(settings, "synth.chorus.active", "yes");
}
break;
case 'o':
process_o_cmd_line_option(settings, optarg);
break;
case 'n':
midi_in = 0;
break;
case 'i':
interactive = 0;
break;
case 'V':
print_version();
break;
case 'h':
print_help();
break;
}
}
}
arg1 = 1;
arg1 = i;
#endif
/* option help requested? "-o help" */
if (option_help)
{
print_welcome ();
printf ("FluidSynth settings:\n");
fluid_settings_foreach (settings, settings, settings_foreach_func);
exit (0);
}
#ifdef WIN32
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
#endif
/* connect to the ladcca server */
#ifdef HAVE_LADCCA
if (ladcca_connect)
/* connect to the lash server */
if (connect_lash)
{
fluid_cca_client = cca_init (cca_args, PACKAGE, CCA_Config_Data_Set | CCA_Terminal, CCA_PROTOCOL (2,0));
if (fluid_cca_client)
fluid_settings_setint (settings, "ladcca.enable", cca_enabled (fluid_cca_client) ? 1 : 0);
enabled_lash = fluid_lash_connect (lash_args);
fluid_settings_setint (settings, "lash.enable", enabled_lash ? 1 : 0);
}
#endif /* HAVE_LADCCA */
/* The 'groups' setting is only relevant for LADSPA operation
* If not given, set number groups to number of audio channels, because
* they are the same (there is nothing between synth output and 'sound card')
@ -474,8 +448,8 @@ int main(int argc, char** argv)
}
/* try to load the user or system configuration */
if (file != NULL) {
fluid_source(cmd_handler, file);
if (config_file != NULL) {
fluid_source(cmd_handler, config_file);
} else if (fluid_get_userconf(buf, 512) != NULL) {
fluid_source(cmd_handler, buf);
} else if (fluid_get_sysconf(buf, 512) != NULL) {
@ -567,15 +541,17 @@ int main(int argc, char** argv)
#endif
#ifdef HAVE_LADCCA
if (ladcca_connect && cca_enabled (fluid_cca_client))
pthread_create (&cca_thread, NULL, cca_run, synth);
#endif /* HAVE_LADCCA */
#ifdef LASH_ENABLED
if (enabled_lash)
fluid_lash_create_thread (synth);
#endif
/* run the shell */
if (interactive) {
print_welcome();
printf ("Type 'help' for information on commands and 'help help' for help topics.\n\n");
/* In dump mode we set the prompt to "". The UI cannot easily
* handle lines, which don't end with CR. Changing the prompt
* cannot be done through a command, because the current shell
@ -648,7 +624,8 @@ static fluid_cmd_handler_t* newclient(void* data, char* addr)
void
print_usage()
{
fprintf(stderr, "Usage: %s [options] [soundfonts]\n", appname);
print_welcome ();
fprintf(stderr, "Usage: fluidsynth [options] [soundfonts]\n");
fprintf(stderr, "Try -h for help.\n");
exit(0);
}
@ -659,23 +636,11 @@ print_usage()
void
print_welcome()
{
printf("fluidsynth version %s\n"
"Copyright (C) 2000-2002 Peter Hanappe and others.\n"
"FLUID Synth comes with ABSOLUTELY NO WARRANTY.\n"
"This is free software, and you are welcome to redistribute it\n"
"under certain conditions; see the COPYING file for details.\n"
"SoundFont(R) is a registered trademark of E-mu Systems, Inc.\n\n"
"Type 'help' to get information on the shell commands.\n\n", FLUIDSYNTH_VERSION);
}
/*
* print_version
*/
void
print_version()
{
printf("fluidsynth %s\n", VERSION);
exit(0);
printf("FluidSynth version %s\n"
"Copyright (C) 2000-2006 Peter Hanappe and others.\n"
"Distributed under the LGPL license.\n"
"SoundFont(R) is a registered trademark of E-mu Systems, Inc.\n\n",
FLUIDSYNTH_VERSION);
}
/*
@ -684,163 +649,55 @@ print_version()
void
print_help()
{
print_welcome ();
printf("Usage: \n");
printf(" fluidsynth [options] [soundfonts] [midifiles]\n");
printf("Possible options:\n");
printf(" -n, --no-midi-in\n"
" Don't create a midi driver to read MIDI input events [default = yes]\n\n");
printf(" -m, --midi-driver=[label]\n"
" The name of the midi driver to use [oss,alsa,alsa_seq,...]\n\n");
printf(" -K, --midi-channels=[num]\n"
" The number of midi channels [default = 16]\n\n");
printf(" -a, --audio-driver=[label]\n"
" The audio driver [alsa,jack,oss,dsound,...]\n\n");
printf(" -j, --connect-jack-outputs\n"
" Attempt to connect the jack outputs to the physical ports\n\n");
printf(" -L, --audio-channels=[num]\n"
" The number of stereo audio channels [default = 1]\n\n");
printf(" -z, --audio-bufsize=[size]\n"
" Size of each audio buffer\n\n");
printf(" -c, --audio-bufcount=[count]\n"
" Number of audio buffers\n\n");
printf(" -r, --sample-rate\n"
" Set the sample rate\n\n");
printf(" -R, --reverb\n"
" Turn the reverb on or off [0|1|yes|no, default = on]\n\n");
" The audio driver [alsa,jack,oss,dsound,...]\n");
printf(" -C, --chorus\n"
" Turn the chorus on or off [0|1|yes|no, default = on]\n\n");
" Turn the chorus on or off [0|1|yes|no, default = on]\n");
printf(" -c, --audio-bufcount=[count]\n"
" Number of audio buffers\n");
printf(" -d, --dump\n"
" Dump incoming and outgoing MIDI events to stdout\n");
printf(" -f, --load-config\n"
" Load command configuration file (shell commands)\n");
printf(" -G, --audio-groups\n"
" Defines the number of LADSPA audio nodes\n");
printf(" -g, --gain\n"
" Set the master gain [0 < gain < 10, default = 0.2]\n\n");
#ifdef HAVE_LADCCA
printf(" -l, --disable-ladcca\n"
" Don't connect to LADCCA server");
#endif
printf(" -o\n"
" Define a setting, -o name=value\n\n");
printf(" -i, --no-shell\n"
" Don't read commands from the shell [default = yes]\n\n");
printf(" -v, --verbose\n"
" Print out verbose messages about midi events\n\n");
" Set the master gain [0 < gain < 10, default = 0.2]\n");
printf(" -h, --help\n"
" Print out this help summary\n\n");
" Print out this help summary\n");
printf(" -i, --no-shell\n"
" Don't read commands from the shell [default = yes]\n");
printf(" -j, --connect-jack-outputs\n"
" Attempt to connect the jack outputs to the physical ports\n");
printf(" -K, --midi-channels=[num]\n"
" The number of midi channels [default = 16]\n");
printf(" -L, --audio-channels=[num]\n"
" The number of stereo audio channels [default = 1]\n");
#ifdef LASH_ENABLED
printf(" -l, --disable-lash\n"
" Don't connect to LASH server\n");
#endif
printf(" -m, --midi-driver=[label]\n"
" The name of the midi driver to use [oss,alsa,alsa_seq,...]\n");
printf(" -n, --no-midi-in\n"
" Don't create a midi driver to read MIDI input events [default = yes]\n");
printf(" -o\n"
" Define a setting, -o name=value (\"-o help\" to dump current values)\n");
printf(" -R, --reverb\n"
" Turn the reverb on or off [0|1|yes|no, default = on]\n");
printf(" -r, --sample-rate\n"
" Set the sample rate\n");
printf(" -s, --server\n"
" Start FluidSynth as a server process\n");
printf(" -V, --version\n"
" Show version of program\n\n");
" Show version of program\n");
printf(" -v, --verbose\n"
" Print out verbose messages about midi events\n");
printf(" -z, --audio-bufsize=[size]\n"
" Size of each audio buffer\n");
exit(0);
}
#ifdef HAVE_LADCCA
#include <unistd.h> /* for usleep() */
#include "fluid_synth.h" /* JG - until fluid_sfont_get_name is public */
#include <sys/types.h>
#include <signal.h>
#include <string.h>
#include <errno.h>
static void
cca_save (fluid_synth_t * synth)
{
int i;
int sfcount;
fluid_sfont_t * sfont;
cca_config_t * config;
char num[32];
sfcount = fluid_synth_sfcount (synth);
config = cca_config_new ();
cca_config_set_key (config, "soundfont count");
cca_config_set_value_int (config, sfcount);
cca_send_config (fluid_cca_client, config);
for (i = sfcount - 1; i >= 0; i--)
{
sfont = fluid_synth_get_sfont (synth, i);
config = cca_config_new ();
sprintf (num, "%d", i);
cca_config_set_key (config, num);
cca_config_set_value_string (config, sfont->get_name (sfont));
cca_send_config (fluid_cca_client, config);
}
}
static void
cca_load (fluid_synth_t * synth, const char * filename)
{
fluid_synth_sfload (synth, filename, 1);
}
static void *
cca_run (void * data)
{
cca_event_t * event;
cca_config_t * config;
fluid_synth_t * synth;
int done = 0;
int err;
int pending_restores = 0;
synth = (fluid_synth_t *) data;
while (!done)
{
while ( (event = cca_get_event (fluid_cca_client)) )
{
switch (cca_event_get_type (event))
{
case CCA_Save_Data_Set:
cca_save (synth);
cca_send_event (fluid_cca_client, event);
break;
case CCA_Restore_Data_Set:
cca_event_destroy (event);
break;
case CCA_Quit:
err = kill (getpid(), SIGQUIT);
if (err)
fprintf (stderr, "%s: error sending signal: %s",
__FUNCTION__, strerror (errno));
cca_event_destroy (event);
done = 1;
break;
case CCA_Server_Lost:
cca_event_destroy (event);
done = 1;
break;
default:
fprintf (stderr, "Recieved unknown LADCCA event of type %d\n", cca_event_get_type (event));
cca_event_destroy (event);
break;
}
}
while ( (config = cca_get_config (fluid_cca_client)) )
{
if (strcmp (cca_config_get_key (config), "soundfont count") == 0)
pending_restores = cca_config_get_value_int (config);
else
{
cca_load (synth, cca_config_get_value_string (config));
pending_restores--;
}
cca_config_destroy (config);
if (!pending_restores)
{
event = cca_event_new_with_type (CCA_Restore_Data_Set);
cca_send_event (fluid_cca_client, event);
}
}
usleep (10000);
}
return NULL;
}
#endif /* HAVE_LADCCA */