aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--INSTALL3
-rw-r--r--NEWS1
-rw-r--r--configure.ac32
-rw-r--r--src/Makefile.am6
-rw-r--r--src/decoder/wildmidi_plugin.c102
-rw-r--r--src/decoder_list.c4
6 files changed, 148 insertions, 0 deletions
diff --git a/INSTALL b/INSTALL
index 994479cd8..c52968695 100644
--- a/INSTALL
+++ b/INSTALL
@@ -101,6 +101,9 @@ For C64 SID support.
libfluidsynth - http://fluidsynth.resonance.org/
For MIDI support.
+libwildmidi - http://wildmidi.sourceforge.net/
+For MIDI support.
+
Optional Miscellaneous Dependencies
-----------------------------------
diff --git a/NEWS b/NEWS
index 8e6f6af9c..95cda402f 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ ver 0.15 - (200?/??/??)
- mikmod disabled by default, due to severe security issues in libmikmod
- sidplay: new decoder plugin for C64 SID (using libsidplay2)
- fluidsynth: new decoder plugin for MIDI files (using libfluidsynth)
+ - wildmidi: another decoder plugin for MIDI files (using libwildmidi)
* audio outputs:
- shout: enlarged buffer size to 32 kB
- null: allow disabling synchronization
diff --git a/configure.ac b/configure.ac
index 84ffce570..67e2cb1f6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -422,6 +422,11 @@ AC_ARG_ENABLE(fluidsynth,
[enable MIDI support via fluidsynth (default: disable)]),,
enable_fluidsynth=no)
+AC_ARG_ENABLE(wildmidi,
+ AS_HELP_STRING([--enable-wildmidi],
+ [enable MIDI support via wildmidi (default: disable)]),,
+ enable_wildmidi=no)
+
AC_ARG_ENABLE(wavpack,
AS_HELP_STRING([--disable-wavpack],
[disable WavPack support (default: enable)]),
@@ -1038,6 +1043,26 @@ fi
AM_CONDITIONAL(ENABLE_FLUIDSYNTH, test x$enable_fluidsynth = xyes)
+if test x$enable_wildmidi = xyes; then
+ oldcflags=$CFLAGS
+ oldlibs=$LIBS
+ oldcppflags=$CPPFLAGS
+
+ AC_CHECK_LIB(WildMidi, WildMidi_Init,,
+ AC_MSG_ERROR([libwildmidi not found]))
+
+ CFLAGS=$oldcflags
+ LIBS=$oldlibs
+ CPPFLAGS=$oldcppflags
+
+ AC_SUBST(WILDMIDI_LIBS,-lWildMidi)
+ AC_SUBST(WILDMIDI_CFLAGS,)
+
+ AC_DEFINE(ENABLE_WILDMIDI, 1, [Define for wildmidi support])
+fi
+
+AM_CONDITIONAL(ENABLE_WILDMIDI, test x$enable_wildmidi = xyes)
+
dnl
dnl Documentation
@@ -1329,6 +1354,12 @@ else
echo " fluidsynth MIDI support .......disabled"
fi
+if test x$enable_wildmidi = xyes; then
+ echo " wildmidi MIDI support .........enabled"
+else
+ echo " wildmidi MIDI support .........disabled"
+fi
+
if test x$enable_ffmpeg = xyes; then
echo " FFMPEG support ................enabled"
else
@@ -1348,6 +1379,7 @@ if
test x$enable_modplug = xno &&
test x$enable_sidplay = xno &&
test x$enable_fluidsynth = xno &&
+ test x$enable_wildmidi = xno &&
test x$enable_mod = xno; then
AC_MSG_ERROR([No input plugins supported!])
fi
diff --git a/src/Makefile.am b/src/Makefile.am
index 935f8b3d6..37fdb2343 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,6 +13,7 @@ mpd_CPPFLAGS = \
$(MODPLUG_CFLAGS) \
$(SIDPLAY_CFLAGS) \
$(FLUIDSYNTH_CFLAGS) \
+ $(WILDMIDI_CFLAGS) \
$(ID3TAG_CFLAGS) \
$(MAD_CFLAGS) \
$(FFMPEG_CFLAGS) \
@@ -28,6 +29,7 @@ mpd_LDADD = $(MPD_LIBS) \
$(MODPLUG_LIBS) \
$(SIDPLAY_LIBS) \
$(FLUIDSYNTH_LIBS) \
+ $(WILDMIDI_LIBS) \
$(ID3TAG_LIBS) \
$(MAD_LIBS) \
$(MP4FF_LIBS) \
@@ -323,6 +325,10 @@ if ENABLE_FLUIDSYNTH
mpd_SOURCES += decoder/fluidsynth_plugin.c
endif
+if ENABLE_WILDMIDI
+mpd_SOURCES += decoder/wildmidi_plugin.c
+endif
+
if HAVE_FFMPEG
mpd_SOURCES += decoder/ffmpeg_plugin.c
endif
diff --git a/src/decoder/wildmidi_plugin.c b/src/decoder/wildmidi_plugin.c
new file mode 100644
index 000000000..e8cd42dee
--- /dev/null
+++ b/src/decoder/wildmidi_plugin.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2003-2009 The Music Player Daemon Project
+ * http://www.musicpd.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "../decoder_api.h"
+
+#include <glib.h>
+
+#include <wildmidi_lib.h>
+
+#undef G_LOG_DOMAIN
+#define G_LOG_DOMAIN "wildmidi"
+
+enum {
+ WILDMIDI_SAMPLE_RATE = 48000,
+};
+
+static bool
+wildmidi_init(void)
+{
+ int ret;
+
+ ret = WildMidi_Init("/etc/timidity/timidity.cfg",
+ WILDMIDI_SAMPLE_RATE, 0);
+ return ret == 0;
+}
+
+static void
+wildmidi_finish(void)
+{
+ WildMidi_Shutdown();
+}
+
+static void
+wildmidi_file_decode(struct decoder *decoder, const char *path_fs)
+{
+ static const struct audio_format audio_format = {
+ .sample_rate = WILDMIDI_SAMPLE_RATE,
+ .bits = 16,
+ .channels = 2,
+ };
+ midi *wm;
+ enum decoder_command cmd;
+
+ wm = WildMidi_Open(path_fs);
+ if (wm == NULL)
+ return;
+
+ decoder_initialized(decoder, &audio_format, false, -1);
+
+ do {
+ char buffer[4096];
+ int len;
+
+ len = WildMidi_GetOutput(wm, buffer, sizeof(buffer));
+ if (len <= 0)
+ break;
+
+ cmd = decoder_data(decoder, NULL, buffer, len, 0, 0, NULL);
+ } while (cmd == DECODE_COMMAND_NONE);
+
+ WildMidi_Close(wm);
+}
+
+static struct tag *
+wildmidi_tag_dup(const char *path_fs)
+{
+ struct tag *tag = tag_new();
+
+ /* to be implemented */
+ (void)path_fs;
+
+ return tag;
+}
+
+static const char *const wildmidi_suffixes[] = {
+ "mid",
+ NULL
+};
+
+const struct decoder_plugin wildmidi_decoder_plugin = {
+ .name = "wildmidi",
+ .init = wildmidi_init,
+ .finish = wildmidi_finish,
+ .file_decode = wildmidi_file_decode,
+ .tag_dup = wildmidi_tag_dup,
+ .suffixes = wildmidi_suffixes,
+};
diff --git a/src/decoder_list.c b/src/decoder_list.c
index e7f757e71..71211a0ea 100644
--- a/src/decoder_list.c
+++ b/src/decoder_list.c
@@ -36,6 +36,7 @@ extern const struct decoder_plugin modplug_plugin;
extern const struct decoder_plugin mikmod_decoder_plugin;
extern const struct decoder_plugin sidplay_decoder_plugin;
extern const struct decoder_plugin fluidsynth_decoder_plugin;
+extern const struct decoder_plugin wildmidi_decoder_plugin;
extern const struct decoder_plugin ffmpeg_plugin;
static const struct decoder_plugin *const decoder_plugins[] = {
@@ -78,6 +79,9 @@ static const struct decoder_plugin *const decoder_plugins[] = {
#ifdef ENABLE_FLUIDSYNTH
&fluidsynth_decoder_plugin,
#endif
+#ifdef ENABLE_WILDMIDI
+ &wildmidi_decoder_plugin,
+#endif
#ifdef HAVE_FFMPEG
&ffmpeg_plugin,
#endif