Skip to content
Permalink
Browse files
Add FluidSynth backend and generic SoundFont functions. No FluidSynth…
… DLL or headers for MSVC in this commit.
  • Loading branch information
chewi committed Mar 20, 2011
1 parent 30f5df9 commit 4fd1e33acdf6c44520fdf6ad1272d7d3d9747376
Showing with 701 additions and 26 deletions.
  1. +1 −1 Makefile.in
  2. +10 −4 SDL_mixer.h
  3. +18 −2 VisualC/SDL_mixer.dsp
  4. +20 −4 VisualC/SDL_mixer.vcproj
  5. +43 −0 configure.in
  6. +85 −0 dynamic_fluidsynth.c
  7. +55 −0 dynamic_fluidsynth.h
  8. +222 −0 fluidsynth.c
  9. +46 −0 fluidsynth.h
  10. +24 −0 mixer.c
  11. +177 −15 music.c
@@ -39,7 +39,7 @@ VERSION_OBJECTS = @VERSION_OBJECTS@
PLAYWAVE_OBJECTS = @PLAYWAVE_OBJECTS@
PLAYMUS_OBJECTS = @PLAYMUS_OBJECTS@

DIST = Android.mk CHANGES COPYING CWProjects.sea.bin MPWmake.sea.bin Makefile.in SDL_mixer.pc.in README SDL_mixer.h SDL_mixer.qpg.in SDL_mixer.spec SDL_mixer.spec.in VisualC.zip Watcom-OS2.zip Xcode.tar.gz acinclude autogen.sh build-scripts configure configure.in dynamic_flac.c dynamic_flac.h dynamic_mod.c dynamic_mod.h dynamic_mp3.c dynamic_mp3.h dynamic_ogg.c dynamic_ogg.h effect_position.c effect_stereoreverse.c effects_internal.c effects_internal.h gcc-fat.sh libmikmod-3.1.12.zip load_aiff.c load_aiff.h load_flac.c load_flac.h load_ogg.c load_ogg.h load_voc.c load_voc.h mixer.c music.c music_cmd.c music_cmd.h music_flac.c music_flac.h music_mad.c music_mad.h music_mod.c music_mod.h music_modplug.c music_modplug.h music_ogg.c music_ogg.h native_midi native_midi_gpl playmus.c playwave.c timidity wavestream.c wavestream.h version.rc
DIST = Android.mk CHANGES COPYING CWProjects.sea.bin MPWmake.sea.bin Makefile.in SDL_mixer.pc.in README SDL_mixer.h SDL_mixer.qpg.in SDL_mixer.spec SDL_mixer.spec.in VisualC.zip Watcom-OS2.zip Xcode.tar.gz acinclude autogen.sh build-scripts configure configure.in dynamic_flac.c dynamic_flac.h dynamic_fluidsynth.c dynamic_fluidsynth.h dynamic_mod.c dynamic_mod.h dynamic_mp3.c dynamic_mp3.h dynamic_ogg.c dynamic_ogg.h effect_position.c effect_stereoreverse.c effects_internal.c effects_internal.h fluidsynth.c fluidsynth.h gcc-fat.sh libmikmod-3.1.12.zip load_aiff.c load_aiff.h load_flac.c load_flac.h load_ogg.c load_ogg.h load_voc.c load_voc.h mixer.c music.c music_cmd.c music_cmd.h music_flac.c music_flac.h music_mad.c music_mad.h music_mod.c music_mod.h music_modplug.c music_modplug.h music_ogg.c music_ogg.h native_midi native_midi_gpl playmus.c playwave.c timidity wavestream.c wavestream.h version.rc

LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@
@@ -67,10 +67,11 @@ extern DECLSPEC const SDL_version * SDLCALL Mix_Linked_Version(void);

typedef enum
{
MIX_INIT_FLAC = 0x00000001,
MIX_INIT_MOD = 0x00000002,
MIX_INIT_MP3 = 0x00000004,
MIX_INIT_OGG = 0x00000008
MIX_INIT_FLAC = 0x00000001,
MIX_INIT_MOD = 0x00000002,
MIX_INIT_MP3 = 0x00000004,
MIX_INIT_OGG = 0x00000008,
MIX_INIT_FLUIDSYNTH = 0x00000016
} MIX_InitFlags;

