diff -rupN qtractor-0.5.5.old/configure.ac qtractor-0.5.5/configure.ac
--- qtractor-0.5.5.old/configure.ac	2012-06-15 06:12:54.000000000 -0400
+++ qtractor-0.5.5/configure.ac	2012-06-24 04:26:35.076671263 -0400
@@ -14,6 +14,22 @@ fi
 AC_SUBST(ac_prefix)
 AC_DEFINE_UNQUOTED(CONFIG_PREFIX, ["$ac_prefix"], [Default installation prefix.])
 
+# Set default installation libdir and plugindir.
+if test "x$exec_prefix" = "xNONE"; then
+    exec_prefix="${ac_prefix}"
+fi
+
+ac_libdir=$libdir
+if test "x$ac_libdir" = "xNONE"; then
+    ac_libdir=$ac_default_libdir
+fi
+# We want to make sure that this expands out. Otherwise we have bash variables
+# such as ${exec_prefix} inside config.h:
+eval ac_libdir="\"$ac_libdir\""
+AC_SUBST(ac_libdir)
+AC_DEFINE_UNQUOTED(CONFIG_LIBDIR, ["$ac_libdir"], [Default installation libdir.])
+AC_DEFINE_UNQUOTED(CONFIG_PLUGINDIR, ["$ac_libdir/qtractor"], [Default plugin installation dir.])
+
 # Enable debugging argument option.
 AC_ARG_ENABLE(debug,
   AC_HELP_STRING([--enable-debug], [enable debugging (default=no)]),
@@ -550,12 +566,14 @@ if test "x$ac_libmad" = "xyes"; then
    AC_CHECK_LIB(mad, main, [ac_libmad="yes"], [ac_libmad="no"])
    if test "x$ac_libmad" = "xyes"; then
       AC_DEFINE(CONFIG_LIBMAD, 1, [Define if libmad is available.])
-      ac_libs="$ac_libs -lmad"
+      ac_have_libmad=1
    else
       AC_MSG_WARN([*** mad library not found.])
       AC_MSG_WARN([*** MPEG Layer III audio file support will be disabled.])
+      ac_have_libmad=0
    fi
 fi
+AC_SUBST(ac_have_libmad)
 
 # Check for optional libsamplerate library.
 if test "x$ac_libsamplerate" = "xyes"; then
@@ -716,6 +734,9 @@ if test "x$ac_jack_latency" = "xyes"; th
    fi
 fi
 
+# To dlopen plugins
+ac_libs="$ac_libs -ldl"
+
 # Some recent distros (eg. fedora, debian) require this.
 ac_libs="$ac_libs -lX11"
 
@@ -1155,6 +1176,7 @@ echo "  Gradient eye-candy . . . . . . .
 echo "  Debugger stack-trace (gdb) . . . . . . . . . . . .: $ac_stacktrace"
 echo
 echo "  Install prefix . . . . . . . . . . . . . . . . . .: $ac_prefix"
+echo "  Install libdir . . . . . . . . . . . . . . . . . .: $ac_libdir"
 echo
 echo "Now type 'make', followed by 'make install' as root."
 echo
diff -rupN qtractor-0.5.5.old/Makefile.in qtractor-0.5.5/Makefile.in
--- qtractor-0.5.5.old/Makefile.in	2012-05-25 12:55:11.000000000 -0400
+++ qtractor-0.5.5/Makefile.in	2012-06-24 04:39:18.798372418 -0400
@@ -2,10 +2,16 @@ prefix  = @ac_prefix@
 qmake   = @ac_qmake@
 lupdate = @ac_lupdate@
 lrelease = @ac_lrelease@
+have_libmad = @ac_have_libmad@
 
 name    = qtractor
 
 target  = src/$(name)
+ifeq ($(have_libmad), 1)
+	mad_target = lib$(name)_mad.so
+	mad_install_target = install_mad
+	mad_clean_target = clean_mad
+endif
 
 headers = \
 	src/config.h \
@@ -17,7 +23,6 @@ headers = \
 	src/qtractorAudioEngine.h \
 	src/qtractorAudioFile.h \
 	src/qtractorAudioListView.h \
-	src/qtractorAudioMadFile.h \
 	src/qtractorAudioMeter.h \
 	src/qtractorAudioMonitor.h \
 	src/qtractorAudioPeak.h \
@@ -128,6 +133,12 @@ headers = \
 	src/qtractorTimeScaleForm.h \
 	src/qtractorTrackForm.h
 
+mad_headers = \
+	src/config.h \
+	src/qtractorAudioMadFile.h \
+	src/qtractorAudioFile.h
+
+
 sources = \
 	src/qtractor.cpp \
 	src/qtractorAudioBuffer.cpp \
@@ -136,7 +147,6 @@ sources = \
 	src/qtractorAudioEngine.cpp \
 	src/qtractorAudioFile.cpp \
 	src/qtractorAudioListView.cpp \
-	src/qtractorAudioMadFile.cpp \
 	src/qtractorAudioMeter.cpp \
 	src/qtractorAudioMonitor.cpp \
 	src/qtractorAudioPeak.cpp \
@@ -239,6 +249,9 @@ sources = \
 	src/qtractorTimeScaleForm.cpp \
 	src/qtractorTrackForm.cpp
 
+mad_sources = \
+	src/qtractorAudioMadFile.cpp \
+
 forms = \
 	src/qtractorBusForm.ui \
 	src/qtractorClipForm.ui \
@@ -279,23 +292,33 @@ export datarootdir = @datarootdir@
 export localedir = @localedir@
 
 
-all:	$(target) $(translations_targets)
+all:	$(target) $(mad_target) $(translations_targets)
 
 
 $(target):	$(name).mak $(resources) ${forms} $(sources) $(headers)
 	@$(MAKE) -f $(name).mak
 
+$(mad_target): $(name)_mad.mak $(mad_sources) $(mad_headers)
+	@$(MAKE) -f $(name)_mad.mak
+
 $(name).mak:	$(name).pro
 	@$(qmake) -o $(name).mak $(name).pro
 
+$(name)_mad.mak: $(name)_mad.pro
+	@$(qmake) -o $(name)_mad.mak $(name)_mad.pro
+
+mad_plugin: $(mad_target)
+
 $(translation_targets):	$(name).pro
 	@$(lupdate) -verbose $(name).pro
 
 %.qm:	%.ts
 	@$(lrelease) -verbose $< -qm $@
 
+install_mad: $(mad_target)
+	@$(MAKE) INSTALL_ROOT=$(DESTDIR) -f $(name)_mad.mak install
 
-install:	$(target) $(translations_targets)
+install:	$(target) $(translations_targets) $(mad_install_target)
 	@$(MAKE) INSTALL_ROOT=$(DESTDIR) -f $(name).mak install
 	@install -d -v -m 0755 $(DESTDIR)$(localedir)
 	@install -v -m 0644 $(translations_targets) $(DESTDIR)$(localedir)
@@ -306,8 +329,11 @@ uninstall:	$(DESTDIR)$(prefix)/bin/$(nam
 	@for x in $(translations_targets); do \
 		rm -vf $(DESTDIR)$(localedir)/`basename $$x`; done
 
+clean_mad: $(name)_mad.mak
+	@$(MAKE) -f $(name)_mad.mak clean
+	@rm -f $(mad_target) $(name)_mad.mak	
 
-clean:	$(name).mak
+clean:	$(name).mak $(mad_clean_target)
 	@$(MAKE) -f $(name).mak clean
 	@rm -f $(target) $(target).mak $(name).mak
 	@rm -rf *.cache *.log *.status $(translations_targets)
diff -rupN qtractor-0.5.5.old/qtractor_mad.pro qtractor-0.5.5/qtractor_mad.pro
--- qtractor-0.5.5.old/qtractor_mad.pro	1969-12-31 19:00:00.000000000 -0500
+++ qtractor-0.5.5/qtractor_mad.pro	2012-06-24 04:27:11.320512459 -0400
@@ -0,0 +1,9 @@
+# qtractor_mad.pro
+#
+QMAKEVERSION = $$[QMAKE_VERSION]
+ISQT4 = $$find(QMAKEVERSION, ^[2-9])
+isEmpty( ISQT4 ) {
+	error("Use the qmake include with Qt4.4 or greater, on Debian that is qmake-qt4");
+}
+
+include(src/mad.pri)
diff -rupN qtractor-0.5.5.old/src/config.h.in qtractor-0.5.5/src/config.h.in
--- qtractor-0.5.5.old/src/config.h.in	2012-06-15 06:13:53.000000000 -0400
+++ qtractor-0.5.5/src/config.h.in	2012-06-24 04:04:30.131475190 -0400
@@ -21,6 +21,9 @@
 /* Define if LADSPA header is available. */
 #undef CONFIG_LADSPA
 
+/* Default installation libdir. */
+#undef CONFIG_LIBDIR
+
 /* Define if liblilv is available. */
 #undef CONFIG_LIBLILV
 
@@ -84,6 +87,9 @@
 /* Define if LV2 Worker/Schedule aupport is available. */
 #undef CONFIG_LV2_WORKER
 
+/* Default plugin installation dir. */
+#undef CONFIG_PLUGINDIR
+
 /* Default installation prefix. */
 #undef CONFIG_PREFIX
 
diff -rupN qtractor-0.5.5.old/src/mad.pri qtractor-0.5.5/src/mad.pri
--- qtractor-0.5.5.old/src/mad.pri	1969-12-31 19:00:00.000000000 -0500
+++ qtractor-0.5.5/src/mad.pri	2012-06-24 04:26:06.994794380 -0400
@@ -0,0 +1,38 @@
+# qtractor.pro
+#
+TARGET = qtractor_mad
+
+TEMPLATE = lib
+CONFIG += plugin
+QT -= gui
+DEPENDPATH += .
+INCLUDEPATH += .
+
+include(src/src.pri)
+
+#DEFINES += DEBUG
+
+HEADERS += src/config.h \
+	src/qtractorAudioFile.h \
+	src/qtractorAudioMadFile.h
+
+SOURCES += \
+	src/qtractorAudioMadFile.cpp
+
+unix {
+	# Additional link flags
+	LIBS = -lmad
+
+	# variables
+	OBJECTS_DIR = .obj
+
+	isEmpty(LIBDIR) {
+		LIBDIR = $$PREFIX/lib
+	}
+
+	# make install
+	INSTALLS += target
+
+	target.path = $$LIBDIR/qtractor
+
+}
diff -rupN qtractor-0.5.5.old/src/qtractorAudioFile.cpp qtractor-0.5.5/src/qtractorAudioFile.cpp
--- qtractor-0.5.5.old/src/qtractorAudioFile.cpp	2011-05-14 18:03:38.000000000 -0400
+++ qtractor-0.5.5/src/qtractorAudioFile.cpp	2012-06-24 04:09:36.980160092 -0400
@@ -29,7 +29,7 @@
 #include <QRegExp>
 
 #include <stdlib.h>
-
+#include <dlfcn.h>
 
 //----------------------------------------------------------------------
 // class qtractorAudioFileFactory -- Audio file factory (singleton).
@@ -131,7 +131,8 @@ qtractorAudioFileFactory::qtractorAudioF
 	m_pDefaultFormat = pFormat;
 #endif
 
-#ifdef CONFIG_LIBMAD
+if (madPluginExists())
+{
 	// Add for libmad (mp3 read-only)...
 	pFormat = new FileFormat;
 	pFormat->type = MadFile;
@@ -142,7 +143,7 @@ qtractorAudioFileFactory::qtractorAudioF
 	m_types[pFormat->ext] = pFormat;
 	m_filters.append(
 		sFilterMask.arg(pFormat->name).arg(sExtMask.arg(pFormat->ext)));
-#endif
+ }
 
 	// Finally, simply build the all (most commonly) supported files entry.
 	QRegExp rx("^(aif(|f)|fla(|c)|mp3|ogg|w(av|64))", Qt::CaseInsensitive);
@@ -198,13 +199,12 @@ qtractorAudioFile *qtractorAudioFileFact
 	case VorbisFile:
 		return new qtractorAudioVorbisFile(iChannels, iSampleRate, iBufferSize);
 	case MadFile:
-		return new qtractorAudioMadFile(iBufferSize);
+		return getQtractorAudioMadFile(iBufferSize);
 	default:
 		return NULL;
 	}
 }
 
