diff --git a/fluidsynth/CMakeLists.txt b/fluidsynth/CMakeLists.txt
index 4118c4c7..350b9bb8 100644
--- a/fluidsynth/CMakeLists.txt
+++ b/fluidsynth/CMakeLists.txt
@@ -101,6 +101,7 @@ include ( DefaultDirs )
# Basic C library checks
include ( CheckSTDC )
include ( CheckIncludeFile )
+include ( CheckFunctionExists )
check_include_file ( string.h HAVE_STRING_H )
check_include_file ( stdlib.h HAVE_STDLIB_H )
check_include_file ( stdio.h HAVE_STDIO_H )
@@ -224,6 +225,16 @@ if ( ${CMAKE_SYSTEM} MATCHES "Darwin" )
endif ( enable-framework )
endif ( ${CMAKE_SYSTEM} MATCHES "Darwin" )
+
+unset ( HAVE_INETNTOP CACHE )
+unset ( IPV6_SUPPORT CACHE )
+CHECK_FUNCTION_EXISTS ( "inet_ntop" HAVE_INETNTOP )
+if ( enable-ipv6 )
+ if ( HAVE_INETNTOP )
+ set ( IPV6_SUPPORT 1 )
+ endif ( HAVE_INETNTOP )
+endif ( enable-ipv6 )
+
unset ( WITH_FLOAT CACHE )
if ( enable-floats )
set ( WITH_FLOAT 1 )
@@ -389,12 +400,6 @@ else ( enable-dbus )
unset_pkg_config ( DBUS )
endif ( enable-dbus )
-unset ( IPV6_SUPPORT CACHE )
-if ( enable-ipv6 )
- set ( IPV6 1 )
- set ( IPV6_SUPPORT 1 )
-endif ( enable-ipv6 )
-
# General configuration file
configure_file ( ${CMAKE_SOURCE_DIR}/src/config.cmake
${CMAKE_BINARY_DIR}/config.h )
diff --git a/fluidsynth/doc/fluidsynth-v11-devdoc.txt b/fluidsynth/doc/fluidsynth-v11-devdoc.txt
index 2084c60a..b934df66 100644
--- a/fluidsynth/doc/fluidsynth-v11-devdoc.txt
+++ b/fluidsynth/doc/fluidsynth-v11-devdoc.txt
@@ -481,7 +481,8 @@ The following table provides details on all the settings used by the synthesizer
gs: (default) CC0 becomes the bank number, CC32 is ignored.
xg: CC32 becomes the bank number, CC0 is ignored.
mma: bank is calculated as CC0*128+CC32.
-
+
+ Note: Drum channels are initialized to \c DRUM_INST_BANK (==128). Since 1.1.7 mma mode also allows the bank of drum channels to be changed the same way as for melodic channels.
diff --git a/fluidsynth/src/config.cmake b/fluidsynth/src/config.cmake
index b622def9..d0415b81 100644
--- a/fluidsynth/src/config.cmake
+++ b/fluidsynth/src/config.cmake
@@ -133,6 +133,9 @@
/* Define to 1 if you have the header file. */
#cmakedefine HAVE_GETOPT_H @HAVE_GETOPT_H@
+/* Define to 1 if you have the inet_ntop() function. */
+#cmakedefine HAVE_INETNTOP @HAVE_INETNTOP@
+
/* Define to enable JACK driver */
#cmakedefine JACK_SUPPORT @JACK_SUPPORT@
@@ -140,7 +143,7 @@
#cmakedefine LADSPA @LADSPA_SUPPORT@
/* Define to enable IPV6 support */
-#cmakedefine IPV6 @IPV6_SUPPORT@
+#cmakedefine IPV6_SUPPORT @IPV6_SUPPORT@
/* libsndfile has ogg vorbis support */
#cmakedefine LIBSNDFILE_HASVORBIS @LIBSNDFILE_HASVORBIS@
diff --git a/fluidsynth/src/drivers/fluid_oss.c b/fluidsynth/src/drivers/fluid_oss.c
index 39c2ee37..a799c397 100644
--- a/fluidsynth/src/drivers/fluid_oss.c
+++ b/fluidsynth/src/drivers/fluid_oss.c
@@ -45,7 +45,7 @@
#define BUFFER_LENGTH 512
// Build issue on some systems (OSS 4.0)?
-#ifdef SNDCTL_DSP_CHANNELS
+#if !defined(SOUND_PCM_WRITE_CHANNELS) && defined(SNDCTL_DSP_CHANNELS)
#define SOUND_PCM_WRITE_CHANNELS SNDCTL_DSP_CHANNELS
#endif
diff --git a/fluidsynth/src/synth/fluid_chan.c b/fluidsynth/src/synth/fluid_chan.c
index c6eb7231..02e69710 100644
--- a/fluidsynth/src/synth/fluid_chan.c
+++ b/fluidsynth/src/synth/fluid_chan.c
@@ -264,7 +264,7 @@ fluid_channel_set_bank_msb(fluid_channel_t* chan, int bankmsb)
}
if (style == FLUID_BANK_STYLE_GM ||
- chan->channel_type == CHANNEL_TYPE_DRUM)
+ (chan->channel_type == CHANNEL_TYPE_DRUM && style != FLUID_BANK_STYLE_MMA))
return; /* ignored */
oldval = chan->sfont_bank_prog;
diff --git a/fluidsynth/src/synth/fluid_synth.c b/fluidsynth/src/synth/fluid_synth.c
index 4e2813ab..ae6b157a 100644
--- a/fluidsynth/src/synth/fluid_synth.c
+++ b/fluidsynth/src/synth/fluid_synth.c
@@ -1945,7 +1945,8 @@ fluid_synth_program_change(fluid_synth_t* synth, int chan, int prognum)
FLUID_API_ENTRY_CHAN(FLUID_FAILED);
channel = synth->channel[chan];
- if (channel->channel_type == CHANNEL_TYPE_DRUM)
+ if (channel->channel_type == CHANNEL_TYPE_DRUM &&
+ synth->bank_select != FLUID_BANK_STYLE_MMA)
banknum = DRUM_INST_BANK;
else
fluid_channel_get_sfont_bank_prog(channel, NULL, &banknum, NULL);
@@ -1969,8 +1970,9 @@ fluid_synth_program_change(fluid_synth_t* synth, int chan, int prognum)
/* Fallback to another preset if not found */
if (!preset) {
/* Percussion: Fallback to preset 0 in percussion bank */
- if (subst_bank == DRUM_INST_BANK) {
+ if (channel->channel_type == CHANNEL_TYPE_DRUM) {
subst_prog = 0;
+ subst_bank = DRUM_INST_BANK;
preset = fluid_synth_find_preset(synth, subst_bank, subst_prog);
}
/* Melodic instrument */
diff --git a/fluidsynth/src/utils/fluid_conv.c b/fluidsynth/src/utils/fluid_conv.c
index 1a790cfb..ff30d1c1 100644
--- a/fluidsynth/src/utils/fluid_conv.c
+++ b/fluidsynth/src/utils/fluid_conv.c
@@ -25,7 +25,6 @@
fluid_real_t fluid_ct2hz_tab[FLUID_CENTS_HZ_SIZE];
fluid_real_t fluid_cb2amp_tab[FLUID_CB_AMP_SIZE];
fluid_real_t fluid_atten2amp_tab[FLUID_ATTEN_AMP_SIZE];
-fluid_real_t fluid_posbp_tab[128];
fluid_real_t fluid_concave_tab[128];
fluid_real_t fluid_convex_tab[128];
fluid_real_t fluid_pan_tab[FLUID_PAN_SIZE];
diff --git a/fluidsynth/src/utils/fluid_conv.h b/fluidsynth/src/utils/fluid_conv.h
index 29793c33..685b9ad8 100644
--- a/fluidsynth/src/utils/fluid_conv.h
+++ b/fluidsynth/src/utils/fluid_conv.h
@@ -54,7 +54,6 @@ fluid_real_t fluid_convex(fluid_real_t val);
extern fluid_real_t fluid_ct2hz_tab[FLUID_CENTS_HZ_SIZE];
extern fluid_real_t fluid_vel2cb_tab[FLUID_VEL_CB_SIZE];
extern fluid_real_t fluid_cb2amp_tab[FLUID_CB_AMP_SIZE];
-extern fluid_real_t fluid_posbp_tab[128];
extern fluid_real_t fluid_concave_tab[128];
extern fluid_real_t fluid_convex_tab[128];
extern fluid_real_t fluid_pan_tab[FLUID_PAN_SIZE];
diff --git a/fluidsynth/src/utils/fluid_sys.c b/fluidsynth/src/utils/fluid_sys.c
index 3daa4c68..0de9e643 100644
--- a/fluidsynth/src/utils/fluid_sys.c
+++ b/fluidsynth/src/utils/fluid_sys.c
@@ -981,7 +981,7 @@ fluid_server_socket_run (void *data)
{
fluid_server_socket_t *server_socket = (fluid_server_socket_t *)data;
fluid_socket_t client_socket;
-#ifdef IPV6
+#ifdef IPV6_SUPPORT
struct sockaddr_in6 addr;
char straddr[INET6_ADDRSTRLEN];
#else
@@ -1008,13 +1008,20 @@ fluid_server_socket_run (void *data)
server_socket->cont = 0;
return;
} else {
-#ifdef IPV6
+#ifdef HAVE_INETNTOP
+#ifdef IPV6_SUPPORT
inet_ntop(AF_INET6, &addr.sin6_addr, straddr, sizeof(straddr));
#else
inet_ntop(AF_INET, &addr.sin_addr, straddr, sizeof(straddr));
#endif
+#endif
+#ifdef HAVE_INETNTOP
retval = server_socket->func (server_socket->data, client_socket,
straddr);
+#else
+ retval = server_socket->func (server_socket->data, client_socket,
+ inet_ntoa (addr.sin_addr));
+#endif
if (retval != 0)
fluid_socket_close(client_socket);
@@ -1028,7 +1035,7 @@ fluid_server_socket_t*
new_fluid_server_socket(int port, fluid_server_func_t func, void* data)
{
fluid_server_socket_t* server_socket;
-#ifdef IPV6
+#ifdef IPV6_SUPPORT
struct sockaddr_in6 addr;
#else
struct sockaddr_in addr;
@@ -1036,7 +1043,7 @@ new_fluid_server_socket(int port, fluid_server_func_t func, void* data)
fluid_socket_t sock;
g_return_val_if_fail (func != NULL, NULL);
-#ifdef IPV6
+#ifdef IPV6_SUPPORT
sock = socket(AF_INET6, SOCK_STREAM, 0);
if (sock == INVALID_SOCKET) {
FLUID_LOG(FLUID_ERR, "Failed to create server socket");
@@ -1136,12 +1143,14 @@ static void fluid_server_socket_run (void *data)
{
fluid_server_socket_t *server_socket = (fluid_server_socket_t *)data;
fluid_socket_t client_socket;
-#ifdef IPV6
+#ifdef IPV6_SUPPORT
struct sockaddr_in6 addr;
char straddr[INET6_ADDRSTRLEN];
#else
struct sockaddr_in addr;
+#ifdef HAVE_INETNTOP
char straddr[INET_ADDRSTRLEN];
+#endif
#endif
socklen_t addrlen = sizeof (addr);
int r;
@@ -1165,13 +1174,20 @@ static void fluid_server_socket_run (void *data)
}
else
{
-#ifdef IPV6
+#ifdef HAVE_INETNTOP
+#ifdef IPV6_SUPPORT
inet_ntop(AF_INET6, &addr.sin6_addr, straddr, sizeof(straddr));
#else
inet_ntop(AF_INET, &addr.sin_addr, straddr, sizeof(straddr));
#endif
+#endif
+#ifdef HAVE_INETNTOP
r = server_socket->func (server_socket->data, client_socket,
straddr);
+#else
+ r = server_socket->func (server_socket->data, client_socket,
+ inet_ntoa (addr.sin_addr));
+#endif
if (r != 0)
fluid_socket_close (client_socket);
}
@@ -1184,7 +1200,7 @@ fluid_server_socket_t*
new_fluid_server_socket(int port, fluid_server_func_t func, void* data)
{
fluid_server_socket_t* server_socket;
-#ifdef IPV6
+#ifdef IPV6_SUPPORT
struct sockaddr_in6 addr;
#else
struct sockaddr_in addr;
@@ -1204,7 +1220,7 @@ new_fluid_server_socket(int port, fluid_server_func_t func, void* data)
FLUID_LOG(FLUID_ERR, "Server socket creation error: WSAStartup failed: %d", retval);
return NULL;
}
-#ifdef IPV6
+#ifdef IPV6_SUPPORT
sock = socket (AF_INET6, SOCK_STREAM, 0);
if (sock == INVALID_SOCKET)
{
diff --git a/fluidsynth/src/utils/fluidsynth_priv.h b/fluidsynth/src/utils/fluidsynth_priv.h
index faf27722..5f6782a6 100644
--- a/fluidsynth/src/utils/fluidsynth_priv.h
+++ b/fluidsynth/src/utils/fluidsynth_priv.h
@@ -112,7 +112,7 @@
#include
#endif
-#if HAVE_WINDOWS_H
+#if defined(WIN32) && HAVE_WINDOWS_H
#include
#include
#include