/* Loads dynamic libraries and prepares them for use. Flags should be
@@ -605,6 +606,11 @@ extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command);
extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value);
extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void);

/* Set/Get/Iterate SoundFonts paths to use by supported MIDI backends */
extern DECLSPEC int SDLCALL Mix_SetSoundFonts(const char *paths);
extern DECLSPEC const char* SDLCALL Mix_GetSoundFonts();
extern DECLSPEC int SDLCALL Mix_EachSoundFont(int (*function)(const char*, void*), void *data);

/* Get the Mix_Chunk currently associated with a mixer channel
Returns NULL if it's an invalid channel, or there's no chunk associated.
*/

Some generated files are not rendered by default. Learn more.

@@ -48,8 +48,8 @@
Name="VCCLCompilerTool"
AdditionalOptions="/D OGG_DYNAMIC=\"libvorbisfile-3.dll\""
Optimization="0"
AdditionalIncludeDirectories="..\timidity;..\native_midi;mikmod\include;smpeg\include;vorbis\include"
PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_CRT_SECURE_NO_WARNINGS;WAV_MUSIC;MOD_MUSIC;MOD_DYNAMIC=\"mikmod.dll\";MID_MUSIC;USE_TIMIDITY_MIDI;USE_NATIVE_MIDI;OGG_MUSIC;OGG_DYNAMIC=\"libvorbisfile-3.dll\";MP3_MUSIC;MP3_DYNAMIC=\"smpeg.dll\""
AdditionalIncludeDirectories="..\timidity;..\native_midi;fluidsynth\include;mikmod\include;smpeg\include;vorbis\include"
PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_CRT_SECURE_NO_WARNINGS;WAV_MUSIC;MOD_MUSIC;MOD_DYNAMIC=\"mikmod.dll\";MID_MUSIC;USE_TIMIDITY_MIDI;USE_NATIVE_MIDI;USE_FLUIDSYNTH_MIDI;FLUIDSYNTH_DYNAMIC=\"libfluidsynth.dll\";OGG_MUSIC;OGG_DYNAMIC=\"libvorbisfile-3.dll\";MP3_MUSIC;MP3_DYNAMIC=\"smpeg.dll\""
MinimalRebuild="true"
RuntimeLibrary="2"
PrecompiledHeaderFile=".\Debug/SDL_mixer.pch"
@@ -145,8 +145,8 @@
AdditionalOptions="/D OGG_DYNAMIC=\"libvorbisfile-3.dll\""
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\timidity;..\native_midi;mikmod\include;smpeg\include;vorbis\include"
PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_CRT_SECURE_NO_WARNINGS;WAV_MUSIC;MOD_MUSIC;MID_MUSIC;MOD_DYNAMIC=\"mikmod.dll\";USE_TIMIDITY_MIDI;USE_NATIVE_MIDI;OGG_MUSIC;OGG_DYNAMIC=\"libvorbisfile-3.dll\";MP3_MUSIC;MP3_DYNAMIC=\"smpeg.dll\""
AdditionalIncludeDirectories="..\timidity;..\native_midi;fluidsynth/include;mikmod\include;smpeg\include;vorbis\include"
PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_CRT_SECURE_NO_WARNINGS;WAV_MUSIC;MOD_MUSIC;MID_MUSIC;MOD_DYNAMIC=\"mikmod.dll\";USE_TIMIDITY_MIDI;USE_NATIVE_MIDI;USE_FLUIDSYNTH_MIDI;FLUIDSYNTH_DYNAMIC=\"libfluidsynth.dll\";OGG_MUSIC;OGG_DYNAMIC=\"libvorbisfile-3.dll\";MP3_MUSIC;MP3_DYNAMIC=\"smpeg.dll\""
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
@@ -218,6 +218,14 @@
RelativePath="..\dynamic_flac.h"
>
</File>
<File
RelativePath="..\dynamic_fluidsynth.c"
>
</File>
<File
RelativePath="..\dynamic_fluidsynth.h"
>
</File>
<File
RelativePath="..\dynamic_mod.c"
>
@@ -348,6 +356,14 @@
RelativePath="..\effects_internal.h"
>
</File>
<File
RelativePath="..\fluidsynth.c"
>
</File>
<File
RelativePath="..\fluidsynth.h"
>
</File>
<File
RelativePath="..\load_aiff.c"
>
@@ -387,6 +387,49 @@ AC_HELP_STRING([--enable-music-native-midi-gpl], [enable native MIDI on UNIX usi
SOURCES="$SOURCES $srcdir/native_midi_gpl/*.c"
fi
fi
AC_ARG_ENABLE([music-fluidsynth-midi],
AC_HELP_STRING([--enable-music-fluidsynth-midi], [enable FluidSynth MIDI output [[default=yes]]]),
[], [enable_music_fluidsynth_midi=yes])
AC_ARG_ENABLE([music-fluidsynth-shared],
AC_HELP_STRING([--enable-music-fluidsynth-shared], [dynamically load FluidSynth support [[default=yes]]]),
[], [enable_music_fluidsynth_shared=yes])
if test x$enable_music_fluidsynth_midi = xyes; then
AC_CHECK_HEADER([fluidsynth.h], [have_fluidsynth_hdr=yes])
AC_CHECK_LIB([fluidsynth], [fluid_player_add_mem], [have_fluidsynth_lib=yes])
if test x$have_fluidsynth_hdr = xyes -a x$have_fluidsynth_lib = xyes; then
case "$host" in
*-*-darwin*)
fluidsynth_lib=[`find_lib libfluidsynth.dylib`]
if test x$fluidsynth_lib = x; then
fluidsynth_lib=[`find_lib libfluidsynth.[0-9]`]
fi
if test x$fluidsynth_lib = x; then
fluidsynth_lib=[`find_lib libfluidsynth.[0-9]*`]
fi
;;
*-*-cygwin* | *-*-mingw32*)
fluidsynth_lib=[`find_lib "fluidsynth*.dll"`]
;;
*)
fluidsynth_lib=[`find_lib "libfluidsynth.so.[0-9]"`]
if test x$fluidsynth_lib = x; then
fluidsynth_lib=[`find_lib "libfluidsynth.so.[0-9]*"`]
fi
;;
esac
SOURCES="$SOURCES $srcdir/dynamic_fluidsynth.c $srcdir/fluidsynth.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_FLUIDSYNTH_MIDI"
if test x$enable_music_fluidsynth_shared = xyes && test x$fluidsynth_lib != x; then
echo "-- dynamic libfluidsyth -> $fluidsynth_lib"
EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLUIDSYNTH_DYNAMIC=\\\"$fluidsynth_lib\\\""
else
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lfluidsynth"
fi
else
AC_MSG_WARN([*** Unable to find FluidSynth library (http://www.fluidsynth.org/)])
AC_MSG_WARN([FluidSynth support disabled])
fi
fi
fi

AC_ARG_ENABLE([music-ogg],
@@ -0,0 +1,85 @@
/*
SDL_mixer: An audio mixer library based on the SDL library
Copyright (C) 1997-2011 Sam Lantinga
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
James Le Cuirot
chewi@aura-online.co.uk
*/

#ifdef USE_FLUIDSYNTH_MIDI

#include "SDL_loadso.h"
#include "dynamic_fluidsynth.h"

fluidsynth_loader fluidsynth = {
0, NULL
};

#ifdef FLUIDSYNTH_DYNAMIC
#define FLUIDSYNTH_LOADER(FUNC, SIG) \
fluidsynth.FUNC = (SIG) SDL_LoadFunction(fluidsynth.handle, #FUNC); \
if (fluidsynth.FUNC == NULL) { SDL_UnloadObject(fluidsynth.handle); return -1; }
#else
#define FLUIDSYNTH_LOADER(FUNC, SIG) \
fluidsynth.FUNC = FUNC;
#endif

int Mix_InitFluidSynth()
{
if ( fluidsynth.loaded == 0 ) {
#ifdef FLUIDSYNTH_DYNAMIC
fluidsynth.handle = SDL_LoadObject(FLUIDSYNTH_DYNAMIC);
if ( fluidsynth.handle == NULL ) return -1;
#endif

FLUIDSYNTH_LOADER(delete_fluid_player, int (*)(fluid_player_t*));
FLUIDSYNTH_LOADER(delete_fluid_settings, void (*)(fluid_settings_t*));
FLUIDSYNTH_LOADER(delete_fluid_synth, int (*)(fluid_synth_t*));
FLUIDSYNTH_LOADER(fluid_player_add, int (*)(fluid_player_t*, const char*));
FLUIDSYNTH_LOADER(fluid_player_add_mem, int (*)(fluid_player_t*, const void*, size_t));
FLUIDSYNTH_LOADER(fluid_player_get_status, int (*)(fluid_player_t*));
FLUIDSYNTH_LOADER(fluid_player_play, int (*)(fluid_player_t*));
FLUIDSYNTH_LOADER(fluid_player_set_loop, int (*)(fluid_player_t*, int));
FLUIDSYNTH_LOADER(fluid_player_stop, int (*)(fluid_player_t*));
FLUIDSYNTH_LOADER(fluid_settings_setnum, int (*)(fluid_settings_t*, const char*, double));
FLUIDSYNTH_LOADER(fluid_synth_get_settings, fluid_settings_t* (*)(fluid_synth_t*));
FLUIDSYNTH_LOADER(fluid_synth_set_gain, void (*)(fluid_synth_t*, float));
FLUIDSYNTH_LOADER(fluid_synth_sfload, int(*)(fluid_synth_t*, const char*, int));
FLUIDSYNTH_LOADER(fluid_synth_write_s16, int(*)(fluid_synth_t*, int, void*, int, int, void*, int, int));
FLUIDSYNTH_LOADER(new_fluid_player, fluid_player_t* (*)(fluid_synth_t*));
FLUIDSYNTH_LOADER(new_fluid_settings, fluid_settings_t* (*)(void));
FLUIDSYNTH_LOADER(new_fluid_synth, fluid_synth_t* (*)(fluid_settings_t*));
}
++fluidsynth.loaded;

return 0;
}

void Mix_QuitFluidSynth()
{
if ( fluidsynth.loaded == 0 ) {
return;
}
if ( fluidsynth.loaded == 1 ) {
#ifdef FLUIDSYNTH_DYNAMIC
SDL_UnloadObject(fluidsynth.handle);
#endif
}
--fluidsynth.loaded;
}

#endif /* USE_FLUIDSYNTH_MIDI */
@@ -0,0 +1,55 @@
/*
SDL_mixer: An audio mixer library based on the SDL library
Copyright (C) 1997-2011 Sam Lantinga
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
James Le Cuirot
chewi@aura-online.co.uk
*/

#ifdef USE_FLUIDSYNTH_MIDI

#include <fluidsynth.h>

typedef struct {
int loaded;
void *handle;

int (*delete_fluid_player)(fluid_player_t*);
void (*delete_fluid_settings)(fluid_settings_t*);
int (*delete_fluid_synth)(fluid_synth_t*);
int (*fluid_player_add)(fluid_player_t*, const char*);
int (*fluid_player_add_mem)(fluid_player_t*, const void*, size_t);
int (*fluid_player_get_status)(fluid_player_t*);
int (*fluid_player_play)(fluid_player_t*);
int (*fluid_player_set_loop)(fluid_player_t*, int);
int (*fluid_player_stop)(fluid_player_t*);
int (*fluid_settings_setnum)(fluid_settings_t*, const char*, double);
fluid_settings_t* (*fluid_synth_get_settings)(fluid_synth_t*);
void (*fluid_synth_set_gain)(fluid_synth_t*, float);
int (*fluid_synth_sfload)(fluid_synth_t*, const char*, int);
int (*fluid_synth_write_s16)(fluid_synth_t*, int, void*, int, int, void*, int, int);
fluid_player_t* (*new_fluid_player)(fluid_synth_t*);
fluid_settings_t* (*new_fluid_settings)(void);
fluid_synth_t* (*new_fluid_synth)(fluid_settings_t*);
} fluidsynth_loader;

extern fluidsynth_loader fluidsynth;

#endif /* USE_FLUIDSYNTH_MIDI */

extern int Mix_InitFluidSynth();
extern void Mix_QuitFluidSynth();

0 comments on commit 4fd1e33

Please sign in to comment.