-
 const qtractorAudioFileFactory::FileFormats& qtractorAudioFileFactory::formats (void)
 {
 	return getInstance().m_formats;
@@ -322,5 +322,44 @@ int qtractorAudioFileFactory::format (
 	return 0;
 }
 
+bool madPluginExists()
+{
+	void* madplugin = madPluginLibrary();
+	if (!madplugin) return false;
+	dlclose(madplugin);
+	return true;
+}
+
+void* madPluginLibrary()
+{
+	// load the mad plugin library
+	void* madplugin = dlopen(CONFIG_PLUGINDIR "/libqtractor_mad.so", RTLD_LAZY);
+	if (!madplugin) {
+#ifdef CONFIG_DEBUG
+		qDebug("Cannot load library: %s", dlerror());
+#endif
+		return NULL;
+	}
+	return madplugin;
+}
+
+qtractorAudioFile* getQtractorAudioMadFile(unsigned int iBufferSize) 
+{
+	void* madplugin = madPluginLibrary();
+	// reset errors
+	dlerror();
+	// load the symbols
+	create_t* create_qtractorAudioMadFile = (create_t*) dlsym(madplugin, "createQtractorAudioMadFile");
+	const char* dlsym_error = dlerror();
+	if (dlsym_error) {
+#ifdef CONFIG_DEBUG
+		qDebug("Cannot load symbol create_qtractorAudioMadFile: %s", dlsym_error)
+#endif
+		return NULL;
+	}
+	// create an instance of the class
+	return create_qtractorAudioMadFile(iBufferSize);
+}
+
 
 // end of qtractorAudioFile.cpp
diff -rupN qtractor-0.5.5.old/src/qtractorAudioFile.h qtractor-0.5.5/src/qtractorAudioFile.h
--- qtractor-0.5.5.old/src/qtractorAudioFile.h	2011-05-14 18:03:38.000000000 -0400
+++ qtractor-0.5.5/src/qtractorAudioFile.h	2012-06-24 04:04:30.133475181 -0400
@@ -59,7 +59,6 @@ public:
 	virtual unsigned int sampleRate() const = 0;
 };
 
-
 //----------------------------------------------------------------------
 // class qtractorAudioFileFactory -- Audio file factory (singleton).
 //
@@ -150,6 +149,19 @@ private:
 	int m_iDefaultQuality;
 };
 
+// Dlopen the plugin library to get an qtractorAudioFile instance
+qtractorAudioFile* getQtractorAudioMadFile(unsigned int iBufferSize);
+// the type of the create factory
+typedef qtractorAudioFile* create_t(unsigned int iBufferSize);
+// Note that we will also need a destroy factory in case we overload "delete".
+// If this is the case the dlopened library should handle its own destruction.
+// Since we don't overload delete, we skip this factory for now.
+
+// Check whether we can dlopen the mad plugin library
+bool madPluginExists();
+// Give us the mad plugin library object
+void* madPluginLibrary();
+
 
 #endif  // __qtractorAudioFile_h
 
diff -rupN qtractor-0.5.5.old/src/qtractorAudioMadFile.cpp qtractor-0.5.5/src/qtractorAudioMadFile.cpp
--- qtractor-0.5.5.old/src/qtractorAudioMadFile.cpp	2011-05-14 18:03:38.000000000 -0400
+++ qtractor-0.5.5/src/qtractorAudioMadFile.cpp	2012-06-24 04:04:30.134475176 -0400
@@ -24,6 +24,11 @@
 
 #include <sys/stat.h>
 
+// factory loader function
+extern "C" qtractorAudioFile* createQtractorAudioMadFile( unsigned int iBufferSize ) {
+  return new qtractorAudioMadFile(iBufferSize);
+}
+
 
 //----------------------------------------------------------------------
 // class qtractorAudioMadFile -- Buffered audio file implementation.
diff -rupN qtractor-0.5.5.old/src/qtractorMainForm.cpp qtractor-0.5.5/src/qtractorMainForm.cpp
--- qtractor-0.5.5.old/src/qtractorMainForm.cpp	2012-06-11 13:26:14.000000000 -0400
+++ qtractor-0.5.5/src/qtractorMainForm.cpp	2012-06-24 04:04:30.141475146 -0400
@@ -39,6 +39,7 @@
 #include "qtractorAudioPeak.h"
 #include "qtractorAudioBuffer.h"
 #include "qtractorAudioEngine.h"
+#include "qtractorAudioFile.h"
 #include "qtractorMidiEngine.h"
 
 #include "qtractorSessionDocument.h"
@@ -4801,9 +4802,9 @@ void qtractorMainForm::helpAbout (void)
 
 	list << tr("Ogg Vorbis (libvorbis) file support disabled.");
 #endif
-#ifndef CONFIG_LIBMAD
+if (!madPluginExists()) {
 	list << tr("MPEG-1 Audio Layer 3 (libmad) file support disabled.");
-#endif
+}
 #ifndef CONFIG_LIBSAMPLERATE
 	list << tr("Sample-rate conversion (libsamplerate) disabled.");
 #endif
diff -rupN qtractor-0.5.5.old/src/src.pri.in qtractor-0.5.5/src/src.pri.in
--- qtractor-0.5.5.old/src/src.pri.in	2010-09-25 18:08:05.000000000 -0400
+++ qtractor-0.5.5/src/src.pri.in	2012-06-24 04:26:15.516757012 -0400
@@ -1,6 +1,7 @@
 # qtractor.pri
 #
 PREFIX  = @ac_prefix@
+LIBDIR = @ac_libdir@
 CONFIG += @ac_debug@
 INCLUDEPATH += @ac_incpath@
 LIBS += @ac_libs@
diff -rupN qtractor-0.5.5.old/src/src.pro qtractor-0.5.5/src/src.pro
--- qtractor-0.5.5.old/src/src.pro	2012-05-25 12:55:11.000000000 -0400
+++ qtractor-0.5.5/src/src.pro	2012-06-24 04:04:30.143475138 -0400
@@ -19,7 +19,6 @@ HEADERS += config.h \
 	qtractorAudioEngine.h \
 	qtractorAudioFile.h \
 	qtractorAudioListView.h \
-	qtractorAudioMadFile.h \
 	qtractorAudioMeter.h \
 	qtractorAudioMonitor.h \
 	qtractorAudioPeak.h \
@@ -141,7 +140,6 @@ SOURCES += \
 	qtractorAudioEngine.cpp \
 	qtractorAudioFile.cpp \
 	qtractorAudioListView.cpp \
-	qtractorAudioMadFile.cpp \
 	qtractorAudioMeter.cpp \
 	qtractorAudioMonitor.cpp \
 	qtractorAudioPeak.cpp \
