Split the dmusic interfaces.

diff --git a/dlls/dmband/Makefile.in b/dlls/dmband/Makefile.in
index 4812ccc..725acbc 100644
--- a/dlls/dmband/Makefile.in
+++ b/dlls/dmband/Makefile.in
@@ -3,13 +3,16 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = dmband.dll
-IMPORTS   = dmusic kernel32
+IMPORTS   = ole32 user32 advapi32 kernel32
+EXTRALIBS = $(LIBUUID)
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
 
 C_SRCS = \
-	dmband_main.c
+	band.c \
+	dmband_main.c \
+	regsvr.c
 
 RC_SRCS = version.rc
 
diff --git a/dlls/dmband/band.c b/dlls/dmband/band.c
new file mode 100644
index 0000000..7df17ed
--- /dev/null
+++ b/dlls/dmband/band.c
@@ -0,0 +1,124 @@
+/* IDirectMusicBand Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmband_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicBand IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicBandImpl_QueryInterface (LPDIRECTMUSICBAND iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicBandImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || 
+	    IsEqualGUID(riid, &IID_IDirectMusicBand))
+	{
+		IDirectMusicBandImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicBandImpl_AddRef (LPDIRECTMUSICBAND iface)
+{
+	ICOM_THIS(IDirectMusicBandImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicBandImpl_Release (LPDIRECTMUSICBAND iface)
+{
+	ICOM_THIS(IDirectMusicBandImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicBand Interface follow: */
+HRESULT WINAPI IDirectMusicBandImpl_CreateSegment (LPDIRECTMUSICBAND iface, IDirectMusicSegment** ppSegment)
+{
+	ICOM_THIS(IDirectMusicBandImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, ppSegment);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicBandImpl_Download (LPDIRECTMUSICBAND iface, IDirectMusicPerformance* pPerformance)
+{
+	ICOM_THIS(IDirectMusicBandImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pPerformance);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicBandImpl_Unload (LPDIRECTMUSICBAND iface, IDirectMusicPerformance* pPerformance)
+{
+	ICOM_THIS(IDirectMusicBandImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pPerformance);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicBand) DirectMusicBand_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicBandImpl_QueryInterface,
+	IDirectMusicBandImpl_AddRef,
+	IDirectMusicBandImpl_Release,
+	IDirectMusicBandImpl_CreateSegment,
+	IDirectMusicBandImpl_Download,
+	IDirectMusicBandImpl_Unload
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicBand (LPCGUID lpcGUID, LPDIRECTMUSICBAND* ppDMBand, LPUNKNOWN pUnkOuter)
+{
+	IDirectMusicBandImpl* dmband;
+	
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicBand))
+	{
+		dmband = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBandImpl));
+		if (NULL == dmband) {
+			*ppDMBand = (LPDIRECTMUSICBAND) NULL;
+			return E_OUTOFMEMORY;
+		}
+		dmband->lpVtbl = &DirectMusicBand_Vtbl;
+		dmband->ref = 1;
+		*ppDMBand = (LPDIRECTMUSICBAND) dmband;
+		return S_OK;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;
+}
diff --git a/dlls/dmband/dmband.spec b/dlls/dmband/dmband.spec
index 3d091d1..938ecd6 100644
--- a/dlls/dmband/dmband.spec
+++ b/dlls/dmband/dmband.spec
@@ -1,6 +1,4 @@
-# Linked to main dmusic.dll for easier implementation
-
-1 stdcall DllCanUnloadNow() dmusic.DllCanUnloadNow
-2 stdcall DllGetClassObject(long long ptr) dmusic.DllGetClassObject
-3 stdcall DllRegisterServer() dmusic.DllRegisterServer
-4 stdcall DllUnregisterServer() dmusic.DllUnregisterServer
+1 stdcall DllCanUnloadNow() DMBAND_DllCanUnloadNow
+2 stdcall DllGetClassObject(long long ptr) DMBAND_DllGetClassObject
+3 stdcall DllRegisterServer() DMBAND_DllRegisterServer
+4 stdcall DllUnregisterServer() DMBAND_DllUnregisterServer
diff --git a/dlls/dmband/dmband_main.c b/dlls/dmband/dmband_main.c
index 67a01ed..8b99a74 100644
--- a/dlls/dmband/dmband_main.c
+++ b/dlls/dmband/dmband_main.c
@@ -1 +1,139 @@
-/* nothing here yet */
+/* DirectMusicBand Main
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "dmband_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+
+/******************************************************************
+ *		DirectMusicBand ClassFactory
+ *
+ *
+ */
+ 
+typedef struct
+{
+    /* IUnknown fields */
+    ICOM_VFIELD(IClassFactory);
+    DWORD                       ref;
+} IClassFactoryImpl;
+
+static HRESULT WINAPI DMBCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+
+	FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+static ULONG WINAPI DMBCF_AddRef(LPCLASSFACTORY iface)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	return ++(This->ref);
+}
+
+static ULONG WINAPI DMBCF_Release(LPCLASSFACTORY iface)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	/* static class, won't be  freed */
+	return --(This->ref);
+}
+
+static HRESULT WINAPI DMBCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+
+	TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
+	if (IsEqualGUID (riid, &IID_IDirectMusicBand)) {
+		return DMUSIC_CreateDirectMusicBand (riid, (LPDIRECTMUSICBAND*) ppobj, pOuter);
+
+	}
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+static HRESULT WINAPI DMBCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	FIXME("(%p)->(%d),stub!\n", This, dolock);
+	return S_OK;
+}
+
+static ICOM_VTABLE(IClassFactory) DMBCF_Vtbl = {
+	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	DMBCF_QueryInterface,
+	DMBCF_AddRef,
+	DMBCF_Release,
+	DMBCF_CreateInstance,
+	DMBCF_LockServer
+};
+
+static IClassFactoryImpl DMBAND_CF = {&DMBCF_Vtbl, 1 };
+
+/******************************************************************
+ *		DllMain
+ *
+ *
+ */
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+	if (fdwReason == DLL_PROCESS_ATTACH)
+	{
+            DisableThreadLibraryCalls(hinstDLL);
+		/* FIXME: Initialisation */
+	}
+	else if (fdwReason == DLL_PROCESS_DETACH)
+	{
+		/* FIXME: Cleanup */
+	}
+
+	return TRUE;
+}
+
+
+/******************************************************************
+ *		DllCanUnloadNow (DMBAND.1)
+ *
+ *
+ */
+HRESULT WINAPI DMBAND_DllCanUnloadNow(void)
+{
+    FIXME("(void): stub\n");
+
+    return S_FALSE;
+}
+
+
+/******************************************************************
+ *		DllGetClassObject (DMBAND.2)
+ *
+ *
+ */
+HRESULT WINAPI DMBAND_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
+{
+    TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    if (IsEqualCLSID (&IID_IClassFactory, riid)) {
+      *ppv = (LPVOID) &DMBAND_CF;
+      IClassFactory_AddRef((IClassFactory*)*ppv);
+      return S_OK;
+    }
+    WARN("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    return CLASS_E_CLASSNOTAVAILABLE;
+}
diff --git a/dlls/dmband/dmband_private.h b/dlls/dmband/dmband_private.h
new file mode 100644
index 0000000..76541fa
--- /dev/null
+++ b/dlls/dmband/dmband_private.h
@@ -0,0 +1,72 @@
+/* DirectMusicBand Private Include
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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.
+ */
+
+#ifndef __WINE_DMBAND_PRIVATE_H
+#define __WINE_DMBAND_PRIVATE_H
+
+#include "windef.h"
+#include "wine/debug.h"
+#include "winbase.h"
+#include "winnt.h"
+#include "dmusicc.h"
+#include "dmusici.h"
+#include "dmusics.h"
+#include "dmplugin.h"
+#include "dmusicf.h"
+#include "dsound.h"
+
+/*****************************************************************************
+ * Interfaces
+ */
+typedef struct IDirectMusicBandImpl IDirectMusicBandImpl;
+
+/*****************************************************************************
+ * Predeclare the interface implementation structures
+ */
+extern ICOM_VTABLE(IDirectMusicBand) DirectMusicBand_Vtbl;
+
+/*****************************************************************************
+ * ClassFactory
+ * can support IID_IDirectMusicBand
+ * return always an IDirectMusicBandImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicBand (LPCGUID lpcGUID, LPDIRECTMUSICBAND* ppDMBand, LPUNKNOWN pUnkOuter);
+
+/*****************************************************************************
+ * IDirectMusicBandImpl implementation structure
+ */
+struct IDirectMusicBandImpl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicBand);
+  DWORD          ref;
+
+  /* IDirectMusicBandImpl fields */
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicBandImpl_QueryInterface (LPDIRECTMUSICBAND iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicBandImpl_AddRef (LPDIRECTMUSICBAND iface);
+extern ULONG WINAPI   IDirectMusicBandImpl_Release (LPDIRECTMUSICBAND iface);
+/* IDirectMusicBand: */
+extern HRESULT WINAPI IDirectMusicBandImpl_CreateSegment (LPDIRECTMUSICBAND iface, IDirectMusicSegment** ppSegment);
+extern HRESULT WINAPI IDirectMusicBandImpl_Download (LPDIRECTMUSICBAND iface, IDirectMusicPerformance* pPerformance);
+extern HRESULT WINAPI IDirectMusicBandImpl_Unload (LPDIRECTMUSICBAND iface, IDirectMusicPerformance* pPerformance);
+
+#endif	/* __WINE_DMBAND_PRIVATE_H */
diff --git a/dlls/dmband/regsvr.c b/dlls/dmband/regsvr.c
new file mode 100644
index 0000000..8db7b69
--- /dev/null
+++ b/dlls/dmband/regsvr.c
@@ -0,0 +1,560 @@
+/*
+ *	self-registerable dll functions for dmband.dll
+ *
+ * Copyright (C) 2003 John K. Hohm
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <string.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "winreg.h"
+#include "winerror.h"
+
+#include "dmusics.h"
+#include "dmusici.h"
+#include "dmplugin.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/*
+ * Near the bottom of this file are the exported DllRegisterServer and
+ * DllUnregisterServer, which make all this worthwhile.
+ */
+
+/***********************************************************************
+ *		interface for self-registering
+ */
+struct regsvr_interface
+{
+    IID const *iid;		/* NULL for end of list */
+    LPCSTR name;		/* can be NULL to omit */
+    IID const *base_iid;	/* can be NULL to omit */
+    int num_methods;		/* can be <0 to omit */
+    CLSID const *ps_clsid;	/* can be NULL to omit */
+    CLSID const *ps_clsid32;	/* can be NULL to omit */
+};
+
+static HRESULT register_interfaces(struct regsvr_interface const *list);
+static HRESULT unregister_interfaces(struct regsvr_interface const *list);
+
+struct regsvr_coclass
+{
+    CLSID const *clsid;		/* NULL for end of list */
+    LPCSTR name;		/* can be NULL to omit */
+    LPCSTR ips;			/* can be NULL to omit */
+    LPCSTR ips32;		/* can be NULL to omit */
+    LPCSTR ips32_tmodel;	/* can be NULL to omit */
+    LPCSTR progid;		/* can be NULL to omit */
+    LPCSTR viprogid;		/* can be NULL to omit */
+    LPCSTR progid_extra;	/* can be NULL to omit */
+};
+
+static HRESULT register_coclasses(struct regsvr_coclass const *list);
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
+
+/***********************************************************************
+ *		static string constants
+ */
+static WCHAR const interface_keyname[10] = {
+    'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
+static WCHAR const base_ifa_keyname[14] = {
+    'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
+    'e', 0 };
+static WCHAR const num_methods_keyname[11] = {
+    'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
+static WCHAR const ps_clsid_keyname[15] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', 0 };
+static WCHAR const ps_clsid32_keyname[17] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', '3', '2', 0 };
+static WCHAR const clsid_keyname[6] = {
+    'C', 'L', 'S', 'I', 'D', 0 };
+static WCHAR const curver_keyname[7] = {
+    'C', 'u', 'r', 'V', 'e', 'r', 0 };
+static WCHAR const ips_keyname[13] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    0 };
+static WCHAR const ips32_keyname[15] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    '3', '2', 0 };
+static WCHAR const progid_keyname[7] = {
+    'P', 'r', 'o', 'g', 'I', 'D', 0 };
+static WCHAR const viprogid_keyname[25] = {
+    'V', 'e', 'r', 's', 'i', 'o', 'n', 'I', 'n', 'd', 'e', 'p',
+    'e', 'n', 'd', 'e', 'n', 't', 'P', 'r', 'o', 'g', 'I', 'D',
+    0 };
+static char const tmodel_valuename[] = "ThreadingModel";
+
+/***********************************************************************
+ *		static helper functions
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
+static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
+				   WCHAR const *value);
+static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
+				   char const *value);
+static LONG register_progid(WCHAR const *clsid,
+			    char const *progid, char const *curver_progid,
+			    char const *name, char const *extra);
+static LONG recursive_delete_key(HKEY key);
+static LONG recursive_delete_keyA(HKEY base, char const *name);
+static LONG recursive_delete_keyW(HKEY base, WCHAR const *name);
+
+/***********************************************************************
+ *		register_interfaces
+ */
+static HRESULT register_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+	WCHAR buf[39];
+	HKEY iid_key;
+
+	StringFromGUID2(list->iid, buf, 39);
+	res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
+			      KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
+	if (res != ERROR_SUCCESS) goto error_close_interface_key;
+
+	if (list->name) {
+	    res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)(list->name),
+				 strlen(list->name) + 1);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->base_iid) {
+	    register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (0 <= list->num_methods) {
+	    static WCHAR const fmt[3] = { '%', 'd', 0 };
+	    HKEY key;
+
+	    res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
+				  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+
+	    wsprintfW(buf, fmt, list->num_methods);
+	    res = RegSetValueExW(key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)buf,
+				 (lstrlenW(buf) + 1) * sizeof(WCHAR));
+	    RegCloseKey(key);
+
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->ps_clsid) {
+	    register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->ps_clsid32) {
+	    register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+    error_close_iid_key:
+	RegCloseKey(iid_key);
+    }
+
+error_close_interface_key:
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		unregister_interfaces
+ */
+static HRESULT unregister_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
+			KEY_READ | KEY_WRITE, &interface_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+	WCHAR buf[39];
+
+	StringFromGUID2(list->iid, buf, 39);
+	res = recursive_delete_keyW(interface_key, buf);
+    }
+
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		register_coclasses
+ */
+static HRESULT register_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+	WCHAR buf[39];
+	HKEY clsid_key;
+
+	StringFromGUID2(list->clsid, buf, 39);
+	res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
+			      KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
+	if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+	if (list->name) {
+	    res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)(list->name),
+				 strlen(list->name) + 1);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->ips) {
+	    res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->ips32) {
+	    HKEY ips32_key;
+
+	    res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
+				  KEY_READ | KEY_WRITE, NULL,
+				  &ips32_key, NULL);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)list->ips32,
+				 lstrlenA(list->ips32) + 1);
+	    if (res == ERROR_SUCCESS && list->ips32_tmodel)
+		res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
+				     (CONST BYTE*)list->ips32_tmodel,
+				     strlen(list->ips32_tmodel) + 1);
+	    RegCloseKey(ips32_key);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->progid) {
+	    res = register_key_defvalueA(clsid_key, progid_keyname,
+					 list->progid);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = register_progid(buf, list->progid, NULL,
+				  list->name, list->progid_extra);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->viprogid) {
+	    res = register_key_defvalueA(clsid_key, viprogid_keyname,
+					 list->viprogid);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = register_progid(buf, list->viprogid, list->progid,
+				  list->name, list->progid_extra);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+    error_close_clsid_key:
+	RegCloseKey(clsid_key);
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		unregister_coclasses
+ */
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
+			KEY_READ | KEY_WRITE, &coclass_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+	WCHAR buf[39];
+
+	StringFromGUID2(list->clsid, buf, 39);
+	res = recursive_delete_keyW(coclass_key, buf);
+	if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+	if (list->progid) {
+	    res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->progid);
+	    if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+	}
+
+	if (list->viprogid) {
+	    res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->viprogid);
+	    if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+	}
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		regsvr_key_guid
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
+{
+    WCHAR buf[39];
+
+    StringFromGUID2(guid, buf, 39);
+    return register_key_defvalueW(base, name, buf);
+}
+
+/***********************************************************************
+ *		regsvr_key_defvalueW
+ */
+static LONG register_key_defvalueW(
+    HKEY base,
+    WCHAR const *name,
+    WCHAR const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+			 (lstrlenW(value) + 1) * sizeof(WCHAR));
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		regsvr_key_defvalueA
+ */
+static LONG register_key_defvalueA(
+    HKEY base,
+    WCHAR const *name,
+    char const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+			 lstrlenA(value) + 1);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		regsvr_progid
+ */
+static LONG register_progid(
+    WCHAR const *clsid,
+    char const *progid,
+    char const *curver_progid,
+    char const *name,
+    char const *extra)
+{
+    LONG res;
+    HKEY progid_key;
+
+    res = RegCreateKeyExA(HKEY_CLASSES_ROOT, progid, 0,
+			  NULL, 0, KEY_READ | KEY_WRITE, NULL,
+			  &progid_key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+
+    if (name) {
+	res = RegSetValueExA(progid_key, NULL, 0, REG_SZ,
+			     (CONST BYTE*)name, strlen(name) + 1);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (clsid) {
+	res = register_key_defvalueW(progid_key, clsid_keyname, clsid);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (curver_progid) {
+	res = register_key_defvalueA(progid_key, curver_keyname,
+				     curver_progid);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (extra) {
+	HKEY extra_key;
+
+	res = RegCreateKeyExA(progid_key, extra, 0,
+			      NULL, 0, KEY_READ | KEY_WRITE, NULL,
+			      &extra_key, NULL);
+	if (res == ERROR_SUCCESS)
+	    RegCloseKey(extra_key);
+    }
+
+error_close_progid_key:
+    RegCloseKey(progid_key);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_key
+ */
+static LONG recursive_delete_key(HKEY key)
+{
+    LONG res;
+    WCHAR subkey_name[MAX_PATH];
+    DWORD cName;
+    HKEY subkey;
+
+    for (;;) {
+	cName = sizeof(subkey_name) / sizeof(WCHAR);
+	res = RegEnumKeyExW(key, 0, subkey_name, &cName,
+			    NULL, NULL, NULL, NULL);
+	if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) {
+	    res = ERROR_SUCCESS; /* presumably we're done enumerating */
+	    break;
+	}
+	res = RegOpenKeyExW(key, subkey_name, 0,
+			    KEY_READ | KEY_WRITE, &subkey);
+	if (res == ERROR_FILE_NOT_FOUND) continue;
+	if (res != ERROR_SUCCESS) break;
+
+	res = recursive_delete_key(subkey);
+	RegCloseKey(subkey);
+	if (res != ERROR_SUCCESS) break;
+    }
+
+    if (res == ERROR_SUCCESS) res = RegDeleteKeyW(key, 0);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_keyA
+ */
+static LONG recursive_delete_keyA(HKEY base, char const *name)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegOpenKeyExA(base, name, 0, KEY_READ | KEY_WRITE, &key);
+    if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
+    if (res != ERROR_SUCCESS) return res;
+    res = recursive_delete_key(key);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_keyW
+ */
+static LONG recursive_delete_keyW(HKEY base, WCHAR const *name)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegOpenKeyExW(base, name, 0, KEY_READ | KEY_WRITE, &key);
+    if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
+    if (res != ERROR_SUCCESS) return res;
+    res = recursive_delete_key(key);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		coclass list
+ */
+static struct regsvr_coclass const coclass_list[] = {
+    {   &CLSID_DirectMusicBand,
+	"DirectMusicBand",
+	NULL,
+	"dmband.dll",
+	"Both",
+	"Microsoft.DirectMusicBand.1",
+	"Microsoft.DirectMusicBand"
+    },
+    {   &CLSID_DirectMusicBandTrack,
+	"DirectMusicBandTrack",
+	NULL,
+	"dmband.dll",
+	"Both",
+	"Microsoft.DirectMusicBandTrack.1",
+	"Microsoft.DirectMusicBandTrack"
+    },
+    { NULL }			/* list terminator */
+};
+
+/***********************************************************************
+ *		interface list
+ */
+
+static struct regsvr_interface const interface_list[] = {
+    { NULL }			/* list terminator */
+};
+
+/***********************************************************************
+ *		DllRegisterServer (DMBAND.3)
+ */
+HRESULT WINAPI DMBAND_DllRegisterServer(void)
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = register_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+	hr = register_interfaces(interface_list);
+    return hr;
+}
+
+/***********************************************************************
+ *		DllUnregisterServer (DMBAND.4)
+ */
+HRESULT WINAPI DMBAND_DllUnregisterServer(void)
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = unregister_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+	hr = unregister_interfaces(interface_list);
+    return hr;
+}
diff --git a/dlls/dmcompos/Makefile.in b/dlls/dmcompos/Makefile.in
index 5df8493..46407a6 100644
--- a/dlls/dmcompos/Makefile.in
+++ b/dlls/dmcompos/Makefile.in
@@ -3,13 +3,17 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = dmcompos.dll
-IMPORTS   = dmusic kernel32
+IMPORTS   = ole32 user32 advapi32 kernel32
+EXTRALIBS = $(LIBUUID)
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
 
 C_SRCS = \
-	dmcompos_main.c
+	chordmap.c \
+	composer.c \
+	dmcompos_main.c \
+	regsvr.c
 
 RC_SRCS = version.rc
 
diff --git a/dlls/dmcompos/chordmap.c b/dlls/dmcompos/chordmap.c
new file mode 100644
index 0000000..d56b25a
--- /dev/null
+++ b/dlls/dmcompos/chordmap.c
@@ -0,0 +1,105 @@
+/* IDirectMusicChordMap Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmcompos_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicChordMap IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicChordMapImpl_QueryInterface (LPDIRECTMUSICCHORDMAP iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicChordMapImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || 
+	    IsEqualGUID(riid, &IID_IDirectMusicChordMap))
+	{
+		IDirectMusicChordMapImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicChordMapImpl_AddRef (LPDIRECTMUSICCHORDMAP iface)
+{
+	ICOM_THIS(IDirectMusicChordMapImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicChordMapImpl_Release (LPDIRECTMUSICCHORDMAP iface)
+{
+	ICOM_THIS(IDirectMusicChordMapImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicChordMap Interface follow: */
+HRESULT WINAPI IDirectMusicChordMapImpl_GetScale (LPDIRECTMUSICCHORDMAP iface, DWORD* pdwScale)
+{
+	ICOM_THIS(IDirectMusicChordMapImpl,iface);
+
+	TRACE("(%p, %p)\n", This, pdwScale);
+	*pdwScale = This->dwScale;
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicChordMap) DirectMusicChordMap_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicChordMapImpl_QueryInterface,
+	IDirectMusicChordMapImpl_AddRef,
+	IDirectMusicChordMapImpl_Release,
+	IDirectMusicChordMapImpl_GetScale
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicChordMap (LPCGUID lpcGUID, LPDIRECTMUSICCHORDMAP* ppDMCM, LPUNKNOWN pUnkOuter)
+{
+	IDirectMusicChordMapImpl* dmchordmap;
+	
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicChordMap))
+	{
+		dmchordmap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicChordMapImpl));
+		if (NULL == dmchordmap) {
+			*ppDMCM = (LPDIRECTMUSICCHORDMAP) NULL;
+			return E_OUTOFMEMORY;
+		}
+		dmchordmap->lpVtbl = &DirectMusicChordMap_Vtbl;
+		dmchordmap->ref = 1;
+		*ppDMCM = (LPDIRECTMUSICCHORDMAP) dmchordmap;
+		return S_OK;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmcompos/composer.c b/dlls/dmcompos/composer.c
new file mode 100644
index 0000000..0940d46
--- /dev/null
+++ b/dlls/dmcompos/composer.c
@@ -0,0 +1,154 @@
+/* IDirectMusicComposer
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmcompos_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicComposer IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicComposerImpl_QueryInterface (LPDIRECTMUSICCOMPOSER iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicComposerImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || 
+	    IsEqualGUID(riid, &IID_IDirectMusicComposer))
+	{
+		IDirectMusicComposerImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicComposerImpl_AddRef (LPDIRECTMUSICCOMPOSER iface)
+{
+	ICOM_THIS(IDirectMusicComposerImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicComposerImpl_Release (LPDIRECTMUSICCOMPOSER iface)
+{
+	ICOM_THIS(IDirectMusicComposerImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicComposer Interface follow: */
+HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromTemplate (LPDIRECTMUSICCOMPOSER iface, IDirectMusicStyle* pStyle, IDirectMusicSegment* pTemplate, WORD wActivity, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppSegment)
+{
+	ICOM_THIS(IDirectMusicComposerImpl,iface);
+
+	FIXME("(%p, %p, %p, %d, %p, %p): stub\n", This, pStyle, pTemplate, wActivity, pChordMap, ppSegment);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromShape (LPDIRECTMUSICCOMPOSER iface, IDirectMusicStyle* pStyle, WORD wNumMeasures, WORD wShape, WORD wActivity, BOOL fIntro, BOOL fEnd, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppSegment)
+{
+	ICOM_THIS(IDirectMusicComposerImpl,iface);
+
+	FIXME("(%p, %p, %d, %d, %d, %d, %d, %p, %p): stub\n", This, pStyle, wNumMeasures, wShape, wActivity, fIntro, fEnd, pChordMap, ppSegment);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicComposerImpl_ComposeTransition (LPDIRECTMUSICCOMPOSER iface, IDirectMusicSegment* pFromSeg, IDirectMusicSegment* pToSeg, MUSIC_TIME mtTime, WORD wCommand, DWORD dwFlags, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppTransSeg)
+{
+	ICOM_THIS(IDirectMusicComposerImpl,iface);
+
+	FIXME("(%p, %p, %p, %ld, %d, %ld, %p, %p): stub\n", This, pFromSeg, pToSeg, mtTime, wCommand, dwFlags, pChordMap, ppTransSeg);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicComposerImpl_AutoTransition (LPDIRECTMUSICCOMPOSER iface, IDirectMusicPerformance* pPerformance, IDirectMusicSegment* pToSeg, WORD wCommand, DWORD dwFlags, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppTransSeg, IDirectMusicSegmentState** ppToSegState, IDirectMusicSegmentState** ppTransSegState)
+{
+	ICOM_THIS(IDirectMusicComposerImpl,iface);
+
+	FIXME("(%p, %p, %d, %ld, %p, %p, %p, %p): stub\n", This, pPerformance, wCommand, dwFlags, pChordMap, ppTransSeg, ppToSegState, ppTransSegState);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicComposerImpl_ComposeTemplateFromShape (LPDIRECTMUSICCOMPOSER iface, WORD wNumMeasures, WORD wShape, BOOL fIntro, BOOL fEnd, WORD wEndLength, IDirectMusicSegment** ppTemplate)
+{
+	ICOM_THIS(IDirectMusicComposerImpl,iface);
+
+	FIXME("(%p, %d, %d, %d, %d, %d, %p): stub\n", This, wNumMeasures, wShape, fIntro, fEnd, wEndLength, ppTemplate);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicComposerImpl_ChangeChordMap (LPDIRECTMUSICCOMPOSER iface, IDirectMusicSegment* pSegment, BOOL fTrackScale, IDirectMusicChordMap* pChordMap)
+{
+	ICOM_THIS(IDirectMusicComposerImpl,iface);
+
+	FIXME("(%p, %p, %d, %p): stub\n", This, pSegment, fTrackScale, pChordMap);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicComposer) DirectMusicComposer_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicComposerImpl_QueryInterface,
+	IDirectMusicComposerImpl_AddRef,
+	IDirectMusicComposerImpl_Release,
+	IDirectMusicComposerImpl_ComposeSegmentFromTemplate,
+	IDirectMusicComposerImpl_ComposeSegmentFromShape,
+	IDirectMusicComposerImpl_ComposeTransition,
+	IDirectMusicComposerImpl_AutoTransition,
+	IDirectMusicComposerImpl_ComposeTemplateFromShape,
+	IDirectMusicComposerImpl_ChangeChordMap
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicComposer (LPCGUID lpcGUID, LPDIRECTMUSICCOMPOSER* ppDMCP, LPUNKNOWN pUnkOuter)
+{
+	IDirectMusicComposerImpl* dmcompos;
+	
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicComposer))
+	{
+		dmcompos = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicComposerImpl));
+		if (NULL == dmcompos) {
+			*ppDMCP = (LPDIRECTMUSICCOMPOSER) NULL;
+			return E_OUTOFMEMORY;
+		}
+		dmcompos->lpVtbl = &DirectMusicComposer_Vtbl;
+		dmcompos->ref = 1;
+		*ppDMCP = (LPDIRECTMUSICCOMPOSER) dmcompos;
+		return S_OK;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmcompos/dmcompos.spec b/dlls/dmcompos/dmcompos.spec
index 7ac7be8..6902f37 100644
--- a/dlls/dmcompos/dmcompos.spec
+++ b/dlls/dmcompos/dmcompos.spec
@@ -1,6 +1,4 @@
-# Linked to main dmusic.dll for easier implementation
-
-1 stdcall DllCanUnloadNow() dmusic.CanUnloadNow
-2 stdcall DllGetClassObject(long long ptr) dmusic.DllGetClassObject
-3 stdcall DllRegisterServer() dmusic.DllRegisterServer
-4 stdcall DllUnregisterServer() dmusic.DllUnregisterServer
+1 stdcall DllCanUnloadNow() DMCOMPOS_DllCanUnloadNow
+2 stdcall DllGetClassObject(long long ptr) DMCOMPOS_DllGetClassObject
+3 stdcall DllRegisterServer() DMCOMPOS_DllRegisterServer
+4 stdcall DllUnregisterServer() DMCOMPOS_DllUnregisterServer
diff --git a/dlls/dmcompos/dmcompos_main.c b/dlls/dmcompos/dmcompos_main.c
index 67a01ed..6a91224 100644
--- a/dlls/dmcompos/dmcompos_main.c
+++ b/dlls/dmcompos/dmcompos_main.c
@@ -1 +1,141 @@
-/* nothing here yet */
+/* DirectMusicComposer Main
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "dmcompos_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+
+/******************************************************************
+ *		DirectMusicComposer ClassFactory
+ *
+ *
+ */
+ 
+typedef struct
+{
+    /* IUnknown fields */
+    ICOM_VFIELD(IClassFactory);
+    DWORD                       ref;
+} IClassFactoryImpl;
+
+static HRESULT WINAPI DMCPCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+
+	FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+static ULONG WINAPI DMCPCF_AddRef(LPCLASSFACTORY iface)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	return ++(This->ref);
+}
+
+static ULONG WINAPI DMCPCF_Release(LPCLASSFACTORY iface)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	/* static class, won't be  freed */
+	return --(This->ref);
+}
+
+static HRESULT WINAPI DMCPCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+
+	TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
+	if (IsEqualGUID (riid, &IID_IDirectMusicChordMap)) {
+		return DMUSIC_CreateDirectMusicChordMap (riid, (LPDIRECTMUSICCHORDMAP*)ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicComposer)) {
+		return DMUSIC_CreateDirectMusicComposer (riid, (LPDIRECTMUSICCOMPOSER*)ppobj, pOuter);
+	}
+		
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+static HRESULT WINAPI DMCPCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	FIXME("(%p)->(%d),stub!\n", This, dolock);
+	return S_OK;
+}
+
+static ICOM_VTABLE(IClassFactory) DMCPCF_Vtbl = {
+	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	DMCPCF_QueryInterface,
+	DMCPCF_AddRef,
+	DMCPCF_Release,
+	DMCPCF_CreateInstance,
+	DMCPCF_LockServer
+};
+
+static IClassFactoryImpl DMCOMPOS_CF = {&DMCPCF_Vtbl, 1 };
+
+/******************************************************************
+ *		DllMain
+ *
+ *
+ */
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+	if (fdwReason == DLL_PROCESS_ATTACH)
+	{
+            DisableThreadLibraryCalls(hinstDLL);
+		/* FIXME: Initialisation */
+	}
+	else if (fdwReason == DLL_PROCESS_DETACH)
+	{
+		/* FIXME: Cleanup */
+	}
+
+	return TRUE;
+}
+
+
+/******************************************************************
+ *		DllCanUnloadNow (DMCOMPOS.1)
+ *
+ *
+ */
+HRESULT WINAPI DMCOMPOS_DllCanUnloadNow(void)
+{
+    FIXME("(void): stub\n");
+
+    return S_FALSE;
+}
+
+
+/******************************************************************
+ *		DllGetClassObject (DMCOMPOS.2)
+ *
+ *
+ */
+HRESULT WINAPI DMCOMPOS_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
+{
+    TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    if (IsEqualCLSID (&IID_IClassFactory, riid)) {
+      *ppv = (LPVOID) &DMCOMPOS_CF;
+      IClassFactory_AddRef((IClassFactory*)*ppv);
+      return S_OK;
+    }
+    WARN("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    return CLASS_E_CLASSNOTAVAILABLE;
+}
diff --git a/dlls/dmcompos/dmcompos_private.h b/dlls/dmcompos/dmcompos_private.h
new file mode 100644
index 0000000..3fc8b63
--- /dev/null
+++ b/dlls/dmcompos/dmcompos_private.h
@@ -0,0 +1,105 @@
+/* DirectMusicComposer Private Include
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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.
+ */
+
+#ifndef __WINE_DMCOMPOS_PRIVATE_H
+#define __WINE_DMCOMPOS_PRIVATE_H
+
+#include "windef.h"
+#include "wine/debug.h"
+#include "winbase.h"
+#include "winnt.h"
+#include "dmusicc.h"
+#include "dmusici.h"
+#include "dmusics.h"
+#include "dmplugin.h"
+#include "dmusicf.h"
+#include "dsound.h"
+
+/*****************************************************************************
+ * Interfaces
+ */
+typedef struct IDirectMusicChordMapImpl IDirectMusicChordMapImpl;
+typedef struct IDirectMusicComposerImpl IDirectMusicComposerImpl;
+
+/*****************************************************************************
+ * Predeclare the interface implementation structures
+ */
+extern ICOM_VTABLE(IDirectMusicChordMap) DirectMusicChordMap_Vtbl;
+extern ICOM_VTABLE(IDirectMusicComposer) DirectMusicComposer_Vtbl;
+
+/*****************************************************************************
+ * ClassFactory
+ */
+
+/* can support IID_IDirectMusicChordMap
+ * return always an IDirectMusicChordMapImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicChordMap (LPCGUID lpcGUID, LPDIRECTMUSICCHORDMAP* ppDMCM, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicComposer
+ * return always an IDirectMusicComposerImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicComposer (LPCGUID lpcGUID, LPDIRECTMUSICCOMPOSER* ppDMCP, LPUNKNOWN pUnkOuter);
+
+
+/*****************************************************************************
+ * IDirectMusicChordMapImpl implementation structure
+ */
+struct IDirectMusicChordMapImpl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicChordMap);
+  DWORD ref;
+
+  /* IDirectMusicChordMapImpl fields */
+  DWORD dwScale;
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicChordMapImpl_QueryInterface (LPDIRECTMUSICCHORDMAP iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicChordMapImpl_AddRef (LPDIRECTMUSICCHORDMAP iface);
+extern ULONG WINAPI   IDirectMusicChordMapImpl_Release (LPDIRECTMUSICCHORDMAP iface);
+/* IDirectMusicChordMap: */
+extern HRESULT WINAPI IDirectMusicChordMapImpl_GetScale (LPDIRECTMUSICCHORDMAP iface, DWORD* pdwScale);
+
+
+/*****************************************************************************
+ * IDirectMusicComposerImpl implementation structure
+ */
+struct IDirectMusicComposerImpl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicComposer);
+  DWORD ref;
+
+  /* IDirectMusicComposerImpl fields */
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicComposerImpl_QueryInterface (LPDIRECTMUSICCOMPOSER iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicComposerImpl_AddRef (LPDIRECTMUSICCOMPOSER iface);
+extern ULONG WINAPI   IDirectMusicComposerImpl_Release (LPDIRECTMUSICCOMPOSER iface);
+/* IDirectMusicComposer: */
+extern HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromTemplate (LPDIRECTMUSICCOMPOSER iface, IDirectMusicStyle* pStyle, IDirectMusicSegment* pTemplate, WORD wActivity, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppSegment);

+extern HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromShape (LPDIRECTMUSICCOMPOSER iface, IDirectMusicStyle* pStyle, WORD wNumMeasures, WORD wShape, WORD wActivity, BOOL fIntro, BOOL fEnd, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppSegment);

+extern HRESULT WINAPI IDirectMusicComposerImpl_ComposeTransition (LPDIRECTMUSICCOMPOSER iface, IDirectMusicSegment* pFromSeg, IDirectMusicSegment* pToSeg, MUSIC_TIME mtTime, WORD wCommand, DWORD dwFlags, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppTransSeg);

+extern HRESULT WINAPI IDirectMusicComposerImpl_AutoTransition (LPDIRECTMUSICCOMPOSER iface, IDirectMusicPerformance* pPerformance, IDirectMusicSegment* pToSeg, WORD wCommand, DWORD dwFlags, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppTransSeg, IDirectMusicSegmentState** ppToSegState, IDirectMusicSegmentState** ppTransSegState);

+extern HRESULT WINAPI IDirectMusicComposerImpl_ComposeTemplateFromShape (LPDIRECTMUSICCOMPOSER iface, WORD wNumMeasures, WORD wShape, BOOL fIntro, BOOL fEnd, WORD wEndLength, IDirectMusicSegment** ppTemplate);

+extern HRESULT WINAPI IDirectMusicComposerImpl_ChangeChordMap (LPDIRECTMUSICCOMPOSER iface, IDirectMusicSegment* pSegment, BOOL fTrackScale, IDirectMusicChordMap* pChordMap);
+
+#endif	/* __WINE_DMCOMPOS_PRIVATE_H */
diff --git a/dlls/dmcompos/regsvr.c b/dlls/dmcompos/regsvr.c
new file mode 100644
index 0000000..8640959
--- /dev/null
+++ b/dlls/dmcompos/regsvr.c
@@ -0,0 +1,584 @@
+/*
+ *	self-registerable dll functions for dmcompos.dll
+ *
+ * Copyright (C) 2003 John K. Hohm
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <string.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "winreg.h"
+#include "winerror.h"
+
+#include "dmusics.h"
+#include "dmusici.h"
+#include "dmplugin.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/*
+ * Near the bottom of this file are the exported DllRegisterServer and
+ * DllUnregisterServer, which make all this worthwhile.
+ */
+
+/***********************************************************************
+ *		interface for self-registering
+ */
+struct regsvr_interface
+{
+    IID const *iid;		/* NULL for end of list */
+    LPCSTR name;		/* can be NULL to omit */
+    IID const *base_iid;	/* can be NULL to omit */
+    int num_methods;		/* can be <0 to omit */
+    CLSID const *ps_clsid;	/* can be NULL to omit */
+    CLSID const *ps_clsid32;	/* can be NULL to omit */
+};
+
+static HRESULT register_interfaces(struct regsvr_interface const *list);
+static HRESULT unregister_interfaces(struct regsvr_interface const *list);
+
+struct regsvr_coclass
+{
+    CLSID const *clsid;		/* NULL for end of list */
+    LPCSTR name;		/* can be NULL to omit */
+    LPCSTR ips;			/* can be NULL to omit */
+    LPCSTR ips32;		/* can be NULL to omit */
+    LPCSTR ips32_tmodel;	/* can be NULL to omit */
+    LPCSTR progid;		/* can be NULL to omit */
+    LPCSTR viprogid;		/* can be NULL to omit */
+    LPCSTR progid_extra;	/* can be NULL to omit */
+};
+
+static HRESULT register_coclasses(struct regsvr_coclass const *list);
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
+
+/***********************************************************************
+ *		static string constants
+ */
+static WCHAR const interface_keyname[10] = {
+    'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
+static WCHAR const base_ifa_keyname[14] = {
+    'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
+    'e', 0 };
+static WCHAR const num_methods_keyname[11] = {
+    'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
+static WCHAR const ps_clsid_keyname[15] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', 0 };
+static WCHAR const ps_clsid32_keyname[17] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', '3', '2', 0 };
+static WCHAR const clsid_keyname[6] = {
+    'C', 'L', 'S', 'I', 'D', 0 };
+static WCHAR const curver_keyname[7] = {
+    'C', 'u', 'r', 'V', 'e', 'r', 0 };
+static WCHAR const ips_keyname[13] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    0 };
+static WCHAR const ips32_keyname[15] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    '3', '2', 0 };
+static WCHAR const progid_keyname[7] = {
+    'P', 'r', 'o', 'g', 'I', 'D', 0 };
+static WCHAR const viprogid_keyname[25] = {
+    'V', 'e', 'r', 's', 'i', 'o', 'n', 'I', 'n', 'd', 'e', 'p',
+    'e', 'n', 'd', 'e', 'n', 't', 'P', 'r', 'o', 'g', 'I', 'D',
+    0 };
+static char const tmodel_valuename[] = "ThreadingModel";
+
+/***********************************************************************
+ *		static helper functions
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
+static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
+				   WCHAR const *value);
+static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
+				   char const *value);
+static LONG register_progid(WCHAR const *clsid,
+			    char const *progid, char const *curver_progid,
+			    char const *name, char const *extra);
+static LONG recursive_delete_key(HKEY key);
+static LONG recursive_delete_keyA(HKEY base, char const *name);
+static LONG recursive_delete_keyW(HKEY base, WCHAR const *name);
+
+/***********************************************************************
+ *		register_interfaces
+ */
+static HRESULT register_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+	WCHAR buf[39];
+	HKEY iid_key;
+
+	StringFromGUID2(list->iid, buf, 39);
+	res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
+			      KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
+	if (res != ERROR_SUCCESS) goto error_close_interface_key;
+
+	if (list->name) {
+	    res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)(list->name),
+				 strlen(list->name) + 1);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->base_iid) {
+	    register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (0 <= list->num_methods) {
+	    static WCHAR const fmt[3] = { '%', 'd', 0 };
+	    HKEY key;
+
+	    res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
+				  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+
+	    wsprintfW(buf, fmt, list->num_methods);
+	    res = RegSetValueExW(key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)buf,
+				 (lstrlenW(buf) + 1) * sizeof(WCHAR));
+	    RegCloseKey(key);
+
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->ps_clsid) {
+	    register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->ps_clsid32) {
+	    register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+    error_close_iid_key:
+	RegCloseKey(iid_key);
+    }
+
+error_close_interface_key:
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		unregister_interfaces
+ */
+static HRESULT unregister_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
+			KEY_READ | KEY_WRITE, &interface_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+	WCHAR buf[39];
+
+	StringFromGUID2(list->iid, buf, 39);
+	res = recursive_delete_keyW(interface_key, buf);
+    }
+
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		register_coclasses
+ */
+static HRESULT register_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+	WCHAR buf[39];
+	HKEY clsid_key;
+
+	StringFromGUID2(list->clsid, buf, 39);
+	res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
+			      KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
+	if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+	if (list->name) {
+	    res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)(list->name),
+				 strlen(list->name) + 1);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->ips) {
+	    res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->ips32) {
+	    HKEY ips32_key;
+
+	    res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
+				  KEY_READ | KEY_WRITE, NULL,
+				  &ips32_key, NULL);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)list->ips32,
+				 lstrlenA(list->ips32) + 1);
+	    if (res == ERROR_SUCCESS && list->ips32_tmodel)
+		res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
+				     (CONST BYTE*)list->ips32_tmodel,
+				     strlen(list->ips32_tmodel) + 1);
+	    RegCloseKey(ips32_key);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->progid) {
+	    res = register_key_defvalueA(clsid_key, progid_keyname,
+					 list->progid);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = register_progid(buf, list->progid, NULL,
+				  list->name, list->progid_extra);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->viprogid) {
+	    res = register_key_defvalueA(clsid_key, viprogid_keyname,
+					 list->viprogid);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = register_progid(buf, list->viprogid, list->progid,
+				  list->name, list->progid_extra);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+    error_close_clsid_key:
+	RegCloseKey(clsid_key);
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		unregister_coclasses
+ */
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
+			KEY_READ | KEY_WRITE, &coclass_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+	WCHAR buf[39];
+
+	StringFromGUID2(list->clsid, buf, 39);
+	res = recursive_delete_keyW(coclass_key, buf);
+	if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+	if (list->progid) {
+	    res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->progid);
+	    if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+	}
+
+	if (list->viprogid) {
+	    res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->viprogid);
+	    if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+	}
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		regsvr_key_guid
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
+{
+    WCHAR buf[39];
+
+    StringFromGUID2(guid, buf, 39);
+    return register_key_defvalueW(base, name, buf);
+}
+
+/***********************************************************************
+ *		regsvr_key_defvalueW
+ */
+static LONG register_key_defvalueW(
+    HKEY base,
+    WCHAR const *name,
+    WCHAR const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+			 (lstrlenW(value) + 1) * sizeof(WCHAR));
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		regsvr_key_defvalueA
+ */
+static LONG register_key_defvalueA(
+    HKEY base,
+    WCHAR const *name,
+    char const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+			 lstrlenA(value) + 1);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		regsvr_progid
+ */
+static LONG register_progid(
+    WCHAR const *clsid,
+    char const *progid,
+    char const *curver_progid,
+    char const *name,
+    char const *extra)
+{
+    LONG res;
+    HKEY progid_key;
+
+    res = RegCreateKeyExA(HKEY_CLASSES_ROOT, progid, 0,
+			  NULL, 0, KEY_READ | KEY_WRITE, NULL,
+			  &progid_key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+
+    if (name) {
+	res = RegSetValueExA(progid_key, NULL, 0, REG_SZ,
+			     (CONST BYTE*)name, strlen(name) + 1);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (clsid) {
+	res = register_key_defvalueW(progid_key, clsid_keyname, clsid);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (curver_progid) {
+	res = register_key_defvalueA(progid_key, curver_keyname,
+				     curver_progid);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (extra) {
+	HKEY extra_key;
+
+	res = RegCreateKeyExA(progid_key, extra, 0,
+			      NULL, 0, KEY_READ | KEY_WRITE, NULL,
+			      &extra_key, NULL);
+	if (res == ERROR_SUCCESS)
+	    RegCloseKey(extra_key);
+    }
+
+error_close_progid_key:
+    RegCloseKey(progid_key);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_key
+ */
+static LONG recursive_delete_key(HKEY key)
+{
+    LONG res;
+    WCHAR subkey_name[MAX_PATH];
+    DWORD cName;
+    HKEY subkey;
+
+    for (;;) {
+	cName = sizeof(subkey_name) / sizeof(WCHAR);
+	res = RegEnumKeyExW(key, 0, subkey_name, &cName,
+			    NULL, NULL, NULL, NULL);
+	if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) {
+	    res = ERROR_SUCCESS; /* presumably we're done enumerating */
+	    break;
+	}
+	res = RegOpenKeyExW(key, subkey_name, 0,
+			    KEY_READ | KEY_WRITE, &subkey);
+	if (res == ERROR_FILE_NOT_FOUND) continue;
+	if (res != ERROR_SUCCESS) break;
+
+	res = recursive_delete_key(subkey);
+	RegCloseKey(subkey);
+	if (res != ERROR_SUCCESS) break;
+    }
+
+    if (res == ERROR_SUCCESS) res = RegDeleteKeyW(key, 0);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_keyA
+ */
+static LONG recursive_delete_keyA(HKEY base, char const *name)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegOpenKeyExA(base, name, 0, KEY_READ | KEY_WRITE, &key);
+    if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
+    if (res != ERROR_SUCCESS) return res;
+    res = recursive_delete_key(key);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_keyW
+ */
+static LONG recursive_delete_keyW(HKEY base, WCHAR const *name)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegOpenKeyExW(base, name, 0, KEY_READ | KEY_WRITE, &key);
+    if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
+    if (res != ERROR_SUCCESS) return res;
+    res = recursive_delete_key(key);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		coclass list
+ */
+static struct regsvr_coclass const coclass_list[] = {
+    {   &CLSID_DirectMusicChordMap,
+	"DirectMusicChordMap",
+	NULL,
+	"dmcompos.dll",
+	"Both",
+	"Microsoft.DirectMusicChordMap.1",
+	"Microsoft.DirectMusicChordMap"
+    },
+    {   &CLSID_DirectMusicComposer,
+	"DirectMusicComposer",
+	NULL,
+	"dmcompos.dll",
+	"Both",
+	"Microsoft.DirectMusicComposer.1",
+	"Microsoft.DirectMusicComposer"
+    },
+    {   &CLSID_DirectMusicChordMapTrack,
+	"DirectMusicChordMapTrack",
+	NULL,
+	"dmcompos.dll",
+	"Both",
+	"Microsoft.DirectMusicChordMapTrack.1",
+	"Microsoft.DirectMusicChordMapTrack"
+    },
+    {   &CLSID_DirectMusicTemplate,
+	"DirectMusicTemplate",
+	NULL,
+	"dmcompos.dll",
+	"Both",
+	"Microsoft.DirectMusicTemplate.1",
+	"Microsoft.DirectMusicTemplate"
+    },
+    {   &CLSID_DirectMusicSignPostTrack,
+	"DirectMusicSignPostTrack",
+	NULL,
+	"dmcompos.dll",
+	"Both",
+	"Microsoft.DirectMusicSignPostTrack.1",
+	"Microsoft.DirectMusicSignPostTrack"
+    },
+    { NULL }			/* list terminator */
+};
+
+/***********************************************************************
+ *		interface list
+ */
+
+static struct regsvr_interface const interface_list[] = {
+    { NULL }			/* list terminator */
+};
+
+/***********************************************************************
+ *		DllRegisterServer (DMCOMPOS.3)
+ */
+HRESULT WINAPI DMCOMPOS_DllRegisterServer(void)
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = register_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+	hr = register_interfaces(interface_list);
+    return hr;
+}
+
+/***********************************************************************
+ *		DllUnregisterServer (DMCOMPOS.4)
+ */
+HRESULT WINAPI DMCOMPOS_DllUnregisterServer(void)
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = unregister_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+	hr = unregister_interfaces(interface_list);
+    return hr;
+}
diff --git a/dlls/dmime/Makefile.in b/dlls/dmime/Makefile.in
index d4b553d..816e829 100644
--- a/dlls/dmime/Makefile.in
+++ b/dlls/dmime/Makefile.in
@@ -3,13 +3,24 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = dmime.dll
-IMPORTS   = dmusic kernel32
+IMPORTS   = dsound winmm ole32 user32 advapi32 kernel32
+EXTRALIBS = $(LIBUUID)
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
 
 C_SRCS = \
-	dmime_main.c
+	audiopath.c \
+	dmime_main.c \
+	graph.c \
+	patterntrack.c \
+	performance.c \
+	regsvr.c \
+	segment.c \
+	segmentstate.c \
+	song.c \
+	tool.c \
+	track.c
 
 RC_SRCS = version.rc
 
diff --git a/dlls/dmime/audiopath.c b/dlls/dmime/audiopath.c
new file mode 100644
index 0000000..f5c4449
--- /dev/null
+++ b/dlls/dmime/audiopath.c
@@ -0,0 +1,209 @@
+/* IDirectMusicAudioPath Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmime_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicAudioPath IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicAudioPathImpl_QueryInterface (LPDIRECTMUSICAUDIOPATH iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicAudioPathImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || 
+	    IsEqualGUID(riid, &IID_IDirectMusicAudioPath))
+	{
+		IDirectMusicAudioPathImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicAudioPathImpl_AddRef (LPDIRECTMUSICAUDIOPATH iface)
+{
+	ICOM_THIS(IDirectMusicAudioPathImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicAudioPathImpl_Release (LPDIRECTMUSICAUDIOPATH iface)
+{
+	ICOM_THIS(IDirectMusicAudioPathImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicAudioPath Interface follow: */
+HRESULT WINAPI IDirectMusicAudioPathImpl_GetObjectInPath (LPDIRECTMUSICAUDIOPATH iface, DWORD dwPChannel, DWORD dwStage, DWORD dwBuffer, REFGUID guidObject, WORD dwIndex, REFGUID iidInterface, void** ppObject)
+{
+	ICOM_THIS(IDirectMusicAudioPathImpl,iface);
+
+	FIXME("(%p, %ld, %ld, %ld, %s, %d, %s, %p): stub\n", This, dwPChannel, dwStage, dwBuffer, debugstr_guid(guidObject), dwIndex, debugstr_guid(iidInterface), ppObject);
+
+	switch (dwStage) {
+	case DMUS_PATH_BUFFER:
+	  {
+	    if (IsEqualGUID(iidInterface,&IID_IDirectSoundBuffer8)) {
+	      IDirectSoundBuffer8_QueryInterface(This->pDSBuffer, &IID_IDirectSoundBuffer8, ppObject);
+	      TRACE("returning %p\n",*ppObject);
+	      return S_OK;
+	    } else if (IsEqualGUID(iidInterface,&IID_IDirectSound3DBuffer)) {
+	      IDirectSoundBuffer8_QueryInterface(This->pDSBuffer, &IID_IDirectSound3DBuffer, ppObject);
+	      TRACE("returning %p\n",*ppObject);
+	      return S_OK;
+	    } else {
+	      FIXME("Bad iid\n");
+	    }
+	  }
+	  break;
+
+	case DMUS_PATH_PRIMARY_BUFFER: {
+	  if (IsEqualGUID(iidInterface,&IID_IDirectSound3DListener)) {
+	    IDirectSoundBuffer8_QueryInterface(This->pPrimary, &IID_IDirectSound3DListener, ppObject);
+	    return S_OK;
+	  }else {
+	    FIXME("bad iid...\n");
+	  }
+	}
+	break;
+
+	case DMUS_PATH_AUDIOPATH_GRAPH:
+	  {
+	    if (IsEqualGUID(iidInterface, &IID_IDirectMusicGraph)) {
+	      if (NULL == This->pToolGraph) {
+		IDirectMusicGraphImpl* pGraph;
+		pGraph = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicGraphImpl));		
+		pGraph->lpVtbl = &DirectMusicGraph_Vtbl;
+		pGraph->ref = 1;
+		This->pToolGraph = (IDirectMusicGraph*) pGraph;
+	      }
+	      *ppObject = (LPDIRECTMUSICGRAPH) This->pToolGraph; 
+	      IDirectMusicGraphImpl_AddRef((LPDIRECTMUSICGRAPH) *ppObject);
+	      return S_OK;
+	    }
+	  }
+	  break;
+
+	case DMUS_PATH_AUDIOPATH_TOOL:
+	  {
+	    /* TODO */
+	  }
+	  break;
+
+	case DMUS_PATH_PERFORMANCE:
+	  {
+	    /* TODO check wanted GUID */
+	    *ppObject = (LPDIRECTMUSICPERFORMANCE8) This->pPerf; 
+	    IDirectMusicPerformance8Impl_AddRef((LPDIRECTMUSICPERFORMANCE8) *ppObject);
+	    return S_OK;
+	  }
+	  break;
+
+	case DMUS_PATH_PERFORMANCE_GRAPH:
+	  {
+	    IDirectMusicGraph* pPerfoGraph = NULL; 
+	    IDirectMusicPerformance8Impl_GetGraph((LPDIRECTMUSICPERFORMANCE8) This->pPerf, &pPerfoGraph);
+	    if (NULL == pPerfoGraph) {
+	      IDirectMusicGraphImpl* pGraph = NULL; 
+	      pGraph = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicGraphImpl));		
+	      pGraph->lpVtbl = &DirectMusicGraph_Vtbl;
+	      pGraph->ref = 1;
+	      IDirectMusicPerformance8Impl_SetGraph((LPDIRECTMUSICPERFORMANCE8) This->pPerf, (IDirectMusicGraph*) pGraph);
+	      /* we need release as SetGraph do an AddRef */
+	      IDirectMusicGraphImpl_Release((LPDIRECTMUSICGRAPH) pGraph);
+	      pPerfoGraph = (LPDIRECTMUSICGRAPH) pGraph;
+	    }
+	    *ppObject = (LPDIRECTMUSICGRAPH) pPerfoGraph; 
+	    return S_OK;
+	  }
+	  break;
+
+	case DMUS_PATH_PERFORMANCE_TOOL:
+	default:
+	  break;
+	}
+
+	*ppObject = NULL;
+	return E_INVALIDARG;
+}
+
+HRESULT WINAPI IDirectMusicAudioPathImpl_Activate (LPDIRECTMUSICAUDIOPATH iface, BOOL fActivate)
+{
+	ICOM_THIS(IDirectMusicAudioPathImpl,iface);
+
+	FIXME("(%p, %d): stub\n", This, fActivate);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicAudioPathImpl_SetVolume (LPDIRECTMUSICAUDIOPATH iface, long lVolume, DWORD dwDuration)
+{
+	ICOM_THIS(IDirectMusicAudioPathImpl,iface);
+
+	FIXME("(%p, %li, %ld): stub\n", This, lVolume, dwDuration);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicAudioPathImpl_ConvertPChannel (LPDIRECTMUSICAUDIOPATH iface, DWORD dwPChannelIn, DWORD* pdwPChannelOut)
+{
+	ICOM_THIS(IDirectMusicAudioPathImpl,iface);
+
+	FIXME("(%p, %ld, %p): stub\n", This, dwPChannelIn, pdwPChannelOut);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicAudioPath) DirectMusicAudioPath_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicAudioPathImpl_QueryInterface,
+	IDirectMusicAudioPathImpl_AddRef,
+	IDirectMusicAudioPathImpl_Release,
+	IDirectMusicAudioPathImpl_GetObjectInPath,
+	IDirectMusicAudioPathImpl_Activate,
+	IDirectMusicAudioPathImpl_SetVolume,
+	IDirectMusicAudioPathImpl_ConvertPChannel
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicAudioPath (LPCGUID lpcGUID, LPDIRECTMUSICAUDIOPATH* ppDMCAPath, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicAudioPath))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmime/dmime.spec b/dlls/dmime/dmime.spec
index 3d091d1..2cb661d 100644
--- a/dlls/dmime/dmime.spec
+++ b/dlls/dmime/dmime.spec
@@ -1,6 +1,4 @@
-# Linked to main dmusic.dll for easier implementation
-
-1 stdcall DllCanUnloadNow() dmusic.DllCanUnloadNow
-2 stdcall DllGetClassObject(long long ptr) dmusic.DllGetClassObject
-3 stdcall DllRegisterServer() dmusic.DllRegisterServer
-4 stdcall DllUnregisterServer() dmusic.DllUnregisterServer
+1 stdcall DllCanUnloadNow() DMIME_DllCanUnloadNow
+2 stdcall DllGetClassObject(long long ptr) DMIME_DllGetClassObject
+3 stdcall DllRegisterServer() DMIME_DllRegisterServer
+4 stdcall DllUnregisterServer() DMIME_DllUnregisterServer
diff --git a/dlls/dmime/dmime_main.c b/dlls/dmime/dmime_main.c
index 67a01ed..896c8c1 100644
--- a/dlls/dmime/dmime_main.c
+++ b/dlls/dmime/dmime_main.c
@@ -1 +1,160 @@
-/* nothing here yet */
+/* DirectMusicInteractiveEngine Main
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "dmime_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+
+/******************************************************************
+ *		DirectMusicInteractiveEngine ClassFactory
+ *
+ *
+ */
+ 
+typedef struct
+{
+    /* IUnknown fields */
+    ICOM_VFIELD(IClassFactory);
+    DWORD                       ref;
+} IClassFactoryImpl;
+
+static HRESULT WINAPI DMIMECF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+
+	FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+static ULONG WINAPI DMIMECF_AddRef(LPCLASSFACTORY iface)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	return ++(This->ref);
+}
+
+static ULONG WINAPI DMIMECF_Release(LPCLASSFACTORY iface)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	/* static class, won't be  freed */
+	return --(This->ref);
+}
+
+static HRESULT WINAPI DMIMECF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+
+	TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
+	if (IsEqualGUID (riid, &IID_IDirectMusicPerformance) ||
+	    IsEqualGUID (riid, &IID_IDirectMusicPerformance8)) {
+		return DMUSIC_CreateDirectMusicPerformance (riid, (LPDIRECTMUSICPERFORMANCE8*) ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicSegment) ||
+		IsEqualGUID (riid, &IID_IDirectMusicSegment8)) {
+		return DMUSIC_CreateDirectMusicSegment (riid, (LPDIRECTMUSICSEGMENT8*) ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicSegmentState) ||
+		IsEqualGUID (riid, &IID_IDirectMusicSegmentState8)) {
+		return DMUSIC_CreateDirectMusicSegmentState (riid, (LPDIRECTMUSICSEGMENTSTATE8*) ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicGraph)) {
+		return DMUSIC_CreateDirectMusicGraph (riid, (LPDIRECTMUSICGRAPH*) ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicAudioPath)) {
+		return DMUSIC_CreateDirectMusicSong (riid, (LPDIRECTMUSICSONG*) ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicAudioPath)) {
+		return DMUSIC_CreateDirectMusicAudioPath (riid, (LPDIRECTMUSICAUDIOPATH*) ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicTool) ||
+		IsEqualGUID (riid, &IID_IDirectMusicTool8)) {
+		return DMUSIC_CreateDirectMusicTool (riid, (LPDIRECTMUSICTOOL8*) ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicTrack) ||
+		IsEqualGUID (riid, &IID_IDirectMusicTrack8)) {
+		return DMUSIC_CreateDirectMusicTrack (riid, (LPDIRECTMUSICTRACK8*) ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicPatternTrack)) {
+		return DMUSIC_CreateDirectMusicPatternTrack (riid, (LPDIRECTMUSICPATTERNTRACK*) ppobj, pOuter);
+	}
+
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);	
+	return E_NOINTERFACE;
+}
+
+static HRESULT WINAPI DMIMECF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	FIXME("(%p)->(%d),stub!\n", This, dolock);
+	return S_OK;
+}
+
+static ICOM_VTABLE(IClassFactory) DMIMECF_Vtbl = {
+	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	DMIMECF_QueryInterface,
+	DMIMECF_AddRef,
+	DMIMECF_Release,
+	DMIMECF_CreateInstance,
+	DMIMECF_LockServer
+};
+
+static IClassFactoryImpl DMIME_CF = {&DMIMECF_Vtbl, 1 };
+
+/******************************************************************
+ *		DllMain
+ *
+ *
+ */
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+	if (fdwReason == DLL_PROCESS_ATTACH)
+	{
+            DisableThreadLibraryCalls(hinstDLL);
+		/* FIXME: Initialisation */
+	}
+	else if (fdwReason == DLL_PROCESS_DETACH)
+	{
+		/* FIXME: Cleanup */
+	}
+
+	return TRUE;
+}
+
+
+/******************************************************************
+ *		DllCanUnloadNow (DMIME.1)
+ *
+ *
+ */
+HRESULT WINAPI DMIME_DllCanUnloadNow(void)
+{
+    FIXME("(void): stub\n");
+
+    return S_FALSE;
+}
+
+
+/******************************************************************
+ *		DllGetClassObject (DMIME.2)
+ *
+ *
+ */
+HRESULT WINAPI DMIME_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
+{
+    TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    if (IsEqualCLSID (&IID_IClassFactory, riid)) {
+      *ppv = (LPVOID) &DMIME_CF;
+      IClassFactory_AddRef((IClassFactory*)*ppv);
+      return S_OK;
+    }
+    WARN("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    return CLASS_E_CLASSNOTAVAILABLE;
+}
diff --git a/dlls/dmime/dmime_private.h b/dlls/dmime/dmime_private.h
new file mode 100644
index 0000000..4187fe5
--- /dev/null
+++ b/dlls/dmime/dmime_private.h
@@ -0,0 +1,421 @@
+/* DirectMusicInteractiveEngine Private Include
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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.
+ */
+
+#ifndef __WINE_DMIME_PRIVATE_H
+#define __WINE_DMIME_PRIVATE_H
+
+#include "windef.h"
+#include "wine/debug.h"
+#include "winbase.h"
+#include "winnt.h"
+#include "dmusicc.h"
+#include "dmusici.h"
+#include "dmusics.h"
+#include "dmplugin.h"
+#include "dmusicf.h"
+#include "dsound.h"
+
+#include "../dmusic/dmusic_private.h"
+
+/*****************************************************************************
+ * Interfaces
+ */
+typedef struct IDirectMusicPerformance8Impl IDirectMusicPerformance8Impl;
+typedef struct IDirectMusicSegment8Impl IDirectMusicSegment8Impl;
+typedef struct IDirectMusicSegmentState8Impl IDirectMusicSegmentState8Impl;
+typedef struct IDirectMusicGraphImpl IDirectMusicGraphImpl;
+typedef struct IDirectMusicSongImpl IDirectMusicSongImpl;
+typedef struct IDirectMusicAudioPathImpl IDirectMusicAudioPathImpl;
+typedef struct IDirectMusicTool8Impl IDirectMusicTool8Impl;
+typedef struct IDirectMusicTrack8Impl IDirectMusicTrack8Impl;
+typedef struct IDirectMusicPatternTrackImpl IDirectMusicPatternTrackImpl;
+
+/*****************************************************************************
+ * Predeclare the interface implementation structures
+ */
+extern ICOM_VTABLE(IDirectMusicPerformance8) DirectMusicPerformance8_Vtbl;
+extern ICOM_VTABLE(IDirectMusicSegment8) DirectMusicSegment8_Vtbl;
+extern ICOM_VTABLE(IDirectMusicSegmentState8) DirectMusicSegmentState8_Vtbl;
+extern ICOM_VTABLE(IDirectMusicGraph) DirectMusicGraph_Vtbl;
+extern ICOM_VTABLE(IDirectMusicSong) DirectMusicSong_Vtbl;
+extern ICOM_VTABLE(IDirectMusicAudioPath) DirectMusicAudioPath_Vtbl;
+extern ICOM_VTABLE(IDirectMusicTool8) DirectMusicTool8_Vtbl;
+extern ICOM_VTABLE(IDirectMusicTrack8) DirectMusicTrack8_Vtbl;
+extern ICOM_VTABLE(IDirectMusicPatternTrack) DirectMusicPatternTrack_Vtbl;
+
+/*****************************************************************************
+ * ClassFactory
+ */
+/* can support IID_IDirectMusicPerformance and IID_IDirectMusicPerformance8
+ * return always an IDirectMusicPerformance8Impl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicPerformance (LPCGUID lpcGUID, LPDIRECTMUSICPERFORMANCE8 *ppDMPerf, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicSegment and IID_IDirectMusicSegment8
+ * return always an IDirectMusicSegment8Impl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicSegment (LPCGUID lpcGUID, LPDIRECTMUSICSEGMENT8 *ppDMSeg, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicSegmentState and IID_IDirectMusicSegmentState8
+ * return always an IDirectMusicSegmentState8Impl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicSegmentState (LPCGUID lpcGUID, LPDIRECTMUSICSEGMENTSTATE8 *ppDMSeg, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicSegmentgraph
+ * return always an IDirectMusicGraphImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicGraph (LPCGUID lpcGUID, LPDIRECTMUSICGRAPH *ppDMGrph, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicSong
+ * return always an IDirectMusicSong
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicSong (LPCGUID lpcGUID, LPDIRECTMUSICSONG *ppDMSng, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicAudioPath
+ * return always an IDirectMusicAudioPathImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicAudioPath (LPCGUID lpcGUID, LPDIRECTMUSICAUDIOPATH *ppDMApath, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicTool and IID_IDirectMusicTool8
+ * return always an IDirectMusicTool8Impl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicTool (LPCGUID lpcGUID, LPDIRECTMUSICTOOL8 *ppDMTool, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicTrack and IID_IDirectMusicTrack8
+ * return always an IDirectMusicTrack8Impl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicTrack (LPCGUID lpcGUID, LPDIRECTMUSICTRACK8 *ppDMTrack, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicPatternTrack
+ * return always an IDirectMusicPatternTrackImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicPatternTrack (LPCGUID lpcGUID, LPDIRECTMUSICPATTERNTRACK *ppDMPtrnTrack, LPUNKNOWN pUnkOuter);
+
+/*****************************************************************************
+ * IDirectMusicPerformance8Impl implementation structure
+ */
+struct IDirectMusicPerformance8Impl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicPerformance8);
+  DWORD                  ref;
+
+  /* IDirectMusicPerformanceImpl fields */
+  IDirectMusic8*         pDirectMusic;
+  IDirectSound*          pDirectSound;
+  IDirectMusicGraph*     pToolGraph;
+  DMUS_AUDIOPARAMS       pParams;
+
+  /* global parameters */
+  BOOL  fAutoDownload;
+  char  cMasterGrooveLevel;
+  float fMasterTempo;
+  long  lMasterVolume;
+	
+  /* performance channels */
+  DMUSIC_PRIVATE_PCHANNEL PChannel[1];
+
+   /* IDirectMusicPerformance8Impl fields */
+  IDirectMusicAudioPath* pDefaultPath;
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_QueryInterface (LPDIRECTMUSICPERFORMANCE8 iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicPerformance8Impl_AddRef (LPDIRECTMUSICPERFORMANCE8 iface);
+extern ULONG WINAPI   IDirectMusicPerformance8Impl_Release (LPDIRECTMUSICPERFORMANCE8 iface);
+/* IDirectMusicPerformance: */
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusic** ppDirectMusic, LPDIRECTSOUND pDirectSound, HWND hWnd);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_Stop (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, IDirectMusicSegmentState* pSegmentState, MUSIC_TIME mtTime, DWORD dwFlags);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetSegmentState (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegmentState** ppSegmentState, MUSIC_TIME mtTime);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_SetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwMilliSeconds);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface, DWORD* pdwMilliSeconds);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_SetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwMilliSeconds);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface, DWORD* pdwMilliSeconds);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_SendPMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pPMSG);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_MusicToReferenceTime (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, REFERENCE_TIME* prtTime);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_ReferenceToMusicTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtTime, MUSIC_TIME* pmtTime);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_IsPlaying (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, IDirectMusicSegmentState* pSegState);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtNow, MUSIC_TIME* pmtNow);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_AllocPMsg (LPDIRECTMUSICPERFORMANCE8 iface, ULONG cb, DMUS_PMSG** ppPMSG);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_FreePMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pPMSG);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph** ppGraph);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_SetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph* pGraph);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_SetNotificationHandle (LPDIRECTMUSICPERFORMANCE8 iface, HANDLE hNotification, REFERENCE_TIME rtMinimum);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetNotificationPMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_NOTIFICATION_PMSG** ppNotificationPMsg);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_AddNotificationType (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidNotificationType);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_RemoveNotificationType (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidNotificationType);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_AddPort (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicPort* pPort);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_RemovePort (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicPort* pPort);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannelBlock (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwBlockNum, IDirectMusicPort* pPort, DWORD dwGroup);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannel (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort* pPort, DWORD dwGroup, DWORD dwMChannel);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_PChannelInfo (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort** ppPort, DWORD* pdwGroup, DWORD* pdwMChannel);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_DownloadInstrument (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicInstrument* pInst, DWORD dwPChannel, IDirectMusicDownloadedInstrument** ppDownInst, DMUS_NOTERANGE* pNoteRanges, DWORD dwNumNoteRanges, IDirectMusicPort** ppPort, DWORD* pdwGroup, DWORD* pdwMChannel);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_Invalidate (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, DWORD dwFlags);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_SetParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, void* pParam);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, void* pParam, DWORD dwSize);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_SetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, void* pParam, DWORD dwSize);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetLatencyTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtTime);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetQueueTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtTime);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_AdjustTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtAmount);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_CloseDown (LPDIRECTMUSICPERFORMANCE8 iface);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetResolvedTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtTime, REFERENCE_TIME* prtResolved, DWORD dwTimeResolveFlags);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_MIDIToMusic (LPDIRECTMUSICPERFORMANCE8 iface, BYTE bMIDIValue, DMUS_CHORD_KEY* pChord, BYTE bPlayMode, BYTE bChordLevel, WORD* pwMusicValue);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_MusicToMIDI (LPDIRECTMUSICPERFORMANCE8 iface, WORD wMusicValue, DMUS_CHORD_KEY* pChord, BYTE bPlayMode, BYTE bChordLevel, BYTE* pbMIDIValue);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_TimeToRhythm (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, DMUS_TIMESIGNATURE* pTimeSig, WORD* pwMeasure, BYTE* pbBeat, BYTE* pbGrid, short* pnOffset);
+extern HRESULT WINAPI IDirectMusicPerformance8Impl_RhythmToTime (LPDIRECTMUSICPERFORMANCE8 iface, WORD wMeasure, BYTE bBeat, BYTE bGrid, short nOffset, DMUS_TIMESIGNATURE* pTimeSig, MUSIC_TIME* pmtTime);
+/* IDirectMusicPerformance8: */
+extern HRESULT WINAPI IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusic** ppDirectMusic, IDirectSound** ppDirectSound, HWND hWnd, DWORD dwDefaultPathType, DWORD dwPChannelCount, DWORD dwFlags, DMUS_AUDIOPARAMS* pParams);
+extern HRESULT WINAPI IDirectMusicPerformance8ImplPlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSource, WCHAR* pwzSegmentName, IUnknown* pTransition, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState, IUnknown* pFrom, IUnknown* pAudioPath);
+extern HRESULT WINAPI IDirectMusicPerformance8ImplStopEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pObjectToStop, __int64 i64StopTime, DWORD dwFlags);
+extern HRESULT WINAPI IDirectMusicPerformance8ImplClonePMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pSourcePMSG, DMUS_PMSG** ppCopyPMSG);
+extern HRESULT WINAPI IDirectMusicPerformance8ImplCreateAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSourceConfig, BOOL fActivate, IDirectMusicAudioPath** ppNewPath);
+extern HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath** ppNewPath);
+extern HRESULT WINAPI IDirectMusicPerformance8ImplSetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath* pAudioPath);
+extern HRESULT WINAPI IDirectMusicPerformance8ImplGetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath** ppAudioPath);
+extern HRESULT WINAPI IDirectMusicPerformance8ImplGetParamEx (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwTrackID, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam);
+/* ClassFactory */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicPerformance8 (LPCGUID lpcGUID, LPDIRECTMUSICPERFORMANCE8 *ppDMPerf8, LPUNKNOWN pUnkOuter);
+
+/*****************************************************************************
+ * IDirectMusicSegment8Impl implementation structure
+ */
+struct IDirectMusicSegment8Impl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicSegment8);
+  DWORD          ref;
+
+  /* IDirectMusicSegment8Impl fields */
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicSegment8Impl_QueryInterface (LPDIRECTMUSICSEGMENT8 iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicSegment8Impl_AddRef (LPDIRECTMUSICSEGMENT8 iface);
+extern ULONG WINAPI   IDirectMusicSegment8Impl_Release (LPDIRECTMUSICSEGMENT8 iface);
+/* IDirectMusicSegment: */
+extern HRESULT WINAPI IDirectMusicSegment8Impl_GetLength (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME* pmtLength);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_SetLength (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtLength);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_GetRepeats (LPDIRECTMUSICSEGMENT8 iface, DWORD* pdwRepeats);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_SetRepeats (LPDIRECTMUSICSEGMENT8 iface, DWORD dwRepeats);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_GetDefaultResolution (LPDIRECTMUSICSEGMENT8 iface, DWORD* pdwResolution);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_SetDefaultResolution (LPDIRECTMUSICSEGMENT8 iface, DWORD dwResolution);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_GetTrack (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, IDirectMusicTrack** ppTrack);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_GetTrackGroup (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicTrack* pTrack, DWORD* pdwGroupBits);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_InsertTrack (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicTrack* pTrack, DWORD dwGroupBits);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_RemoveTrack (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicTrack* pTrack);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_InitPlay (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicSegmentState** ppSegState, IDirectMusicPerformance* pPerformance, DWORD dwFlags);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_GetGraph (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicGraph** ppGraph);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_SetGraph (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicGraph* pGraph);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_AddNotificationType (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidNotificationType);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_RemoveNotificationType (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidNotificationType);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_GetParam (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_SetParam (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, void* pParam);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_Clone (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, IDirectMusicSegment** ppSegment);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_SetStartPoint (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtStart);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_GetStartPoint (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME* pmtStart);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_SetLoopPoints (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtStart, MUSIC_TIME mtEnd);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_GetLoopPoints (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME* pmtStart, MUSIC_TIME* pmtEnd);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_SetPChannelsUsed (LPDIRECTMUSICSEGMENT8 iface, DWORD dwNumPChannels, DWORD* paPChannels);
+/* IDirectMusicSegment8: */
+extern HRESULT WINAPI IDirectMusicSegment8Impl_SetTrackConfig (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidTrackClassID, DWORD dwGroupBits, DWORD dwIndex, DWORD dwFlagsOn, DWORD dwFlagsOff);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_GetAudioPathConfig (LPDIRECTMUSICSEGMENT8 iface, IUnknown** ppAudioPathConfig);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_Compose (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtTime, IDirectMusicSegment* pFromSegment, IDirectMusicSegment* pToSegment, IDirectMusicSegment** ppComposedSegment);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_Download (LPDIRECTMUSICSEGMENT8 iface, IUnknown *pAudioPath);
+extern HRESULT WINAPI IDirectMusicSegment8Impl_Unload (LPDIRECTMUSICSEGMENT8 iface, IUnknown *pAudioPath);
+	
+/*****************************************************************************
+ * IDirectMusicSegmentState8Impl implementation structure
+ */
+struct IDirectMusicSegmentState8Impl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicSegmentState8);
+  DWORD          ref;
+
+  /* IDirectMusicSegmentState8Impl fields */
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicSegmentState8Impl_QueryInterface (LPDIRECTMUSICSEGMENTSTATE8 iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicSegmentState8Impl_AddRef (LPDIRECTMUSICSEGMENTSTATE8 iface);
+extern ULONG WINAPI   IDirectMusicSegmentState8Impl_Release (LPDIRECTMUSICSEGMENTSTATE8 iface);
+/* IDirectMusicSegmentState: */
+extern HRESULT WINAPI IDirectMusicSegmentState8Impl_GetRepeats (LPDIRECTMUSICSEGMENTSTATE8 iface,  DWORD* pdwRepeats);
+extern HRESULT WINAPI IDirectMusicSegmentState8Impl_GetSegment (LPDIRECTMUSICSEGMENTSTATE8 iface, IDirectMusicSegment** ppSegment);
+extern HRESULT WINAPI IDirectMusicSegmentState8Impl_GetStartTime (LPDIRECTMUSICSEGMENTSTATE8 iface, MUSIC_TIME* pmtStart);
+extern HRESULT WINAPI IDirectMusicSegmentState8Impl_GetSeek (LPDIRECTMUSICSEGMENTSTATE8 iface, MUSIC_TIME* pmtSeek);
+extern HRESULT WINAPI IDirectMusicSegmentState8Impl_GetStartPoint (LPDIRECTMUSICSEGMENTSTATE8 iface, MUSIC_TIME* pmtStart);
+/* IDirectMusicSegmentState8: */
+extern HRESULT WINAPI IDirectMusicSegmentState8Impl_SetTrackConfig (LPDIRECTMUSICSEGMENTSTATE8 iface, REFGUID rguidTrackClassID, DWORD dwGroupBits, DWORD dwIndex, DWORD dwFlagsOn, DWORD dwFlagsOff);
+extern HRESULT WINAPI IDirectMusicSegmentState8Impl_GetObjectInPath (LPDIRECTMUSICSEGMENTSTATE8 iface, DWORD dwPChannel, DWORD dwStage, DWORD dwBuffer, REFGUID guidObject, DWORD dwIndex, REFGUID iidInterface, void** ppObject);
+
+/*****************************************************************************
+ * IDirectMusicGraphImpl implementation structure
+ */
+struct IDirectMusicGraphImpl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicGraph);
+  DWORD          ref;
+
+  /* IDirectMusicGraphImpl fields */
+  IDirectMusicTool8Impl* pFirst;
+  IDirectMusicTool8Impl* pLast;
+  WORD                  num_tools;
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicGraphImpl_QueryInterface (LPDIRECTMUSICGRAPH iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicGraphImpl_AddRef (LPDIRECTMUSICGRAPH iface);
+extern ULONG WINAPI   IDirectMusicGraphImpl_Release (LPDIRECTMUSICGRAPH iface);
+/* IDirectMusicGraph: */
+extern HRESULT WINAPI IDirectMusicGraphImpl_StampPMsg (LPDIRECTMUSICGRAPH iface, DMUS_PMSG* pPMSG);
+extern HRESULT WINAPI IDirectMusicGraphImpl_InsertTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool, DWORD* pdwPChannels, DWORD cPChannels, LONG lIndex);
+extern HRESULT WINAPI IDirectMusicGraphImpl_GetTool (LPDIRECTMUSICGRAPH iface, DWORD dwIndex, IDirectMusicTool** ppTool);
+extern HRESULT WINAPI IDirectMusicGraphImpl_RemoveTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool);
+
+/*****************************************************************************
+ * IDirectMusicSongImpl implementation structure
+ */
+struct IDirectMusicSongImpl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicSong);
+  DWORD          ref;
+
+  /* IDirectMusicSongImpl fields */
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicSongImpl_QueryInterface (LPDIRECTMUSICSONG iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicSongImpl_AddRef (LPDIRECTMUSICSONG iface);
+extern ULONG WINAPI   IDirectMusicSongImpll_Release (LPDIRECTMUSICSONG iface);
+/* IDirectMusicContainer: */
+extern HRESULT WINAPI IDirectMusicSongImpl_Compose (LPDIRECTMUSICSONG iface);
+extern HRESULT WINAPI IDirectMusicSongImpl_GetParam (LPDIRECTMUSICSONG iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam);
+extern HRESULT WINAPI IDirectMusicSongImpl_GetSegment (LPDIRECTMUSICSONG iface, WCHAR* pwzName, IDirectMusicSegment** ppSegment);
+extern HRESULT WINAPI IDirectMusicSongImpl_GetAudioPathConfig (LPDIRECTMUSICSONG iface, IUnknown** ppAudioPathConfig);
+extern HRESULT WINAPI IDirectMusicSongImpl_Download (LPDIRECTMUSICSONG iface, IUnknown* pAudioPath);
+extern HRESULT WINAPI IDirectMusicSongImpl_Unload (LPDIRECTMUSICSONG iface, IUnknown* pAudioPath);
+extern HRESULT WINAPI IDirectMusicSongImpl_EnumSegment (LPDIRECTMUSICSONG iface, DWORD dwIndex, IDirectMusicSegment** ppSegment);
+
+/*****************************************************************************
+ * IDirectMusicAudioPathImpl implementation structure
+ */
+struct IDirectMusicAudioPathImpl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicAudioPath);
+  DWORD          ref;
+
+  /* IDirectMusicAudioPathImpl fields */
+  IDirectMusicPerformance8* pPerf;
+  IDirectMusicGraph*        pToolGraph;
+  IDirectSoundBuffer*       pDSBuffer;
+  IDirectSoundBuffer*       pPrimary;
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicAudioPathImpl_QueryInterface (LPDIRECTMUSICAUDIOPATH iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicAudioPathImpl_AddRef (LPDIRECTMUSICAUDIOPATH iface);
+extern ULONG WINAPI   IDirectMusicAudioPathImpl_Release (LPDIRECTMUSICAUDIOPATH iface);
+/* IDirectMusicAudioPath: */
+extern HRESULT WINAPI IDirectMusicAudioPathImpl_GetObjectInPath (LPDIRECTMUSICAUDIOPATH iface, DWORD dwPChannel, DWORD dwStage, DWORD dwBuffer, REFGUID guidObject, WORD dwIndex, REFGUID iidInterface, void** ppObject);
+extern HRESULT WINAPI IDirectMusicAudioPathImpl_Activate (LPDIRECTMUSICAUDIOPATH iface, BOOL fActivate);
+extern HRESULT WINAPI IDirectMusicAudioPathImpl_SetVolume (LPDIRECTMUSICAUDIOPATH iface, long lVolume, DWORD dwDuration);
+extern HRESULT WINAPI IDirectMusicAudioPathImpl_ConvertPChannel (LPDIRECTMUSICAUDIOPATH iface, DWORD dwPChannelIn, DWORD* pdwPChannelOut);
+
+/*****************************************************************************
+ * IDirectMusicTool8Impl implementation structure
+ */
+struct IDirectMusicTool8Impl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicTool8);
+  DWORD          ref;
+
+  /* IDirectMusicTool8Impl fields */
+  IDirectMusicTool8Impl* pPrev;
+  IDirectMusicTool8Impl* pNext;
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicTool8Impl_QueryInterface (LPDIRECTMUSICTOOL8 iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicTool8Impl_AddRef (LPDIRECTMUSICTOOL8 iface);
+extern ULONG WINAPI   IDirectMusicTool8Impl_Release (LPDIRECTMUSICTOOL8 iface);
+/* IDirectMusicTool8Impl: */
+extern HRESULT WINAPI IDirectMusicTool8Impl_Init (LPDIRECTMUSICTOOL8 iface, IDirectMusicGraph* pGraph);
+extern HRESULT WINAPI IDirectMusicTool8Impl_GetMsgDeliveryType (LPDIRECTMUSICTOOL8 iface, DWORD* pdwDeliveryType);
+extern HRESULT WINAPI IDirectMusicTool8Impl_GetMediaTypeArraySize (LPDIRECTMUSICTOOL8 iface, DWORD* pdwNumElements);
+extern HRESULT WINAPI IDirectMusicTool8Impl_GetMediaTypes (LPDIRECTMUSICTOOL8 iface, DWORD** padwMediaTypes, DWORD dwNumElements);
+extern HRESULT WINAPI IDirectMusicTool8Impl_ProcessPMsg (LPDIRECTMUSICTOOL8 iface, IDirectMusicPerformance* pPerf, DMUS_PMSG* pPMSG);
+extern HRESULT WINAPI IDirectMusicTool8Impl_Flush (LPDIRECTMUSICTOOL8 iface, IDirectMusicPerformance* pPerf, DMUS_PMSG* pPMSG, REFERENCE_TIME rtTime);
+/* IDirectMusicToolImpl8: */
+extern HRESULT WINAPI IDirectMusicTool8Impl_Clone (LPDIRECTMUSICTOOL8 iface, IDirectMusicTool** ppTool);
+
+/*****************************************************************************
+ * IDirectMusicTrack8Impl implementation structure
+ */
+struct IDirectMusicTrack8Impl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicTrack8);
+  DWORD          ref;
+
+  /* IDirectMusicTrack8Impl fields */
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicTrack8Impl_QueryInterface (LPDIRECTMUSICTRACK8 iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicTrack8Impl_AddRef (LPDIRECTMUSICTRACK8 iface);
+extern ULONG WINAPI   IDirectMusicTrack8Impl_Release (LPDIRECTMUSICTRACK8 iface);
+/* IDirectMusicTrack: */
+extern HRESULT WINAPI IDirectMusicTrack8Impl_Init (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegment* pSegment);
+extern HRESULT WINAPI IDirectMusicTrack8Impl_InitPlay (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegmentState* pSegmentState, IDirectMusicPerformance* pPerformance, void** ppStateData, DWORD dwVirtualTrackID, DWORD dwFlags);
+extern HRESULT WINAPI IDirectMusicTrack8Impl_EndPlay (LPDIRECTMUSICTRACK8 iface, void* pStateData);
+extern HRESULT WINAPI IDirectMusicTrack8Impl_Play (LPDIRECTMUSICTRACK8 iface, void* pStateData, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, MUSIC_TIME mtOffset, DWORD dwFlags, IDirectMusicPerformance* pPerf, IDirectMusicSegmentState* pSegSt, DWORD dwVirtualID);
+extern HRESULT WINAPI IDirectMusicTrack8Impl_GetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam);
+extern HRESULT WINAPI IDirectMusicTrack8Impl_SetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, void* pParam);
+extern HRESULT WINAPI IDirectMusicTrack8Impl_IsParamSupported (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType);
+extern HRESULT WINAPI IDirectMusicTrack8Impl_AddNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType);
+extern HRESULT WINAPI IDirectMusicTrack8Impl_RemoveNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType);
+extern HRESULT WINAPI IDirectMusicTrack8Impl_Clone (LPDIRECTMUSICTRACK8 iface, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, IDirectMusicTrack** ppTrack);
+/* IDirectMusicTrack8: */
+extern HRESULT WINAPI IDirectMusicTrack8Impl_PlayEx (LPDIRECTMUSICTRACK8 iface, void* pStateData, REFERENCE_TIME rtStart, REFERENCE_TIME rtEnd, REFERENCE_TIME rtOffset, DWORD dwFlags, IDirectMusicPerformance* pPerf, IDirectMusicSegmentState* pSegSt, DWORD dwVirtualID);
+extern HRESULT WINAPI IDirectMusicTrack8Impl_GetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, REFERENCE_TIME* prtNext, void* pParam, void* pStateData, DWORD dwFlags);
+extern HRESULT WINAPI IDirectMusicTrack8Impl_SetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, void* pParam, void* pStateData, DWORD dwFlags);
+extern HRESULT WINAPI IDirectMusicTrack8Impl_Compose (LPDIRECTMUSICTRACK8 iface, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack);
+extern HRESULT WINAPI IDirectMusicTrack8Impl_Join (LPDIRECTMUSICTRACK8 iface, IDirectMusicTrack* pNewTrack, MUSIC_TIME mtJoin, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack);
+
+/*****************************************************************************
+ * IDirectMusicPatternTrackImpl implementation structure
+ */
+struct IDirectMusicPatternTrackImpl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicPatternTrack);
+  DWORD          ref;
+
+  /* IDirectMusicComposerImpl fields */
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicPatternTrackImpl_QueryInterface (LPDIRECTMUSICPATTERNTRACK iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicPatternTrackImpl_AddRef (LPDIRECTMUSICPATTERNTRACK iface);
+extern ULONG WINAPI   IDirectMusicPatternTrackImpl_Release (LPDIRECTMUSICPATTERNTRACK iface);
+/* IDirectMusicPatternTrack: */
+extern HRESULT WINAPI IDirectMusicPatternTrackImpl_CreateSegment (LPDIRECTMUSICPATTERNTRACK iface, IDirectMusicStyle* pStyle, IDirectMusicSegment** ppSegment);
+extern HRESULT WINAPI IDirectMusicPatternTrackImpl_SetVariation (LPDIRECTMUSICPATTERNTRACK iface, IDirectMusicSegmentState* pSegState, DWORD dwVariationFlags, DWORD dwPart);
+extern HRESULT WINAPI IDirectMusicPatternTrackImpl_SetPatternByName (LPDIRECTMUSICPATTERNTRACK iface, IDirectMusicSegmentState* pSegState, WCHAR* wszName, IDirectMusicStyle* pStyle, DWORD dwPatternType, DWORD* pdwLength);
+
+#endif	/* __WINE_DMIME_PRIVATE_H */
diff --git a/dlls/dmime/graph.c b/dlls/dmime/graph.c
new file mode 100644
index 0000000..7cdbe98
--- /dev/null
+++ b/dlls/dmime/graph.c
@@ -0,0 +1,171 @@
+/* IDirectMusicGraph
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmime_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicGraph IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicGraphImpl_QueryInterface (LPDIRECTMUSICGRAPH iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicGraphImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || 
+	    IsEqualGUID(riid, &IID_IDirectMusicGraph))
+	{
+		IDirectMusicGraphImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicGraphImpl_AddRef (LPDIRECTMUSICGRAPH iface)
+{
+	ICOM_THIS(IDirectMusicGraphImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicGraphImpl_Release (LPDIRECTMUSICGRAPH iface)
+{
+	ICOM_THIS(IDirectMusicGraphImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicGraph Interface follow: */
+HRESULT WINAPI IDirectMusicGraphImpl_StampPMsg (LPDIRECTMUSICGRAPH iface, DMUS_PMSG* pPMSG)
+{
+	ICOM_THIS(IDirectMusicGraphImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pPMSG);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicGraphImpl_InsertTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool, DWORD* pdwPChannels, DWORD cPChannels, LONG lIndex)
+{
+    int i;
+	IDirectMusicTool8Impl* p;
+	IDirectMusicTool8Impl* toAdd = (IDirectMusicTool8Impl*) pTool;
+    ICOM_THIS(IDirectMusicGraphImpl,iface);
+
+	FIXME("(%p, %p, %p, %ld, %li): use of pdwPChannels\n", This, pTool, pdwPChannels, cPChannels, lIndex);
+
+	if (0 == This->num_tools) {
+	  This->pFirst = This->pLast = toAdd;
+	  toAdd->pPrev = toAdd->pNext = NULL;
+	} else if (lIndex == 0 || lIndex <= -This->num_tools) {
+	  This->pFirst->pPrev = toAdd;
+	  toAdd->pNext = This->pFirst;
+	  toAdd->pPrev = NULL;
+	  This->pFirst = toAdd;
+	} else if (lIndex < 0) {
+	  p = This->pLast;
+	  for (i = 0; i < -lIndex; ++i) {
+	    p = p->pPrev;
+	  }
+	  toAdd->pNext = p->pNext;
+	  if (p->pNext) p->pNext->pPrev = toAdd;
+	  p->pNext = toAdd;
+	  toAdd->pPrev = p;
+	} else if (lIndex >= This->num_tools) {
+	  This->pLast->pNext = toAdd;
+	  toAdd->pPrev = This->pLast;
+	  toAdd->pNext = NULL;
+	  This->pLast = toAdd;
+	} else if (lIndex > 0) {
+	  p = This->pFirst;
+	  for (i = 0; i < lIndex; ++i) {
+	    p = p->pNext;
+	  }
+	  toAdd->pPrev = p->pPrev;
+	  if (p->pPrev) p->pPrev->pNext = toAdd;
+	  p->pPrev = toAdd;
+	  toAdd->pNext = p;
+	}
+	++This->num_tools;
+	return DS_OK;
+}
+
+HRESULT WINAPI IDirectMusicGraphImpl_GetTool (LPDIRECTMUSICGRAPH iface, DWORD dwIndex, IDirectMusicTool** ppTool)
+{
+	int i;
+	IDirectMusicTool8Impl* p = NULL;
+	ICOM_THIS(IDirectMusicGraphImpl,iface);
+	
+	FIXME("(%p, %ld, %p): stub\n", This, dwIndex, ppTool);
+
+	p = This->pFirst;
+	for (i = 0; i < dwIndex && i < This->num_tools; ++i) {
+	  p = p->pNext;
+	}
+	*ppTool = (IDirectMusicTool*) p;
+	if (NULL != *ppTool) {
+	  IDirectMusicTool8Impl_AddRef((LPDIRECTMUSICTOOL8) *ppTool);
+	}
+	return DS_OK;
+}
+
+HRESULT WINAPI IDirectMusicGraphImpl_RemoveTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool)
+{
+	ICOM_THIS(IDirectMusicGraphImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pTool);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicGraph) DirectMusicGraph_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicGraphImpl_QueryInterface,
+	IDirectMusicGraphImpl_AddRef,
+	IDirectMusicGraphImpl_Release,
+	IDirectMusicGraphImpl_StampPMsg,
+	IDirectMusicGraphImpl_InsertTool,
+	IDirectMusicGraphImpl_GetTool,
+	IDirectMusicGraphImpl_RemoveTool
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicGraph (LPCGUID lpcGUID, LPDIRECTMUSICGRAPH *ppDMGrph, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicGraph))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmime/patterntrack.c b/dlls/dmime/patterntrack.c
new file mode 100644
index 0000000..f5ca1ff
--- /dev/null
+++ b/dlls/dmime/patterntrack.c
@@ -0,0 +1,115 @@
+/* IDirectMusicPatternTrack Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmime_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicPatternTrack IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicPatternTrackImpl_QueryInterface (LPDIRECTMUSICPATTERNTRACK iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicPatternTrackImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || 
+	    IsEqualGUID(riid, &IID_IDirectMusicPatternTrack))
+	{
+		IDirectMusicPatternTrackImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicPatternTrackImpl_AddRef (LPDIRECTMUSICPATTERNTRACK iface)
+{
+	ICOM_THIS(IDirectMusicPatternTrackImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicPatternTrackImpl_Release (LPDIRECTMUSICPATTERNTRACK iface)
+{
+	ICOM_THIS(IDirectMusicPatternTrackImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicPatternTrack Interface follow: */
+HRESULT WINAPI IDirectMusicPatternTrackImpl_CreateSegment (LPDIRECTMUSICPATTERNTRACK iface, IDirectMusicStyle* pStyle, IDirectMusicSegment** ppSegment)
+{
+	ICOM_THIS(IDirectMusicPatternTrackImpl,iface);
+
+	FIXME("(%p, %p, %p): stub\n", This, pStyle, ppSegment);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicPatternTrackImpl_SetVariation (LPDIRECTMUSICPATTERNTRACK iface, IDirectMusicSegmentState* pSegState, DWORD dwVariationFlags, DWORD dwPart)
+{
+	ICOM_THIS(IDirectMusicPatternTrackImpl,iface);
+
+	FIXME("(%p, %p, %ld, %ld): stub\n", This, pSegState, dwVariationFlags, dwPart);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicPatternTrackImpl_SetPatternByName (LPDIRECTMUSICPATTERNTRACK iface, IDirectMusicSegmentState* pSegState, WCHAR* wszName, IDirectMusicStyle* pStyle, DWORD dwPatternType, DWORD* pdwLength)
+{
+	ICOM_THIS(IDirectMusicPatternTrackImpl,iface);
+
+	FIXME("(%p, %p, %p, %p, %ld, %p): stub\n", This, pSegState, wszName, pStyle, dwPatternType, pdwLength);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicPatternTrack) DirectMusicPatternTrack_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicPatternTrackImpl_QueryInterface,
+	IDirectMusicPatternTrackImpl_AddRef,
+	IDirectMusicPatternTrackImpl_Release,
+	IDirectMusicPatternTrackImpl_CreateSegment,
+	IDirectMusicPatternTrackImpl_SetVariation,
+	IDirectMusicPatternTrackImpl_SetPatternByName
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicPatternTrack (LPCGUID lpcGUID, LPDIRECTMUSICPATTERNTRACK *ppDMPtrnTrack, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicComposer))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmusic/dmusic_performance.c b/dlls/dmime/performance.c
similarity index 84%
rename from dlls/dmusic/dmusic_performance.c
rename to dlls/dmime/performance.c
index f60f225..ee1d6bd 100644
--- a/dlls/dmusic/dmusic_performance.c
+++ b/dlls/dmime/performance.c
@@ -1,5 +1,4 @@
 /* IDirectMusicPerformance Implementation
- * IDirectMusicPerformance8 Implementation
  *
  * Copyright (C) 2003 Rok Mandeljc
  *
@@ -24,17 +23,10 @@
 #include "wingdi.h"
 #include "wine/debug.h"
 
-#include "dmusic_private.h"
+#include "dmime_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
 
-/* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateDirectMusicPerformance (LPCGUID lpcGUID, LPDIRECTMUSICPERFORMANCE *ppDMPerf, LPUNKNOWN pUnkOuter)
-{
-	return DMUSIC_CreateDirectMusicPerformance8(lpcGUID, (LPDIRECTMUSICPERFORMANCE8*) ppDMPerf, pUnkOuter);
-}
-
-
 /* IDirectMusicPerformance8 IUnknown part follow: */
 HRESULT WINAPI IDirectMusicPerformance8Impl_QueryInterface (LPDIRECTMUSICPERFORMANCE8 iface, REFIID riid, LPVOID *ppobj)
 {
@@ -77,29 +69,28 @@
 	ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 
 	FIXME("(iface = %p, dmusic = %p, dsound = %p, hwnd = %p)\n", This, ppDirectMusic, pDirectSound, hWnd);
-        if (This->dmusic || This->dsound)
+        if (This->pDirectMusic || This->pDirectSound)
 	  return DMUS_E_ALREADY_INITED;
 	
 	if (NULL != pDirectSound) {
-	  This->dsound = (IDirectSound*) pDirectSound;
-	  IDirectSound_AddRef((LPDIRECTSOUND) This->dsound);
+	  This->pDirectSound = (IDirectSound*) pDirectSound;
+	  IDirectSound_AddRef((LPDIRECTSOUND) This->pDirectSound);
 	} else {
-	  DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->dsound, NULL);
-	  if (!This->dsound)
+	  DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->pDirectSound, NULL);
+	  if (!This->pDirectSound)
 	    return DSERR_NODRIVER;
 	}
 
 	if (NULL != ppDirectMusic && NULL != *ppDirectMusic) {
 	  /* app creates it's own dmusic object and gives it to performance */
-	  This->dmusic = (IDirectMusic8*) *ppDirectMusic;
-	  IDirectMusic8Impl_AddRef((LPDIRECTMUSIC8) This->dmusic);
+	  This->pDirectMusic = (IDirectMusic8*) *ppDirectMusic;
+	  IDirectMusic8_AddRef((LPDIRECTMUSIC8) This->pDirectMusic);
 	} else {
 	  /* app allows the performance to initialise itfself and needs a pointer to object*/
-	  /* maybe IID_IDirectMusic8 must be used here */
-	  DMUSIC_CreateDirectMusic(&IID_IDirectMusic8, (LPDIRECTMUSIC*) &This->dmusic, NULL);
+		CoCreateInstance (&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8, (void**)&This->pDirectMusic);
 	  if (ppDirectMusic) {
-	    *ppDirectMusic = (LPDIRECTMUSIC) This->dmusic;
-	    IDirectMusic8Impl_AddRef((LPDIRECTMUSIC8) *ppDirectMusic);
+	    *ppDirectMusic = (LPDIRECTMUSIC) This->pDirectMusic;
+	    IDirectMusic8_AddRef((LPDIRECTMUSIC8) *ppDirectMusic);
 	  }
 	}
 
@@ -111,7 +102,7 @@
 {
 	ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 
-	FIXME("(%p, %p, %ld, FIXME, %p): stub\n", This, pSegment, dwFlags/*, i64StartTime*/, ppSegmentState);
+	FIXME("(%p, %p, %ld, %lli, %p): stub\n", This, pSegment, dwFlags, i64StartTime, ppSegmentState);
 
 	return S_OK;
 }
@@ -183,7 +174,7 @@
 {
 	ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 
-	FIXME("(%p, %ld, FIXME): stub\n", This, mtTime/*,prtTime*/);
+	FIXME("(%p, %ld, %p): stub\n", This, mtTime, prtTime);
 
 	return S_OK;
 }
@@ -192,7 +183,7 @@
 {
 	ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 
-	FIXME("(%p, FIXME, %p): stub\n", This/*, rtTime*/, pmtTime);
+	FIXME("(%p, %lli, %p): stub\n", This, rtTime, pmtTime);
 
 	return S_OK;
 }
@@ -210,7 +201,7 @@
 {
 	ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 
-	FIXME("(%p, FIXME, %p): stub\n", This/*, prtNow*/, pmtNow);	
+	FIXME("(%p, %p, %p): stub\n", This, prtNow, pmtNow);	
 	
 	return S_OK;
 }
@@ -239,11 +230,11 @@
 
 	FIXME("(%p, %p): to check\n", This, ppGraph);
 
-	if (NULL != This->toolGraph) {
-	  *ppGraph = (LPDIRECTMUSICGRAPH) This->toolGraph; 
+	if (NULL != This->pToolGraph) {
+	  *ppGraph = (LPDIRECTMUSICGRAPH) This->pToolGraph; 
 	  IDirectMusicGraphImpl_AddRef((LPDIRECTMUSICGRAPH) *ppGraph);
 	}
-	return DS_OK;
+	return S_OK;
 }
 
 HRESULT WINAPI IDirectMusicPerformance8Impl_SetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph* pGraph)
@@ -252,22 +243,22 @@
 
 	FIXME("(%p, %p): to check\n", This, pGraph);
 
-	if (NULL != This->toolGraph) {
+	if (NULL != This->pToolGraph) {
 	  /* Todo clean buffers and tools before */
-	  IDirectMusicGraphImpl_Release((LPDIRECTMUSICGRAPH) This->toolGraph);
+	  IDirectMusicGraphImpl_Release((LPDIRECTMUSICGRAPH) This->pToolGraph);
 	}
-	This->toolGraph = pGraph;
-	if (NULL != This->toolGraph) {
-	  IDirectMusicGraphImpl_AddRef((LPDIRECTMUSICGRAPH) This->toolGraph);
+	This->pToolGraph = pGraph;
+	if (NULL != This->pToolGraph) {
+	  IDirectMusicGraphImpl_AddRef((LPDIRECTMUSICGRAPH) This->pToolGraph);
 	}
-	return DS_OK;
+	return S_OK;
 }
 
 HRESULT WINAPI IDirectMusicPerformance8Impl_SetNotificationHandle (LPDIRECTMUSICPERFORMANCE8 iface, HANDLE hNotification, REFERENCE_TIME rtMinimum)
 {
 	ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 
-	FIXME("(%p, %p, FIXME): stub\n", This, hNotification/*, rtMinimum*/);
+	FIXME("(%p, %p, %lli): stub\n", This, hNotification, rtMinimum);
 
 	return S_OK;
 }
@@ -304,7 +295,8 @@
 	ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 
 	FIXME("(%p, %p): stub\n", This, pPort);
-
+	IDirectMusicPort_AddRef (pPort);
+	
 	return S_OK;
 }
 
@@ -313,6 +305,7 @@
 	ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 
 	FIXME("(%p, %p): stub\n", This, pPort);
+	IDirectMusicPort_Release (pPort);
 
 	return S_OK;
 }
@@ -323,7 +316,6 @@
 	ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 
 	FIXME("(%p, %ld, %p, %ld): semi-stub\n", This, dwBlockNum, pPort, dwGroup-1);
-        
         range = 16 * dwBlockNum;
         j = 0;
                 
@@ -335,8 +327,7 @@
                 This->PChannel[i].channel = j; /* FIXME: should this be assigned? */
                 j++;
         }
-                
-        return S_FALSE;
+        return S_OK;
 }
 
 HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannel (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort* pPort, DWORD dwGroup, DWORD dwMChannel)
@@ -403,13 +394,13 @@
 	TRACE("(%p, %s, %p, %ld): stub\n", This, debugstr_guid(rguidType), pParam, dwSize);
 	
 	if (IsEqualGUID(rguidType, &GUID_PerfAutoDownload))
-		memcpy(pParam, &This->AutoDownload, sizeof(&This->AutoDownload));
+		memcpy(pParam, &This->fAutoDownload, sizeof(&This->fAutoDownload));
 	if (IsEqualGUID(rguidType, &GUID_PerfMasterGrooveLevel))
-		memcpy(pParam, &This->MasterGrooveLevel, sizeof(&This->MasterGrooveLevel));
+		memcpy(pParam, &This->cMasterGrooveLevel, sizeof(&This->cMasterGrooveLevel));
 	if (IsEqualGUID(rguidType, &GUID_PerfMasterTempo))
-		memcpy(pParam, &This->MasterTempo, sizeof(&This->MasterTempo));
+		memcpy(pParam, &This->fMasterTempo, sizeof(&This->fMasterTempo));
 	if (IsEqualGUID(rguidType, &GUID_PerfMasterVolume))
-		memcpy(pParam, &This->MasterVolume, sizeof(&This->MasterVolume));
+		memcpy(pParam, &This->lMasterVolume, sizeof(&This->lMasterVolume));
 
 	return S_OK;
 }
@@ -422,23 +413,23 @@
 	
 	if (IsEqualGUID(rguidType, &GUID_PerfAutoDownload))
 	{
-		memcpy(&This->AutoDownload, pParam, dwSize);
-		TRACE("=> AutoDownload set to %d\n", This->AutoDownload);
+		memcpy(&This->fAutoDownload, pParam, dwSize);
+		TRACE("=> AutoDownload set to %d\n", This->fAutoDownload);
 	}
 	if (IsEqualGUID(rguidType, &GUID_PerfMasterGrooveLevel))
 	{
-		memcpy(&This->MasterGrooveLevel, pParam, dwSize);
-		TRACE("=> MasterGrooveLevel set to %i\n", This->MasterGrooveLevel);
+		memcpy(&This->cMasterGrooveLevel, pParam, dwSize);
+		TRACE("=> MasterGrooveLevel set to %i\n", This->cMasterGrooveLevel);
 	}
 	if (IsEqualGUID(rguidType, &GUID_PerfMasterTempo))
 	{
-		memcpy(&This->MasterTempo, pParam, dwSize);
-		TRACE("=> MasterTempo set to %f\n", This->MasterTempo);
+		memcpy(&This->fMasterTempo, pParam, dwSize);
+		TRACE("=> MasterTempo set to %f\n", This->fMasterTempo);
 	}
 	if (IsEqualGUID(rguidType, &GUID_PerfMasterVolume))
 	{
-		memcpy(&This->MasterVolume, pParam, dwSize);
-		TRACE("=> MasterVolume set to %li\n", This->MasterVolume);
+		memcpy(&This->lMasterVolume, pParam, dwSize);
+		TRACE("=> MasterVolume set to %li\n", This->lMasterVolume);
 	}
 
 	return S_OK;
@@ -466,7 +457,7 @@
 {
 	ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 
-	FIXME("(%p, FIXME): stub\n", This/*, rtAmount*/);
+	FIXME("(%p, %lli): stub\n", This, rtAmount);
 
 	return S_OK;
 }
@@ -484,7 +475,7 @@
 {
 	ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 
-	FIXME("(%p, FIXME, %p, %ld): stub\n", This/*, rtTime*/, prtResolved, dwTimeResolveFlags);
+	FIXME("(%p, %lli, %p, %ld): stub\n", This, rtTime, prtResolved, dwTimeResolveFlags);
 
 	return S_OK;
 }
@@ -540,7 +531,7 @@
         ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 	FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This, ppDirectMusic, ppDirectSound, hWnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams);
 
-	if (This->dmusic || This->dsound)
+	if (This->pDirectMusic || This->pDirectSound)
 	  return DMUS_E_ALREADY_INITED;
 
 	if (NULL != ppDirectSound && NULL != *ppDirectSound) {
@@ -557,24 +548,24 @@
 
 	/* Init increases the ref count of the dsound object. Decremente it if the app don't want a pointer to the object. */
 	if (!ppDirectSound)
-	  IDirectSound_Release(This->dsound);
+	  IDirectSound_Release(This->pDirectSound);
 	
 	/* as seen in msdn we need params init before audio path creation */
 	if (NULL != pParams) {
-	  memcpy(&This->params, pParams, sizeof(DMUS_AUDIOPARAMS));
+	  memcpy(&This->pParams, pParams, sizeof(DMUS_AUDIOPARAMS));
 	} else {
 	  /* TODO, how can i fill the struct */
 	}
-	IDirectMusicPerformance8ImplCreateStandardAudioPath(iface, dwDefaultPathType, dwPChannelCount, FALSE, (IDirectMusicAudioPath**) &This->default_path);
+	IDirectMusicPerformance8ImplCreateStandardAudioPath(iface, dwDefaultPathType, dwPChannelCount, FALSE, (IDirectMusicAudioPath**) &This->pDefaultPath);
 
-	return DS_OK;
+	return S_OK;
 }
 
 HRESULT WINAPI IDirectMusicPerformance8ImplPlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSource, WCHAR* pwzSegmentName, IUnknown* pTransition, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState, IUnknown* pFrom, IUnknown* pAudioPath)
 {
 	ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 
-	FIXME("(%p, %p, %p, %p, %ld, FIXME, %p, %p, %p): stub\n", This, pSource, pwzSegmentName, pTransition, dwFlags/*, i64StartTime*/, ppSegmentState, pFrom, pAudioPath);
+	FIXME("(%p, %p, %p, %p, %ld, %lli, %p, %p, %p): stub\n", This, pSource, pwzSegmentName, pTransition, dwFlags, i64StartTime, ppSegmentState, pFrom, pAudioPath);
 
 	return S_OK;
 }
@@ -583,7 +574,7 @@
 {
 	ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 
-	FIXME("(%p, %p, FIXME, %ld): stub\n", This, pObjectToStop/*, i64StopTime*/, dwFlags);
+	FIXME("(%p, %p, %lli, %ld): stub\n", This, pObjectToStop, i64StopTime, dwFlags);
 
 	return S_OK;
 }
@@ -624,7 +615,7 @@
 	}
 	default_path->lpVtbl = &DirectMusicAudioPath_Vtbl;
 	default_path->ref = 1;
-	default_path->perfo = (IDirectMusicPerformance8*) This;
+	default_path->pPerf = (IDirectMusicPerformance8*) This;
 
 	/* Secondary buffer description */
 	format.wFormatTag = WAVE_FORMAT_PCM;
@@ -659,23 +650,23 @@
 	}
 
 	/* FIXME: Should we create one secondary buffer for each PChannel? */
-	IDirectSound8_CreateSoundBuffer((LPDIRECTSOUND8) This->dsound, &desc, &buffer, NULL);
-	default_path->buffer = (IDirectSoundBuffer*) buffer;
+	IDirectSound8_CreateSoundBuffer((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL);
+	default_path->pDSBuffer = (IDirectSoundBuffer*) buffer;
 
 	/* Update description for creating primary buffer */
 	desc.dwFlags |= DSBCAPS_PRIMARYBUFFER;
 	desc.dwBufferBytes = 0;
 	desc.lpwfxFormat = NULL;
 
-	IDirectSound8_CreateSoundBuffer((LPDIRECTSOUND8) This->dsound, &desc, &buffer, NULL);
+	IDirectSound8_CreateSoundBuffer((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL);
 
-	default_path->primary = (IDirectSoundBuffer*) buffer;
+	default_path->pPrimary = (IDirectSoundBuffer*) buffer;
 
 	*ppNewPath = (LPDIRECTMUSICAUDIOPATH) default_path;
 	
 	TRACE(" returning IDirectMusicPerformance interface at %p.\n", *ppNewPath);
 
-	return DS_OK;
+	return S_OK;
 }
 
 HRESULT WINAPI IDirectMusicPerformance8ImplSetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath* pAudioPath)
@@ -684,32 +675,32 @@
 
        	FIXME("(%p, %p): semi-stub\n", This, pAudioPath);
 
-       if (NULL != This->default_path) {
-         IDirectMusicAudioPathImpl_Release((LPDIRECTMUSICAUDIOPATH) This->default_path);
-	 ((IDirectMusicAudioPathImpl*) This->default_path)->perfo = NULL;
-         This->default_path = NULL;
+       if (NULL != This->pDefaultPath) {
+         IDirectMusicAudioPathImpl_Release((LPDIRECTMUSICAUDIOPATH) This->pDefaultPath);
+	 ((IDirectMusicAudioPathImpl*) This->pDefaultPath)->pPerf = NULL;
+         This->pDefaultPath = NULL;
        }
-       This->default_path = pAudioPath;
-       if (NULL != This->default_path) {
-         IDirectMusicAudioPathImpl_AddRef((LPDIRECTMUSICAUDIOPATH) This->default_path);
-	 ((IDirectMusicAudioPathImpl*) This->default_path)->perfo = (IDirectMusicPerformance8*) This;
+       This->pDefaultPath = pAudioPath;
+       if (NULL != This->pDefaultPath) {
+         IDirectMusicAudioPathImpl_AddRef((LPDIRECTMUSICAUDIOPATH) This->pDefaultPath);
+	 ((IDirectMusicAudioPathImpl*) This->pDefaultPath)->pPerf = (IDirectMusicPerformance8*) This;
        }
-       return DS_OK;
+       return S_OK;
 }
 
 HRESULT WINAPI IDirectMusicPerformance8ImplGetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath** ppAudioPath)
 {
-        ICOM_THIS(IDirectMusicPerformance8Impl,iface);
+    ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 
 	FIXME("(%p, %p): semi-stub\n", This, ppAudioPath);
 
-	if (NULL != This->default_path) {
-	  *ppAudioPath = (LPDIRECTMUSICAUDIOPATH) This->default_path;
+	if (NULL != This->pDefaultPath) {
+	  *ppAudioPath = (LPDIRECTMUSICAUDIOPATH) This->pDefaultPath;
           IDirectMusicAudioPathImpl_AddRef(*ppAudioPath);
         } else {
 	  *ppAudioPath = NULL;
         }
-	return DS_OK;
+	return S_OK;
 }
 
 HRESULT WINAPI IDirectMusicPerformance8ImplGetParamEx (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwTrackID, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam)
@@ -780,26 +771,26 @@
 };
 
 /* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateDirectMusicPerformance8 (LPCGUID lpcGUID, LPDIRECTMUSICPERFORMANCE8 *ppDMPerf8, LPUNKNOWN pUnkOuter)
+HRESULT WINAPI DMUSIC_CreateDirectMusicPerformance (LPCGUID lpcGUID, LPDIRECTMUSICPERFORMANCE8 *ppDMPerf, LPUNKNOWN pUnkOuter)
 {
-	IDirectMusicPerformance8Impl *pPerf8;
+	IDirectMusicPerformance8Impl *pPerf;
 
-	TRACE("(%p,%p,%p)\n",lpcGUID, ppDMPerf8, pUnkOuter);
+	TRACE("(%p,%p,%p)\n",lpcGUID, ppDMPerf, pUnkOuter);
 	if (IsEqualGUID(lpcGUID, &IID_IDirectMusicPerformance) ||
 	    IsEqualGUID(lpcGUID, &IID_IDirectMusicPerformance8)) {
-		pPerf8 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicPerformance8Impl));
-		if (NULL == pPerf8)
+		pPerf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicPerformance8Impl));
+		if (NULL == pPerf)
 		{
-			*ppDMPerf8 = (LPDIRECTMUSICPERFORMANCE8)NULL;
+			*ppDMPerf = (LPDIRECTMUSICPERFORMANCE8)NULL;
 			return E_OUTOFMEMORY;
 		}
-		pPerf8->lpVtbl = &DirectMusicPerformance8_Vtbl;
-		pPerf8->ref = 1;
-		pPerf8->dmusic = NULL;
-		pPerf8->dsound = NULL;
-		pPerf8->default_path = NULL;
+		pPerf->lpVtbl = &DirectMusicPerformance8_Vtbl;
+		pPerf->ref = 1;
+		pPerf->pDirectMusic = NULL;
+		pPerf->pDirectSound = NULL;
+		pPerf->pDefaultPath = NULL;
 		
-		*ppDMPerf8 = (LPDIRECTMUSICPERFORMANCE8) pPerf8;
+		*ppDMPerf = (LPDIRECTMUSICPERFORMANCE8) pPerf;
 		return S_OK;
 	}
 	WARN("No interface found\n");
diff --git a/dlls/dmime/regsvr.c b/dlls/dmime/regsvr.c
new file mode 100644
index 0000000..5cebeb5
--- /dev/null
+++ b/dlls/dmime/regsvr.c
@@ -0,0 +1,664 @@
+/*
+ *	self-registerable dll functions for dmime.dll
+ *
+ * Copyright (C) 2003 John K. Hohm
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <string.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "winreg.h"
+#include "winerror.h"
+
+#include "dmusics.h"
+#include "dmusici.h"
+#include "dmplugin.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/*
+ * Near the bottom of this file are the exported DllRegisterServer and
+ * DllUnregisterServer, which make all this worthwhile.
+ */
+
+/***********************************************************************
+ *		interface for self-registering
+ */
+struct regsvr_interface
+{
+    IID const *iid;		/* NULL for end of list */
+    LPCSTR name;		/* can be NULL to omit */
+    IID const *base_iid;	/* can be NULL to omit */
+    int num_methods;		/* can be <0 to omit */
+    CLSID const *ps_clsid;	/* can be NULL to omit */
+    CLSID const *ps_clsid32;	/* can be NULL to omit */
+};
+
+static HRESULT register_interfaces(struct regsvr_interface const *list);
+static HRESULT unregister_interfaces(struct regsvr_interface const *list);
+
+struct regsvr_coclass
+{
+    CLSID const *clsid;		/* NULL for end of list */
+    LPCSTR name;		/* can be NULL to omit */
+    LPCSTR ips;			/* can be NULL to omit */
+    LPCSTR ips32;		/* can be NULL to omit */
+    LPCSTR ips32_tmodel;	/* can be NULL to omit */
+    LPCSTR progid;		/* can be NULL to omit */
+    LPCSTR viprogid;		/* can be NULL to omit */
+    LPCSTR progid_extra;	/* can be NULL to omit */
+};
+
+static HRESULT register_coclasses(struct regsvr_coclass const *list);
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
+
+/***********************************************************************
+ *		static string constants
+ */
+static WCHAR const interface_keyname[10] = {
+    'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
+static WCHAR const base_ifa_keyname[14] = {
+    'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
+    'e', 0 };
+static WCHAR const num_methods_keyname[11] = {
+    'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
+static WCHAR const ps_clsid_keyname[15] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', 0 };
+static WCHAR const ps_clsid32_keyname[17] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', '3', '2', 0 };
+static WCHAR const clsid_keyname[6] = {
+    'C', 'L', 'S', 'I', 'D', 0 };
+static WCHAR const curver_keyname[7] = {
+    'C', 'u', 'r', 'V', 'e', 'r', 0 };
+static WCHAR const ips_keyname[13] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    0 };
+static WCHAR const ips32_keyname[15] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    '3', '2', 0 };
+static WCHAR const progid_keyname[7] = {
+    'P', 'r', 'o', 'g', 'I', 'D', 0 };
+static WCHAR const viprogid_keyname[25] = {
+    'V', 'e', 'r', 's', 'i', 'o', 'n', 'I', 'n', 'd', 'e', 'p',
+    'e', 'n', 'd', 'e', 'n', 't', 'P', 'r', 'o', 'g', 'I', 'D',
+    0 };
+static char const tmodel_valuename[] = "ThreadingModel";
+
+/***********************************************************************
+ *		static helper functions
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
+static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
+				   WCHAR const *value);
+static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
+				   char const *value);
+static LONG register_progid(WCHAR const *clsid,
+			    char const *progid, char const *curver_progid,
+			    char const *name, char const *extra);
+static LONG recursive_delete_key(HKEY key);
+static LONG recursive_delete_keyA(HKEY base, char const *name);
+static LONG recursive_delete_keyW(HKEY base, WCHAR const *name);
+
+/***********************************************************************
+ *		register_interfaces
+ */
+static HRESULT register_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+	WCHAR buf[39];
+	HKEY iid_key;
+
+	StringFromGUID2(list->iid, buf, 39);
+	res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
+			      KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
+	if (res != ERROR_SUCCESS) goto error_close_interface_key;
+
+	if (list->name) {
+	    res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)(list->name),
+				 strlen(list->name) + 1);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->base_iid) {
+	    register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (0 <= list->num_methods) {
+	    static WCHAR const fmt[3] = { '%', 'd', 0 };
+	    HKEY key;
+
+	    res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
+				  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+
+	    wsprintfW(buf, fmt, list->num_methods);
+	    res = RegSetValueExW(key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)buf,
+				 (lstrlenW(buf) + 1) * sizeof(WCHAR));
+	    RegCloseKey(key);
+
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->ps_clsid) {
+	    register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->ps_clsid32) {
+	    register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+    error_close_iid_key:
+	RegCloseKey(iid_key);
+    }
+
+error_close_interface_key:
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		unregister_interfaces
+ */
+static HRESULT unregister_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
+			KEY_READ | KEY_WRITE, &interface_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+	WCHAR buf[39];
+
+	StringFromGUID2(list->iid, buf, 39);
+	res = recursive_delete_keyW(interface_key, buf);
+    }
+
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		register_coclasses
+ */
+static HRESULT register_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+	WCHAR buf[39];
+	HKEY clsid_key;
+
+	StringFromGUID2(list->clsid, buf, 39);
+	res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
+			      KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
+	if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+	if (list->name) {
+	    res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)(list->name),
+				 strlen(list->name) + 1);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->ips) {
+	    res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->ips32) {
+	    HKEY ips32_key;
+
+	    res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
+				  KEY_READ | KEY_WRITE, NULL,
+				  &ips32_key, NULL);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)list->ips32,
+				 lstrlenA(list->ips32) + 1);
+	    if (res == ERROR_SUCCESS && list->ips32_tmodel)
+		res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
+				     (CONST BYTE*)list->ips32_tmodel,
+				     strlen(list->ips32_tmodel) + 1);
+	    RegCloseKey(ips32_key);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->progid) {
+	    res = register_key_defvalueA(clsid_key, progid_keyname,
+					 list->progid);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = register_progid(buf, list->progid, NULL,
+				  list->name, list->progid_extra);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->viprogid) {
+	    res = register_key_defvalueA(clsid_key, viprogid_keyname,
+					 list->viprogid);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = register_progid(buf, list->viprogid, list->progid,
+				  list->name, list->progid_extra);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+    error_close_clsid_key:
+	RegCloseKey(clsid_key);
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		unregister_coclasses
+ */
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
+			KEY_READ | KEY_WRITE, &coclass_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+	WCHAR buf[39];
+
+	StringFromGUID2(list->clsid, buf, 39);
+	res = recursive_delete_keyW(coclass_key, buf);
+	if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+	if (list->progid) {
+	    res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->progid);
+	    if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+	}
+
+	if (list->viprogid) {
+	    res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->viprogid);
+	    if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+	}
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		regsvr_key_guid
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
+{
+    WCHAR buf[39];
+
+    StringFromGUID2(guid, buf, 39);
+    return register_key_defvalueW(base, name, buf);
+}
+
+/***********************************************************************
+ *		regsvr_key_defvalueW
+ */
+static LONG register_key_defvalueW(
+    HKEY base,
+    WCHAR const *name,
+    WCHAR const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+			 (lstrlenW(value) + 1) * sizeof(WCHAR));
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		regsvr_key_defvalueA
+ */
+static LONG register_key_defvalueA(
+    HKEY base,
+    WCHAR const *name,
+    char const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+			 lstrlenA(value) + 1);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		regsvr_progid
+ */
+static LONG register_progid(
+    WCHAR const *clsid,
+    char const *progid,
+    char const *curver_progid,
+    char const *name,
+    char const *extra)
+{
+    LONG res;
+    HKEY progid_key;
+
+    res = RegCreateKeyExA(HKEY_CLASSES_ROOT, progid, 0,
+			  NULL, 0, KEY_READ | KEY_WRITE, NULL,
+			  &progid_key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+
+    if (name) {
+	res = RegSetValueExA(progid_key, NULL, 0, REG_SZ,
+			     (CONST BYTE*)name, strlen(name) + 1);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (clsid) {
+	res = register_key_defvalueW(progid_key, clsid_keyname, clsid);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (curver_progid) {
+	res = register_key_defvalueA(progid_key, curver_keyname,
+				     curver_progid);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (extra) {
+	HKEY extra_key;
+
+	res = RegCreateKeyExA(progid_key, extra, 0,
+			      NULL, 0, KEY_READ | KEY_WRITE, NULL,
+			      &extra_key, NULL);
+	if (res == ERROR_SUCCESS)
+	    RegCloseKey(extra_key);
+    }
+
+error_close_progid_key:
+    RegCloseKey(progid_key);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_key
+ */
+static LONG recursive_delete_key(HKEY key)
+{
+    LONG res;
+    WCHAR subkey_name[MAX_PATH];
+    DWORD cName;
+    HKEY subkey;
+
+    for (;;) {
+	cName = sizeof(subkey_name) / sizeof(WCHAR);
+	res = RegEnumKeyExW(key, 0, subkey_name, &cName,
+			    NULL, NULL, NULL, NULL);
+	if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) {
+	    res = ERROR_SUCCESS; /* presumably we're done enumerating */
+	    break;
+	}
+	res = RegOpenKeyExW(key, subkey_name, 0,
+			    KEY_READ | KEY_WRITE, &subkey);
+	if (res == ERROR_FILE_NOT_FOUND) continue;
+	if (res != ERROR_SUCCESS) break;
+
+	res = recursive_delete_key(subkey);
+	RegCloseKey(subkey);
+	if (res != ERROR_SUCCESS) break;
+    }
+
+    if (res == ERROR_SUCCESS) res = RegDeleteKeyW(key, 0);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_keyA
+ */
+static LONG recursive_delete_keyA(HKEY base, char const *name)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegOpenKeyExA(base, name, 0, KEY_READ | KEY_WRITE, &key);
+    if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
+    if (res != ERROR_SUCCESS) return res;
+    res = recursive_delete_key(key);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_keyW
+ */
+static LONG recursive_delete_keyW(HKEY base, WCHAR const *name)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegOpenKeyExW(base, name, 0, KEY_READ | KEY_WRITE, &key);
+    if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
+    if (res != ERROR_SUCCESS) return res;
+    res = recursive_delete_key(key);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		coclass list
+ */
+static struct regsvr_coclass const coclass_list[] = {
+    {   &CLSID_DirectMusicPerformance,
+	"DirectMusicPerformance",
+	NULL,
+	"dmime.dll",
+	"Both",
+	"Microsoft.DirectMusicPerformance.1",
+	"Microsoft.DirectMusicPerformance"
+    },
+    {   &CLSID_DirectMusicSegment,
+	"DirectMusicSegment",
+	NULL,
+	"dmime.dll",
+	"Both",
+	"Microsoft.DirectMusicSegment.1",
+	"Microsoft.DirectMusicSegment"
+    },
+    {   &CLSID_DirectMusicSegmentState,
+	"DirectMusicSegmentState",
+	NULL,
+	"dmime.dll",
+	"Both",
+	"Microsoft.DirectMusicSegmentState.1",
+	"Microsoft.DirectMusicSegmentState"
+    },
+    {   &CLSID_DirectMusicGraph,
+	"DirectMusicGraph",
+	NULL,
+	"dmime.dll",
+	"Both",
+	"Microsoft.DirectMusicGraph.1",
+	"Microsoft.DirectMusicGraph"
+    },
+    {   &CLSID_DirectMusicTempoTrack,
+	"DirectMusicTempoTrack",
+	NULL,
+	"dmime.dll",
+	"Both",
+	"Microsoft.DirectMusicTempoTrack.1",
+	"Microsoft.DirectMusicTempoTrack"
+    },
+    {   &CLSID_DirectMusicSeqTrack,
+	"DirectMusicSeqTrack",
+	NULL,
+	"dmime.dll",
+	"Both",
+	"Microsoft.DirectMusicSeqTrack.1",
+	"Microsoft.DirectMusicSeqTrack"
+    },
+    {   &CLSID_DirectMusicSysExTrack,
+	"DirectMusicSysExTrack",
+	NULL,
+	"dmime.dll",
+	"Both",
+	"Microsoft.DirectMusicSysExTrack.1",
+	"Microsoft.DirectMusicSysExTrack"
+    },
+    {   &CLSID_DirectMusicTimeSigTrack,
+	"DirectMusicTimeSigTrack",
+	NULL,
+	"dmime.dll",
+	"Both",
+	"Microsoft.DirectMusicTimeSigTrack.1",
+	"Microsoft.DirectMusicTimeSigTrack"
+    },
+    {   &CLSID_DirectMusicParamControlTrack,
+	"DirectMusicParamControlTrack",
+	NULL,
+	"dmime.dll",
+	"Both",
+	"Microsoft.DirectMusicParamControlTrack.1",
+	"Microsoft.DirectMusicParamControlTrack"
+    },
+    {   &CLSID_DirectMusicMarkerTrack,
+	"DirectMusicMarkerTrack",
+	NULL,
+	"dmime.dll",
+	"Both",
+	"Microsoft.DirectMusicMarkerTrack.1",
+	"Microsoft.DirectMusicMarkerTrack"
+    },
+    {   &CLSID_DirectMusicLyricsTrack,
+	"DirectMusicLyricsTrack",
+	NULL,
+	"dmime.dll",
+	"Both",
+	"Microsoft.DirectMusicLyricsTrack.1",
+	"Microsoft.DirectMusicLyricsTrack"
+    },
+    {   &CLSID_DirectMusicSong,
+	"DirectMusicSong",
+	NULL,
+	"dmime.dll",
+	"Both",
+	"Microsoft.DirectMusicSong.1",
+	"Microsoft.DirectMusicSong"
+    },
+    {   &CLSID_DirectMusicSegTriggerTrack,
+	"DirectMusicSegTriggerTrack",
+	NULL,
+	"dmime.dll",
+	"Both",
+	"Microsoft.DirectMusicSegTriggerTrack.1",
+	"Microsoft.DirectMusicSegTriggerTrack"
+    },
+    {   &CLSID_DirectMusicAudioPath,
+	"DirectMusicAudioPath",
+	NULL,
+	"dmime.dll",
+	"Both",
+	"Microsoft.DirectMusicAudioPath.1",
+	"Microsoft.DirectMusicAudioPath"
+    },
+    {   &CLSID_DirectMusicWaveTrack,
+	"DirectMusicWaveTrack",
+	NULL,
+	"dmime.dll",
+	"Both",
+	"Microsoft.DirectMusicWaveTrack.1",
+	"Microsoft.DirectMusicWaveTrack"
+    },
+    { NULL }			/* list terminator */
+};
+
+/***********************************************************************
+ *		interface list
+ */
+
+static struct regsvr_interface const interface_list[] = {
+    { NULL }			/* list terminator */
+};
+
+/***********************************************************************
+ *		DllRegisterServer (DMIME.3)
+ */
+HRESULT WINAPI DMIME_DllRegisterServer(void)
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = register_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+	hr = register_interfaces(interface_list);
+    return hr;
+}
+
+/***********************************************************************
+ *		DllUnregisterServer (DMIME.4)
+ */
+HRESULT WINAPI DMIME_DllUnregisterServer(void)
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = unregister_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+	hr = unregister_interfaces(interface_list);
+    return hr;
+}
diff --git a/dlls/dmusic/dmusic_segment.c b/dlls/dmime/segment.c
similarity index 61%
rename from dlls/dmusic/dmusic_segment.c
rename to dlls/dmime/segment.c
index 7636467..b6d48c4 100644
--- a/dlls/dmusic/dmusic_segment.c
+++ b/dlls/dmime/segment.c
@@ -1,8 +1,4 @@
-/* IDirectMusicSegment Implementation
- * IDirectMusicSegment8 Implementation
- * IDirectMusicSegmentState Implementation
- * IDirectMusicSegmentState8 Implementation
- * IDirectMusicPatternTrack Implementation
+/* IDirectMusicSegment8 Implementation
  *
  * Copyright (C) 2003 Rok Mandeljc
  *
@@ -27,7 +23,7 @@
 #include "wingdi.h"
 #include "wine/debug.h"
 
-#include "dmusic_private.h"
+#include "dmime_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
 
@@ -276,7 +272,7 @@
 	return S_OK;
 }
 
-/* IDirectMusicSegment Interface part follow: */
+/* IDirectMusicSegment8 Interface part follow: */
 HRESULT WINAPI IDirectMusicSegment8Impl_SetTrackConfig (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidTrackClassID, DWORD dwGroupBits, DWORD dwIndex, DWORD dwFlagsOn, DWORD dwFlagsOff)
 {
 	ICOM_THIS(IDirectMusicSegment8Impl,iface);
@@ -358,194 +354,15 @@
 	IDirectMusicSegment8Impl_Unload
 };
 
-
-/* IDirectMusicSegmentState8 IUnknown part follow: */
-HRESULT WINAPI IDirectMusicSegmentState8Impl_QueryInterface (LPDIRECTMUSICSEGMENTSTATE8 iface, REFIID riid, LPVOID *ppobj)
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicSegment (LPCGUID lpcGUID, LPDIRECTMUSICSEGMENT8 *ppDMSeg, LPUNKNOWN pUnkOuter)
 {
-	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || 
-	    IsEqualGUID(riid, &IID_IDirectMusicSegmentState) ||
-	    IsEqualGUID(riid, &IID_IDirectMusicSegmentState8))
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicComposer))
 	{
-		IDirectMusicSegmentState8Impl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
 	}
-	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
-	return E_NOINTERFACE;
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
 }
-
-ULONG WINAPI IDirectMusicSegmentState8Impl_AddRef (LPDIRECTMUSICSEGMENTSTATE8 iface)
-{
-	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicSegmentState8Impl_Release (LPDIRECTMUSICSEGMENTSTATE8 iface)
-{
-	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicSegmentState Interface part follow: */
-HRESULT WINAPI IDirectMusicSegmentState8Impl_GetRepeats (LPDIRECTMUSICSEGMENTSTATE8 iface,  DWORD* pdwRepeats)
-{
-	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pdwRepeats);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSegmentState8Impl_GetSegment (LPDIRECTMUSICSEGMENTSTATE8 iface, IDirectMusicSegment** ppSegment)
-{
-	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
-
-	FIXME("(%p, %p): stub\n", This, ppSegment);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSegmentState8Impl_GetStartTime (LPDIRECTMUSICSEGMENTSTATE8 iface, MUSIC_TIME* pmtStart)
-{
-	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pmtStart);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSegmentState8Impl_GetSeek (LPDIRECTMUSICSEGMENTSTATE8 iface, MUSIC_TIME* pmtSeek)
-{
-	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pmtSeek);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSegmentState8Impl_GetStartPoint (LPDIRECTMUSICSEGMENTSTATE8 iface, MUSIC_TIME* pmtStart)
-{
-	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pmtStart);
-
-	return S_OK;
-}
-
-/* IDirectMusicSegmentState8 Interface part follow: */
-HRESULT WINAPI IDirectMusicSegmentState8Impl_SetTrackConfig (LPDIRECTMUSICSEGMENTSTATE8 iface, REFGUID rguidTrackClassID, DWORD dwGroupBits, DWORD dwIndex, DWORD dwFlagsOn, DWORD dwFlagsOff)
-{
-	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
-
-	FIXME("(%p, %s, %ld, %ld, %ld, %ld): stub\n", This, debugstr_guid(rguidTrackClassID), dwGroupBits, dwIndex, dwFlagsOn, dwFlagsOff);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSegmentState8Impl_GetObjectInPath (LPDIRECTMUSICSEGMENTSTATE8 iface, DWORD dwPChannel, DWORD dwStage, DWORD dwBuffer, REFGUID guidObject, DWORD dwIndex, REFGUID iidInterface, void** ppObject)
-{
-	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
-
-	FIXME("(%p, %ld, %ld, %ld, %s, %ld, %s, %p): stub\n", This, dwPChannel, dwStage, dwBuffer, debugstr_guid(guidObject), dwIndex, debugstr_guid(iidInterface), ppObject);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicSegmentState8) DirectMusicSegmentState8_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicSegmentState8Impl_QueryInterface,
-	IDirectMusicSegmentState8Impl_AddRef,
-	IDirectMusicSegmentState8Impl_Release,
-	IDirectMusicSegmentState8Impl_GetRepeats,
-	IDirectMusicSegmentState8Impl_GetSegment,
-	IDirectMusicSegmentState8Impl_GetStartTime,
-	IDirectMusicSegmentState8Impl_GetSeek,
-	IDirectMusicSegmentState8Impl_GetStartPoint,
-	IDirectMusicSegmentState8Impl_SetTrackConfig,
-	IDirectMusicSegmentState8Impl_GetObjectInPath
-};
-
-
-/* IDirectMusicPatternTrack IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicPatternTrackImpl_QueryInterface (LPDIRECTMUSICPATTERNTRACK iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicPatternTrackImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || 
-	    IsEqualGUID(riid, &IID_IDirectMusicPatternTrack))
-	{
-		IDirectMusicPatternTrackImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicPatternTrackImpl_AddRef (LPDIRECTMUSICPATTERNTRACK iface)
-{
-	ICOM_THIS(IDirectMusicPatternTrackImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicPatternTrackImpl_Release (LPDIRECTMUSICPATTERNTRACK iface)
-{
-	ICOM_THIS(IDirectMusicPatternTrackImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicPatternTrack Interface follow: */
-HRESULT WINAPI IDirectMusicPatternTrackImpl_CreateSegment (LPDIRECTMUSICPATTERNTRACK iface, IDirectMusicStyle* pStyle, IDirectMusicSegment** ppSegment)
-{
-	ICOM_THIS(IDirectMusicPatternTrackImpl,iface);
-
-	FIXME("(%p, %p, %p): stub\n", This, pStyle, ppSegment);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicPatternTrackImpl_SetVariation (LPDIRECTMUSICPATTERNTRACK iface, IDirectMusicSegmentState* pSegState, DWORD dwVariationFlags, DWORD dwPart)
-{
-	ICOM_THIS(IDirectMusicPatternTrackImpl,iface);
-
-	FIXME("(%p, %p, %ld, %ld): stub\n", This, pSegState, dwVariationFlags, dwPart);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicPatternTrackImpl_SetPatternByName (LPDIRECTMUSICPATTERNTRACK iface, IDirectMusicSegmentState* pSegState, WCHAR* wszName, IDirectMusicStyle* pStyle, DWORD dwPatternType, DWORD* pdwLength)
-{
-	ICOM_THIS(IDirectMusicPatternTrackImpl,iface);
-
-	FIXME("(%p, %p, %p, %p, %ld, %p): stub\n", This, pSegState, wszName, pStyle, dwPatternType, pdwLength);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicPatternTrack) DirectMusicPatternTrack_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicPatternTrackImpl_QueryInterface,
-	IDirectMusicPatternTrackImpl_AddRef,
-	IDirectMusicPatternTrackImpl_Release,
-	IDirectMusicPatternTrackImpl_CreateSegment,
-	IDirectMusicPatternTrackImpl_SetVariation,
-	IDirectMusicPatternTrackImpl_SetPatternByName
-};
diff --git a/dlls/dmime/segmentstate.c b/dlls/dmime/segmentstate.c
new file mode 100644
index 0000000..2e01ebb
--- /dev/null
+++ b/dlls/dmime/segmentstate.c
@@ -0,0 +1,158 @@
+/* IDirectMusicSegmentState8 Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmime_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+
+/* IDirectMusicSegmentState8 IUnknown part follow: */
+HRESULT WINAPI IDirectMusicSegmentState8Impl_QueryInterface (LPDIRECTMUSICSEGMENTSTATE8 iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || 
+	    IsEqualGUID(riid, &IID_IDirectMusicSegmentState) ||
+	    IsEqualGUID(riid, &IID_IDirectMusicSegmentState8))
+	{
+		IDirectMusicSegmentState8Impl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicSegmentState8Impl_AddRef (LPDIRECTMUSICSEGMENTSTATE8 iface)
+{
+	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicSegmentState8Impl_Release (LPDIRECTMUSICSEGMENTSTATE8 iface)
+{
+	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicSegmentState Interface part follow: */
+HRESULT WINAPI IDirectMusicSegmentState8Impl_GetRepeats (LPDIRECTMUSICSEGMENTSTATE8 iface,  DWORD* pdwRepeats)
+{
+	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pdwRepeats);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSegmentState8Impl_GetSegment (LPDIRECTMUSICSEGMENTSTATE8 iface, IDirectMusicSegment** ppSegment)
+{
+	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
+
+	FIXME("(%p, %p): stub\n", This, ppSegment);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSegmentState8Impl_GetStartTime (LPDIRECTMUSICSEGMENTSTATE8 iface, MUSIC_TIME* pmtStart)
+{
+	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pmtStart);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSegmentState8Impl_GetSeek (LPDIRECTMUSICSEGMENTSTATE8 iface, MUSIC_TIME* pmtSeek)
+{
+	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pmtSeek);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSegmentState8Impl_GetStartPoint (LPDIRECTMUSICSEGMENTSTATE8 iface, MUSIC_TIME* pmtStart)
+{
+	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pmtStart);
+
+	return S_OK;
+}
+
+/* IDirectMusicSegmentState8 Interface part follow: */
+HRESULT WINAPI IDirectMusicSegmentState8Impl_SetTrackConfig (LPDIRECTMUSICSEGMENTSTATE8 iface, REFGUID rguidTrackClassID, DWORD dwGroupBits, DWORD dwIndex, DWORD dwFlagsOn, DWORD dwFlagsOff)
+{
+	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
+
+	FIXME("(%p, %s, %ld, %ld, %ld, %ld): stub\n", This, debugstr_guid(rguidTrackClassID), dwGroupBits, dwIndex, dwFlagsOn, dwFlagsOff);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSegmentState8Impl_GetObjectInPath (LPDIRECTMUSICSEGMENTSTATE8 iface, DWORD dwPChannel, DWORD dwStage, DWORD dwBuffer, REFGUID guidObject, DWORD dwIndex, REFGUID iidInterface, void** ppObject)
+{
+	ICOM_THIS(IDirectMusicSegmentState8Impl,iface);
+
+	FIXME("(%p, %ld, %ld, %ld, %s, %ld, %s, %p): stub\n", This, dwPChannel, dwStage, dwBuffer, debugstr_guid(guidObject), dwIndex, debugstr_guid(iidInterface), ppObject);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicSegmentState8) DirectMusicSegmentState8_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicSegmentState8Impl_QueryInterface,
+	IDirectMusicSegmentState8Impl_AddRef,
+	IDirectMusicSegmentState8Impl_Release,
+	IDirectMusicSegmentState8Impl_GetRepeats,
+	IDirectMusicSegmentState8Impl_GetSegment,
+	IDirectMusicSegmentState8Impl_GetStartTime,
+	IDirectMusicSegmentState8Impl_GetSeek,
+	IDirectMusicSegmentState8Impl_GetStartPoint,
+	IDirectMusicSegmentState8Impl_SetTrackConfig,
+	IDirectMusicSegmentState8Impl_GetObjectInPath
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicSegmentState (LPCGUID lpcGUID, LPDIRECTMUSICSEGMENTSTATE8 *ppDMSeg, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicComposer))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmime/song.c b/dlls/dmime/song.c
new file mode 100644
index 0000000..d68950e
--- /dev/null
+++ b/dlls/dmime/song.c
@@ -0,0 +1,155 @@
+/* IDirectMusicSong Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmime_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicSong IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicSongImpl_QueryInterface (LPDIRECTMUSICSONG iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicSongImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || 
+	    IsEqualGUID(riid, &IID_IDirectMusicSong))
+	{
+		IDirectMusicSongImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicSongImpl_AddRef (LPDIRECTMUSICSONG iface)
+{
+	ICOM_THIS(IDirectMusicSongImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicSongImpl_Release (LPDIRECTMUSICSONG iface)
+{
+	ICOM_THIS(IDirectMusicSongImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicSong Interface follow: */
+HRESULT WINAPI IDirectMusicSongImpl_Compose (LPDIRECTMUSICSONG iface)
+{
+	ICOM_THIS(IDirectMusicSongImpl,iface);
+
+	FIXME("(%p): stub\n", This);
+	
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSongImpl_GetParam (LPDIRECTMUSICSONG iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam)
+{
+	ICOM_THIS(IDirectMusicSongImpl,iface);
+
+	FIXME("(%p, %s, %ld, %ld, %ld, %p, %p): stub\n", This, debugstr_guid(rguidType), dwGroupBits, dwIndex, mtTime, pmtNext, pParam);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSongImpl_GetSegment (LPDIRECTMUSICSONG iface, WCHAR* pwzName, IDirectMusicSegment** ppSegment)
+{
+	ICOM_THIS(IDirectMusicSongImpl,iface);
+
+	FIXME("(%p, %p, %p): stub\n", This, pwzName, ppSegment);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSongImpl_GetAudioPathConfig (LPDIRECTMUSICSONG iface, IUnknown** ppAudioPathConfig)
+{
+	ICOM_THIS(IDirectMusicSongImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, ppAudioPathConfig);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSongImpl_Download (LPDIRECTMUSICSONG iface, IUnknown* pAudioPath)
+{
+	ICOM_THIS(IDirectMusicSongImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pAudioPath);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSongImpl_Unload (LPDIRECTMUSICSONG iface, IUnknown* pAudioPath)
+{
+	ICOM_THIS(IDirectMusicSongImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pAudioPath);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSongImpl_EnumSegment (LPDIRECTMUSICSONG iface, DWORD dwIndex, IDirectMusicSegment** ppSegment)
+{
+	ICOM_THIS(IDirectMusicSongImpl,iface);
+
+	FIXME("(%p, %ld, %p): stub\n", This, dwIndex, ppSegment);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicSong) DirectMusicSong_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicSongImpl_QueryInterface,
+	IDirectMusicSongImpl_AddRef,
+	IDirectMusicSongImpl_Release,
+	IDirectMusicSongImpl_Compose,
+	IDirectMusicSongImpl_GetParam,
+	IDirectMusicSongImpl_GetSegment,
+	IDirectMusicSongImpl_GetAudioPathConfig,
+	IDirectMusicSongImpl_Download,
+	IDirectMusicSongImpl_Unload,
+	IDirectMusicSongImpl_EnumSegment
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicSong (LPCGUID lpcGUID, LPDIRECTMUSICSONG *ppDMSng, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicComposer))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmime/tool.c b/dlls/dmime/tool.c
new file mode 100644
index 0000000..691d893
--- /dev/null
+++ b/dlls/dmime/tool.c
@@ -0,0 +1,158 @@
+/* IDirectMusicTool8 Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmime_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+
+/* IDirectMusicTool8 IUnknown part follow: */
+HRESULT WINAPI IDirectMusicTool8Impl_QueryInterface (LPDIRECTMUSICTOOL8 iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicTool8Impl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || 
+	    IsEqualGUID(riid, &IID_IDirectMusicTool) ||
+	    IsEqualGUID(riid, &IID_IDirectMusicTool8))
+	{
+		IDirectMusicTool8Impl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicTool8Impl_AddRef (LPDIRECTMUSICTOOL8 iface)
+{
+	ICOM_THIS(IDirectMusicTool8Impl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicTool8Impl_Release (LPDIRECTMUSICTOOL8 iface)
+{
+	ICOM_THIS(IDirectMusicTool8Impl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicTool Interface follow: */
+HRESULT WINAPI IDirectMusicTool8Impl_Init (LPDIRECTMUSICTOOL8 iface, IDirectMusicGraph* pGraph)
+{
+	ICOM_THIS(IDirectMusicTool8Impl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pGraph);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicTool8Impl_GetMsgDeliveryType (LPDIRECTMUSICTOOL8 iface, DWORD* pdwDeliveryType)
+{
+	ICOM_THIS(IDirectMusicTool8Impl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pdwDeliveryType);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicTool8Impl_GetMediaTypeArraySize (LPDIRECTMUSICTOOL8 iface, DWORD* pdwNumElements)
+{
+	ICOM_THIS(IDirectMusicTool8Impl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pdwNumElements);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicTool8Impl_GetMediaTypes (LPDIRECTMUSICTOOL8 iface, DWORD** padwMediaTypes, DWORD dwNumElements)
+{
+	ICOM_THIS(IDirectMusicTool8Impl,iface);
+
+	FIXME("(%p, %p, %ld): stub\n", This, padwMediaTypes, dwNumElements);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicTool8Impl_ProcessPMsg (LPDIRECTMUSICTOOL8 iface, IDirectMusicPerformance* pPerf, DMUS_PMSG* pPMSG)
+{
+	ICOM_THIS(IDirectMusicTool8Impl,iface);
+
+	FIXME("(%p, %p, %p): stub\n", This, pPerf, pPMSG);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicTool8Impl_Flush (LPDIRECTMUSICTOOL8 iface, IDirectMusicPerformance* pPerf, DMUS_PMSG* pPMSG, REFERENCE_TIME rtTime)
+{
+	ICOM_THIS(IDirectMusicTool8Impl,iface);
+
+	FIXME("(%p, %p, %p, %lli): stub\n", This, pPerf, pPMSG, rtTime);
+
+	return S_OK;
+}
+
+/* IDirectMusicTool8 Interface part follow: */
+HRESULT WINAPI IDirectMusicTool8Impl_Clone (LPDIRECTMUSICTOOL8 iface, IDirectMusicTool** ppTool)
+{
+	ICOM_THIS(IDirectMusicTool8Impl,iface);
+
+	FIXME("(%p, %p): stub\n", This, ppTool);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicTool8) DirectMusicTool8_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicTool8Impl_QueryInterface,
+	IDirectMusicTool8Impl_AddRef,
+	IDirectMusicTool8Impl_Release,
+	IDirectMusicTool8Impl_Init,
+	IDirectMusicTool8Impl_GetMsgDeliveryType,
+	IDirectMusicTool8Impl_GetMediaTypeArraySize,
+	IDirectMusicTool8Impl_GetMediaTypes,
+	IDirectMusicTool8Impl_ProcessPMsg,
+	IDirectMusicTool8Impl_Flush,
+	IDirectMusicTool8Impl_Clone
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicTool (LPCGUID lpcGUID, LPDIRECTMUSICTOOL8 *ppDMTool, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicComposer))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmusic/dmusic_plugins.c b/dlls/dmime/track.c
similarity index 65%
rename from dlls/dmusic/dmusic_plugins.c
rename to dlls/dmime/track.c
index cadf265..5f66a48 100644
--- a/dlls/dmusic/dmusic_plugins.c
+++ b/dlls/dmime/track.c
@@ -1,7 +1,4 @@
-/* IDirectMusicTool Implementation
- * IDirectMusicTool8 Implementation
- * IDirectMusicTrack Implementation
- * IDirectMusicTrack8 Implementation
+/* IDirectMusicTrack8 Implementation
  *
  * Copyright (C) 2003 Rok Mandeljc
  *
@@ -26,128 +23,10 @@
 #include "wingdi.h"
 #include "wine/debug.h"
 
-#include "dmusic_private.h"
+#include "dmime_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
 
-
-/* IDirectMusicTool8 IUnknown part follow: */
-HRESULT WINAPI IDirectMusicTool8Impl_QueryInterface (LPDIRECTMUSICTOOL8 iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicTool8Impl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || 
-	    IsEqualGUID(riid, &IID_IDirectMusicTool) ||
-	    IsEqualGUID(riid, &IID_IDirectMusicTool8))
-	{
-		IDirectMusicTool8Impl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicTool8Impl_AddRef (LPDIRECTMUSICTOOL8 iface)
-{
-	ICOM_THIS(IDirectMusicTool8Impl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicTool8Impl_Release (LPDIRECTMUSICTOOL8 iface)
-{
-	ICOM_THIS(IDirectMusicTool8Impl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicTool Interface follow: */
-HRESULT WINAPI IDirectMusicTool8Impl_Init (LPDIRECTMUSICTOOL8 iface, IDirectMusicGraph* pGraph)
-{
-	ICOM_THIS(IDirectMusicTool8Impl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pGraph);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicTool8Impl_GetMsgDeliveryType (LPDIRECTMUSICTOOL8 iface, DWORD* pdwDeliveryType)
-{
-	ICOM_THIS(IDirectMusicTool8Impl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pdwDeliveryType);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicTool8Impl_GetMediaTypeArraySize (LPDIRECTMUSICTOOL8 iface, DWORD* pdwNumElements)
-{
-	ICOM_THIS(IDirectMusicTool8Impl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pdwNumElements);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicTool8Impl_GetMediaTypes (LPDIRECTMUSICTOOL8 iface, DWORD** padwMediaTypes, DWORD dwNumElements)
-{
-	ICOM_THIS(IDirectMusicTool8Impl,iface);
-
-	FIXME("(%p, %p, %ld): stub\n", This, padwMediaTypes, dwNumElements);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicTool8Impl_ProcessPMsg (LPDIRECTMUSICTOOL8 iface, IDirectMusicPerformance* pPerf, DMUS_PMSG* pPMSG)
-{
-	ICOM_THIS(IDirectMusicTool8Impl,iface);
-
-	FIXME("(%p, %p, %p): stub\n", This, pPerf, pPMSG);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicTool8Impl_Flush (LPDIRECTMUSICTOOL8 iface, IDirectMusicPerformance* pPerf, DMUS_PMSG* pPMSG, REFERENCE_TIME rtTime)
-{
-	ICOM_THIS(IDirectMusicTool8Impl,iface);
-
-	FIXME("(%p, %p, %p, FIXME): stub\n", This, pPerf, pPMSG/*, rtTime*/);
-
-	return S_OK;
-}
-
-/* IDirectMusicTool8 Interface part follow: */
-HRESULT WINAPI IDirectMusicTool8Impl_Clone (LPDIRECTMUSICTOOL8 iface, IDirectMusicTool** ppTool)
-{
-	ICOM_THIS(IDirectMusicTool8Impl,iface);
-
-	FIXME("(%p, %p): stub\n", This, ppTool);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicTool8) DirectMusicTool8_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicTool8Impl_QueryInterface,
-	IDirectMusicTool8Impl_AddRef,
-	IDirectMusicTool8Impl_Release,
-	IDirectMusicTool8Impl_Init,
-	IDirectMusicTool8Impl_GetMsgDeliveryType,
-	IDirectMusicTool8Impl_GetMediaTypeArraySize,
-	IDirectMusicTool8Impl_GetMediaTypes,
-	IDirectMusicTool8Impl_ProcessPMsg,
-	IDirectMusicTool8Impl_Flush,
-	IDirectMusicTool8Impl_Clone
-};
-
-
 /* IDirectMusicTrack8 IUnknown part follow: */
 HRESULT WINAPI IDirectMusicTrack8Impl_QueryInterface (LPDIRECTMUSICTRACK8 iface, REFIID riid, LPVOID *ppobj)
 {
@@ -280,7 +159,7 @@
 {
 	ICOM_THIS(IDirectMusicTrack8Impl,iface);
 
-	FIXME("(%p, %p, FIXME, FIXME, FIXME, %ld, %p, %p, %ld): stub\n", This, pStateData/*, rtStart, rtEnd, rtOffset*/, dwFlags, pPerf, pSegSt, dwVirtualID);
+	FIXME("(%p, %p, %lli, %lli, %lli, %ld, %p, %p, %ld): stub\n", This, pStateData, rtStart, rtEnd, rtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
 
 	return S_OK;
 }
@@ -289,7 +168,7 @@
 {
 	ICOM_THIS(IDirectMusicTrack8Impl,iface);
 
-	FIXME("(%p, %s, FIXME, %p, %p, %p, %ld): stub\n", This, debugstr_guid(rguidType)/*, rtTime*/, prtNext, pParam, pStateData, dwFlags);
+	FIXME("(%p, %s, %lli, %p, %p, %p, %ld): stub\n", This, debugstr_guid(rguidType), rtTime, prtNext, pParam, pStateData, dwFlags);
 
 	return S_OK;
 }
@@ -298,7 +177,7 @@
 {
 	ICOM_THIS(IDirectMusicTrack8Impl,iface);
 
-	FIXME("(%p, %s, FIXME, %p, %p, %ld): stub\n", This, debugstr_guid(rguidType)/*, rtTime*/, pParam, pStateData, dwFlags);
+	FIXME("(%p, %s, %lli, %p, %p, %ld): stub\n", This, debugstr_guid(rguidType), rtTime, pParam, pStateData, dwFlags);
 
 	return S_OK;
 }
@@ -343,3 +222,16 @@
 	IDirectMusicTrack8Impl_Compose,
 	IDirectMusicTrack8Impl_Join
 };
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicTrack (LPCGUID lpcGUID, LPDIRECTMUSICTRACK8 *ppDMTrack, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicComposer))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmloader/Makefile.in b/dlls/dmloader/Makefile.in
index d6c49d2..6208f19 100644
--- a/dlls/dmloader/Makefile.in
+++ b/dlls/dmloader/Makefile.in
@@ -3,13 +3,18 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = dmloader.dll
-IMPORTS   = dmusic kernel32
+IMPORTS   = ole32 user32 advapi32 kernel32
+EXTRALIBS = $(LIBUUID)
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
 
 C_SRCS = \
-	dmloader_main.c
+	container.c \
+	dmloader_main.c \
+	getloader.c \
+	loader.c \
+	regsvr.c
 
 RC_SRCS = version.rc
 
diff --git a/dlls/dmloader/container.c b/dlls/dmloader/container.c
new file mode 100644
index 0000000..37867ab
--- /dev/null
+++ b/dlls/dmloader/container.c
@@ -0,0 +1,95 @@
+/* IDirectMusicContainer
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmloader_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicContainer IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicContainerImpl_QueryInterface (LPDIRECTMUSICCONTAINER iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicContainerImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || 
+	    IsEqualGUID(riid, &IID_IDirectMusicContainer))
+	{
+		IDirectMusicContainerImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicContainerImpl_AddRef (LPDIRECTMUSICCONTAINER iface)
+{
+	ICOM_THIS(IDirectMusicContainerImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicContainerImpl_Release (LPDIRECTMUSICCONTAINER iface)
+{
+	ICOM_THIS(IDirectMusicContainerImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicContainer Interface follow: */
+HRESULT WINAPI IDirectMusicContainerImpl_EnumObject (LPDIRECTMUSICCONTAINER iface, REFGUID rguidClass, DWORD dwIndex, LPDMUS_OBJECTDESC pDesc, WCHAR* pwszAlias)
+{
+	ICOM_THIS(IDirectMusicContainerImpl,iface);
+
+	FIXME("(%p, %s, %ld, %p, %p): stub\n", This, debugstr_guid(rguidClass), dwIndex, pDesc, pwszAlias);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicContainer) DirectMusicContainer_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicContainerImpl_QueryInterface,
+	IDirectMusicContainerImpl_AddRef,
+	IDirectMusicContainerImpl_Release,
+	IDirectMusicContainerImpl_EnumObject
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicContainer (LPCGUID lpcGUID, LPDIRECTMUSICCONTAINER *ppDMCon, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicContainer))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmloader/dmloader.spec b/dlls/dmloader/dmloader.spec
index 3d091d1..ae9237b 100644
--- a/dlls/dmloader/dmloader.spec
+++ b/dlls/dmloader/dmloader.spec
@@ -1,6 +1,4 @@
-# Linked to main dmusic.dll for easier implementation
-
-1 stdcall DllCanUnloadNow() dmusic.DllCanUnloadNow
-2 stdcall DllGetClassObject(long long ptr) dmusic.DllGetClassObject
-3 stdcall DllRegisterServer() dmusic.DllRegisterServer
-4 stdcall DllUnregisterServer() dmusic.DllUnregisterServer
+1 stdcall DllCanUnloadNow() DMLOADER_DllCanUnloadNow
+2 stdcall DllGetClassObject(long long ptr) DMLOADER_DllGetClassObject
+3 stdcall DllRegisterServer() DMLOADER_DllRegisterServer
+4 stdcall DllUnregisterServer() DMLOADER_DllUnregisterServer
diff --git a/dlls/dmloader/dmloader_main.c b/dlls/dmloader/dmloader_main.c
index 67a01ed..ec9351d 100644
--- a/dlls/dmloader/dmloader_main.c
+++ b/dlls/dmloader/dmloader_main.c
@@ -1 +1,140 @@
-/* nothing here yet */
+/* DirectMusicLoader Main
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "dmloader_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+
+/******************************************************************
+ *		DirectMusicLoader ClassFactory
+ *
+ *
+ */
+ 
+typedef struct
+{
+    /* IUnknown fields */
+    ICOM_VFIELD(IClassFactory);
+    DWORD                       ref;
+} IClassFactoryImpl;
+
+static HRESULT WINAPI DMLOADCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+
+	FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+static ULONG WINAPI DMLOADCF_AddRef(LPCLASSFACTORY iface)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	return ++(This->ref);
+}
+
+static ULONG WINAPI DMLOADCF_Release(LPCLASSFACTORY iface)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	/* static class, won't be  freed */
+	return --(This->ref);
+}
+
+static HRESULT WINAPI DMLOADCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+
+	TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
+	if (IsEqualGUID (&IID_IDirectMusicLoader, riid) ||
+	    IsEqualGUID (&IID_IDirectMusicLoader8, riid)) {
+	  return DMUSIC_CreateDirectMusicLoader(riid, (LPDIRECTMUSICLOADER8*) ppobj, pOuter);
+	}
+	
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+static HRESULT WINAPI DMLOADCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	FIXME("(%p)->(%d),stub!\n", This, dolock);
+	return S_OK;
+}
+
+static ICOM_VTABLE(IClassFactory) DMLOADCF_Vtbl = {
+	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	DMLOADCF_QueryInterface,
+	DMLOADCF_AddRef,
+	DMLOADCF_Release,
+	DMLOADCF_CreateInstance,
+	DMLOADCF_LockServer
+};
+
+static IClassFactoryImpl DMLOADER_CF = {&DMLOADCF_Vtbl, 1 };
+
+/******************************************************************
+ *		DllMain
+ *
+ *
+ */
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+	if (fdwReason == DLL_PROCESS_ATTACH)
+	{
+            DisableThreadLibraryCalls(hinstDLL);
+		/* FIXME: Initialisation */
+	}
+	else if (fdwReason == DLL_PROCESS_DETACH)
+	{
+		/* FIXME: Cleanup */
+	}
+
+	return TRUE;
+}
+
+
+/******************************************************************
+ *		DllCanUnloadNow (DMLOADER.1)
+ *
+ *
+ */
+HRESULT WINAPI DMLOADER_DllCanUnloadNow(void)
+{
+    FIXME("(void): stub\n");
+
+    return S_FALSE;
+}
+
+
+/******************************************************************
+ *		DllGetClassObject (DMLOADER.2)
+ *
+ *
+ */
+HRESULT WINAPI DMLOADER_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
+{
+    TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    if (IsEqualCLSID (&IID_IClassFactory, riid)) {
+      *ppv = (LPVOID) &DMLOADER_CF;
+      IClassFactory_AddRef((IClassFactory*)*ppv);
+      return S_OK;
+    }
+    WARN("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    return CLASS_E_CLASSNOTAVAILABLE;
+}
diff --git a/dlls/dmloader/dmloader_private.h b/dlls/dmloader/dmloader_private.h
new file mode 100644
index 0000000..3014d7d
--- /dev/null
+++ b/dlls/dmloader/dmloader_private.h
@@ -0,0 +1,135 @@
+/* DirectMusicLoader Private Include
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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.
+ */
+
+#ifndef __WINE_DMLOADER_PRIVATE_H
+#define __WINE_DMLOADER_PRIVATE_H
+
+#include "windef.h"
+#include "wine/debug.h"
+#include "winbase.h"
+#include "winnt.h"
+#include "dmusicc.h"
+#include "dmusici.h"
+#include "dmusics.h"
+#include "dmplugin.h"
+#include "dmusicf.h"
+#include "dsound.h"
+
+/*****************************************************************************
+ * Interfaces
+ */
+typedef struct IDirectMusicLoader8Impl IDirectMusicLoader8Impl;
+typedef struct IDirectMusicContainerImpl IDirectMusicContainerImpl;
+typedef struct IDirectMusicGetLoaderImpl IDirectMusicGetLoaderImpl;
+
+/*****************************************************************************
+ * Predeclare the interface implementation structures
+ */
+extern ICOM_VTABLE(IDirectMusicLoader8) DirectMusicLoader8_Vtbl;
+extern ICOM_VTABLE(IDirectMusicContainer) DirectMusicContainer_Vtbl;
+extern ICOM_VTABLE(IDirectMusicGetLoader) DirectMusicGetLoader_Vtbl;
+
+/*****************************************************************************
+ * ClassFactory
+ */
+/* can support IID_IDirectMusicLoader and IID_IDirectMusicLoader8
+ * return always an IDirectMusicLoader8Impl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicLoader (LPCGUID lpcGUID, LPDIRECTMUSICLOADER8 *ppDMLoad, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicContainer
+ * return always an IDirectMusicContainerImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicContainer (LPCGUID lpcGUID, LPDIRECTMUSICCONTAINER *ppDMCon, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicGetLoader
+ * return always an IDirectMusicGetLoaderImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicGetLoader (LPCGUID lpcGUID, LPDIRECTMUSICGETLOADER *ppDMGetLoad, LPUNKNOWN pUnkOuter);
+
+/*****************************************************************************
+ * IDirectMusicLoader8Impl implementation structure
+ */
+struct IDirectMusicLoader8Impl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicLoader8);
+  DWORD          ref;
+
+  /* IDirectMusicLoaderImpl fields */
+  WCHAR          wzSearchPath[MAX_PATH];
+  /* IDirectMusicLoader8Impl fields */ 
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicLoader8Impl_QueryInterface (LPDIRECTMUSICLOADER8 iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicLoader8Impl_AddRef (LPDIRECTMUSICLOADER8 iface);
+extern ULONG WINAPI   IDirectMusicLoader8Impl_Release (LPDIRECTMUSICLOADER8 iface);
+/* IDirectMusicLoader: */
+extern HRESULT WINAPI IDirectMusicLoader8Impl_GetObject (LPDIRECTMUSICLOADER8 iface, LPDMUS_OBJECTDESC pDesc, REFIID riid, LPVOID*ppv);
+extern HRESULT WINAPI IDirectMusicLoader8Impl_SetObject (LPDIRECTMUSICLOADER8 iface, LPDMUS_OBJECTDESC pDesc);
+extern HRESULT WINAPI IDirectMusicLoader8Impl_SetSearchDirectory (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, WCHAR* pwzPath, BOOL fClear);
+extern HRESULT WINAPI IDirectMusicLoader8Impl_ScanDirectory (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, WCHAR* pwzFileExtension, WCHAR* pwzScanFileName);
+extern HRESULT WINAPI IDirectMusicLoader8Impl_CacheObject (LPDIRECTMUSICLOADER8 iface, IDirectMusicObject* pObject);
+extern HRESULT WINAPI IDirectMusicLoader8Impl_ReleaseObject (LPDIRECTMUSICLOADER8 iface, IDirectMusicObject* pObject);
+extern HRESULT WINAPI IDirectMusicLoader8Impl_ClearCache (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass);
+extern HRESULT WINAPI IDirectMusicLoader8Impl_EnableCache (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, BOOL fEnable);
+extern HRESULT WINAPI IDirectMusicLoader8Impl_EnumObject (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, DWORD dwIndex, LPDMUS_OBJECTDESC pDesc);
+/* IDirectMusicLoader8: */
+extern void    WINAPI IDirectMusicLoader8Impl_CollectGarbage (LPDIRECTMUSICLOADER8 iface);
+extern HRESULT WINAPI IDirectMusicLoader8Impl_ReleaseObjectByUnknown (LPDIRECTMUSICLOADER8 iface, IUnknown* pObject);
+extern HRESULT WINAPI IDirectMusicLoader8Impl_LoadObjectFromFile (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClassID, REFIID iidInterfaceID, WCHAR* pwzFilePath, void** ppObject);
+
+/*****************************************************************************
+ * IDirectMusicContainerImpl implementation structure
+ */
+struct IDirectMusicContainerImpl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicContainer);
+  DWORD          ref;
+
+  /* IDirectMusicContainerImpl fields */
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicContainerImpl_QueryInterface (LPDIRECTMUSICCONTAINER iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicContainerImpl_AddRef (LPDIRECTMUSICCONTAINER iface);
+extern ULONG WINAPI   IDirectMusicContainerImpl_Release (LPDIRECTMUSICCONTAINER iface);
+/* IDirectMusicContainer: */
+extern HRESULT WINAPI IDirectMusicContainerImpl_EnumObject (LPDIRECTMUSICCONTAINER iface, REFGUID rguidClass, DWORD dwIndex, LPDMUS_OBJECTDESC pDesc, WCHAR* pwszAlias);
+
+/*****************************************************************************
+ * IDirectMusicGetLoaderImpl implementation structure
+ */
+struct IDirectMusicGetLoaderImpl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicGetLoader);
+  DWORD          ref;
+
+  /* IDirectMusicGetLoaderImpl fields */
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicGetLoaderImpl_QueryInterface (LPDIRECTMUSICGETLOADER iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicGetLoaderImpl_AddRef (LPDIRECTMUSICGETLOADER iface);
+extern ULONG WINAPI   IDirectMusicGetLoaderImpl_Release (LPDIRECTMUSICGETLOADER iface);
+/* IDirectMusicGetLoader: */
+extern HRESULT WINAPI IDirectMusicGetLoaderImpl_GetLoader (LPDIRECTMUSICGETLOADER iface, IDirectMusicLoader** ppLoader);
+
+#endif	/* __WINE_DMLOADER_PRIVATE_H */
diff --git a/dlls/dmloader/getloader.c b/dlls/dmloader/getloader.c
new file mode 100644
index 0000000..5f34a23
--- /dev/null
+++ b/dlls/dmloader/getloader.c
@@ -0,0 +1,96 @@
+/* IDirectMusicGetLoader Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
+#include "dmloader_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicGetLoader IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicGetLoaderImpl_QueryInterface (LPDIRECTMUSICGETLOADER iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicGetLoaderImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || 
+	    IsEqualGUID(riid, &IID_IDirectMusicGetLoader))
+	{
+		IDirectMusicGetLoaderImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicGetLoaderImpl_AddRef (LPDIRECTMUSICGETLOADER iface)
+{
+	ICOM_THIS(IDirectMusicGetLoaderImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicGetLoaderImpl_Release (LPDIRECTMUSICGETLOADER iface)
+{
+	ICOM_THIS(IDirectMusicGetLoaderImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicGetLoader Interface follow: */
+HRESULT WINAPI IDirectMusicGetLoaderImpl_GetLoader (LPDIRECTMUSICGETLOADER iface, IDirectMusicLoader** ppLoader)
+{
+	ICOM_THIS(IDirectMusicGetLoaderImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, ppLoader);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicGetLoader) DirectMusicGetLoader_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicGetLoaderImpl_QueryInterface,
+	IDirectMusicGetLoaderImpl_AddRef,
+	IDirectMusicGetLoaderImpl_Release,
+	IDirectMusicGetLoaderImpl_GetLoader
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicGetLoader (LPCGUID lpcGUID, LPDIRECTMUSICGETLOADER *ppDMGetLoad, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicGetLoader))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmusic/dmusic_loader.c b/dlls/dmloader/loader.c
similarity index 69%
rename from dlls/dmusic/dmusic_loader.c
rename to dlls/dmloader/loader.c
index c2e6cf0..7132b03 100644
--- a/dlls/dmusic/dmusic_loader.c
+++ b/dlls/dmloader/loader.c
@@ -1,6 +1,4 @@
-/* IDirectMusicLoader Implementation
- * IDirectMusicLoader8 Implementation
- * IDirectMusicGetLoader Implementation
+/* IDirectMusicLoader8 Implementation
  *
  * Copyright (C) 2003 Rok Mandeljc
  *
@@ -26,7 +24,7 @@
 #include "wine/debug.h"
 #include "wine/unicode.h"
 
-#include "dmusic_private.h"
+#include "dmloader_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
 
@@ -74,10 +72,8 @@
 	FIXME("(%p, %p, %s, %p): stub\n", This, pDesc, debugstr_guid(riid), ppv);
 
 	if (IsEqualGUID(riid, &IID_IDirectMusicScript)) {
-	  IDirectMusicScriptImpl* script;
-	  script = (IDirectMusicScriptImpl*) HeapAlloc(GetProcessHeap(), 0, sizeof(IDirectMusicScriptImpl));
-	  script->lpVtbl = &DirectMusicScript_Vtbl;
-	  script->ref = 1;
+	  IDirectMusicScript* script;
+	  CoCreateInstance (&CLSID_DirectMusicScript, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicScript, (void**)&script);
 	  *ppv = script;
 	}
 
@@ -99,10 +95,10 @@
 
 	FIXME("(%p, %s, %p, %d): to check\n", This, debugstr_guid(rguidClass), pwzPath, fClear);
 
-        if (0 == strncmpW(This->searchPath, pwzPath, MAX_PATH)) {
+        if (0 == strncmpW(This->wzSearchPath, pwzPath, MAX_PATH)) {
 	  return S_FALSE;
 	} 
-	strncpyW(This->searchPath, pwzPath, MAX_PATH);
+	strncpyW(This->wzSearchPath, pwzPath, MAX_PATH);
 	return DS_OK;
 }
 
@@ -183,36 +179,24 @@
 							   WCHAR* pwzFilePath, 
 							   void** ppObject)
 {
-	HANDLE fd;
-
 	ICOM_THIS(IDirectMusicLoader8Impl,iface);
 
 	FIXME("(%p, %s, %s, %s, %p): stub\n", This, debugstr_guid(rguidClassID), debugstr_guid(iidInterfaceID), debugstr_w(pwzFilePath), ppObject);
 	
-	fd = CreateFileW (pwzFilePath, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
-	if (!fd) {
-		WARN ("could not load file\n");
-		return DMUS_E_LOADER_FAILEDOPEN;
-	}
-	
 	if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicAudioPathConfig)) {
 		FIXME("wanted 'aud'\n");
 	} else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicBand)) {
 		FIXME("wanted 'bnd'\n");
-		DMUSIC_FillBandFromFileHandle (NULL, fd);
 	} else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicContainer)) {
 		FIXME("wanted 'con'\n");
-		DMUSIC_FillContainerFromFileHandle (NULL, fd);		
 	} else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicCollection)) {
 		FIXME("wanted 'dls'\n");
 	} else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicChordMap)) {
 		FIXME("wanted 'cdm'\n");
 	} else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicSegment)) {
 		FIXME("wanted 'sgt'\n");
-		DMUSIC_FillSegmentFromFileHandle (NULL, fd);
 	} else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicScript)) {
 		FIXME("wanted 'spt'\n");
-		DMUSIC_FillScriptFromFileHandle (NULL, fd);
 	} else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicSong)) {
 		FIXME("wanted 'sng'\n");
 	} else if (IsEqualGUID(rguidClassID, &CLSID_DirectMusicStyle)) {
@@ -225,28 +209,20 @@
 		FIXME("wanted 'wav'\n");
 	}
 
-	CloseHandle (fd);
-	
 	if (IsEqualGUID(iidInterfaceID, &IID_IDirectMusicSegment) || 
 	    IsEqualGUID(iidInterfaceID, &IID_IDirectMusicSegment8)) {
-	  IDirectMusicSegment8Impl* segment;
-	  segment = (IDirectMusicSegment8Impl*) HeapAlloc(GetProcessHeap(), 0, sizeof(IDirectMusicSegment8Impl));
-	  segment->lpVtbl = &DirectMusicSegment8_Vtbl;
-	  segment->ref = 1;
+	  IDirectMusicSegment8* segment;
+	  CoCreateInstance (&CLSID_DirectMusicSegment, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSegment8, (void**)&segment);
 	  *ppObject = segment;
 	  return S_OK;
 	} else if (IsEqualGUID(iidInterfaceID, &IID_IDirectMusicContainer)) {
-	  IDirectMusicContainerImpl* container;
-	  container = HeapAlloc(GetProcessHeap(), 0, sizeof(IDirectMusicContainerImpl));
-	  container->lpVtbl = &DirectMusicContainer_Vtbl;
-	  container->ref = 1;
+	  IDirectMusicContainer* container;
+	  CoCreateInstance (&CLSID_DirectMusicContainer, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicContainer, (void**)&container);
 	  *ppObject = container;
 	  return S_OK;
 	} else if (IsEqualGUID(iidInterfaceID, &IID_IDirectMusicScript)) {
-	  IDirectMusicScriptImpl* script;
-	  script = HeapAlloc(GetProcessHeap(), 0, sizeof(IDirectMusicScriptImpl));
-	  script->lpVtbl = &DirectMusicScript_Vtbl;
-	  script->ref = 1;
+	  IDirectMusicScript* script;
+	  CoCreateInstance (&CLSID_DirectMusicScript, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicScript, (void**)&script);
 	  *ppObject = script;
 	  return S_OK;		
 	} else {
@@ -277,80 +253,26 @@
 	IDirectMusicLoader8Impl_LoadObjectFromFile
 };
 
-HRESULT WINAPI DMUSIC_CreateDirectMusicLoader8 (LPCGUID lpcGUID, LPDIRECTMUSICLOADER8 *ppDMLoad8, LPUNKNOWN pUnkOuter)
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicLoader (LPCGUID lpcGUID, LPDIRECTMUSICLOADER8 *ppDMLoad, LPUNKNOWN pUnkOuter)
 {
-	IDirectMusicLoader8Impl *dmloader8;
+	IDirectMusicLoader8Impl *dmloader;
 
-	TRACE("(%p,%p,%p)\n",lpcGUID, ppDMLoad8, pUnkOuter);
+	TRACE("(%p,%p,%p)\n",lpcGUID, ppDMLoad, pUnkOuter);
 	if (IsEqualGUID(lpcGUID, &IID_IDirectMusicLoader) || 
 	    IsEqualGUID(lpcGUID, &IID_IDirectMusicLoader8))
 	{
-		dmloader8 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicLoader8Impl));
-		if (NULL == dmloader8) {
-			*ppDMLoad8 = (LPDIRECTMUSICLOADER8)NULL;
+		dmloader = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicLoader8Impl));
+		if (NULL == dmloader) {
+			*ppDMLoad = (LPDIRECTMUSICLOADER8)NULL;
 			return E_OUTOFMEMORY;
 		}
-		dmloader8->lpVtbl = &DirectMusicLoader8_Vtbl;
-		dmloader8->ref = 1;
-		*ppDMLoad8 = (LPDIRECTMUSICLOADER8)dmloader8;
+		dmloader->lpVtbl = &DirectMusicLoader8_Vtbl;
+		dmloader->ref = 1;
+		*ppDMLoad = (LPDIRECTMUSICLOADER8)dmloader;
 		return S_OK;
 	}
 	WARN("No interface found\n");
 	
 	return E_NOINTERFACE;
 }
-
-
-/* IDirectMusicGetLoader IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicGetLoaderImpl_QueryInterface (LPDIRECTMUSICGETLOADER iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicGetLoaderImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || 
-	    IsEqualGUID(riid, &IID_IDirectMusicGetLoader))
-	{
-		IDirectMusicGetLoaderImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicGetLoaderImpl_AddRef (LPDIRECTMUSICGETLOADER iface)
-{
-	ICOM_THIS(IDirectMusicGetLoaderImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicGetLoaderImpl_Release (LPDIRECTMUSICGETLOADER iface)
-{
-	ICOM_THIS(IDirectMusicGetLoaderImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicGetLoader Interface follow: */
-HRESULT WINAPI IDirectMusicGetLoaderImpl_GetLoader (LPDIRECTMUSICGETLOADER iface, IDirectMusicLoader** ppLoader)
-{
-	ICOM_THIS(IDirectMusicGetLoaderImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, ppLoader);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicGetLoader) DirectMusicGetLoader_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicGetLoaderImpl_QueryInterface,
-	IDirectMusicGetLoaderImpl_AddRef,
-	IDirectMusicGetLoaderImpl_Release,
-	IDirectMusicGetLoaderImpl_GetLoader
-};
diff --git a/dlls/dmloader/regsvr.c b/dlls/dmloader/regsvr.c
new file mode 100644
index 0000000..c323d90
--- /dev/null
+++ b/dlls/dmloader/regsvr.c
@@ -0,0 +1,560 @@
+/*
+ *	self-registerable dll functions for dmloader.dll
+ *
+ * Copyright (C) 2003 John K. Hohm
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <string.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "winreg.h"
+#include "winerror.h"
+
+#include "dmusics.h"
+#include "dmusici.h"
+#include "dmplugin.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/*
+ * Near the bottom of this file are the exported DllRegisterServer and
+ * DllUnregisterServer, which make all this worthwhile.
+ */
+
+/***********************************************************************
+ *		interface for self-registering
+ */
+struct regsvr_interface
+{
+    IID const *iid;		/* NULL for end of list */
+    LPCSTR name;		/* can be NULL to omit */
+    IID const *base_iid;	/* can be NULL to omit */
+    int num_methods;		/* can be <0 to omit */
+    CLSID const *ps_clsid;	/* can be NULL to omit */
+    CLSID const *ps_clsid32;	/* can be NULL to omit */
+};
+
+static HRESULT register_interfaces(struct regsvr_interface const *list);
+static HRESULT unregister_interfaces(struct regsvr_interface const *list);
+
+struct regsvr_coclass
+{
+    CLSID const *clsid;		/* NULL for end of list */
+    LPCSTR name;		/* can be NULL to omit */
+    LPCSTR ips;			/* can be NULL to omit */
+    LPCSTR ips32;		/* can be NULL to omit */
+    LPCSTR ips32_tmodel;	/* can be NULL to omit */
+    LPCSTR progid;		/* can be NULL to omit */
+    LPCSTR viprogid;		/* can be NULL to omit */
+    LPCSTR progid_extra;	/* can be NULL to omit */
+};
+
+static HRESULT register_coclasses(struct regsvr_coclass const *list);
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
+
+/***********************************************************************
+ *		static string constants
+ */
+static WCHAR const interface_keyname[10] = {
+    'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
+static WCHAR const base_ifa_keyname[14] = {
+    'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
+    'e', 0 };
+static WCHAR const num_methods_keyname[11] = {
+    'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
+static WCHAR const ps_clsid_keyname[15] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', 0 };
+static WCHAR const ps_clsid32_keyname[17] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', '3', '2', 0 };
+static WCHAR const clsid_keyname[6] = {
+    'C', 'L', 'S', 'I', 'D', 0 };
+static WCHAR const curver_keyname[7] = {
+    'C', 'u', 'r', 'V', 'e', 'r', 0 };
+static WCHAR const ips_keyname[13] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    0 };
+static WCHAR const ips32_keyname[15] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    '3', '2', 0 };
+static WCHAR const progid_keyname[7] = {
+    'P', 'r', 'o', 'g', 'I', 'D', 0 };
+static WCHAR const viprogid_keyname[25] = {
+    'V', 'e', 'r', 's', 'i', 'o', 'n', 'I', 'n', 'd', 'e', 'p',
+    'e', 'n', 'd', 'e', 'n', 't', 'P', 'r', 'o', 'g', 'I', 'D',
+    0 };
+static char const tmodel_valuename[] = "ThreadingModel";
+
+/***********************************************************************
+ *		static helper functions
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
+static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
+				   WCHAR const *value);
+static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
+				   char const *value);
+static LONG register_progid(WCHAR const *clsid,
+			    char const *progid, char const *curver_progid,
+			    char const *name, char const *extra);
+static LONG recursive_delete_key(HKEY key);
+static LONG recursive_delete_keyA(HKEY base, char const *name);
+static LONG recursive_delete_keyW(HKEY base, WCHAR const *name);
+
+/***********************************************************************
+ *		register_interfaces
+ */
+static HRESULT register_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+	WCHAR buf[39];
+	HKEY iid_key;
+
+	StringFromGUID2(list->iid, buf, 39);
+	res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
+			      KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
+	if (res != ERROR_SUCCESS) goto error_close_interface_key;
+
+	if (list->name) {
+	    res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)(list->name),
+				 strlen(list->name) + 1);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->base_iid) {
+	    register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (0 <= list->num_methods) {
+	    static WCHAR const fmt[3] = { '%', 'd', 0 };
+	    HKEY key;
+
+	    res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
+				  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+
+	    wsprintfW(buf, fmt, list->num_methods);
+	    res = RegSetValueExW(key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)buf,
+				 (lstrlenW(buf) + 1) * sizeof(WCHAR));
+	    RegCloseKey(key);
+
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->ps_clsid) {
+	    register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->ps_clsid32) {
+	    register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+    error_close_iid_key:
+	RegCloseKey(iid_key);
+    }
+
+error_close_interface_key:
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		unregister_interfaces
+ */
+static HRESULT unregister_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
+			KEY_READ | KEY_WRITE, &interface_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+	WCHAR buf[39];
+
+	StringFromGUID2(list->iid, buf, 39);
+	res = recursive_delete_keyW(interface_key, buf);
+    }
+
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		register_coclasses
+ */
+static HRESULT register_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+	WCHAR buf[39];
+	HKEY clsid_key;
+
+	StringFromGUID2(list->clsid, buf, 39);
+	res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
+			      KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
+	if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+	if (list->name) {
+	    res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)(list->name),
+				 strlen(list->name) + 1);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->ips) {
+	    res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->ips32) {
+	    HKEY ips32_key;
+
+	    res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
+				  KEY_READ | KEY_WRITE, NULL,
+				  &ips32_key, NULL);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)list->ips32,
+				 lstrlenA(list->ips32) + 1);
+	    if (res == ERROR_SUCCESS && list->ips32_tmodel)
+		res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
+				     (CONST BYTE*)list->ips32_tmodel,
+				     strlen(list->ips32_tmodel) + 1);
+	    RegCloseKey(ips32_key);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->progid) {
+	    res = register_key_defvalueA(clsid_key, progid_keyname,
+					 list->progid);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = register_progid(buf, list->progid, NULL,
+				  list->name, list->progid_extra);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->viprogid) {
+	    res = register_key_defvalueA(clsid_key, viprogid_keyname,
+					 list->viprogid);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = register_progid(buf, list->viprogid, list->progid,
+				  list->name, list->progid_extra);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+    error_close_clsid_key:
+	RegCloseKey(clsid_key);
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		unregister_coclasses
+ */
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
+			KEY_READ | KEY_WRITE, &coclass_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+	WCHAR buf[39];
+
+	StringFromGUID2(list->clsid, buf, 39);
+	res = recursive_delete_keyW(coclass_key, buf);
+	if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+	if (list->progid) {
+	    res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->progid);
+	    if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+	}
+
+	if (list->viprogid) {
+	    res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->viprogid);
+	    if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+	}
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		regsvr_key_guid
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
+{
+    WCHAR buf[39];
+
+    StringFromGUID2(guid, buf, 39);
+    return register_key_defvalueW(base, name, buf);
+}
+
+/***********************************************************************
+ *		regsvr_key_defvalueW
+ */
+static LONG register_key_defvalueW(
+    HKEY base,
+    WCHAR const *name,
+    WCHAR const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+			 (lstrlenW(value) + 1) * sizeof(WCHAR));
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		regsvr_key_defvalueA
+ */
+static LONG register_key_defvalueA(
+    HKEY base,
+    WCHAR const *name,
+    char const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+			 lstrlenA(value) + 1);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		regsvr_progid
+ */
+static LONG register_progid(
+    WCHAR const *clsid,
+    char const *progid,
+    char const *curver_progid,
+    char const *name,
+    char const *extra)
+{
+    LONG res;
+    HKEY progid_key;
+
+    res = RegCreateKeyExA(HKEY_CLASSES_ROOT, progid, 0,
+			  NULL, 0, KEY_READ | KEY_WRITE, NULL,
+			  &progid_key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+
+    if (name) {
+	res = RegSetValueExA(progid_key, NULL, 0, REG_SZ,
+			     (CONST BYTE*)name, strlen(name) + 1);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (clsid) {
+	res = register_key_defvalueW(progid_key, clsid_keyname, clsid);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (curver_progid) {
+	res = register_key_defvalueA(progid_key, curver_keyname,
+				     curver_progid);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (extra) {
+	HKEY extra_key;
+
+	res = RegCreateKeyExA(progid_key, extra, 0,
+			      NULL, 0, KEY_READ | KEY_WRITE, NULL,
+			      &extra_key, NULL);
+	if (res == ERROR_SUCCESS)
+	    RegCloseKey(extra_key);
+    }
+
+error_close_progid_key:
+    RegCloseKey(progid_key);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_key
+ */
+static LONG recursive_delete_key(HKEY key)
+{
+    LONG res;
+    WCHAR subkey_name[MAX_PATH];
+    DWORD cName;
+    HKEY subkey;
+
+    for (;;) {
+	cName = sizeof(subkey_name) / sizeof(WCHAR);
+	res = RegEnumKeyExW(key, 0, subkey_name, &cName,
+			    NULL, NULL, NULL, NULL);
+	if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) {
+	    res = ERROR_SUCCESS; /* presumably we're done enumerating */
+	    break;
+	}
+	res = RegOpenKeyExW(key, subkey_name, 0,
+			    KEY_READ | KEY_WRITE, &subkey);
+	if (res == ERROR_FILE_NOT_FOUND) continue;
+	if (res != ERROR_SUCCESS) break;
+
+	res = recursive_delete_key(subkey);
+	RegCloseKey(subkey);
+	if (res != ERROR_SUCCESS) break;
+    }
+
+    if (res == ERROR_SUCCESS) res = RegDeleteKeyW(key, 0);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_keyA
+ */
+static LONG recursive_delete_keyA(HKEY base, char const *name)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegOpenKeyExA(base, name, 0, KEY_READ | KEY_WRITE, &key);
+    if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
+    if (res != ERROR_SUCCESS) return res;
+    res = recursive_delete_key(key);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_keyW
+ */
+static LONG recursive_delete_keyW(HKEY base, WCHAR const *name)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegOpenKeyExW(base, name, 0, KEY_READ | KEY_WRITE, &key);
+    if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
+    if (res != ERROR_SUCCESS) return res;
+    res = recursive_delete_key(key);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		coclass list
+ */
+static struct regsvr_coclass const coclass_list[] = {
+    {   &CLSID_DirectMusicLoader,
+        "DirectMusicLoader",
+	NULL,
+	"dmloader.dll",
+	"Both",
+	"Microsoft.DirectMusicLoader.1",
+	"Microsoft.DirectMusicLoader"
+    },
+    {   &CLSID_DirectMusicContainer,
+        "DirectMusicContainer",
+	NULL,
+	"dmloader.dll",
+	"Both",
+	"Microsoft.DirectMusicContainer.1",
+	"Microsoft.DirectMusicContainer"
+    },
+    { NULL }			/* list terminator */
+};
+
+/***********************************************************************
+ *		interface list
+ */
+
+static struct regsvr_interface const interface_list[] = {
+    { NULL }			/* list terminator */
+};
+
+/***********************************************************************
+ *		DllRegisterServer (DMLOADER.3)
+ */
+HRESULT WINAPI DMLOADER_DllRegisterServer(void)
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = register_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+	hr = register_interfaces(interface_list);
+    return hr;
+}
+
+/***********************************************************************
+ *		DllUnregisterServer (DMLOADER.4)
+ */
+HRESULT WINAPI DMLOADER_DllUnregisterServer(void)
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = unregister_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+	hr = unregister_interfaces(interface_list);
+    return hr;
+}
diff --git a/dlls/dmscript/Makefile.in b/dlls/dmscript/Makefile.in
index c8e8fd0..d78e831 100644
--- a/dlls/dmscript/Makefile.in
+++ b/dlls/dmscript/Makefile.in
@@ -3,13 +3,16 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = dmscript.dll
-IMPORTS   = dmusic kernel32
+IMPORTS   = ole32 user32 advapi32 kernel32
+EXTRALIBS = $(LIBUUID)
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
 
 C_SRCS = \
-	dmscript_main.c
+	dmscript_main.c \
+	regsvr.c \
+	script.c
 
 RC_SRCS = version.rc
 
diff --git a/dlls/dmscript/dmscript.spec b/dlls/dmscript/dmscript.spec
index 3d091d1..8c4bda5 100644
--- a/dlls/dmscript/dmscript.spec
+++ b/dlls/dmscript/dmscript.spec
@@ -1,6 +1,4 @@
-# Linked to main dmusic.dll for easier implementation
-
-1 stdcall DllCanUnloadNow() dmusic.DllCanUnloadNow
-2 stdcall DllGetClassObject(long long ptr) dmusic.DllGetClassObject
-3 stdcall DllRegisterServer() dmusic.DllRegisterServer
-4 stdcall DllUnregisterServer() dmusic.DllUnregisterServer
+1 stdcall DllCanUnloadNow() DMSCRIPT_DllCanUnloadNow
+2 stdcall DllGetClassObject(long long ptr) DMSCRIPT_DllGetClassObject
+3 stdcall DllRegisterServer() DMSCRIPT_DllRegisterServer
+4 stdcall DllUnregisterServer() DMSCRIPT_DllUnregisterServer
diff --git a/dlls/dmscript/dmscript_main.c b/dlls/dmscript/dmscript_main.c
index 67a01ed..4fe2f99 100644
--- a/dlls/dmscript/dmscript_main.c
+++ b/dlls/dmscript/dmscript_main.c
@@ -1 +1,138 @@
-/* nothing here yet */
+/* DirectMusicScript Main
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "dmscript_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+
+/******************************************************************
+ *		DirectMusicScript ClassFactory
+ *
+ *
+ */
+ 
+typedef struct
+{
+    /* IUnknown fields */
+    ICOM_VFIELD(IClassFactory);
+    DWORD                       ref;
+} IClassFactoryImpl;
+
+static HRESULT WINAPI DMSCRCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+
+	FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+static ULONG WINAPI DMSCRCF_AddRef(LPCLASSFACTORY iface)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	return ++(This->ref);
+}
+
+static ULONG WINAPI DMSCRCF_Release(LPCLASSFACTORY iface)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	/* static class, won't be  freed */
+	return --(This->ref);
+}
+
+static HRESULT WINAPI DMSCRCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+
+	TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
+	if (IsEqualGUID (riid, &IID_IDirectMusicScript)) {
+		return DMUSIC_CreateDirectMusicScript (riid, (LPDIRECTMUSICSCRIPT*)ppobj, pOuter);
+	}
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+static HRESULT WINAPI DMSCRCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	FIXME("(%p)->(%d),stub!\n", This, dolock);
+	return S_OK;
+}
+
+static ICOM_VTABLE(IClassFactory) DMSCRCF_Vtbl = {
+	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	DMSCRCF_QueryInterface,
+	DMSCRCF_AddRef,
+	DMSCRCF_Release,
+	DMSCRCF_CreateInstance,
+	DMSCRCF_LockServer
+};
+
+static IClassFactoryImpl DMSCRIPT_CF = {&DMSCRCF_Vtbl, 1 };
+
+/******************************************************************
+ *		DllMain
+ *
+ *
+ */
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+	if (fdwReason == DLL_PROCESS_ATTACH)
+	{
+            DisableThreadLibraryCalls(hinstDLL);
+		/* FIXME: Initialisation */
+	}
+	else if (fdwReason == DLL_PROCESS_DETACH)
+	{
+		/* FIXME: Cleanup */
+	}
+
+	return TRUE;
+}
+
+
+/******************************************************************
+ *		DllCanUnloadNow (DMSCRIPT.1)
+ *
+ *
+ */
+HRESULT WINAPI DMSCRIPT_DllCanUnloadNow(void)
+{
+    FIXME("(void): stub\n");
+
+    return S_FALSE;
+}
+
+
+/******************************************************************
+ *		DllGetClassObject (DMSCRIPT.2)
+ *
+ *
+ */
+HRESULT WINAPI DMSCRIPT_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
+{
+    TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    if (IsEqualCLSID (&IID_IClassFactory, riid)) {
+      *ppv = (LPVOID) &DMSCRIPT_CF;
+      IClassFactory_AddRef((IClassFactory*)*ppv);
+      return S_OK;
+    }
+    WARN("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    return CLASS_E_CLASSNOTAVAILABLE;
+}
diff --git a/dlls/dmscript/dmscript_private.h b/dlls/dmscript/dmscript_private.h
new file mode 100644
index 0000000..6380edb
--- /dev/null
+++ b/dlls/dmscript/dmscript_private.h
@@ -0,0 +1,80 @@
+/* DirectMusicScript Private Include
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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.
+ */
+
+#ifndef __WINE_DMSCRIPT_PRIVATE_H
+#define __WINE_DMSCRIPT_PRIVATE_H
+
+#include "windef.h"
+#include "wine/debug.h"
+#include "winbase.h"
+#include "winnt.h"
+#include "dmusicc.h"
+#include "dmusici.h"
+#include "dmusics.h"
+#include "dmplugin.h"
+#include "dmusicf.h"
+#include "dsound.h"
+
+/*****************************************************************************
+ * Interfaces
+ */
+typedef struct IDirectMusicScriptImpl IDirectMusicScriptImpl;
+
+/*****************************************************************************
+ * Predeclare the interface implementation structures
+ */
+extern ICOM_VTABLE(IDirectMusicScript) DirectMusicScript_Vtbl;
+
+/*****************************************************************************
+ * ClassFactory
+ *
+ * can support IID_IDirectMusicScript
+ * return always an IDirectMusicScriptImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicScript (LPCGUID lpcGUID, LPDIRECTMUSICSCRIPT* ppDMScript, LPUNKNOWN pUnkOuter);
+
+/*****************************************************************************
+ * IDirectMusicScriptImpl implementation structure
+ */
+struct IDirectMusicScriptImpl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicScript);
+  DWORD          ref;
+
+  /* IDirectMusicScriptImpl fields */
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicScriptImpl_QueryInterface (LPDIRECTMUSICSCRIPT iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicScriptImpl_AddRef (LPDIRECTMUSICSCRIPT iface);
+extern ULONG WINAPI   IDirectMusicScriptImpl_Release (LPDIRECTMUSICSCRIPT iface);
+/* IDirectMusicScript: */
+extern HRESULT WINAPI IDirectMusicScriptImpl_Init (LPDIRECTMUSICSCRIPT iface, IDirectMusicPerformance* pPerformance, DMUS_SCRIPT_ERRORINFO* pErrorInfo);
+extern HRESULT WINAPI IDirectMusicScriptImpl_CallRoutine (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszRoutineName, DMUS_SCRIPT_ERRORINFO* pErrorInfo);
+extern HRESULT WINAPI IDirectMusicScriptImpl_SetVariableVariant (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, VARIANT varValue, BOOL fSetRef, DMUS_SCRIPT_ERRORINFO* pErrorInfo);
+extern HRESULT WINAPI IDirectMusicScriptImpl_GetVariableVariant (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, VARIANT* pvarValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo);
+extern HRESULT WINAPI IDirectMusicScriptImpl_SetVariableNumber (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, LONG lValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo);
+extern HRESULT WINAPI IDirectMusicScriptImpl_GetVariableNumber (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, LONG* plValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo);
+extern HRESULT WINAPI IDirectMusicScriptImpl_SetVariableObject (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, IUnknown* punkValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo);
+extern HRESULT WINAPI IDirectMusicScriptImpl_GetVariableObject (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, REFIID riid, LPVOID* ppv, DMUS_SCRIPT_ERRORINFO* pErrorInfo);
+extern HRESULT WINAPI IDirectMusicScriptImpl_EnumRoutine (LPDIRECTMUSICSCRIPT iface, DWORD dwIndex, WCHAR* pwszName);
+extern HRESULT WINAPI IDirectMusicScriptImpl_EnumVariable (LPDIRECTMUSICSCRIPT iface, DWORD dwIndex, WCHAR* pwszName);
+
+#endif	/* __WINE_DMSCRIPT_PRIVATE_H */
diff --git a/dlls/dmscript/regsvr.c b/dlls/dmscript/regsvr.c
new file mode 100644
index 0000000..db9b597
--- /dev/null
+++ b/dlls/dmscript/regsvr.c
@@ -0,0 +1,625 @@
+/*
+ *	self-registerable dll functions for dmscript.dll
+ *
+ * Copyright (C) 2003 John K. Hohm
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "winreg.h"
+#include "winerror.h"
+
+#include "dmusics.h"
+#include "dmusici.h"
+#include "dmplugin.h"
+
+#include <string.h>
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/*
+ * Near the bottom of this file are the exported DllRegisterServer and
+ * DllUnregisterServer, which make all this worthwhile.
+ */
+
+/***********************************************************************
+ *		interface for self-registering
+ */
+struct regsvr_interface
+{
+    IID const *iid;		/* NULL for end of list */
+    LPCSTR name;		/* can be NULL to omit */
+    IID const *base_iid;	/* can be NULL to omit */
+    int num_methods;		/* can be <0 to omit */
+    CLSID const *ps_clsid;	/* can be NULL to omit */
+    CLSID const *ps_clsid32;	/* can be NULL to omit */
+};
+
+static HRESULT register_interfaces(struct regsvr_interface const *list);
+static HRESULT unregister_interfaces(struct regsvr_interface const *list);
+
+struct regsvr_coclass
+{
+    CLSID const *clsid;		/* NULL for end of list */
+    LPCSTR name;		/* can be NULL to omit */
+    LPCSTR ips;			/* can be NULL to omit */
+    LPCSTR ips32;		/* can be NULL to omit */
+    LPCSTR ips32_tmodel;	/* can be NULL to omit */
+    LPCSTR progid;		/* can be NULL to omit */
+    LPCSTR viprogid;		/* can be NULL to omit */
+    LPCSTR progid_extra;	/* can be NULL to omit */
+};
+
+static HRESULT register_coclasses(struct regsvr_coclass const *list);
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
+
+/***********************************************************************
+ *		static string constants
+ */
+static WCHAR const interface_keyname[10] = {
+    'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
+static WCHAR const base_ifa_keyname[14] = {
+    'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
+    'e', 0 };
+static WCHAR const num_methods_keyname[11] = {
+    'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
+static WCHAR const ps_clsid_keyname[15] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', 0 };
+static WCHAR const ps_clsid32_keyname[17] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', '3', '2', 0 };
+static WCHAR const clsid_keyname[6] = {
+    'C', 'L', 'S', 'I', 'D', 0 };
+static WCHAR const curver_keyname[7] = {
+    'C', 'u', 'r', 'V', 'e', 'r', 0 };
+static WCHAR const ips_keyname[13] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    0 };
+static WCHAR const ips32_keyname[15] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    '3', '2', 0 };
+static WCHAR const progid_keyname[7] = {
+    'P', 'r', 'o', 'g', 'I', 'D', 0 };
+static WCHAR const viprogid_keyname[25] = {
+    'V', 'e', 'r', 's', 'i', 'o', 'n', 'I', 'n', 'd', 'e', 'p',
+    'e', 'n', 'd', 'e', 'n', 't', 'P', 'r', 'o', 'g', 'I', 'D',
+    0 };
+static char const tmodel_valuename[] = "ThreadingModel";
+
+/***********************************************************************
+ *		static helper functions
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
+static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
+				   WCHAR const *value);
+static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
+				   char const *value);
+static LONG register_progid(WCHAR const *clsid,
+			    char const *progid, char const *curver_progid,
+			    char const *name, char const *extra);
+static LONG recursive_delete_key(HKEY key);
+static LONG recursive_delete_keyA(HKEY base, char const *name);
+static LONG recursive_delete_keyW(HKEY base, WCHAR const *name);
+
+/***********************************************************************
+ *		register_interfaces
+ */
+static HRESULT register_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+	WCHAR buf[39];
+	HKEY iid_key;
+
+	StringFromGUID2(list->iid, buf, 39);
+	res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
+			      KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
+	if (res != ERROR_SUCCESS) goto error_close_interface_key;
+
+	if (list->name) {
+	    res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)(list->name),
+				 strlen(list->name) + 1);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->base_iid) {
+	    register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (0 <= list->num_methods) {
+	    static WCHAR const fmt[3] = { '%', 'd', 0 };
+	    HKEY key;
+
+	    res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
+				  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+
+	    wsprintfW(buf, fmt, list->num_methods);
+	    res = RegSetValueExW(key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)buf,
+				 (lstrlenW(buf) + 1) * sizeof(WCHAR));
+	    RegCloseKey(key);
+
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->ps_clsid) {
+	    register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->ps_clsid32) {
+	    register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+    error_close_iid_key:
+	RegCloseKey(iid_key);
+    }
+
+error_close_interface_key:
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		unregister_interfaces
+ */
+static HRESULT unregister_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
+			KEY_READ | KEY_WRITE, &interface_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+	WCHAR buf[39];
+
+	StringFromGUID2(list->iid, buf, 39);
+	res = recursive_delete_keyW(interface_key, buf);
+    }
+
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		register_coclasses
+ */
+static HRESULT register_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+	WCHAR buf[39];
+	HKEY clsid_key;
+
+	StringFromGUID2(list->clsid, buf, 39);
+	res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
+			      KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
+	if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+	if (list->name) {
+	    res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)(list->name),
+				 strlen(list->name) + 1);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->ips) {
+	    res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->ips32) {
+	    HKEY ips32_key;
+
+	    res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
+				  KEY_READ | KEY_WRITE, NULL,
+				  &ips32_key, NULL);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)list->ips32,
+				 lstrlenA(list->ips32) + 1);
+	    if (res == ERROR_SUCCESS && list->ips32_tmodel)
+		res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
+				     (CONST BYTE*)list->ips32_tmodel,
+				     strlen(list->ips32_tmodel) + 1);
+	    RegCloseKey(ips32_key);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->progid) {
+	    res = register_key_defvalueA(clsid_key, progid_keyname,
+					 list->progid);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = register_progid(buf, list->progid, NULL,
+				  list->name, list->progid_extra);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->viprogid) {
+	    res = register_key_defvalueA(clsid_key, viprogid_keyname,
+					 list->viprogid);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = register_progid(buf, list->viprogid, list->progid,
+				  list->name, list->progid_extra);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+    error_close_clsid_key:
+	RegCloseKey(clsid_key);
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		unregister_coclasses
+ */
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
+			KEY_READ | KEY_WRITE, &coclass_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+	WCHAR buf[39];
+
+	StringFromGUID2(list->clsid, buf, 39);
+	res = recursive_delete_keyW(coclass_key, buf);
+	if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+	if (list->progid) {
+	    res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->progid);
+	    if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+	}
+
+	if (list->viprogid) {
+	    res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->viprogid);
+	    if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+	}
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		regsvr_key_guid
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
+{
+    WCHAR buf[39];
+
+    StringFromGUID2(guid, buf, 39);
+    return register_key_defvalueW(base, name, buf);
+}
+
+/***********************************************************************
+ *		regsvr_key_defvalueW
+ */
+static LONG register_key_defvalueW(
+    HKEY base,
+    WCHAR const *name,
+    WCHAR const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+			 (lstrlenW(value) + 1) * sizeof(WCHAR));
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		regsvr_key_defvalueA
+ */
+static LONG register_key_defvalueA(
+    HKEY base,
+    WCHAR const *name,
+    char const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+			 lstrlenA(value) + 1);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		regsvr_progid
+ */
+static LONG register_progid(
+    WCHAR const *clsid,
+    char const *progid,
+    char const *curver_progid,
+    char const *name,
+    char const *extra)
+{
+    LONG res;
+    HKEY progid_key;
+
+    res = RegCreateKeyExA(HKEY_CLASSES_ROOT, progid, 0,
+			  NULL, 0, KEY_READ | KEY_WRITE, NULL,
+			  &progid_key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+
+    if (name) {
+	res = RegSetValueExA(progid_key, NULL, 0, REG_SZ,
+			     (CONST BYTE*)name, strlen(name) + 1);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (clsid) {
+	res = register_key_defvalueW(progid_key, clsid_keyname, clsid);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (curver_progid) {
+	res = register_key_defvalueA(progid_key, curver_keyname,
+				     curver_progid);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (extra) {
+	HKEY extra_key;
+
+	res = RegCreateKeyExA(progid_key, extra, 0,
+			      NULL, 0, KEY_READ | KEY_WRITE, NULL,
+			      &extra_key, NULL);
+	if (res == ERROR_SUCCESS)
+	    RegCloseKey(extra_key);
+    }
+
+error_close_progid_key:
+    RegCloseKey(progid_key);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_key
+ */
+static LONG recursive_delete_key(HKEY key)
+{
+    LONG res;
+    WCHAR subkey_name[MAX_PATH];
+    DWORD cName;
+    HKEY subkey;
+
+    for (;;) {
+	cName = sizeof(subkey_name) / sizeof(WCHAR);
+	res = RegEnumKeyExW(key, 0, subkey_name, &cName,
+			    NULL, NULL, NULL, NULL);
+	if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) {
+	    res = ERROR_SUCCESS; /* presumably we're done enumerating */
+	    break;
+	}
+	res = RegOpenKeyExW(key, subkey_name, 0,
+			    KEY_READ | KEY_WRITE, &subkey);
+	if (res == ERROR_FILE_NOT_FOUND) continue;
+	if (res != ERROR_SUCCESS) break;
+
+	res = recursive_delete_key(subkey);
+	RegCloseKey(subkey);
+	if (res != ERROR_SUCCESS) break;
+    }
+
+    if (res == ERROR_SUCCESS) res = RegDeleteKeyW(key, 0);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_keyA
+ */
+static LONG recursive_delete_keyA(HKEY base, char const *name)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegOpenKeyExA(base, name, 0, KEY_READ | KEY_WRITE, &key);
+    if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
+    if (res != ERROR_SUCCESS) return res;
+    res = recursive_delete_key(key);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_keyW
+ */
+static LONG recursive_delete_keyW(HKEY base, WCHAR const *name)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegOpenKeyExW(base, name, 0, KEY_READ | KEY_WRITE, &key);
+    if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
+    if (res != ERROR_SUCCESS) return res;
+    res = recursive_delete_key(key);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		coclass list
+ */
+static struct regsvr_coclass const coclass_list[] = {
+    {   &CLSID_DirectMusicScriptAutoImpSegment,
+    "DirectMusic Script AutoImp Segment",
+	NULL,
+	"dmscript.dll",
+	"Both",
+	"Microsoft.DirectMusicScriptAutoImpSegment.1",
+	"Microsoft.DirectMusicScriptAutoImpSegment"
+    },
+    {   &CLSID_DirectMusicScriptTrack,
+        "DirectMusicScriptTrack",
+	NULL,
+	"dmscript.dll",
+	"Both",
+	"Microsoft.DirectMusicScriptTrack.1",
+	"Microsoft.DirectMusicScriptTrack"
+    },
+    {   &CLSID_AudioVBScript,
+	"DirectMusic Audio VB Script Language",
+	NULL,
+	"dmscript.dll",
+	"Both",
+	"AudioVBScript.1",
+	"AudioVBScript",
+	"DMScript"
+    },
+    {   &CLSID_DirectMusicScript,
+        "DirectMusic Script Object",
+	NULL,
+	"dmscript.dll",
+	"Both",
+	"Microsoft.DirectMusicScript.1",
+	"Microsoft.DirectMusicScript"
+    },
+    {   &CLSID_DirectMusicScriptAutoImpPerformance,
+    "DirectMusic Script AutoImp Performance",
+	NULL,
+	"dmscript.dll",
+	"Both",
+	"Microsoft.DirectMusicScriptAutoImpPerformance.1",
+	"Microsoft.DirectMusicScriptAutoImpPerformance"
+    },
+    {   &CLSID_DirectMusicScripSourceCodeLoader,
+        "DirectMusic Script Source Code Loader",
+	NULL,
+	"dmscript.dll",
+	"Both",
+	"Microsoft.DirectMusicScripSourceCodeLoader.1",	/* [sic] */
+	"Microsoft.DirectMusicScripSourceCodeLoader"
+    },
+    {   &CLSID_DirectMusicScriptAutoImpSegmentState,
+        "DirectMusic Script AutoImp SegmentState",
+	NULL,
+	"dmscript.dll",
+	"Both",
+	"Microsoft.DirectMusicScriptAutoImpSegmentState.1",
+	"Microsoft.DirectMusicScriptAutoImpSegmentState"
+    },
+    {   &CLSID_DirectMusicScriptAutoImpAudioPathConfig,
+        "DirectMusic Script AutoImp AudioPathConfig",
+	NULL,
+	"dmscript.dll",
+	"Both",
+	"Microsoft.DirectMusicScriptAutoImpAudioPathConfig.1",
+	"Microsoft.DirectMusicScriptAutoImpAudioPathConfig"
+    },
+    {   &CLSID_DirectMusicScriptAutoImpAudioPath,
+        "DirectMusic Script AutoImp AudioPath",
+	NULL,
+	"dmscript.dll",
+	"Both",
+	"Microsoft.DirectMusicScriptAutoImpAudioPath.1",
+	"Microsoft.DirectMusicScriptAutoImpAudioPath"
+    },
+    {   &CLSID_DirectMusicScriptAutoImpSong,
+        "DirectMusic Script AutoImp Song",
+	NULL,
+	"dmscript.dll",
+	"Both",
+	"Microsoft.DirectMusicScriptAutoImpSong.1",
+	"Microsoft.DirectMusicScriptAutoImpSong"
+    },
+    { NULL }			/* list terminator */
+};
+
+/***********************************************************************
+ *		interface list
+ */
+
+static struct regsvr_interface const interface_list[] = {
+    { NULL }			/* list terminator */
+};
+
+/***********************************************************************
+ *		DllRegisterServer (DMSCRIPT.3)
+ */
+HRESULT WINAPI DMSCRIPT_DllRegisterServer(void)
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = register_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+	hr = register_interfaces(interface_list);
+    return hr;
+}
+
+/***********************************************************************
+ *		DllUnregisterServer (DMSCRIPT.4)
+ */
+HRESULT WINAPI DMSCRIPT_DllUnregisterServer(void)
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = unregister_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+	hr = unregister_interfaces(interface_list);
+    return hr;
+}
diff --git a/dlls/dmscript/script.c b/dlls/dmscript/script.c
new file mode 100644
index 0000000..59162f8
--- /dev/null
+++ b/dlls/dmscript/script.c
@@ -0,0 +1,185 @@
+/* IDirectMusicScript
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmscript_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicScript IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicScriptImpl_QueryInterface (LPDIRECTMUSICSCRIPT iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicScriptImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || 
+	    IsEqualGUID(riid, &IID_IDirectMusicScript))
+	{
+		IDirectMusicScriptImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicScriptImpl_AddRef (LPDIRECTMUSICSCRIPT iface)
+{
+	ICOM_THIS(IDirectMusicScriptImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicScriptImpl_Release (LPDIRECTMUSICSCRIPT iface)
+{
+	ICOM_THIS(IDirectMusicScriptImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicScript Interface follow: */
+HRESULT WINAPI IDirectMusicScriptImpl_Init (LPDIRECTMUSICSCRIPT iface, IDirectMusicPerformance* pPerformance, DMUS_SCRIPT_ERRORINFO* pErrorInfo)
+{
+	ICOM_THIS(IDirectMusicScriptImpl,iface);
+
+	FIXME("(%p, %p, %p): stub\n", This, pPerformance, pErrorInfo);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicScriptImpl_CallRoutine (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszRoutineName, DMUS_SCRIPT_ERRORINFO* pErrorInfo)
+{
+	ICOM_THIS(IDirectMusicScriptImpl,iface);
+
+	FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszRoutineName), pErrorInfo);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicScriptImpl_SetVariableVariant (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, VARIANT varValue, BOOL fSetRef, DMUS_SCRIPT_ERRORINFO* pErrorInfo)
+{
+	ICOM_THIS(IDirectMusicScriptImpl,iface);
+
+	FIXME("(%p, %p, FIXME, %d, %p): stub\n", This, pwszVariableName,/* varValue,*/ fSetRef, pErrorInfo);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicScriptImpl_GetVariableVariant (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, VARIANT* pvarValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo)
+{
+	ICOM_THIS(IDirectMusicScriptImpl,iface);
+
+	FIXME("(%p, %p, %p, %p): stub\n", This, pwszVariableName, pvarValue, pErrorInfo);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicScriptImpl_SetVariableNumber (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, LONG lValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo)
+{
+	ICOM_THIS(IDirectMusicScriptImpl,iface);
+
+	FIXME("(%p, %p, %li, %p): stub\n", This, pwszVariableName, lValue, pErrorInfo);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicScriptImpl_GetVariableNumber (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, LONG* plValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo)
+{
+	ICOM_THIS(IDirectMusicScriptImpl,iface);
+
+	FIXME("(%p, %p, %p, %p): stub\n", This, pwszVariableName, plValue, pErrorInfo);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicScriptImpl_SetVariableObject (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, IUnknown* punkValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo)
+{
+	ICOM_THIS(IDirectMusicScriptImpl,iface);
+
+	FIXME("(%p, %p, %p, %p): stub\n", This, pwszVariableName, punkValue, pErrorInfo);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicScriptImpl_GetVariableObject (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, REFIID riid, LPVOID* ppv, DMUS_SCRIPT_ERRORINFO* pErrorInfo)
+{
+	ICOM_THIS(IDirectMusicScriptImpl,iface);
+
+	FIXME("(%p, %p, %s, %p, %p): stub\n", This, pwszVariableName, debugstr_guid(riid), ppv, pErrorInfo);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicScriptImpl_EnumRoutine (LPDIRECTMUSICSCRIPT iface, DWORD dwIndex, WCHAR* pwszName)
+{
+	ICOM_THIS(IDirectMusicScriptImpl,iface);
+
+	FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicScriptImpl_EnumVariable (LPDIRECTMUSICSCRIPT iface, DWORD dwIndex, WCHAR* pwszName)
+{
+	ICOM_THIS(IDirectMusicScriptImpl,iface);
+
+	FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicScript) DirectMusicScript_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicScriptImpl_QueryInterface,
+	IDirectMusicScriptImpl_AddRef,
+	IDirectMusicScriptImpl_Release,
+	IDirectMusicScriptImpl_Init,
+	IDirectMusicScriptImpl_CallRoutine,
+	IDirectMusicScriptImpl_SetVariableVariant,
+	IDirectMusicScriptImpl_GetVariableVariant,
+	IDirectMusicScriptImpl_SetVariableNumber,
+	IDirectMusicScriptImpl_GetVariableNumber,
+	IDirectMusicScriptImpl_SetVariableObject,
+	IDirectMusicScriptImpl_GetVariableObject,
+	IDirectMusicScriptImpl_EnumRoutine,
+	IDirectMusicScriptImpl_EnumVariable
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicScript (LPCGUID lpcGUID, LPDIRECTMUSICSCRIPT* ppDMScript, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicScript))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmstyle/Makefile.in b/dlls/dmstyle/Makefile.in
index ac45fbd..8756828 100644
--- a/dlls/dmstyle/Makefile.in
+++ b/dlls/dmstyle/Makefile.in
@@ -3,13 +3,16 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = dmstyle.dll
-IMPORTS   = dmusic kernel32
+IMPORTS   = ole32 user32 advapi32 kernel32
+EXTRALIBS = $(LIBUUID)
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
 
 C_SRCS = \
-	dmstyle_main.c
+	dmstyle_main.c \
+	style.c \
+	regsvr.c
 
 RC_SRCS = version.rc
 
diff --git a/dlls/dmstyle/dmstyle.spec b/dlls/dmstyle/dmstyle.spec
index 3d091d1..6508c82 100644
--- a/dlls/dmstyle/dmstyle.spec
+++ b/dlls/dmstyle/dmstyle.spec
@@ -1,6 +1,4 @@
-# Linked to main dmusic.dll for easier implementation
-
-1 stdcall DllCanUnloadNow() dmusic.DllCanUnloadNow
-2 stdcall DllGetClassObject(long long ptr) dmusic.DllGetClassObject
-3 stdcall DllRegisterServer() dmusic.DllRegisterServer
-4 stdcall DllUnregisterServer() dmusic.DllUnregisterServer
+1 stdcall DllCanUnloadNow() DMSTYLE_DllCanUnloadNow
+2 stdcall DllGetClassObject(long long ptr) DMSTYLE_DllGetClassObject
+3 stdcall DllRegisterServer() DMSTYLE_DllRegisterServer
+4 stdcall DllUnregisterServer() DMSTYLE_DllUnregisterServer
diff --git a/dlls/dmstyle/dmstyle_main.c b/dlls/dmstyle/dmstyle_main.c
index 67a01ed..415dd3e 100644
--- a/dlls/dmstyle/dmstyle_main.c
+++ b/dlls/dmstyle/dmstyle_main.c
@@ -1 +1,140 @@
-/* nothing here yet */
+/* DirectMusicStyle Main
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "dmstyle_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+
+/******************************************************************
+ *		DirectMusicStyle ClassFactory
+ *
+ *
+ */
+ 
+typedef struct
+{
+    /* IUnknown fields */
+    ICOM_VFIELD(IClassFactory);
+    DWORD                       ref;
+} IClassFactoryImpl;
+
+static HRESULT WINAPI DMSTYLCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+
+	FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+static ULONG WINAPI DMSTYLCF_AddRef(LPCLASSFACTORY iface)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	return ++(This->ref);
+}
+
+static ULONG WINAPI DMSTYLCF_Release(LPCLASSFACTORY iface)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	/* static class, won't be  freed */
+	return --(This->ref);
+}
+
+static HRESULT WINAPI DMSTYLCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+
+	TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
+	if (IsEqualGUID (riid, &IID_IDirectMusicStyle) ||
+		IsEqualGUID (riid, &IID_IDirectMusicStyle8)) {
+		return DMUSIC_CreateDirectMusicStyle (riid, (LPDIRECTMUSICSTYLE*)ppobj, pOuter);
+	}
+	
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+static HRESULT WINAPI DMSTYLCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	FIXME("(%p)->(%d),stub!\n", This, dolock);
+	return S_OK;
+}
+
+static ICOM_VTABLE(IClassFactory) DMSTYLCF_Vtbl = {
+	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	DMSTYLCF_QueryInterface,
+	DMSTYLCF_AddRef,
+	DMSTYLCF_Release,
+	DMSTYLCF_CreateInstance,
+	DMSTYLCF_LockServer
+};
+
+static IClassFactoryImpl DMSTYLE_CF = {&DMSTYLCF_Vtbl, 1 };
+
+/******************************************************************
+ *		DllMain
+ *
+ *
+ */
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+	if (fdwReason == DLL_PROCESS_ATTACH)
+	{
+            DisableThreadLibraryCalls(hinstDLL);
+		/* FIXME: Initialisation */
+	}
+	else if (fdwReason == DLL_PROCESS_DETACH)
+	{
+		/* FIXME: Cleanup */
+	}
+
+	return TRUE;
+}
+
+
+/******************************************************************
+ *		DllCanUnloadNow (DMSTYLE.1)
+ *
+ *
+ */
+HRESULT WINAPI DMSTYLE_DllCanUnloadNow(void)
+{
+    FIXME("(void): stub\n");
+
+    return S_FALSE;
+}
+
+
+/******************************************************************
+ *		DllGetClassObject (DMSTYLE.2)
+ *
+ *
+ */
+HRESULT WINAPI DMSTYLE_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
+{
+    TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    if (IsEqualCLSID (&IID_IClassFactory, riid)) {
+      *ppv = (LPVOID) &DMSTYLE_CF;
+      IClassFactory_AddRef((IClassFactory*)*ppv);
+      return S_OK;
+    }
+    WARN("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    return CLASS_E_CLASSNOTAVAILABLE;
+}
diff --git a/dlls/dmstyle/dmstyle_private.h b/dlls/dmstyle/dmstyle_private.h
new file mode 100644
index 0000000..9f83881
--- /dev/null
+++ b/dlls/dmstyle/dmstyle_private.h
@@ -0,0 +1,84 @@
+/* DirectMusicStyle Private Include
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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.
+ */
+
+#ifndef __WINE_DMSTYLE_PRIVATE_H
+#define __WINE_DMSTYLE_PRIVATE_H
+
+#include "windef.h"
+#include "wine/debug.h"
+#include "winbase.h"
+#include "winnt.h"
+#include "dmusicc.h"
+#include "dmusici.h"
+#include "dmusics.h"
+#include "dmplugin.h"
+#include "dmusicf.h"
+#include "dsound.h"
+
+/*****************************************************************************
+ * Interfaces
+ */
+typedef struct IDirectMusicStyle8Impl IDirectMusicStyle8Impl;
+
+
+/*****************************************************************************
+ * Predeclare the interface implementation structures
+ */
+extern ICOM_VTABLE(IDirectMusicStyle8) DirectMusicStyle8_Vtbl;
+
+/*****************************************************************************
+ * ClassFactory
+ *
+ * can support IID_IDirectMusicStyle and IID_IDirectMusicStyle8
+ * return always an IDirectMusicStyle8Impl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicStyle (LPCGUID lpcGUID, LPDIRECTMUSICSTYLE* ppDMStyle, LPUNKNOWN pUnkOuter);
+
+/*****************************************************************************
+ * IDirectMusicStyle8Impl implementation structure
+ */
+struct IDirectMusicStyle8Impl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicStyle8);
+  DWORD          ref;
+
+  /* IDirectMusicStyle8Impl fields */
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicStyle8Impl_QueryInterface (LPDIRECTMUSICSTYLE8 iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicStyle8Impl_AddRef (LPDIRECTMUSICSTYLE8 iface);
+extern ULONG WINAPI   IDirectMusicStyle8Impl_Release (LPDIRECTMUSICSTYLE8 iface);
+/* IDirectMusicStyle: */
+extern HRESULT WINAPI IDirectMusicStyle8Impl_GetBand (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicBand** ppBand);
+extern HRESULT WINAPI IDirectMusicStyle8Impl_EnumBand (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName);
+extern HRESULT WINAPI IDirectMusicStyle8Impl_GetDefaultBand (LPDIRECTMUSICSTYLE8 iface, IDirectMusicBand** ppBand);
+extern HRESULT WINAPI IDirectMusicStyle8Impl_EnumMotif (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName);
+extern HRESULT WINAPI IDirectMusicStyle8Impl_GetMotif (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicSegment** ppSegment);
+extern HRESULT WINAPI IDirectMusicStyle8Impl_GetDefaultChordMap (LPDIRECTMUSICSTYLE8 iface, IDirectMusicChordMap** ppChordMap);
+extern HRESULT WINAPI IDirectMusicStyle8Impl_EnumChordMap (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName);
+extern HRESULT WINAPI IDirectMusicStyle8Impl_GetChordMap (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicChordMap** ppChordMap);
+extern HRESULT WINAPI IDirectMusicStyle8Impl_GetTimeSignature (LPDIRECTMUSICSTYLE8 iface, DMUS_TIMESIGNATURE* pTimeSig);
+extern HRESULT WINAPI IDirectMusicStyle8Impl_GetEmbellishmentLength (LPDIRECTMUSICSTYLE8 iface, DWORD dwType, DWORD dwLevel, DWORD* pdwMin, DWORD* pdwMax);
+extern HRESULT WINAPI IDirectMusicStyle8Impl_GetTempo (LPDIRECTMUSICSTYLE8 iface, double* pTempo);
+/* IDirectMusicStyle8: */
+extern HRESULT WINAPI IDirectMusicStyle8ImplEnumPattern (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, DWORD dwPatternType, WCHAR* pwszName);
+
+#endif	/* __WINE_DMSTYLE_PRIVATE_H */
diff --git a/dlls/dmstyle/regsvr.c b/dlls/dmstyle/regsvr.c
new file mode 100644
index 0000000..f1210d6
--- /dev/null
+++ b/dlls/dmstyle/regsvr.c
@@ -0,0 +1,616 @@
+/*
+ *	self-registerable dll functions for dmstyle.dll
+ *
+ * Copyright (C) 2003 John K. Hohm
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "winreg.h"
+#include "winerror.h"
+
+#include "dmusics.h"
+#include "dmusici.h"
+#include "dmplugin.h"
+
+#include <string.h>
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/*
+ * Near the bottom of this file are the exported DllRegisterServer and
+ * DllUnregisterServer, which make all this worthwhile.
+ */
+
+/***********************************************************************
+ *		interface for self-registering
+ */
+struct regsvr_interface
+{
+    IID const *iid;		/* NULL for end of list */
+    LPCSTR name;		/* can be NULL to omit */
+    IID const *base_iid;	/* can be NULL to omit */
+    int num_methods;		/* can be <0 to omit */
+    CLSID const *ps_clsid;	/* can be NULL to omit */
+    CLSID const *ps_clsid32;	/* can be NULL to omit */
+};
+
+static HRESULT register_interfaces(struct regsvr_interface const *list);
+static HRESULT unregister_interfaces(struct regsvr_interface const *list);
+
+struct regsvr_coclass
+{
+    CLSID const *clsid;		/* NULL for end of list */
+    LPCSTR name;		/* can be NULL to omit */
+    LPCSTR ips;			/* can be NULL to omit */
+    LPCSTR ips32;		/* can be NULL to omit */
+    LPCSTR ips32_tmodel;	/* can be NULL to omit */
+    LPCSTR progid;		/* can be NULL to omit */
+    LPCSTR viprogid;		/* can be NULL to omit */
+    LPCSTR progid_extra;	/* can be NULL to omit */
+};
+
+static HRESULT register_coclasses(struct regsvr_coclass const *list);
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
+
+/***********************************************************************
+ *		static string constants
+ */
+static WCHAR const interface_keyname[10] = {
+    'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
+static WCHAR const base_ifa_keyname[14] = {
+    'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
+    'e', 0 };
+static WCHAR const num_methods_keyname[11] = {
+    'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
+static WCHAR const ps_clsid_keyname[15] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', 0 };
+static WCHAR const ps_clsid32_keyname[17] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', '3', '2', 0 };
+static WCHAR const clsid_keyname[6] = {
+    'C', 'L', 'S', 'I', 'D', 0 };
+static WCHAR const curver_keyname[7] = {
+    'C', 'u', 'r', 'V', 'e', 'r', 0 };
+static WCHAR const ips_keyname[13] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    0 };
+static WCHAR const ips32_keyname[15] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    '3', '2', 0 };
+static WCHAR const progid_keyname[7] = {
+    'P', 'r', 'o', 'g', 'I', 'D', 0 };
+static WCHAR const viprogid_keyname[25] = {
+    'V', 'e', 'r', 's', 'i', 'o', 'n', 'I', 'n', 'd', 'e', 'p',
+    'e', 'n', 'd', 'e', 'n', 't', 'P', 'r', 'o', 'g', 'I', 'D',
+    0 };
+static char const tmodel_valuename[] = "ThreadingModel";
+
+/***********************************************************************
+ *		static helper functions
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
+static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
+				   WCHAR const *value);
+static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
+				   char const *value);
+static LONG register_progid(WCHAR const *clsid,
+			    char const *progid, char const *curver_progid,
+			    char const *name, char const *extra);
+static LONG recursive_delete_key(HKEY key);
+static LONG recursive_delete_keyA(HKEY base, char const *name);
+static LONG recursive_delete_keyW(HKEY base, WCHAR const *name);
+
+/***********************************************************************
+ *		register_interfaces
+ */
+static HRESULT register_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+	WCHAR buf[39];
+	HKEY iid_key;
+
+	StringFromGUID2(list->iid, buf, 39);
+	res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
+			      KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
+	if (res != ERROR_SUCCESS) goto error_close_interface_key;
+
+	if (list->name) {
+	    res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)(list->name),
+				 strlen(list->name) + 1);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->base_iid) {
+	    register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (0 <= list->num_methods) {
+	    static WCHAR const fmt[3] = { '%', 'd', 0 };
+	    HKEY key;
+
+	    res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
+				  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+
+	    wsprintfW(buf, fmt, list->num_methods);
+	    res = RegSetValueExW(key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)buf,
+				 (lstrlenW(buf) + 1) * sizeof(WCHAR));
+	    RegCloseKey(key);
+
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->ps_clsid) {
+	    register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->ps_clsid32) {
+	    register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+    error_close_iid_key:
+	RegCloseKey(iid_key);
+    }
+
+error_close_interface_key:
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		unregister_interfaces
+ */
+static HRESULT unregister_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
+			KEY_READ | KEY_WRITE, &interface_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+	WCHAR buf[39];
+
+	StringFromGUID2(list->iid, buf, 39);
+	res = recursive_delete_keyW(interface_key, buf);
+    }
+
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		register_coclasses
+ */
+static HRESULT register_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+	WCHAR buf[39];
+	HKEY clsid_key;
+
+	StringFromGUID2(list->clsid, buf, 39);
+	res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
+			      KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
+	if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+	if (list->name) {
+	    res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)(list->name),
+				 strlen(list->name) + 1);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->ips) {
+	    res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->ips32) {
+	    HKEY ips32_key;
+
+	    res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
+				  KEY_READ | KEY_WRITE, NULL,
+				  &ips32_key, NULL);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)list->ips32,
+				 lstrlenA(list->ips32) + 1);
+	    if (res == ERROR_SUCCESS && list->ips32_tmodel)
+		res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
+				     (CONST BYTE*)list->ips32_tmodel,
+				     strlen(list->ips32_tmodel) + 1);
+	    RegCloseKey(ips32_key);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->progid) {
+	    res = register_key_defvalueA(clsid_key, progid_keyname,
+					 list->progid);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = register_progid(buf, list->progid, NULL,
+				  list->name, list->progid_extra);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->viprogid) {
+	    res = register_key_defvalueA(clsid_key, viprogid_keyname,
+					 list->viprogid);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = register_progid(buf, list->viprogid, list->progid,
+				  list->name, list->progid_extra);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+    error_close_clsid_key:
+	RegCloseKey(clsid_key);
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		unregister_coclasses
+ */
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
+			KEY_READ | KEY_WRITE, &coclass_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+	WCHAR buf[39];
+
+	StringFromGUID2(list->clsid, buf, 39);
+	res = recursive_delete_keyW(coclass_key, buf);
+	if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+	if (list->progid) {
+	    res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->progid);
+	    if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+	}
+
+	if (list->viprogid) {
+	    res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->viprogid);
+	    if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+	}
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		regsvr_key_guid
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
+{
+    WCHAR buf[39];
+
+    StringFromGUID2(guid, buf, 39);
+    return register_key_defvalueW(base, name, buf);
+}
+
+/***********************************************************************
+ *		regsvr_key_defvalueW
+ */
+static LONG register_key_defvalueW(
+    HKEY base,
+    WCHAR const *name,
+    WCHAR const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+			 (lstrlenW(value) + 1) * sizeof(WCHAR));
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		regsvr_key_defvalueA
+ */
+static LONG register_key_defvalueA(
+    HKEY base,
+    WCHAR const *name,
+    char const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+			 lstrlenA(value) + 1);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		regsvr_progid
+ */
+static LONG register_progid(
+    WCHAR const *clsid,
+    char const *progid,
+    char const *curver_progid,
+    char const *name,
+    char const *extra)
+{
+    LONG res;
+    HKEY progid_key;
+
+    res = RegCreateKeyExA(HKEY_CLASSES_ROOT, progid, 0,
+			  NULL, 0, KEY_READ | KEY_WRITE, NULL,
+			  &progid_key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+
+    if (name) {
+	res = RegSetValueExA(progid_key, NULL, 0, REG_SZ,
+			     (CONST BYTE*)name, strlen(name) + 1);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (clsid) {
+	res = register_key_defvalueW(progid_key, clsid_keyname, clsid);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (curver_progid) {
+	res = register_key_defvalueA(progid_key, curver_keyname,
+				     curver_progid);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (extra) {
+	HKEY extra_key;
+
+	res = RegCreateKeyExA(progid_key, extra, 0,
+			      NULL, 0, KEY_READ | KEY_WRITE, NULL,
+			      &extra_key, NULL);
+	if (res == ERROR_SUCCESS)
+	    RegCloseKey(extra_key);
+    }
+
+error_close_progid_key:
+    RegCloseKey(progid_key);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_key
+ */
+static LONG recursive_delete_key(HKEY key)
+{
+    LONG res;
+    WCHAR subkey_name[MAX_PATH];
+    DWORD cName;
+    HKEY subkey;
+
+    for (;;) {
+	cName = sizeof(subkey_name) / sizeof(WCHAR);
+	res = RegEnumKeyExW(key, 0, subkey_name, &cName,
+			    NULL, NULL, NULL, NULL);
+	if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) {
+	    res = ERROR_SUCCESS; /* presumably we're done enumerating */
+	    break;
+	}
+	res = RegOpenKeyExW(key, subkey_name, 0,
+			    KEY_READ | KEY_WRITE, &subkey);
+	if (res == ERROR_FILE_NOT_FOUND) continue;
+	if (res != ERROR_SUCCESS) break;
+
+	res = recursive_delete_key(subkey);
+	RegCloseKey(subkey);
+	if (res != ERROR_SUCCESS) break;
+    }
+
+    if (res == ERROR_SUCCESS) res = RegDeleteKeyW(key, 0);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_keyA
+ */
+static LONG recursive_delete_keyA(HKEY base, char const *name)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegOpenKeyExA(base, name, 0, KEY_READ | KEY_WRITE, &key);
+    if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
+    if (res != ERROR_SUCCESS) return res;
+    res = recursive_delete_key(key);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_keyW
+ */
+static LONG recursive_delete_keyW(HKEY base, WCHAR const *name)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegOpenKeyExW(base, name, 0, KEY_READ | KEY_WRITE, &key);
+    if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
+    if (res != ERROR_SUCCESS) return res;
+    res = recursive_delete_key(key);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		coclass list
+ */
+static struct regsvr_coclass const coclass_list[] = {
+    {   &CLSID_DirectMusicSection,
+	"DirectMusicSection",
+	NULL,
+	"dmstyle.dll",
+	"Both",
+	"Microsoft.DirectMusicSection.1",
+	"Microsoft.DirectMusicSection"
+    },
+    {   &CLSID_DirectMusicStyle,
+	"DirectMusicStyle",
+	NULL,
+	"dmstyle.dll",
+	"Both",
+	"Microsoft.DirectMusicStyle.1",
+	"Microsoft.DirectMusicStyle"
+    },
+    {   &CLSID_DirectMusicChordTrack,
+	"DirectMusicChordTrack",
+	NULL,
+	"dmstyle.dll",
+	"Both",
+	"Microsoft.DirectMusicChordTrack.1",
+	"Microsoft.DirectMusicChordTrack"
+    },
+    {   &CLSID_DirectMusicCommandTrack,
+	"DirectMusicCommandTrack",
+	NULL,
+	"dmstyle.dll",
+	"Both",
+	"Microsoft.DirectMusicCommandTrack.1",
+	"Microsoft.DirectMusicCommandTrack"
+    },
+    {   &CLSID_DirectMusicStyleTrack,
+	"DirectMusicStyleTrack",
+	NULL,
+	"dmstyle.dll",
+	"Both",
+	"Microsoft.DirectMusicStyleTrack.1",
+	"Microsoft.DirectMusicStyleTrack"
+    },
+    {   &CLSID_DirectMusicMotifTrack,
+	"DirectMusicMotifTrack",
+	NULL,
+	"dmstyle.dll",
+	"Both",
+	"Microsoft.DirectMusicMotifTrack.1",
+	"Microsoft.DirectMusicMotifTrack"
+    },
+    {   &CLSID_DirectMusicAuditionTrack,
+	"DirectMusicAuditionTrack",
+	NULL,
+	"dmstyle.dll",
+	"Both",
+	"Microsoft.DirectMusicAuditionTrack.1",
+	"Microsoft.DirectMusicAuditionTrack"
+    },
+    {   &CLSID_DirectMusicMuteTrack,
+	"DirectMusicMuteTrack",
+	NULL,
+	"dmstyle.dll",
+	"Both",
+	"Microsoft.DirectMusicMuteTrack.1",
+	"Microsoft.DirectMusicMuteTrack"
+    },
+    {   &CLSID_DirectMusicMelodyFormulationTrack,
+	"DirectMusicMelodyFormulationTrack",
+	NULL,
+	"dmstyle.dll",
+	"Both",
+	"Microsoft.DirectMusicMelodyFormulationTrack.1",
+	"Microsoft.DirectMusicMelodyFormulationTrack"
+    },
+    { NULL }			/* list terminator */
+};
+
+/***********************************************************************
+ *		interface list
+ */
+
+static struct regsvr_interface const interface_list[] = {
+    { NULL }			/* list terminator */
+};
+
+/***********************************************************************
+ *		DllRegisterServer (DMSTYLE.3)
+ */
+HRESULT WINAPI DMSTYLE_DllRegisterServer()
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = register_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+	hr = register_interfaces(interface_list);
+    return hr;
+}
+
+/***********************************************************************
+ *		DllUnregisterServer (DMSTYLE.4)
+ */
+HRESULT WINAPI DMSTYLE_DllUnregisterServer()
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = unregister_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+	hr = unregister_interfaces(interface_list);
+    return hr;
+}
diff --git a/dlls/dmusic/dmusic_style.c b/dlls/dmstyle/style.c
similarity index 92%
rename from dlls/dmusic/dmusic_style.c
rename to dlls/dmstyle/style.c
index ec16b3a..58577fb 100644
--- a/dlls/dmusic/dmusic_style.c
+++ b/dlls/dmstyle/style.c
@@ -1,5 +1,4 @@
-/* IDirectMusicStyle Implementation
- * IDirectMusicStyle8 Implementation
+/* IDirectMusicStyle8 Implementation
  *
  * Copyright (C) 2003 Rok Mandeljc
  *
@@ -24,7 +23,7 @@
 #include "wingdi.h"
 #include "wine/debug.h"
 
-#include "dmusic_private.h"
+#include "dmstyle_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
 
@@ -194,3 +193,17 @@
 	IDirectMusicStyle8Impl_GetTempo,
 	IDirectMusicStyle8ImplEnumPattern
 };
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicStyle (LPCGUID lpcGUID, LPDIRECTMUSICSTYLE* ppDMStyle, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicStyle) ||
+		IsEqualGUID (lpcGUID, &IID_IDirectMusicStyle8)) 
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmsynth/Makefile.in b/dlls/dmsynth/Makefile.in
index fcedb30..c9cc6d9 100644
--- a/dlls/dmsynth/Makefile.in
+++ b/dlls/dmsynth/Makefile.in
@@ -3,13 +3,17 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = dmsynth.dll
-IMPORTS   = dmusic kernel32
+IMPORTS   = winmm ole32 user32 advapi32 kernel32
+EXTRALIBS = $(LIBUUID)
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
 
 C_SRCS = \
-	dmsynth_main.c
+	dmsynth_main.c \
+	regsvr.c \
+	synth.c \
+	synthsink.c
 
 RC_SRCS = version.rc
 
diff --git a/dlls/dmsynth/dmsynth.spec b/dlls/dmsynth/dmsynth.spec
index bd5a7b5..cfc6964 100644
--- a/dlls/dmsynth/dmsynth.spec
+++ b/dlls/dmsynth/dmsynth.spec
@@ -1,6 +1,4 @@
-# Linked to main dmusic.dll for easier implementation
-
-1 stdcall DllCanUnloadNow() dmusic.DllCanUnloadNow
-2 stdcall DllGetClassObject( long long ptr ) dmusic.DllGetClassObject
-3 stdcall DllRegisterServer() dmusic.DllRegisterServer
-4 stdcall DllUnregisterServer() dmusic.DllUnregisterServer
+1 stdcall DllCanUnloadNow() DMSYNTH_DllCanUnloadNow
+2 stdcall DllGetClassObject( long long ptr ) DMSYNTH_DllGetClassObject
+3 stdcall DllRegisterServer() DMSYNTH_DllRegisterServer
+4 stdcall DllUnregisterServer() DMSYNTH_DllUnregisterServer
diff --git a/dlls/dmsynth/dmsynth_main.c b/dlls/dmsynth/dmsynth_main.c
index 67a01ed..d7df8be 100644
--- a/dlls/dmsynth/dmsynth_main.c
+++ b/dlls/dmsynth/dmsynth_main.c
@@ -1 +1,141 @@
-/* nothing here yet */
+/* DirectMusicSynthesizer Main
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "dmsynth_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+
+/******************************************************************
+ *		DirectMusicSynthesizer ClassFactory
+ *
+ *
+ */
+ 
+typedef struct
+{
+    /* IUnknown fields */
+    ICOM_VFIELD(IClassFactory);
+    DWORD                       ref;
+} IClassFactoryImpl;
+
+static HRESULT WINAPI DMSYCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+
+	FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+static ULONG WINAPI DMSYCF_AddRef(LPCLASSFACTORY iface)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	return ++(This->ref);
+}
+
+static ULONG WINAPI DMSYCF_Release(LPCLASSFACTORY iface)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	/* static class, won't be  freed */
+	return --(This->ref);
+}
+
+static HRESULT WINAPI DMSYCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+
+	TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
+	if (IsEqualGUID (riid, &IID_IDirectMusicSynth) ||
+		IsEqualGUID (riid, &IID_IDirectMusicSynth8)) {
+		return DMUSIC_CreateDirectMusicSynth (riid, (LPDIRECTMUSICSYNTH8*)ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicSynthSink)) {
+		return DMUSIC_CreateDirectMusicSynthSink (riid, (LPDIRECTMUSICSYNTHSINK*)ppobj, pOuter);
+	}
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+static HRESULT WINAPI DMSYCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
+{
+	ICOM_THIS(IClassFactoryImpl,iface);
+	FIXME("(%p)->(%d),stub!\n", This, dolock);
+	return S_OK;
+}
+
+static ICOM_VTABLE(IClassFactory) DMSYCF_Vtbl = {
+	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	DMSYCF_QueryInterface,
+	DMSYCF_AddRef,
+	DMSYCF_Release,
+	DMSYCF_CreateInstance,
+	DMSYCF_LockServer
+};
+
+static IClassFactoryImpl DMSYNTH_CF = {&DMSYCF_Vtbl, 1 };
+
+/******************************************************************
+ *		DllMain
+ *
+ *
+ */
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+	if (fdwReason == DLL_PROCESS_ATTACH)
+	{
+            DisableThreadLibraryCalls(hinstDLL);
+		/* FIXME: Initialisation */
+	}
+	else if (fdwReason == DLL_PROCESS_DETACH)
+	{
+		/* FIXME: Cleanup */
+	}
+
+	return TRUE;
+}
+
+
+/******************************************************************
+ *		DllCanUnloadNow (DMSYNTH.1)
+ *
+ *
+ */
+HRESULT WINAPI DMSYNTH_DllCanUnloadNow(void)
+{
+    FIXME("(void): stub\n");
+
+    return S_FALSE;
+}
+
+
+/******************************************************************
+ *		DllGetClassObject (DMSYNTH.2)
+ *
+ *
+ */
+HRESULT WINAPI DMSYNTH_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
+{
+    TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    if (IsEqualCLSID (&IID_IClassFactory, riid)) {
+      *ppv = (LPVOID) &DMSYNTH_CF;
+      IClassFactory_AddRef((IClassFactory*)*ppv);
+      return S_OK;
+    }
+    WARN("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    return CLASS_E_CLASSNOTAVAILABLE;
+}
diff --git a/dlls/dmsynth/dmsynth_private.h b/dlls/dmsynth/dmsynth_private.h
new file mode 100644
index 0000000..a255837
--- /dev/null
+++ b/dlls/dmsynth/dmsynth_private.h
@@ -0,0 +1,129 @@
+/* DirectMusicSynthesizer Private Include
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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.
+ */
+
+#ifndef __WINE_DMSYNTH_PRIVATE_H
+#define __WINE_DMSYNTH_PRIVATE_H
+
+#include "windef.h"
+#include "wine/debug.h"
+#include "winbase.h"
+#include "winnt.h"
+#include "dmusicc.h"
+#include "dmusici.h"
+#include "dmusics.h"
+#include "dmplugin.h"
+#include "dmusicf.h"
+#include "dsound.h"
+
+/*****************************************************************************
+ * Interfaces
+ */
+typedef struct IDirectMusicSynth8Impl IDirectMusicSynth8Impl;
+typedef struct IDirectMusicSynthSinkImpl IDirectMusicSynthSinkImpl;
+
+/*****************************************************************************
+ * Predeclare the interface implementation structures
+ */
+extern ICOM_VTABLE(IDirectMusicSynth8) DirectMusicSynth8_Vtbl;
+extern ICOM_VTABLE(IDirectMusicSynthSink) DirectMusicSynthSink_Vtbl;
+
+/*****************************************************************************
+ * ClassFactory
+ */
+/* can support IID_IDirectMusicSynth and IID_IDirectMusicSynth8
+ * return always an IDirectMusicSynthImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicSynth (LPCGUID lpcGUID, LPDIRECTMUSICSYNTH8* ppDMSynth, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicSynthSink
+ * return always an IDirectMusicSynthSinkImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicSynthSink (LPCGUID lpcGUID, LPDIRECTMUSICSYNTHSINK* ppDMSynthSink, LPUNKNOWN pUnkOuter);
+
+/*****************************************************************************
+ * IDirectMusicSynth8Impl implementation structure
+ */
+struct IDirectMusicSynth8Impl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicSynth8);
+  DWORD          ref;
+
+  /* IDirectMusicSynth8 fields */
+  DMUS_PORTCAPS pCaps;
+  BOOL fActive;
+  IReferenceClock* pLatencyClock;
+  IDirectMusicSynthSinkImpl* pSynthSink;
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicSynth8Impl_QueryInterface (LPDIRECTMUSICSYNTH8 iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicSynth8Impl_AddRef (LPDIRECTMUSICSYNTH8 iface);
+extern ULONG WINAPI   IDirectMusicSynth8Impl_Release (LPDIRECTMUSICSYNTH8 iface);
+/* IDirectMusicSynth: */
+extern HRESULT WINAPI IDirectMusicSynth8Impl_Open (LPDIRECTMUSICSYNTH8 iface, LPDMUS_PORTPARAMS pPortParams);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_Close (LPDIRECTMUSICSYNTH8 iface);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_SetNumChannelGroups (LPDIRECTMUSICSYNTH8 iface, DWORD dwGroups);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_Download (LPDIRECTMUSICSYNTH8 iface, LPHANDLE phDownload, LPVOID pvData, LPBOOL pbFree);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_Unload (LPDIRECTMUSICSYNTH8 iface, HANDLE hDownload, HRESULT (CALLBACK* lpFreeHandle)(HANDLE,HANDLE), HANDLE hUserData);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_PlayBuffer (LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME rt, LPBYTE pbBuffer, DWORD cbBuffer);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_GetRunningStats (LPDIRECTMUSICSYNTH8 iface, LPDMUS_SYNTHSTATS pStats);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_GetPortCaps (LPDIRECTMUSICSYNTH8 iface, LPDMUS_PORTCAPS pCaps);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_SetMasterClock (LPDIRECTMUSICSYNTH8 iface, IReferenceClock* pClock);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_GetLatencyClock (LPDIRECTMUSICSYNTH8 iface, IReferenceClock** ppClock);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_Activate (LPDIRECTMUSICSYNTH8 iface, BOOL fEnable);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_SetSynthSink (LPDIRECTMUSICSYNTH8 iface, IDirectMusicSynthSink* pSynthSink);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_Render (LPDIRECTMUSICSYNTH8 iface, short* pBuffer, DWORD dwLength, LONGLONG llPosition);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_SetChannelPriority (LPDIRECTMUSICSYNTH8 iface, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_GetChannelPriority (LPDIRECTMUSICSYNTH8 iface, DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_GetFormat (LPDIRECTMUSICSYNTH8 iface, LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSiz);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_GetAppend (LPDIRECTMUSICSYNTH8 iface, DWORD* pdwAppend);
+/* IDirectMusicSynth8: */
+extern HRESULT WINAPI IDirectMusicSynth8Impl_PlayVoice (LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME rt, DWORD dwVoiceId, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwDLId, long prPitch, long vrVolume, SAMPLE_TIME stVoiceStart, SAMPLE_TIME stLoopStart, SAMPLE_TIME stLoopEnd);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_StopVoice (LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME rt, DWORD dwVoiceId);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_GetVoiceState (LPDIRECTMUSICSYNTH8 iface, DWORD dwVoice[], DWORD cbVoice, DMUS_VOICE_STATE dwVoiceState[]);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_Refresh (LPDIRECTMUSICSYNTH8 iface, DWORD dwDownloadID, DWORD dwFlags);
+extern HRESULT WINAPI IDirectMusicSynth8Impl_AssignChannelToBuses (LPDIRECTMUSICSYNTH8 iface, DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwBuses, DWORD cBuses);
+
+/*****************************************************************************
+ * IDirectMusicSynthSinkImpl implementation structure
+ */
+struct IDirectMusicSynthSinkImpl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicSynthSink);
+  DWORD          ref;
+
+  /* IDirectMusicSynthSinkImpl fields */
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicSynthSinkImpl_QueryInterface (LPDIRECTMUSICSYNTHSINK iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicSynthSinkImpl_AddRef (LPDIRECTMUSICSYNTHSINK iface);
+extern ULONG WINAPI   IDirectMusicSynthSinkImpl_Release (LPDIRECTMUSICSYNTHSINK iface);
+/* IDirectMusicSynthSinkImpl: */
+extern HRESULT WINAPI IDirectMusicSynthSinkImpl_Init (LPDIRECTMUSICSYNTHSINK iface, IDirectMusicSynth* pSynth);
+extern HRESULT WINAPI IDirectMusicSynthSinkImpl_SetMasterClock (LPDIRECTMUSICSYNTHSINK iface, IReferenceClock* pClock);
+extern HRESULT WINAPI IDirectMusicSynthSinkImpl_GetLatencyClock (LPDIRECTMUSICSYNTHSINK iface, IReferenceClock** ppClock);
+extern HRESULT WINAPI IDirectMusicSynthSinkImpl_Activate (LPDIRECTMUSICSYNTHSINK iface, BOOL fEnable);
+extern HRESULT WINAPI IDirectMusicSynthSinkImpl_SampleToRefTime (LPDIRECTMUSICSYNTHSINK iface, LONGLONG llSampleTime, REFERENCE_TIME* prfTime);
+extern HRESULT WINAPI IDirectMusicSynthSinkImpl_RefTimeToSample (LPDIRECTMUSICSYNTHSINK iface, REFERENCE_TIME rfTime, LONGLONG* pllSampleTime);
+extern HRESULT WINAPI IDirectMusicSynthSinkImpl_SetDirectSound (LPDIRECTMUSICSYNTHSINK iface, LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer);
+extern HRESULT WINAPI IDirectMusicSynthSinkImpl_GetDesiredBufferSize (LPDIRECTMUSICSYNTHSINK iface, LPDWORD pdwBufferSizeInSamples);
+
+#endif	/* __WINE_DMSYNTH_PRIVATE_H */
diff --git a/dlls/dmsynth/regsvr.c b/dlls/dmsynth/regsvr.c
new file mode 100644
index 0000000..9a23de9
--- /dev/null
+++ b/dlls/dmsynth/regsvr.c
@@ -0,0 +1,560 @@
+/*
+ *	self-registerable dll functions for dmsynth.dll
+ *
+ * Copyright (C) 2003 John K. Hohm
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <string.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "winreg.h"
+#include "winerror.h"
+
+#include "dmusics.h"
+#include "dmusici.h"
+#include "dmplugin.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/*
+ * Near the bottom of this file are the exported DllRegisterServer and
+ * DllUnregisterServer, which make all this worthwhile.
+ */
+
+/***********************************************************************
+ *		interface for self-registering
+ */
+struct regsvr_interface
+{
+    IID const *iid;		/* NULL for end of list */
+    LPCSTR name;		/* can be NULL to omit */
+    IID const *base_iid;	/* can be NULL to omit */
+    int num_methods;		/* can be <0 to omit */
+    CLSID const *ps_clsid;	/* can be NULL to omit */
+    CLSID const *ps_clsid32;	/* can be NULL to omit */
+};
+
+static HRESULT register_interfaces(struct regsvr_interface const *list);
+static HRESULT unregister_interfaces(struct regsvr_interface const *list);
+
+struct regsvr_coclass
+{
+    CLSID const *clsid;		/* NULL for end of list */
+    LPCSTR name;		/* can be NULL to omit */
+    LPCSTR ips;			/* can be NULL to omit */
+    LPCSTR ips32;		/* can be NULL to omit */
+    LPCSTR ips32_tmodel;	/* can be NULL to omit */
+    LPCSTR progid;		/* can be NULL to omit */
+    LPCSTR viprogid;		/* can be NULL to omit */
+    LPCSTR progid_extra;	/* can be NULL to omit */
+};
+
+static HRESULT register_coclasses(struct regsvr_coclass const *list);
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
+
+/***********************************************************************
+ *		static string constants
+ */
+static WCHAR const interface_keyname[10] = {
+    'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
+static WCHAR const base_ifa_keyname[14] = {
+    'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
+    'e', 0 };
+static WCHAR const num_methods_keyname[11] = {
+    'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
+static WCHAR const ps_clsid_keyname[15] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', 0 };
+static WCHAR const ps_clsid32_keyname[17] = {
+    'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
+    'i', 'd', '3', '2', 0 };
+static WCHAR const clsid_keyname[6] = {
+    'C', 'L', 'S', 'I', 'D', 0 };
+static WCHAR const curver_keyname[7] = {
+    'C', 'u', 'r', 'V', 'e', 'r', 0 };
+static WCHAR const ips_keyname[13] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    0 };
+static WCHAR const ips32_keyname[15] = {
+    'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
+    '3', '2', 0 };
+static WCHAR const progid_keyname[7] = {
+    'P', 'r', 'o', 'g', 'I', 'D', 0 };
+static WCHAR const viprogid_keyname[25] = {
+    'V', 'e', 'r', 's', 'i', 'o', 'n', 'I', 'n', 'd', 'e', 'p',
+    'e', 'n', 'd', 'e', 'n', 't', 'P', 'r', 'o', 'g', 'I', 'D',
+    0 };
+static char const tmodel_valuename[] = "ThreadingModel";
+
+/***********************************************************************
+ *		static helper functions
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
+static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
+				   WCHAR const *value);
+static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
+				   char const *value);
+static LONG register_progid(WCHAR const *clsid,
+			    char const *progid, char const *curver_progid,
+			    char const *name, char const *extra);
+static LONG recursive_delete_key(HKEY key);
+static LONG recursive_delete_keyA(HKEY base, char const *name);
+static LONG recursive_delete_keyW(HKEY base, WCHAR const *name);
+
+/***********************************************************************
+ *		register_interfaces
+ */
+static HRESULT register_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+	WCHAR buf[39];
+	HKEY iid_key;
+
+	StringFromGUID2(list->iid, buf, 39);
+	res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
+			      KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
+	if (res != ERROR_SUCCESS) goto error_close_interface_key;
+
+	if (list->name) {
+	    res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)(list->name),
+				 strlen(list->name) + 1);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->base_iid) {
+	    register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (0 <= list->num_methods) {
+	    static WCHAR const fmt[3] = { '%', 'd', 0 };
+	    HKEY key;
+
+	    res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
+				  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+
+	    wsprintfW(buf, fmt, list->num_methods);
+	    res = RegSetValueExW(key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)buf,
+				 (lstrlenW(buf) + 1) * sizeof(WCHAR));
+	    RegCloseKey(key);
+
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->ps_clsid) {
+	    register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+	if (list->ps_clsid32) {
+	    register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
+	    if (res != ERROR_SUCCESS) goto error_close_iid_key;
+	}
+
+    error_close_iid_key:
+	RegCloseKey(iid_key);
+    }
+
+error_close_interface_key:
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		unregister_interfaces
+ */
+static HRESULT unregister_interfaces(struct regsvr_interface const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY interface_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
+			KEY_READ | KEY_WRITE, &interface_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->iid; ++list) {
+	WCHAR buf[39];
+
+	StringFromGUID2(list->iid, buf, 39);
+	res = recursive_delete_keyW(interface_key, buf);
+    }
+
+    RegCloseKey(interface_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		register_coclasses
+ */
+static HRESULT register_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+	WCHAR buf[39];
+	HKEY clsid_key;
+
+	StringFromGUID2(list->clsid, buf, 39);
+	res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
+			      KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
+	if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+	if (list->name) {
+	    res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)(list->name),
+				 strlen(list->name) + 1);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->ips) {
+	    res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->ips32) {
+	    HKEY ips32_key;
+
+	    res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
+				  KEY_READ | KEY_WRITE, NULL,
+				  &ips32_key, NULL);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
+				 (CONST BYTE*)list->ips32,
+				 lstrlenA(list->ips32) + 1);
+	    if (res == ERROR_SUCCESS && list->ips32_tmodel)
+		res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
+				     (CONST BYTE*)list->ips32_tmodel,
+				     strlen(list->ips32_tmodel) + 1);
+	    RegCloseKey(ips32_key);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->progid) {
+	    res = register_key_defvalueA(clsid_key, progid_keyname,
+					 list->progid);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = register_progid(buf, list->progid, NULL,
+				  list->name, list->progid_extra);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+	if (list->viprogid) {
+	    res = register_key_defvalueA(clsid_key, viprogid_keyname,
+					 list->viprogid);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+
+	    res = register_progid(buf, list->viprogid, list->progid,
+				  list->name, list->progid_extra);
+	    if (res != ERROR_SUCCESS) goto error_close_clsid_key;
+	}
+
+    error_close_clsid_key:
+	RegCloseKey(clsid_key);
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		unregister_coclasses
+ */
+static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
+{
+    LONG res = ERROR_SUCCESS;
+    HKEY coclass_key;
+
+    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
+			KEY_READ | KEY_WRITE, &coclass_key);
+    if (res == ERROR_FILE_NOT_FOUND) return S_OK;
+    if (res != ERROR_SUCCESS) goto error_return;
+
+    for (; res == ERROR_SUCCESS && list->clsid; ++list) {
+	WCHAR buf[39];
+
+	StringFromGUID2(list->clsid, buf, 39);
+	res = recursive_delete_keyW(coclass_key, buf);
+	if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+
+	if (list->progid) {
+	    res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->progid);
+	    if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+	}
+
+	if (list->viprogid) {
+	    res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->viprogid);
+	    if (res != ERROR_SUCCESS) goto error_close_coclass_key;
+	}
+    }
+
+error_close_coclass_key:
+    RegCloseKey(coclass_key);
+error_return:
+    return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
+}
+
+/***********************************************************************
+ *		regsvr_key_guid
+ */
+static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
+{
+    WCHAR buf[39];
+
+    StringFromGUID2(guid, buf, 39);
+    return register_key_defvalueW(base, name, buf);
+}
+
+/***********************************************************************
+ *		regsvr_key_defvalueW
+ */
+static LONG register_key_defvalueW(
+    HKEY base,
+    WCHAR const *name,
+    WCHAR const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+			 (lstrlenW(value) + 1) * sizeof(WCHAR));
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		regsvr_key_defvalueA
+ */
+static LONG register_key_defvalueA(
+    HKEY base,
+    WCHAR const *name,
+    char const *value)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegCreateKeyExW(base, name, 0, NULL, 0,
+			  KEY_READ | KEY_WRITE, NULL, &key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+    res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
+			 lstrlenA(value) + 1);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		regsvr_progid
+ */
+static LONG register_progid(
+    WCHAR const *clsid,
+    char const *progid,
+    char const *curver_progid,
+    char const *name,
+    char const *extra)
+{
+    LONG res;
+    HKEY progid_key;
+
+    res = RegCreateKeyExA(HKEY_CLASSES_ROOT, progid, 0,
+			  NULL, 0, KEY_READ | KEY_WRITE, NULL,
+			  &progid_key, NULL);
+    if (res != ERROR_SUCCESS) return res;
+
+    if (name) {
+	res = RegSetValueExA(progid_key, NULL, 0, REG_SZ,
+			     (CONST BYTE*)name, strlen(name) + 1);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (clsid) {
+	res = register_key_defvalueW(progid_key, clsid_keyname, clsid);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (curver_progid) {
+	res = register_key_defvalueA(progid_key, curver_keyname,
+				     curver_progid);
+	if (res != ERROR_SUCCESS) goto error_close_progid_key;
+    }
+
+    if (extra) {
+	HKEY extra_key;
+
+	res = RegCreateKeyExA(progid_key, extra, 0,
+			      NULL, 0, KEY_READ | KEY_WRITE, NULL,
+			      &extra_key, NULL);
+	if (res == ERROR_SUCCESS)
+	    RegCloseKey(extra_key);
+    }
+
+error_close_progid_key:
+    RegCloseKey(progid_key);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_key
+ */
+static LONG recursive_delete_key(HKEY key)
+{
+    LONG res;
+    WCHAR subkey_name[MAX_PATH];
+    DWORD cName;
+    HKEY subkey;
+
+    for (;;) {
+	cName = sizeof(subkey_name) / sizeof(WCHAR);
+	res = RegEnumKeyExW(key, 0, subkey_name, &cName,
+			    NULL, NULL, NULL, NULL);
+	if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) {
+	    res = ERROR_SUCCESS; /* presumably we're done enumerating */
+	    break;
+	}
+	res = RegOpenKeyExW(key, subkey_name, 0,
+			    KEY_READ | KEY_WRITE, &subkey);
+	if (res == ERROR_FILE_NOT_FOUND) continue;
+	if (res != ERROR_SUCCESS) break;
+
+	res = recursive_delete_key(subkey);
+	RegCloseKey(subkey);
+	if (res != ERROR_SUCCESS) break;
+    }
+
+    if (res == ERROR_SUCCESS) res = RegDeleteKeyW(key, 0);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_keyA
+ */
+static LONG recursive_delete_keyA(HKEY base, char const *name)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegOpenKeyExA(base, name, 0, KEY_READ | KEY_WRITE, &key);
+    if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
+    if (res != ERROR_SUCCESS) return res;
+    res = recursive_delete_key(key);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		recursive_delete_keyW
+ */
+static LONG recursive_delete_keyW(HKEY base, WCHAR const *name)
+{
+    LONG res;
+    HKEY key;
+
+    res = RegOpenKeyExW(base, name, 0, KEY_READ | KEY_WRITE, &key);
+    if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
+    if (res != ERROR_SUCCESS) return res;
+    res = recursive_delete_key(key);
+    RegCloseKey(key);
+    return res;
+}
+
+/***********************************************************************
+ *		coclass list
+ */
+static struct regsvr_coclass const coclass_list[] = {
+    {   &CLSID_DirectMusicSynth,
+	"DirectMusicSynth",
+	NULL,
+	"dmsynth.dll",
+	"Both",
+	"Microsoft.DirectMusicSynth.1",
+	"Microsoft.DirectMusicSynth",
+    },
+    {   &CLSID_DirectMusicSynthSink,
+	"DirectMusicSynthSink",
+	NULL,
+	"dmsynth.dll",
+	"Both",
+	"Microsoft.DirectMusicSynthSink.1",
+	"Microsoft.DirectMusicSynthSink"
+    },
+    { NULL }			/* list terminator */
+};
+
+/***********************************************************************
+ *		interface list
+ */
+
+static struct regsvr_interface const interface_list[] = {
+    { NULL }			/* list terminator */
+};
+
+/***********************************************************************
+ *		DllRegisterServer (DMSYNTH.3)
+ */
+HRESULT WINAPI DMSYNTH_DllRegisterServer(void)
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = register_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+	hr = register_interfaces(interface_list);
+    return hr;
+}
+
+/***********************************************************************
+ *		DllUnregisterServer (DMSYNTH.4)
+ */
+HRESULT WINAPI DMSYNTH_DllUnregisterServer(void)
+{
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = unregister_coclasses(coclass_list);
+    if (SUCCEEDED(hr))
+	hr = unregister_interfaces(interface_list);
+    return hr;
+}
diff --git a/dlls/dmusic/dmusic_synth.c b/dlls/dmsynth/synth.c
similarity index 64%
rename from dlls/dmusic/dmusic_synth.c
rename to dlls/dmsynth/synth.c
index 713952d..10a965c 100644
--- a/dlls/dmusic/dmusic_synth.c
+++ b/dlls/dmsynth/synth.c
@@ -1,6 +1,4 @@
-/* IDirectMusicSynth Implementation
- * IDirectMusicSynth8 Implementation
- * IDirectMusicSynthSink Implementation
+/* IDirectMusicSynth8 Implementation
  *
  * Copyright (C) 2003 Rok Mandeljc
  *
@@ -24,8 +22,9 @@
 #include "winuser.h"
 #include "wingdi.h"
 #include "wine/debug.h"
+#include "winnls.h"
 
-#include "dmusic_private.h"
+#include "dmsynth_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
 
@@ -115,7 +114,7 @@
 {
 	ICOM_THIS(IDirectMusicSynth8Impl,iface);
 
-	FIXME("(%p, FIXME, %p, %ld): stub\n", This/*, rt*/, pbBuffer, cbBuffer);
+	FIXME("(%p, %lli, %p, %ld): stub\n", This, rt, pbBuffer, cbBuffer);
 
 	return S_OK;
 }
@@ -133,8 +132,9 @@
 {
 	ICOM_THIS(IDirectMusicSynth8Impl,iface);
 
-	FIXME("(%p, %p): stub\n", This, pCaps);
-
+	TRACE("(%p, %p)\n", This, pCaps);
+	*pCaps = This->pCaps;
+	
 	return S_OK;
 }
 
@@ -151,7 +151,8 @@
 {
 	ICOM_THIS(IDirectMusicSynth8Impl,iface);
 
-	FIXME("(%p, %p): stub\n", This, ppClock);
+	TRACE("(%p, %p)\n", This, ppClock);
+	*ppClock = This->pLatencyClock;
 
 	return S_OK;
 }
@@ -160,7 +161,8 @@
 {
 	ICOM_THIS(IDirectMusicSynth8Impl,iface);
 
-	FIXME("(%p, %d): stub\n", This, fEnable);
+	TRACE("(%p, %d)\n", This, fEnable);
+	This->fActive = fEnable;
 
 	return S_OK;
 }
@@ -169,7 +171,8 @@
 {
 	ICOM_THIS(IDirectMusicSynth8Impl,iface);
 
-	FIXME("(%p, %p): stub\n", This, pSynthSink);
+	TRACE("(%p, %p)\n", This, pSynthSink);
+	This->pSynthSink = (IDirectMusicSynthSinkImpl*)pSynthSink;
 
 	return S_OK;
 }
@@ -178,16 +181,17 @@
 {
 	ICOM_THIS(IDirectMusicSynth8Impl,iface);
 
-	FIXME("(%p, %p, %ld, FIXME): stub\n", This, pBuffer, dwLength/*, llPosition*/);
+	FIXME("(%p, %p, %ld, %lli): stub\n", This, pBuffer, dwLength, llPosition);
 
 	return S_OK;
 }
 
 HRESULT WINAPI IDirectMusicSynth8Impl_SetChannelPriority (LPDIRECTMUSICSYNTH8 iface, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority)
 {
-	ICOM_THIS(IDirectMusicSynth8Impl,iface);
-
-	FIXME("(%p, %ld, %ld, %ld): stub\n", This, dwChannelGroup, dwChannel, dwPriority);
+	/*ICOM_THIS(IDirectMusicSynth8Impl,iface); */
+	
+	/* silenced because of too many messages - 1000 groups * 16 channels ;=) */
+	/*FIXME("(%p, %ld, %ld, %ld): stub\n", This, dwChannelGroup, dwChannel, dwPriority); */
 
 	return S_OK;
 }
@@ -224,7 +228,7 @@
 {
 	ICOM_THIS(IDirectMusicSynth8Impl,iface);
 
-	FIXME("(%p, FIXME, %ld, %ld, %ld, %ld, %li, %li, FIXME, FIXME, FIXME): stub\n", This/*, rt*/, dwVoiceId, dwChannelGroup, dwChannel, dwDLId, prPitch, vrVolume/*, stVoiceStart, stLoopStart, stLoopEnd*/);
+	FIXME("(%p, %lli, %ld, %ld, %ld, %ld, %li, %li,%lli, %lli, %lli): stub\n", This, rt, dwVoiceId, dwChannelGroup, dwChannel, dwDLId, prPitch, vrVolume, stVoiceStart, stLoopStart, stLoopEnd);
 
 	return S_OK;
 }
@@ -233,7 +237,7 @@
 {
 	ICOM_THIS(IDirectMusicSynth8Impl,iface);
 
-	FIXME("(%p, FIXME, %ld): stub\n", This/*, rt*/, dwVoiceId);
+	FIXME("(%p, %lli, %ld): stub\n", This, rt, dwVoiceId);
 
 	return S_OK;
 }
@@ -295,127 +299,40 @@
 	IDirectMusicSynth8Impl_AssignChannelToBuses
 };
 
-
-/* IDirectMusicSynthSink IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicSynthSinkImpl_QueryInterface (LPDIRECTMUSICSYNTHSINK iface, REFIID riid, LPVOID *ppobj)
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicSynth (LPCGUID lpcGUID, LPDIRECTMUSICSYNTH8* ppDMSynth, LPUNKNOWN pUnkOuter)
 {
-	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
+	IDirectMusicSynth8Impl *dmsynth;
+	
+	TRACE("(%p,%p,%p)\n", lpcGUID, ppDMSynth, pUnkOuter);
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicSynth) ||
+		IsEqualGUID (lpcGUID, &IID_IDirectMusicSynth8))	{
+		dmsynth = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSynth8Impl));
+		if (NULL == dmsynth) {
+			*ppDMSynth = (LPDIRECTMUSICSYNTH8) NULL;
+			return E_OUTOFMEMORY;
+		}
+		dmsynth->lpVtbl = &DirectMusicSynth8_Vtbl;
+		dmsynth->ref = 1;
+		/* fill in caps */
+		dmsynth->pCaps.dwSize = sizeof(DMUS_PORTCAPS);
+		dmsynth->pCaps.dwFlags = DMUS_PC_DLS | DMUS_PC_SOFTWARESYNTH | DMUS_PC_DIRECTSOUND | DMUS_PC_DLS2 | DMUS_PC_AUDIOPATH | DMUS_PC_WAVE;
+		dmsynth->pCaps.guidPort = CLSID_DirectMusicSynth;
+		dmsynth->pCaps.dwClass = DMUS_PC_OUTPUTCLASS;
+		dmsynth->pCaps.dwType = DMUS_PORT_WINMM_DRIVER;
+		dmsynth->pCaps.dwMemorySize = DMUS_PC_SYSTEMMEMORY;
+		dmsynth->pCaps.dwMaxChannelGroups = 1000;
+		dmsynth->pCaps.dwMaxVoices = 1000;
+		dmsynth->pCaps.dwMaxAudioChannels = -1;
+		dmsynth->pCaps.dwEffectFlags = DMUS_EFFECT_REVERB | DMUS_EFFECT_CHORUS | DMUS_EFFECT_DELAY;
+		MultiByteToWideChar (CP_ACP, 0, "Microsotf Synthesizer", -1, dmsynth->pCaps.wszDescription, sizeof(dmsynth->pCaps.wszDescription)/sizeof(WCHAR));
+		/* assign latency clock */
+		/*DMUSIC_CreateReferenceClock (&IID_IReferenceClock, (LPREFERENCECLOCK*)&This->pLatencyClock, NULL); */
 
-	if (IsEqualGUID(riid, &IID_IUnknown) || 
-	    IsEqualGUID(riid, &IID_IDirectMusicSynthSink))
-	{
-		IDirectMusicSynthSinkImpl_AddRef(iface);
-		*ppobj = This;
+		*ppDMSynth = (LPDIRECTMUSICSYNTH8) dmsynth;
 		return S_OK;
 	}
-	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	WARN("No interface found\n");
+	
 	return E_NOINTERFACE;
 }
-
-ULONG WINAPI IDirectMusicSynthSinkImpl_AddRef (LPDIRECTMUSICSYNTHSINK iface)
-{
-	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicSynthSinkImpl_Release (LPDIRECTMUSICSYNTHSINK iface)
-{
-	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicSynth Interface follow: */
-HRESULT WINAPI IDirectMusicSinkSynthImpl_Init (LPDIRECTMUSICSYNTHSINK iface, IDirectMusicSynth* pSynth)
-{
-	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pSynth);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSinkSynthImpl_SetMasterClock (LPDIRECTMUSICSYNTHSINK iface, IReferenceClock* pClock)
-{
-	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pClock);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSinkSynthImpl_GetLatencyClock (LPDIRECTMUSICSYNTHSINK iface, IReferenceClock** ppClock)
-{
-	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, ppClock);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSinkSynthImpl_Activate (LPDIRECTMUSICSYNTHSINK iface, BOOL fEnable)
-{
-	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
-
-	FIXME("(%p, %d): stub\n", This, fEnable);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSinkSynthImpl_SampleToRefTime (LPDIRECTMUSICSYNTHSINK iface, LONGLONG llSampleTime, REFERENCE_TIME* prfTime)
-{
-	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
-
-	FIXME("(%p, FIXME, %p): stub\n", This/*, llSampleTime*/, prfTime);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSinkSynthImpl_RefTimeToSample (LPDIRECTMUSICSYNTHSINK iface, REFERENCE_TIME rfTime, LONGLONG* pllSampleTime)
-{
-	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
-
-	FIXME("(%p, FIXME, %p): stub\n", This/*, rfTime*/, pllSampleTime );
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSinkSynthImpl_SetDirectSound (LPDIRECTMUSICSYNTHSINK iface, LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer)
-{
-	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
-
-	FIXME("(%p, %p, %p): stub\n", This, pDirectSound, pDirectSoundBuffer);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSinkSynthImpl_GetDesiredBufferSize (LPDIRECTMUSICSYNTHSINK iface, LPDWORD pdwBufferSizeInSamples)
-{
-	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pdwBufferSizeInSamples);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicSynthSink) DirectMusicSynthSink_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicSynthSinkImpl_QueryInterface,
-	IDirectMusicSynthSinkImpl_AddRef,
-	IDirectMusicSynthSinkImpl_Release,
-	IDirectMusicSinkSynthImpl_Init,
-	IDirectMusicSinkSynthImpl_SetMasterClock,
-	IDirectMusicSinkSynthImpl_GetLatencyClock,
-	IDirectMusicSinkSynthImpl_Activate,
-	IDirectMusicSinkSynthImpl_SampleToRefTime,
-	IDirectMusicSinkSynthImpl_RefTimeToSample,
-	IDirectMusicSinkSynthImpl_SetDirectSound,
-	IDirectMusicSinkSynthImpl_GetDesiredBufferSize
-};
diff --git a/dlls/dmsynth/synthsink.c b/dlls/dmsynth/synthsink.c
new file mode 100644
index 0000000..0432f65
--- /dev/null
+++ b/dlls/dmsynth/synthsink.c
@@ -0,0 +1,174 @@
+/* IDirectMusicSynthSink Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmsynth_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicSynthSink IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicSynthSinkImpl_QueryInterface (LPDIRECTMUSICSYNTHSINK iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || 
+	    IsEqualGUID(riid, &IID_IDirectMusicSynthSink))
+	{
+		IDirectMusicSynthSinkImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicSynthSinkImpl_AddRef (LPDIRECTMUSICSYNTHSINK iface)
+{
+	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicSynthSinkImpl_Release (LPDIRECTMUSICSYNTHSINK iface)
+{
+	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicSynth Interface follow: */
+HRESULT WINAPI IDirectMusicSynthSinkImpl_Init (LPDIRECTMUSICSYNTHSINK iface, IDirectMusicSynth* pSynth)
+{
+	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pSynth);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSynthSinkImpl_SetMasterClock (LPDIRECTMUSICSYNTHSINK iface, IReferenceClock* pClock)
+{
+	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pClock);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSynthSinkImpl_GetLatencyClock (LPDIRECTMUSICSYNTHSINK iface, IReferenceClock** ppClock)
+{
+	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, ppClock);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSynthSinkImpl_Activate (LPDIRECTMUSICSYNTHSINK iface, BOOL fEnable)
+{
+	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
+
+	FIXME("(%p, %d): stub\n", This, fEnable);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSynthSinkImpl_SampleToRefTime (LPDIRECTMUSICSYNTHSINK iface, LONGLONG llSampleTime, REFERENCE_TIME* prfTime)
+{
+	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
+
+	FIXME("(%p, %lli, %p): stub\n", This, llSampleTime, prfTime);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSynthSinkImpl_RefTimeToSample (LPDIRECTMUSICSYNTHSINK iface, REFERENCE_TIME rfTime, LONGLONG* pllSampleTime)
+{
+	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
+
+	FIXME("(%p, %lli, %p): stub\n", This, rfTime, pllSampleTime );
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSynthSinkImpl_SetDirectSound (LPDIRECTMUSICSYNTHSINK iface, LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer)
+{
+	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
+
+	FIXME("(%p, %p, %p): stub\n", This, pDirectSound, pDirectSoundBuffer);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicSynthSinkImpl_GetDesiredBufferSize (LPDIRECTMUSICSYNTHSINK iface, LPDWORD pdwBufferSizeInSamples)
+{
+	ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pdwBufferSizeInSamples);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicSynthSink) DirectMusicSynthSink_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicSynthSinkImpl_QueryInterface,
+	IDirectMusicSynthSinkImpl_AddRef,
+	IDirectMusicSynthSinkImpl_Release,
+	IDirectMusicSynthSinkImpl_Init,
+	IDirectMusicSynthSinkImpl_SetMasterClock,
+	IDirectMusicSynthSinkImpl_GetLatencyClock,
+	IDirectMusicSynthSinkImpl_Activate,
+	IDirectMusicSynthSinkImpl_SampleToRefTime,
+	IDirectMusicSynthSinkImpl_RefTimeToSample,
+	IDirectMusicSynthSinkImpl_SetDirectSound,
+	IDirectMusicSynthSinkImpl_GetDesiredBufferSize
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicSynthSink (LPCGUID lpcGUID, LPDIRECTMUSICSYNTHSINK* ppDMSynthSink, LPUNKNOWN pUnkOuter)
+{
+	IDirectMusicSynthSinkImpl *dmsink;
+	
+	TRACE("(%p,%p,%p)\n", lpcGUID, ppDMSynthSink, pUnkOuter);
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicSynthSink)) {
+		dmsink = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSynthSinkImpl));
+		if (NULL == dmsink) {
+			*ppDMSynthSink = (LPDIRECTMUSICSYNTHSINK) NULL;
+			return E_OUTOFMEMORY;
+		}
+		dmsink->lpVtbl = &DirectMusicSynthSink_Vtbl;
+		dmsink->ref = 1;
+		*ppDMSynthSink = (LPDIRECTMUSICSYNTHSINK) dmsink;
+		return S_OK;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;
+}
diff --git a/dlls/dmusic/Makefile.in b/dlls/dmusic/Makefile.in
index a103f6b..43adab8 100644
--- a/dlls/dmusic/Makefile.in
+++ b/dlls/dmusic/Makefile.in
@@ -3,26 +3,27 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = dmusic.dll
-IMPORTS   = dsound winmm ole32 user32 advapi32 kernel32
+IMPORTS   = winmm ole32 msacm32 dsound rpcrt4 user32 advapi32 kernel32
 EXTRALIBS = $(LIBUUID)
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
 
 C_SRCS = \
+	buffer.c \
+	clock.c \
+	collection.c \
 	dmusic.c \
-	dmusic_instrument.c \
-	dmusic_loader.c \
 	dmusic_main.c \
-	dmusic_misc.c \
-	dmusic_performance.c \
-	dmusic_plugins.c \
-	dmusic_port.c \
-	dmusic_segment.c \
-	dmusic_style.c \
-	dmusic_synth.c \
+	download.c \
+	downloadedinstrument.c \
 	helper.c \
-	regsvr.c
+	instrument.c \
+	object.c \
+	port.c \
+	portdownload.c \
+	regsvr.c \
+	thru.c
 
 RC_SRCS = version.rc
 
diff --git a/dlls/dmusic/buffer.c b/dlls/dmusic/buffer.c
new file mode 100644
index 0000000..952ded22
--- /dev/null
+++ b/dlls/dmusic/buffer.c
@@ -0,0 +1,225 @@
+/* IDirectMusicBuffer Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "config.h"
+
+#include "windef.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "winerror.h"
+#include "mmsystem.h"
+#include "winternl.h"
+#include "mmddk.h"
+#include "wine/windef16.h"
+#include "wine/winbase16.h"
+#include "wine/debug.h"
+#include "dsound.h"
+
+#include "dmusic_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicBuffer IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicBufferImpl_QueryInterface (LPDIRECTMUSICBUFFER iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicBufferImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicBuffer))
+	{
+		IDirectMusicBufferImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicBufferImpl_AddRef (LPDIRECTMUSICBUFFER iface)
+{
+	ICOM_THIS(IDirectMusicBufferImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicBufferImpl_Release (LPDIRECTMUSICBUFFER iface)
+{
+	ICOM_THIS(IDirectMusicBufferImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicBuffer Interface follow: */
+HRESULT WINAPI IDirectMusicBufferImpl_Flush (LPDIRECTMUSICBUFFER iface)
+{
+	ICOM_THIS(IDirectMusicBufferImpl,iface);
+
+	FIXME("(%p): stub\n", This);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicBufferImpl_TotalTime (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prtTime)
+{
+	ICOM_THIS(IDirectMusicBufferImpl,iface);
+	
+	FIXME("(%p, %p): stub\n", This, prtTime);
+	
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicBufferImpl_PackStructured (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD dwChannelMessage)
+{
+	ICOM_THIS(IDirectMusicBufferImpl,iface);
+
+	FIXME("(%p, %lli, %ld, %ld): stub\n", This, rt, dwChannelGroup, dwChannelMessage);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicBufferImpl_PackUnstructured (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD cb, LPBYTE lpb)
+{
+	ICOM_THIS(IDirectMusicBufferImpl,iface);
+
+	FIXME("(%p, %lli, %ld, %ld, %p): stub\n", This, rt, dwChannelGroup, cb, lpb);
+	
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicBufferImpl_ResetReadPtr (LPDIRECTMUSICBUFFER iface)
+{
+	ICOM_THIS(IDirectMusicBufferImpl,iface);
+
+	FIXME("(%p): stub\n", This);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicBufferImpl_GetNextEvent (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt, LPDWORD pdwChannelGroup, LPDWORD pdwLength, LPBYTE* ppData)
+{
+	ICOM_THIS(IDirectMusicBufferImpl,iface);
+
+	FIXME("(%p, %p, %p, %p, %p): stub\n", This, prt, pdwChannelGroup, pdwLength, ppData);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicBufferImpl_GetRawBufferPtr (LPDIRECTMUSICBUFFER iface, LPBYTE* ppData)
+{
+	ICOM_THIS(IDirectMusicBufferImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, ppData);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicBufferImpl_GetStartTime (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt)
+{
+	ICOM_THIS(IDirectMusicBufferImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, prt);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicBufferImpl_GetUsedBytes (LPDIRECTMUSICBUFFER iface, LPDWORD pcb)
+{
+	ICOM_THIS(IDirectMusicBufferImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pcb);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicBufferImpl_GetMaxBytes (LPDIRECTMUSICBUFFER iface, LPDWORD pcb)
+{
+	ICOM_THIS(IDirectMusicBufferImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pcb);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicBufferImpl_GetBufferFormat (LPDIRECTMUSICBUFFER iface, LPGUID pGuidFormat)
+{
+	ICOM_THIS(IDirectMusicBufferImpl,iface);
+
+	FIXME("(%p, %p): stub\n", This, pGuidFormat);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicBufferImpl_SetStartTime (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt)
+{
+	ICOM_THIS(IDirectMusicBufferImpl,iface);
+
+	FIXME("(%p, %lli): stub\n", This, rt);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicBufferImpl_SetUsedBytes (LPDIRECTMUSICBUFFER iface, DWORD cb)
+{
+	ICOM_THIS(IDirectMusicBufferImpl,iface);
+
+	FIXME("(%p, %ld): stub\n", This, cb);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicBuffer) DirectMusicBuffer_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicBufferImpl_QueryInterface,
+	IDirectMusicBufferImpl_AddRef,
+	IDirectMusicBufferImpl_Release,
+	IDirectMusicBufferImpl_Flush,
+	IDirectMusicBufferImpl_TotalTime,
+	IDirectMusicBufferImpl_PackStructured,
+	IDirectMusicBufferImpl_PackUnstructured,
+	IDirectMusicBufferImpl_ResetReadPtr,
+	IDirectMusicBufferImpl_GetNextEvent,
+	IDirectMusicBufferImpl_GetRawBufferPtr,
+	IDirectMusicBufferImpl_GetStartTime,
+	IDirectMusicBufferImpl_GetUsedBytes,
+	IDirectMusicBufferImpl_GetMaxBytes,
+	IDirectMusicBufferImpl_GetBufferFormat,
+	IDirectMusicBufferImpl_SetStartTime,
+	IDirectMusicBufferImpl_SetUsedBytes
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicBuffer (LPCGUID lpcGUID, LPDIRECTMUSICBUFFER* ppDMBuff, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicBuffer))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmusic/clock.c b/dlls/dmusic/clock.c
new file mode 100644
index 0000000..452e643
--- /dev/null
+++ b/dlls/dmusic/clock.c
@@ -0,0 +1,138 @@
+/* IReferenceClock Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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
+ * MERCHANTABILIY 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 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmusic_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IReferenceClock IUnknown parts follow: */
+HRESULT WINAPI IReferenceClockImpl_QueryInterface (IReferenceClock *iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IReferenceClockImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || 
+	    IsEqualGUID(riid, &IID_IReferenceClock))
+	{
+		IReferenceClockImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IReferenceClockImpl_AddRef (IReferenceClock *iface)
+{
+	ICOM_THIS(IReferenceClockImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IReferenceClockImpl_Release (IReferenceClock *iface)
+{
+	ICOM_THIS(IReferenceClockImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IReferenceClock Interface follow: */
+HRESULT WINAPI IReferenceClockImpl_GetTime (IReferenceClock *iface, REFERENCE_TIME* pTime)
+{
+	ICOM_THIS(IReferenceClockImpl,iface);
+
+	TRACE("(%p, %p)\n", This, pTime);
+	*pTime = This->rtTime;
+	
+	return S_OK;
+}
+
+HRESULT WINAPI IReferenceClockImpl_AdviseTime (IReferenceClock *iface, REFERENCE_TIME baseTime, REFERENCE_TIME streamTime, HANDLE hEvent, DWORD* pdwAdviseCookie)
+{
+	ICOM_THIS(IReferenceClockImpl,iface);
+
+	FIXME("(%p, %lli, %lli, %p, %p): stub\n", This, baseTime, streamTime, hEvent, pdwAdviseCookie);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IReferenceClockImpl_AdvisePeriodic (IReferenceClock *iface, REFERENCE_TIME startTime, REFERENCE_TIME periodTime, HANDLE hSemaphore, DWORD* pdwAdviseCookie)
+{
+	ICOM_THIS(IReferenceClockImpl,iface);
+
+	FIXME("(%p, %lli, %lli, %p, %p): stub\n", This, startTime, periodTime, hSemaphore, pdwAdviseCookie);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IReferenceClockImpl_Unadvise (IReferenceClock *iface, DWORD dwAdviseCookie)
+{
+	ICOM_THIS(IReferenceClockImpl,iface);
+
+	FIXME("(%p, %ld): stub\n", This, dwAdviseCookie);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IReferenceClock) ReferenceClock_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IReferenceClockImpl_QueryInterface,
+	IReferenceClockImpl_AddRef,
+	IReferenceClockImpl_Release,
+	IReferenceClockImpl_GetTime,
+	IReferenceClockImpl_AdviseTime,
+	IReferenceClockImpl_AdvisePeriodic,
+	IReferenceClockImpl_Unadvise
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateReferenceClock (LPCGUID lpcGUID, IReferenceClock** ppRC, LPUNKNOWN pUnkOuter)
+{
+	IReferenceClockImpl* clock;
+	
+	if (IsEqualGUID (lpcGUID, &IID_IReferenceClock))
+	{
+		clock = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IReferenceClockImpl));
+		if (NULL == clock) {
+			*ppRC = NULL;
+			return E_OUTOFMEMORY;
+		}
+		clock->lpVtbl = &ReferenceClock_Vtbl;
+		clock->ref = 1;
+		clock->rtTime = 0;
+		clock->pClockInfo.dwSize = sizeof (DMUS_CLOCKINFO);
+		
+		*ppRC = (IReferenceClock *) clock;
+		return S_OK;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmusic/collection.c b/dlls/dmusic/collection.c
new file mode 100644
index 0000000..39dd945
--- /dev/null
+++ b/dlls/dmusic/collection.c
@@ -0,0 +1,104 @@
+/* IDirectMusicCollection Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmusic_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicCollection IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicCollectionImpl_QueryInterface (LPDIRECTMUSICCOLLECTION iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicCollectionImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicCollection))
+	{
+		IDirectMusicCollectionImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicCollectionImpl_AddRef (LPDIRECTMUSICCOLLECTION iface)
+{
+	ICOM_THIS(IDirectMusicCollectionImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicCollectionImpl_Release (LPDIRECTMUSICCOLLECTION iface)
+{
+	ICOM_THIS(IDirectMusicCollectionImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicCollection Interface follow: */
+HRESULT WINAPI IDirectMusicCollectionImpl_GetInstrument (LPDIRECTMUSICCOLLECTION iface, DWORD dwPatch, IDirectMusicInstrument** ppInstrument)
+{
+	ICOM_THIS(IDirectMusicCollectionImpl,iface);
+
+	FIXME("(%p, %ld, %p): stub\n", This, dwPatch, ppInstrument);
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicCollectionImpl_EnumInstrument (LPDIRECTMUSICCOLLECTION iface, DWORD dwIndex, DWORD* pdwPatch, LPWSTR pwszName, DWORD dwNameLen)
+{
+	ICOM_THIS(IDirectMusicCollectionImpl,iface);
+
+	FIXME("(%p, %ld, %p, %p, %ld): stub\n", This, dwIndex, pdwPatch, pwszName, dwNameLen);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicCollection) DirectMusicCollection_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicCollectionImpl_QueryInterface,
+	IDirectMusicCollectionImpl_AddRef,
+	IDirectMusicCollectionImpl_Release,
+	IDirectMusicCollectionImpl_GetInstrument,
+	IDirectMusicCollectionImpl_EnumInstrument
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicCollection (LPCGUID lpcGUID, LPDIRECTMUSICCOLLECTION* ppDMColl, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicCollection))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmusic/dmusic.c b/dlls/dmusic/dmusic.c
index 09414a5..9674a82 100644
--- a/dlls/dmusic/dmusic.c
+++ b/dlls/dmusic/dmusic.c
@@ -1,8 +1,4 @@
-/* IDirectMusic Implementation
- * IDirectMusic8 Implementation
- * IDirectMusicDownload Implementation
- * IDirectMusicBuffer Implementation
- * IDirectMusicObject Implementation
+/* IDirectMusic8 Implementation
  *
  * Copyright (C) 2003 Rok Mandeljc
  *
@@ -21,8 +17,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-#include "config.h"
-
 #include "windef.h"
 #include "winbase.h"
 #include "winreg.h"
@@ -42,31 +36,6 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
 
-/* for ClassFactory */
-HRESULT WINAPI DMUSIC_CreateDirectMusic (LPCGUID lpcGUID, LPDIRECTMUSIC *ppDM, LPUNKNOWN pUnkOuter)
-{
-	IDirectMusic8Impl *dmusic;
-
-	TRACE("(%p,%p,%p)\n",lpcGUID, ppDM, pUnkOuter);
-	if (IsEqualGUID(lpcGUID, &IID_IDirectMusic) ||
-	    IsEqualGUID(lpcGUID, &IID_IDirectMusic2) ||
-	    IsEqualGUID(lpcGUID, &IID_IDirectMusic8)) {
-	  dmusic = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusic8Impl));
-	  if (NULL == dmusic) {
-	    *ppDM = (LPDIRECTMUSIC) NULL;
-	    return E_OUTOFMEMORY;
-	  }
-	  dmusic->lpVtbl = &DirectMusic8_Vtbl;
-	  dmusic->ref = 1;
-	  *ppDM = (LPDIRECTMUSIC) dmusic;
-	  return S_OK;
-	}
-	WARN("No interface found\n");
-	
-	return E_NOINTERFACE;
-}
-
-
 /* IDirectMusic8 IUnknown parts follow: */
 HRESULT WINAPI IDirectMusic8Impl_QueryInterface (LPDIRECTMUSIC8 iface, REFIID riid, LPVOID *ppobj)
 {
@@ -107,29 +76,24 @@
 HRESULT WINAPI IDirectMusic8Impl_EnumPort(LPDIRECTMUSIC8 iface, DWORD dwIndex, LPDMUS_PORTCAPS pPortCaps)
 {
 	ICOM_THIS(IDirectMusic8Impl,iface);
-	int numMIDI = midiOutGetNumDevs();
-	int numWAVE = waveOutGetNumDevs();
-	int i;
 	
 	TRACE("(%p, %ld, %p)\n", This, dwIndex, pPortCaps);
-	TRACE("1 software synth. + %i WAVE + %i MIDI available\n", numWAVE, numMIDI);
 	/* i guess the first port shown is always software synthesizer */
 	if (dwIndex == 0) 
 	{
+		IDirectMusicSynth8* synth;
 		TRACE("enumerating 'Microsoft Software Synthesizer' port\n");
-		pPortCaps->dwSize = sizeof(DMUS_PORTCAPS);
-		pPortCaps->dwFlags = DMUS_PC_DLS | DMUS_PC_SOFTWARESYNTH | DMUS_PC_DIRECTSOUND | DMUS_PC_DLS2 | DMUS_PC_AUDIOPATH | DMUS_PC_WAVE;
-		pPortCaps->guidPort = CLSID_DirectMusicSynth;
-		pPortCaps->dwClass = DMUS_PC_OUTPUTCLASS;
-		pPortCaps->dwType = DMUS_PORT_WINMM_DRIVER;
-		pPortCaps->dwMemorySize = DMUS_PC_SYSTEMMEMORY;
-		pPortCaps->dwMaxChannelGroups = 1000;
-		pPortCaps->dwMaxVoices = 1000;
-		pPortCaps->dwMaxAudioChannels = -1;
-		pPortCaps->dwEffectFlags = DMUS_EFFECT_REVERB | DMUS_EFFECT_CHORUS | DMUS_EFFECT_DELAY;
-		MultiByteToWideChar(CP_ACP, 0, "Microsotf Synthesizer", -1, pPortCaps->wszDescription, sizeof(pPortCaps->wszDescription)/sizeof(WCHAR));
+		CoCreateInstance (&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth8, (void**)&synth);
+		IDirectMusicSynth8_GetPortCaps (synth, pPortCaps);
+		IDirectMusicSynth8_Release (synth);
 		return S_OK;
 	}
+
+/* it seems that the rest of devices are obtained thru dmusic32.EnumLegacyDevices...*sigh*...which is undocumented*/
+#if 0
+	int numMIDI = midiOutGetNumDevs();
+	int numWAVE = waveOutGetNumDevs();
+	int i;
 	/* then return digital sound ports */
 	for (i = 1; i <= numWAVE; i++)
 	{
@@ -147,7 +111,7 @@
 		if (i == dwIndex)
 			FIXME("Found MIDI port, but *real* MIDI ports not supported yet\n");
 	}
-	
+#endif	
 	return S_FALSE;
 }
 
@@ -163,23 +127,26 @@
 HRESULT WINAPI IDirectMusic8Impl_CreatePort (LPDIRECTMUSIC8 iface, REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT* ppPort, LPUNKNOWN pUnkOuter)
 {
 	ICOM_THIS(IDirectMusic8Impl,iface);
-	int i, j;
+	int i/*, j*/;
 	DMUS_PORTCAPS PortCaps;
 	
 	TRACE("(%p, %s, %p, %p, %p)\n", This, debugstr_guid(rclsidPort), pPortParams, ppPort, pUnkOuter);
 	for (i = 0; S_FALSE != IDirectMusic8Impl_EnumPort(iface, i, &PortCaps); i++) {				
 		if (IsEqualGUID(rclsidPort, &PortCaps.guidPort)) {		
-			This->ports = HeapReAlloc(GetProcessHeap(), 0, This->ports, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
-			if (NULL == This->ports[This->nrofports]) {
+			This->ppPorts = HeapReAlloc(GetProcessHeap(), 0, This->ppPorts, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
+			if (NULL == This->ppPorts[This->nrofports]) {
 				*ppPort = (LPDIRECTMUSICPORT)NULL;
 				return E_OUTOFMEMORY;
 			}
-			This->ports[This->nrofports]->lpVtbl = &DirectMusicPort_Vtbl;
-			This->ports[This->nrofports]->ref = 0;
-			This->ports[This->nrofports]->active = FALSE;
-			This->ports[This->nrofports]->caps = &PortCaps;
-			This->ports[This->nrofports]->params = pPortParams; /* this one is here just because there's a funct. which retrieves it back */
-			
+			This->ppPorts[This->nrofports]->lpVtbl = &DirectMusicPort_Vtbl;
+			This->ppPorts[This->nrofports]->ref = 1;
+			This->ppPorts[This->nrofports]->fActive = FALSE;
+			This->ppPorts[This->nrofports]->pCaps = &PortCaps;
+			This->ppPorts[This->nrofports]->pParams = pPortParams; /* this one is here just because there's a funct. which retrieves it back */
+			This->ppPorts[This->nrofports]->pDirectSound = NULL;
+			DMUSIC_CreateReferenceClock (&IID_IReferenceClock, (IReferenceClock**)&This->ppPorts[This->nrofports]->pLatencyClock, NULL);
+
+#if 0
 			if (pPortParams->dwValidParams & DMUS_PORTPARAMS_CHANNELGROUPS) {
 				This->ports[This->nrofports]->nrofgroups = pPortParams->dwChannelGroups;
 				/* setting default priorities */			
@@ -203,9 +170,8 @@
 					This->ports[This->nrofports]->group[j].channel[15].priority = DAUD_CHAN16_DEF_VOICE_PRIORITY;
 				}
 			}
-
-			*ppPort = (LPDIRECTMUSICPORT) This->ports[This->nrofports];
-			IDirectMusicPortImpl_AddRef((LPDIRECTMUSICPORT) This->ports[This->nrofports]);
+#endif
+			*ppPort = (LPDIRECTMUSICPORT) This->ppPorts[This->nrofports];
 			This->nrofports++;
 			return S_OK;			
 		}
@@ -220,14 +186,18 @@
 
 	FIXME("(%p, %ld, %p): stub\n", This, dwIndex, lpClockInfo);
 
-	return S_OK;
+	return S_FALSE;
 }
 
 HRESULT WINAPI IDirectMusic8Impl_GetMasterClock (LPDIRECTMUSIC8 iface, LPGUID pguidClock, IReferenceClock** ppReferenceClock)
 {
 	ICOM_THIS(IDirectMusic8Impl,iface);
 
-	FIXME("(%p, %p, %p): stub\n", This, pguidClock, ppReferenceClock);
+	TRACE("(%p, %p, %p)\n", This, pguidClock, ppReferenceClock);
+	if (pguidClock)
+		*pguidClock = This->pMasterClock->pClockInfo.guidClock;
+	if(ppReferenceClock)
+		*ppReferenceClock = (IReferenceClock *)This->pMasterClock;
 
 	return S_OK;
 }
@@ -249,7 +219,7 @@
 	FIXME("(%p, %d): stub\n", This, fEnable);
 	for (i = 0; i < This->nrofports; i++)	
 	{
-		This->ports[i]->active = fEnable;
+		This->ppPorts[i]->fActive = fEnable;
 	}
 	
 	return S_OK;
@@ -316,311 +286,6 @@
 	IDirectMusic8Impl_SetExternalMasterClock
 };
 
-
-/* IDirectMusicDownload IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicDownloadImpl_QueryInterface (LPDIRECTMUSICDOWNLOAD iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicDownloadImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicDownload))
-	{
-		IDirectMusicDownloadImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicDownloadImpl_AddRef (LPDIRECTMUSICDOWNLOAD iface)
-{
-	ICOM_THIS(IDirectMusicDownloadImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicDownloadImpl_Release (LPDIRECTMUSICDOWNLOAD iface)
-{
-	ICOM_THIS(IDirectMusicDownloadImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicDownload Interface follow: */
-HRESULT WINAPI IDirectMusicDownloadImpl_GetBuffer (LPDIRECTMUSICDOWNLOAD iface, void** ppvBuffer, DWORD* pdwSize)
-{
-	ICOM_THIS(IDirectMusicDownloadImpl,iface);
-
-	FIXME("(%p,%p, %p): stub\n", This, ppvBuffer, pdwSize);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicDownload) DirectMusicDownload_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicDownloadImpl_QueryInterface,
-	IDirectMusicDownloadImpl_AddRef,
-	IDirectMusicDownloadImpl_Release,
-	IDirectMusicDownloadImpl_GetBuffer
-};
-
-
-/* IDirectMusicBuffer IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicBufferImpl_QueryInterface (LPDIRECTMUSICBUFFER iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicBufferImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicBuffer))
-	{
-		IDirectMusicBufferImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicBufferImpl_AddRef (LPDIRECTMUSICBUFFER iface)
-{
-	ICOM_THIS(IDirectMusicBufferImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicBufferImpl_Release (LPDIRECTMUSICBUFFER iface)
-{
-	ICOM_THIS(IDirectMusicBufferImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicBuffer Interface follow: */
-HRESULT WINAPI IDirectMusicBufferImpl_Flush (LPDIRECTMUSICBUFFER iface)
-{
-	ICOM_THIS(IDirectMusicBufferImpl,iface);
-
-	FIXME("(%p): stub\n", This);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicBufferImpl_TotalTime (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prtTime)
-{
-	ICOM_THIS(IDirectMusicBufferImpl,iface);
-	
-	FIXME("(%p, %p): stub\n", This, prtTime);
-	
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicBufferImpl_PackStructured (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD dwChannelMessage)
-{
-	ICOM_THIS(IDirectMusicBufferImpl,iface);
-
-	FIXME("(%p, FIXME, %ld, %ld): stub\n", This,/* rt,*/ dwChannelGroup, dwChannelMessage);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicBufferImpl_PackUnstructured (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD cb, LPBYTE lpb)
-{
-	ICOM_THIS(IDirectMusicBufferImpl,iface);
-
-	FIXME("(%p, FIXME, %ld, %ld, %p): stub\n", This,/* rt,*/ dwChannelGroup, cb, lpb);
-	
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicBufferImpl_ResetReadPtr (LPDIRECTMUSICBUFFER iface)
-{
-	ICOM_THIS(IDirectMusicBufferImpl,iface);
-
-	FIXME("(%p): stub\n", This);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicBufferImpl_GetNextEvent (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt, LPDWORD pdwChannelGroup, LPDWORD pdwLength, LPBYTE* ppData)
-{
-	ICOM_THIS(IDirectMusicBufferImpl,iface);
-
-	FIXME("(%p, %p, %p, %p, %p): stub\n", This, prt, pdwChannelGroup, pdwLength, ppData);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicBufferImpl_GetRawBufferPtr (LPDIRECTMUSICBUFFER iface, LPBYTE* ppData)
-{
-	ICOM_THIS(IDirectMusicBufferImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, ppData);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicBufferImpl_GetStartTime (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt)
-{
-	ICOM_THIS(IDirectMusicBufferImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, prt);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicBufferImpl_GetUsedBytes (LPDIRECTMUSICBUFFER iface, LPDWORD pcb)
-{
-	ICOM_THIS(IDirectMusicBufferImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pcb);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicBufferImpl_GetMaxBytes (LPDIRECTMUSICBUFFER iface, LPDWORD pcb)
-{
-	ICOM_THIS(IDirectMusicBufferImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pcb);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicBufferImpl_GetBufferFormat (LPDIRECTMUSICBUFFER iface, LPGUID pGuidFormat)
-{
-	ICOM_THIS(IDirectMusicBufferImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pGuidFormat);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicBufferImpl_SetStartTime (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt)
-{
-	ICOM_THIS(IDirectMusicBufferImpl,iface);
-
-	FIXME("(%p, FIXME): stub\n", This/*, rt*/);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicBufferImpl_SetUsedBytes (LPDIRECTMUSICBUFFER iface, DWORD cb)
-{
-	ICOM_THIS(IDirectMusicBufferImpl,iface);
-
-	FIXME("(%p, %ld): stub\n", This, cb);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicBuffer) DirectMusicBuffer_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicBufferImpl_QueryInterface,
-	IDirectMusicBufferImpl_AddRef,
-	IDirectMusicBufferImpl_Release,
-	IDirectMusicBufferImpl_Flush,
-	IDirectMusicBufferImpl_TotalTime,
-	IDirectMusicBufferImpl_PackStructured,
-	IDirectMusicBufferImpl_PackUnstructured,
-	IDirectMusicBufferImpl_ResetReadPtr,
-	IDirectMusicBufferImpl_GetNextEvent,
-	IDirectMusicBufferImpl_GetRawBufferPtr,
-	IDirectMusicBufferImpl_GetStartTime,
-	IDirectMusicBufferImpl_GetUsedBytes,
-	IDirectMusicBufferImpl_GetMaxBytes,
-	IDirectMusicBufferImpl_GetBufferFormat,
-	IDirectMusicBufferImpl_SetStartTime,
-	IDirectMusicBufferImpl_SetUsedBytes
-};
-
-
-/* IDirectMusicObject IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicObjectImpl_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicObjectImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicObject))
-	{
-		IDirectMusicObjectImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicObjectImpl_AddRef (LPDIRECTMUSICOBJECT iface)
-{
-	ICOM_THIS(IDirectMusicObjectImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicObjectImpl_Release (LPDIRECTMUSICOBJECT iface)
-{
-	ICOM_THIS(IDirectMusicObjectImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicObject Interface follow: */
-HRESULT WINAPI IDirectMusicObjectImpl_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
-{
-	ICOM_THIS(IDirectMusicObjectImpl,iface);
-
-	TRACE("(%p, %p)\n", This, pDesc);
-	pDesc = This->desc;
-	
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicObjectImpl_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
-{
-	ICOM_THIS(IDirectMusicObjectImpl,iface);
-
-	TRACE("(%p, %p)\n", This, pDesc);
-	This->desc = pDesc;
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicObjectImpl_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc)
-{
-	ICOM_THIS(IDirectMusicObjectImpl,iface);
-
-	FIXME("(%p, %p, %p): stub\n", This, pStream, pDesc);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicObject) DirectMusicObject_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicObjectImpl_QueryInterface,
-	IDirectMusicObjectImpl_AddRef,
-	IDirectMusicObjectImpl_Release,
-	IDirectMusicObjectImpl_GetDescriptor,
-	IDirectMusicObjectImpl_SetDescriptor,
-	IDirectMusicObjectImpl_ParseDescriptor
-};
-
-
 /* helper stuff */
 void register_waveport (LPGUID lpGUID, LPCSTR lpszDesc, LPCSTR lpszDrvName, LPVOID lpContext)
 {
@@ -638,3 +303,32 @@
 	pPortCaps->dwEffectFlags = DMUS_EFFECT_REVERB | DMUS_EFFECT_CHORUS | DMUS_EFFECT_DELAY;
 	MultiByteToWideChar (CP_ACP, 0, lpszDesc, -1, pPortCaps->wszDescription, sizeof(pPortCaps->wszDescription)/sizeof(WCHAR));
 }
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusic (LPCGUID lpcGUID, LPDIRECTMUSIC8 *ppDM, LPUNKNOWN pUnkOuter)
+{
+	IDirectMusic8Impl *dmusic;
+
+	TRACE("(%p,%p,%p)\n",lpcGUID, ppDM, pUnkOuter);
+	if (IsEqualGUID(lpcGUID, &IID_IDirectMusic) ||
+	    IsEqualGUID(lpcGUID, &IID_IDirectMusic2) ||
+	    IsEqualGUID(lpcGUID, &IID_IDirectMusic8)) {
+		dmusic = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusic8Impl));
+		if (NULL == dmusic) {
+			*ppDM = (LPDIRECTMUSIC8) NULL;
+			return E_OUTOFMEMORY;
+		}
+		dmusic->lpVtbl = &DirectMusic8_Vtbl;
+		dmusic->ref = 1;
+		dmusic->pMasterClock = NULL;
+		dmusic->ppPorts = NULL;
+		dmusic->nrofports = 0;
+		DMUSIC_CreateReferenceClock (&IID_IReferenceClock, (IReferenceClock**)&dmusic->pMasterClock, NULL);
+		
+		*ppDM = (LPDIRECTMUSIC8) dmusic;
+		return S_OK;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;
+}
diff --git a/dlls/dmusic/dmusic_instrument.c b/dlls/dmusic/dmusic_instrument.c
deleted file mode 100644
index 6559400..0000000
--- a/dlls/dmusic/dmusic_instrument.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/* IDirectMusicInstrument Implementation
- * IDirectMusicDownloadedInstrument Implementation
- * IDirectMusicCollection Implementation
- *
- * Copyright (C) 2003 Rok Mandeljc
- *
- * 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 Library 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 "windef.h"
-#include "winbase.h"
-#include "winuser.h"
-#include "wingdi.h"
-#include "wine/debug.h"
-
-#include "dmusic_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
-
-/* IDirectMusicInstrument IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicInstrumentImpl_QueryInterface (LPDIRECTMUSICINSTRUMENT iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicInstrumentImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicInstrument))
-	{
-		IDirectMusicInstrumentImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicInstrumentImpl_AddRef (LPDIRECTMUSICINSTRUMENT iface)
-{
-	ICOM_THIS(IDirectMusicInstrumentImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicInstrumentImpl_Release (LPDIRECTMUSICINSTRUMENT iface)
-{
-	ICOM_THIS(IDirectMusicInstrumentImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicInstrument Interface follow: */
-HRESULT WINAPI IDirectMusicInstrumentImpl_GetPatch (LPDIRECTMUSICINSTRUMENT iface, DWORD* pdwPatch)
-{
-	ICOM_THIS(IDirectMusicInstrumentImpl,iface);
-
-	TRACE("(%p, %p)\n", This, pdwPatch);
-	*pdwPatch = This->patch;
-	
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicInstrumentImpl_SetPatch (LPDIRECTMUSICINSTRUMENT iface, DWORD dwPatch)
-{
-	ICOM_THIS(IDirectMusicInstrumentImpl,iface);
-
-	TRACE("(%p, %ld)\n", This, dwPatch);
-	This->patch = dwPatch;
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicInstrument) DirectMusicInstrument_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicInstrumentImpl_QueryInterface,
-	IDirectMusicInstrumentImpl_AddRef,
-	IDirectMusicInstrumentImpl_Release,
-	IDirectMusicInstrumentImpl_GetPatch,
-	IDirectMusicInstrumentImpl_SetPatch
-};
-
-
-/* IDirectMusicDownloadedInstrument IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicDownloadedInstrumentImpl_QueryInterface (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicDownloadedInstrumentImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicDownloadedInstrument))
-	{
-		IDirectMusicDownloadedInstrumentImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_AddRef (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface)
-{
-	ICOM_THIS(IDirectMusicDownloadedInstrumentImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_Release (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface)
-{
-	ICOM_THIS(IDirectMusicDownloadedInstrumentImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicDownloadedInstrument Interface follow: */
-/* none at this time */
-
-ICOM_VTABLE(IDirectMusicDownloadedInstrument) DirectMusicDownloadedInstrument_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicDownloadedInstrumentImpl_QueryInterface,
-	IDirectMusicDownloadedInstrumentImpl_AddRef,
-	IDirectMusicDownloadedInstrumentImpl_Release
-};
-
-
-/* IDirectMusicCollection IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicCollectionImpl_QueryInterface (LPDIRECTMUSICCOLLECTION iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicCollectionImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicCollection))
-	{
-		IDirectMusicCollectionImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicCollectionImpl_AddRef (LPDIRECTMUSICCOLLECTION iface)
-{
-	ICOM_THIS(IDirectMusicCollectionImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicCollectionImpl_Release (LPDIRECTMUSICCOLLECTION iface)
-{
-	ICOM_THIS(IDirectMusicCollectionImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicCollection Interface follow: */
-HRESULT WINAPI IDirectMusicCollectionImpl_GetInstrument (LPDIRECTMUSICCOLLECTION iface, DWORD dwPatch, IDirectMusicInstrument** ppInstrument)
-{
-	ICOM_THIS(IDirectMusicCollectionImpl,iface);
-
-	FIXME("(%p, %ld, %p): stub\n", This, dwPatch, ppInstrument);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicCollectionImpl_EnumInstrument (LPDIRECTMUSICCOLLECTION iface, DWORD dwIndex, DWORD* pdwPatch, LPWSTR pwszName, DWORD dwNameLen)
-{
-	ICOM_THIS(IDirectMusicCollectionImpl,iface);
-
-	FIXME("(%p, %ld, %p, %p, %ld): stub\n", This, dwIndex, pdwPatch, pwszName, dwNameLen);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicCollection) DirectMusicCollection_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicCollectionImpl_QueryInterface,
-	IDirectMusicCollectionImpl_AddRef,
-	IDirectMusicCollectionImpl_Release,
-	IDirectMusicCollectionImpl_GetInstrument,
-	IDirectMusicCollectionImpl_EnumInstrument
-};
diff --git a/dlls/dmusic/dmusic_main.c b/dlls/dmusic/dmusic_main.c
index ba9aa25..53614bd 100644
--- a/dlls/dmusic/dmusic_main.c
+++ b/dlls/dmusic/dmusic_main.c
@@ -61,19 +61,30 @@
 	ICOM_THIS(IClassFactoryImpl,iface);
 
 	TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
-	if (IsEqualGUID (&IID_IDirectMusic, riid) ||
-	    IsEqualGUID (&IID_IDirectMusic2, riid) ||
-	    IsEqualGUID (&IID_IDirectMusic8, riid)) {
-	  return DMUSIC_CreateDirectMusic(riid, (LPDIRECTMUSIC*) ppobj, pOuter);
-	}
-	if (IsEqualGUID (&IID_IDirectMusicPerformance, riid) ||
-	    IsEqualGUID (&IID_IDirectMusicPerformance8, riid)) {
-	  return DMUSIC_CreateDirectMusicPerformance8(riid, (LPDIRECTMUSICPERFORMANCE8*) ppobj, pOuter);
-
-	}
-	if (IsEqualGUID (&IID_IDirectMusicLoader, riid) ||
-	    IsEqualGUID (&IID_IDirectMusicLoader8, riid)) {
-	  return DMUSIC_CreateDirectMusicLoader8(riid, (LPDIRECTMUSICLOADER8*) ppobj, pOuter);
+	if (IsEqualGUID (riid, &IID_IDirectMusic) ||
+	    IsEqualGUID (riid, &IID_IDirectMusic2) ||
+	    IsEqualGUID (riid, &IID_IDirectMusic8)) {
+	  return DMUSIC_CreateDirectMusic (riid, (LPDIRECTMUSIC8*) ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicBuffer)) {
+		return DMUSIC_CreateDirectMusicBuffer (riid, (LPDIRECTMUSICBUFFER*)ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicInstrument)) {
+		return DMUSIC_CreateDirectMusicInstrument (riid, (LPDIRECTMUSICINSTRUMENT*)ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicDownloadedInstrument)) {
+		return DMUSIC_CreateDirectMusicDownloadedInstrument (riid, (LPDIRECTMUSICDOWNLOADEDINSTRUMENT*)ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicCollection)) {
+		return DMUSIC_CreateDirectMusicCollection (riid, (LPDIRECTMUSICCOLLECTION*)ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicDownload)) {
+		return DMUSIC_CreateDirectMusicDownload (riid, (LPDIRECTMUSICDOWNLOAD*)ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicPortDownload)) {
+		return DMUSIC_CreateDirectMusicPortDownload (riid, (LPDIRECTMUSICPORTDOWNLOAD*)ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicPort)) {
+		return DMUSIC_CreateDirectMusicPort (riid, (LPDIRECTMUSICPORT*)ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicThru)) {
+		return DMUSIC_CreateDirectMusicThru (riid, (LPDIRECTMUSICTHRU*)ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IDirectMusicObject)) {
+		return DMUSIC_CreateDirectMusicObject (riid, (LPDIRECTMUSICOBJECT*)ppobj, pOuter);
+	} else if (IsEqualGUID (riid, &IID_IReferenceClock)) {
+		return DMUSIC_CreateReferenceClock (riid, (IReferenceClock**)ppobj, pOuter);
 	}
 	
 	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
diff --git a/dlls/dmusic/dmusic_misc.c b/dlls/dmusic/dmusic_misc.c
deleted file mode 100644
index fed87b5..0000000
--- a/dlls/dmusic/dmusic_misc.c
+++ /dev/null
@@ -1,1026 +0,0 @@
-/* IReferenceClock Implementation
- * IDirectMusicThru Implementation
- * IDirectMusicAudioPath Implementation
- * IDirectMusicBand Implementation
- * IDirectMusicSong Implementation
- * IDirectMusicChordMap Implementation
- * IDirectMusicComposer
- * IDirectMusicContainer
- * IDirectMusicGraph
- * IDirectMusicScript
- *
- * Copyright (C) 2003 Rok Mandeljc
- *
- * 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 Library 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 "windef.h"
-#include "winbase.h"
-#include "winuser.h"
-#include "wingdi.h"
-#include "wine/debug.h"
-
-#include "dmusic_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
-
-/* IReferenceClock IUnknown parts follow: */
-HRESULT WINAPI IReferenceClockImpl_QueryInterface (IReferenceClock *iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IReferenceClockImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || 
-	    IsEqualGUID(riid, &IID_IReferenceClock))
-	{
-		IReferenceClockImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IReferenceClockImpl_AddRef (IReferenceClock *iface)
-{
-	ICOM_THIS(IReferenceClockImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IReferenceClockImpl_Release (IReferenceClock *iface)
-{
-	ICOM_THIS(IReferenceClockImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IReferenceClock Interface follow: */
-HRESULT WINAPI IReferenceClockImpl_GetTime (IReferenceClock *iface, REFERENCE_TIME* pTime)
-{
-	ICOM_THIS(IReferenceClockImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pTime);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IReferenceClockImpl_AdviseTime (IReferenceClock *iface, REFERENCE_TIME baseTime, REFERENCE_TIME streamTime, HANDLE hEvent, DWORD* pdwAdviseCookie)
-{
-	ICOM_THIS(IReferenceClockImpl,iface);
-
-	FIXME("(%p, FIXME, FIXME, %p, %p): stub\n", This,/* baseTime, streamTime,*/ hEvent, pdwAdviseCookie);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IReferenceClockImpl_AdvisePeriodic (IReferenceClock *iface, REFERENCE_TIME startTime, REFERENCE_TIME periodTime, HANDLE hSemaphore, DWORD* pdwAdviseCookie)
-{
-	ICOM_THIS(IReferenceClockImpl,iface);
-
-	FIXME("(%p, FIXME, FIXME, %p, %p): stub\n", This,/* startTime, periodTime,*/ hSemaphore, pdwAdviseCookie);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IReferenceClockImpl_Unadvise (IReferenceClock *iface, DWORD dwAdviseCookie)
-{
-	ICOM_THIS(IReferenceClockImpl,iface);
-
-	FIXME("(%p, %ld): stub\n", This, dwAdviseCookie);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IReferenceClock) ReferenceClock_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IReferenceClockImpl_QueryInterface,
-	IReferenceClockImpl_AddRef,
-	IReferenceClockImpl_Release,
-	IReferenceClockImpl_GetTime,
-	IReferenceClockImpl_AdviseTime,
-	IReferenceClockImpl_AdvisePeriodic,
-	IReferenceClockImpl_Unadvise
-};
-
-
-/* IDirectMusicThru IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicThruImpl_QueryInterface (LPDIRECTMUSICTHRU iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicThruImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || 
-	    IsEqualGUID(riid, &IID_IDirectMusicThru))
-	{
-		IDirectMusicThruImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicThruImpl_AddRef (LPDIRECTMUSICTHRU iface)
-{
-	ICOM_THIS(IDirectMusicThruImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicThruImpl_Release (LPDIRECTMUSICTHRU iface)
-{
-	ICOM_THIS(IDirectMusicThruImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicThru Interface follow: */
-HRESULT WINAPI IDirectMusicThruImpl_ThruChannel (LPDIRECTMUSICTHRU iface, DWORD dwSourceChannelGroup, DWORD dwSourceChannel, DWORD dwDestinationChannelGroup, DWORD dwDestinationChannel, LPDIRECTMUSICPORT pDestinationPort)
-{
-	ICOM_THIS(IDirectMusicThruImpl,iface);
-
-	FIXME("(%p, %ld, %ld, %ld, %ld, %p): stub\n", This, dwSourceChannelGroup, dwSourceChannel, dwDestinationChannelGroup, dwDestinationChannel, pDestinationPort);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicThru) DirectMusicThru_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicThruImpl_QueryInterface,
-	IDirectMusicThruImpl_AddRef,
-	IDirectMusicThruImpl_Release,
-	IDirectMusicThruImpl_ThruChannel
-};
-
-
-/* IDirectMusicAudioPath IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicAudioPathImpl_QueryInterface (LPDIRECTMUSICAUDIOPATH iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicAudioPathImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || 
-	    IsEqualGUID(riid, &IID_IDirectMusicAudioPath))
-	{
-		IDirectMusicAudioPathImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicAudioPathImpl_AddRef (LPDIRECTMUSICAUDIOPATH iface)
-{
-	ICOM_THIS(IDirectMusicAudioPathImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicAudioPathImpl_Release (LPDIRECTMUSICAUDIOPATH iface)
-{
-	ICOM_THIS(IDirectMusicAudioPathImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicAudioPath Interface follow: */
-HRESULT WINAPI IDirectMusicAudioPathImpl_GetObjectInPath (LPDIRECTMUSICAUDIOPATH iface, DWORD dwPChannel, DWORD dwStage, DWORD dwBuffer, REFGUID guidObject, WORD dwIndex, REFGUID iidInterface, void** ppObject)
-{
-	ICOM_THIS(IDirectMusicAudioPathImpl,iface);
-
-	FIXME("(%p, %ld, %ld, %ld, %s, %d, %s, %p): stub\n", This, dwPChannel, dwStage, dwBuffer, debugstr_guid(guidObject), dwIndex, debugstr_guid(iidInterface), ppObject);
-
-	switch (dwStage) {
-	case DMUS_PATH_BUFFER:
-	  {
-	    if (IsEqualGUID(iidInterface,&IID_IDirectSoundBuffer8)) {
-	      IDirectSoundBuffer8_QueryInterface(This->buffer, &IID_IDirectSoundBuffer8, ppObject);
-	      TRACE("returning %p\n",*ppObject);
-	      return S_OK;
-	    } else if (IsEqualGUID(iidInterface,&IID_IDirectSound3DBuffer)) {
-	      IDirectSoundBuffer8_QueryInterface(This->buffer, &IID_IDirectSound3DBuffer, ppObject);
-	      TRACE("returning %p\n",*ppObject);
-	      return S_OK;
-	    } else {
-	      FIXME("Bad iid\n");
-	    }
-	  }
-	  break;
-
-	case DMUS_PATH_PRIMARY_BUFFER: {
-	  if (IsEqualGUID(iidInterface,&IID_IDirectSound3DListener)) {
-	    IDirectSoundBuffer8_QueryInterface(This->primary, &IID_IDirectSound3DListener, ppObject);
-	    return S_OK;
-	  }else {
-	    FIXME("bad iid...\n");
-	  }
-	}
-	break;
-
-	case DMUS_PATH_AUDIOPATH_GRAPH:
-	  {
-	    if (IsEqualGUID(iidInterface, &IID_IDirectMusicGraph)) {
-	      if (NULL == This->toolGraph) {
-		IDirectMusicGraphImpl* pGraph;
-		pGraph = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicGraphImpl));		
-		pGraph->lpVtbl = &DirectMusicGraph_Vtbl;
-		pGraph->ref = 1;
-		This->toolGraph = (IDirectMusicGraph*) pGraph;
-	      }
-	      *ppObject = (LPDIRECTMUSICGRAPH) This->toolGraph; 
-	      IDirectMusicGraphImpl_AddRef((LPDIRECTMUSICGRAPH) *ppObject);
-	      return S_OK;
-	    }
-	  }
-	  break;
-
-	case DMUS_PATH_AUDIOPATH_TOOL:
-	  {
-	    /* TODO */
-	  }
-	  break;
-
-	case DMUS_PATH_PERFORMANCE:
-	  {
-	    /* TODO check wanted GUID */
-	    *ppObject = (LPDIRECTMUSICPERFORMANCE8) This->perfo; 
-	    IDirectMusicPerformance8Impl_AddRef((LPDIRECTMUSICPERFORMANCE8) *ppObject);
-	    return S_OK;
-	  }
-	  break;
-
-	case DMUS_PATH_PERFORMANCE_GRAPH:
-	  {
-	    IDirectMusicGraph* pPerfoGraph = NULL; 
-	    IDirectMusicPerformance8Impl_GetGraph((LPDIRECTMUSICPERFORMANCE8) This->perfo, &pPerfoGraph);
-	    if (NULL == pPerfoGraph) {
-	      IDirectMusicGraphImpl* pGraph = NULL; 
-	      pGraph = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicGraphImpl));		
-	      pGraph->lpVtbl = &DirectMusicGraph_Vtbl;
-	      pGraph->ref = 1;
-	      IDirectMusicPerformance8Impl_SetGraph((LPDIRECTMUSICPERFORMANCE8) This->perfo, (IDirectMusicGraph*) pGraph);
-	      /* we need release as SetGraph do an AddRef */
-	      IDirectMusicGraphImpl_Release((LPDIRECTMUSICGRAPH) pGraph);
-	      pPerfoGraph = (LPDIRECTMUSICGRAPH) pGraph;
-	    }
-	    *ppObject = (LPDIRECTMUSICGRAPH) pPerfoGraph; 
-	    return S_OK;
-	  }
-	  break;
-
-	case DMUS_PATH_PERFORMANCE_TOOL:
-	default:
-	  break;
-	}
-
-	*ppObject = NULL;
-	return E_INVALIDARG;
-}
-
-HRESULT WINAPI IDirectMusicAudioPathImpl_Activate (LPDIRECTMUSICAUDIOPATH iface, BOOL fActivate)
-{
-	ICOM_THIS(IDirectMusicAudioPathImpl,iface);
-
-	FIXME("(%p, %d): stub\n", This, fActivate);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicAudioPathImpl_SetVolume (LPDIRECTMUSICAUDIOPATH iface, long lVolume, DWORD dwDuration)
-{
-	ICOM_THIS(IDirectMusicAudioPathImpl,iface);
-
-	FIXME("(%p, %li, %ld): stub\n", This, lVolume, dwDuration);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicAudioPathImpl_ConvertPChannel (LPDIRECTMUSICAUDIOPATH iface, DWORD dwPChannelIn, DWORD* pdwPChannelOut)
-{
-	ICOM_THIS(IDirectMusicAudioPathImpl,iface);
-
-	FIXME("(%p, %ld, %p): stub\n", This, dwPChannelIn, pdwPChannelOut);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicAudioPath) DirectMusicAudioPath_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicAudioPathImpl_QueryInterface,
-	IDirectMusicAudioPathImpl_AddRef,
-	IDirectMusicAudioPathImpl_Release,
-	IDirectMusicAudioPathImpl_GetObjectInPath,
-	IDirectMusicAudioPathImpl_Activate,
-	IDirectMusicAudioPathImpl_SetVolume,
-	IDirectMusicAudioPathImpl_ConvertPChannel
-};
-
-
-/* IDirectMusicBand IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicBandImpl_QueryInterface (LPDIRECTMUSICBAND iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicBandImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || 
-	    IsEqualGUID(riid, &IID_IDirectMusicBand))
-	{
-		IDirectMusicBandImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicBandImpl_AddRef (LPDIRECTMUSICBAND iface)
-{
-	ICOM_THIS(IDirectMusicBandImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicBandImpl_Release (LPDIRECTMUSICBAND iface)
-{
-	ICOM_THIS(IDirectMusicBandImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicBand Interface follow: */
-HRESULT WINAPI IDirectMusicBandImpl_CreateSegment (LPDIRECTMUSICBAND iface, IDirectMusicSegment** ppSegment)
-{
-	ICOM_THIS(IDirectMusicBandImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, ppSegment);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicBandImpl_Download (LPDIRECTMUSICBAND iface, IDirectMusicPerformance* pPerformance)
-{
-	ICOM_THIS(IDirectMusicBandImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pPerformance);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicBandImpl_Unload (LPDIRECTMUSICBAND iface, IDirectMusicPerformance* pPerformance)
-{
-	ICOM_THIS(IDirectMusicBandImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pPerformance);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicBand) DirectMusicBand_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicBandImpl_QueryInterface,
-	IDirectMusicBandImpl_AddRef,
-	IDirectMusicBandImpl_Release,
-	IDirectMusicBandImpl_CreateSegment,
-	IDirectMusicBandImpl_Download,
-	IDirectMusicBandImpl_Unload
-};
-
-
-/* IDirectMusicSong IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicSongImpl_QueryInterface (LPDIRECTMUSICSONG iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicSongImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || 
-	    IsEqualGUID(riid, &IID_IDirectMusicSong))
-	{
-		IDirectMusicSongImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicSongImpl_AddRef (LPDIRECTMUSICSONG iface)
-{
-	ICOM_THIS(IDirectMusicSongImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicSongImpl_Release (LPDIRECTMUSICSONG iface)
-{
-	ICOM_THIS(IDirectMusicSongImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicSong Interface follow: */
-HRESULT WINAPI IDirectMusicSongImpl_Compose (LPDIRECTMUSICSONG iface)
-{
-	ICOM_THIS(IDirectMusicSongImpl,iface);
-
-	FIXME("(%p): stub\n", This);
-	
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSongImpl_GetParam (LPDIRECTMUSICSONG iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam)
-{
-	ICOM_THIS(IDirectMusicSongImpl,iface);
-
-	FIXME("(%p, %s, %ld, %ld, %ld, %p, %p): stub\n", This, debugstr_guid(rguidType), dwGroupBits, dwIndex, mtTime, pmtNext, pParam);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSongImpl_GetSegment (LPDIRECTMUSICSONG iface, WCHAR* pwzName, IDirectMusicSegment** ppSegment)
-{
-	ICOM_THIS(IDirectMusicSongImpl,iface);
-
-	FIXME("(%p, %p, %p): stub\n", This, pwzName, ppSegment);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSongImpl_GetAudioPathConfig (LPDIRECTMUSICSONG iface, IUnknown** ppAudioPathConfig)
-{
-	ICOM_THIS(IDirectMusicSongImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, ppAudioPathConfig);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSongImpl_Download (LPDIRECTMUSICSONG iface, IUnknown* pAudioPath)
-{
-	ICOM_THIS(IDirectMusicSongImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pAudioPath);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSongImpl_Unload (LPDIRECTMUSICSONG iface, IUnknown* pAudioPath)
-{
-	ICOM_THIS(IDirectMusicSongImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pAudioPath);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicSongImpl_EnumSegment (LPDIRECTMUSICSONG iface, DWORD dwIndex, IDirectMusicSegment** ppSegment)
-{
-	ICOM_THIS(IDirectMusicSongImpl,iface);
-
-	FIXME("(%p, %ld, %p): stub\n", This, dwIndex, ppSegment);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicSong) DirectMusicSong_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicSongImpl_QueryInterface,
-	IDirectMusicSongImpl_AddRef,
-	IDirectMusicSongImpl_Release,
-	IDirectMusicSongImpl_Compose,
-	IDirectMusicSongImpl_GetParam,
-	IDirectMusicSongImpl_GetSegment,
-	IDirectMusicSongImpl_GetAudioPathConfig,
-	IDirectMusicSongImpl_Download,
-	IDirectMusicSongImpl_Unload,
-	IDirectMusicSongImpl_EnumSegment
-};
-
-
-/* IDirectMusicChordMap IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicChordMapImpl_QueryInterface (LPDIRECTMUSICCHORDMAP iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicChordMapImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || 
-	    IsEqualGUID(riid, &IID_IDirectMusicChordMap))
-	{
-		IDirectMusicChordMapImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicChordMapImpl_AddRef (LPDIRECTMUSICCHORDMAP iface)
-{
-	ICOM_THIS(IDirectMusicChordMapImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicChordMapImpl_Release (LPDIRECTMUSICCHORDMAP iface)
-{
-	ICOM_THIS(IDirectMusicChordMapImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicChordMap Interface follow: */
-HRESULT WINAPI IDirectMusicChordMapImpl_GetScale (LPDIRECTMUSICCHORDMAP iface, DWORD* pdwScale)
-{
-	ICOM_THIS(IDirectMusicChordMapImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pdwScale);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicChordMap) DirectMusicChordMap_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicChordMapImpl_QueryInterface,
-	IDirectMusicChordMapImpl_AddRef,
-	IDirectMusicChordMapImpl_Release,
-	IDirectMusicChordMapImpl_GetScale
-};
-
-
-/* IDirectMusicComposer IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicComposerImpl_QueryInterface (LPDIRECTMUSICCOMPOSER iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicComposerImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || 
-	    IsEqualGUID(riid, &IID_IDirectMusicComposer))
-	{
-		IDirectMusicComposerImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicComposerImpl_AddRef (LPDIRECTMUSICCOMPOSER iface)
-{
-	ICOM_THIS(IDirectMusicComposerImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicComposerImpl_Release (LPDIRECTMUSICCOMPOSER iface)
-{
-	ICOM_THIS(IDirectMusicComposerImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicComposer Interface follow: */
-HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromTemplate (LPDIRECTMUSICCOMPOSER iface, IDirectMusicStyle* pStyle, IDirectMusicSegment* pTemplate, WORD wActivity, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppSegment)
-{
-	ICOM_THIS(IDirectMusicComposerImpl,iface);
-
-	FIXME("(%p, %p, %p, %d, %p, %p): stub\n", This, pStyle, pTemplate, wActivity, pChordMap, ppSegment);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromShape (LPDIRECTMUSICCOMPOSER iface, IDirectMusicStyle* pStyle, WORD wNumMeasures, WORD wShape, WORD wActivity, BOOL fIntro, BOOL fEnd, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppSegment)
-{
-	ICOM_THIS(IDirectMusicComposerImpl,iface);
-
-	FIXME("(%p, %p, %d, %d, %d, %d, %d, %p, %p): stub\n", This, pStyle, wNumMeasures, wShape, wActivity, fIntro, fEnd, pChordMap, ppSegment);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicComposerImpl_ComposeTransition (LPDIRECTMUSICCOMPOSER iface, IDirectMusicSegment* pFromSeg, IDirectMusicSegment* pToSeg, MUSIC_TIME mtTime, WORD wCommand, DWORD dwFlags, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppTransSeg)
-{
-	ICOM_THIS(IDirectMusicComposerImpl,iface);
-
-	FIXME("(%p, %p, %p, %ld, %d, %ld, %p, %p): stub\n", This, pFromSeg, pToSeg, mtTime, wCommand, dwFlags, pChordMap, ppTransSeg);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicComposerImpl_AutoTransition (LPDIRECTMUSICCOMPOSER iface, IDirectMusicPerformance* pPerformance, IDirectMusicSegment* pToSeg, WORD wCommand, DWORD dwFlags, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppTransSeg, IDirectMusicSegmentState** ppToSegState, IDirectMusicSegmentState** ppTransSegState)
-{
-	ICOM_THIS(IDirectMusicComposerImpl,iface);
-
-	FIXME("(%p, %p, %d, %ld, %p, %p, %p, %p): stub\n", This, pPerformance, wCommand, dwFlags, pChordMap, ppTransSeg, ppToSegState, ppTransSegState);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicComposerImpl_ComposeTemplateFromShape (LPDIRECTMUSICCOMPOSER iface, WORD wNumMeasures, WORD wShape, BOOL fIntro, BOOL fEnd, WORD wEndLength, IDirectMusicSegment** ppTemplate)
-{
-	ICOM_THIS(IDirectMusicComposerImpl,iface);
-
-	FIXME("(%p, %d, %d, %d, %d, %d, %p): stub\n", This, wNumMeasures, wShape, fIntro, fEnd, wEndLength, ppTemplate);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicComposerImpl_ChangeChordMap (LPDIRECTMUSICCOMPOSER iface, IDirectMusicSegment* pSegment, BOOL fTrackScale, IDirectMusicChordMap* pChordMap)
-{
-	ICOM_THIS(IDirectMusicComposerImpl,iface);
-
-	FIXME("(%p, %p, %d, %p): stub\n", This, pSegment, fTrackScale, pChordMap);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicComposer) DirectMusicComposer_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicComposerImpl_QueryInterface,
-	IDirectMusicComposerImpl_AddRef,
-	IDirectMusicComposerImpl_Release,
-	IDirectMusicComposerImpl_ComposeSegmentFromTemplate,
-	IDirectMusicComposerImpl_ComposeSegmentFromShape,
-	IDirectMusicComposerImpl_ComposeTransition,
-	IDirectMusicComposerImpl_AutoTransition,
-	IDirectMusicComposerImpl_ComposeTemplateFromShape,
-	IDirectMusicComposerImpl_ChangeChordMap
-};
-
-
-/* IDirectMusicContainer IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicContainerImpl_QueryInterface (LPDIRECTMUSICCONTAINER iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicContainerImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || 
-	    IsEqualGUID(riid, &IID_IDirectMusicContainer))
-	{
-		IDirectMusicContainerImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicContainerImpl_AddRef (LPDIRECTMUSICCONTAINER iface)
-{
-	ICOM_THIS(IDirectMusicContainerImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicContainerImpl_Release (LPDIRECTMUSICCONTAINER iface)
-{
-	ICOM_THIS(IDirectMusicContainerImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicContainer Interface follow: */
-HRESULT WINAPI IDirectMusicContainerImpl_EnumObject (LPDIRECTMUSICCONTAINER iface, REFGUID rguidClass, DWORD dwIndex, LPDMUS_OBJECTDESC pDesc, WCHAR* pwszAlias)
-{
-	ICOM_THIS(IDirectMusicContainerImpl,iface);
-
-	FIXME("(%p, %s, %ld, %p, %p): stub\n", This, debugstr_guid(rguidClass), dwIndex, pDesc, pwszAlias);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicContainer) DirectMusicContainer_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicContainerImpl_QueryInterface,
-	IDirectMusicContainerImpl_AddRef,
-	IDirectMusicContainerImpl_Release,
-	IDirectMusicContainerImpl_EnumObject
-};
-
-
-/* IDirectMusicGraph IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicGraphImpl_QueryInterface (LPDIRECTMUSICGRAPH iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicGraphImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || 
-	    IsEqualGUID(riid, &IID_IDirectMusicGraph))
-	{
-		IDirectMusicGraphImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicGraphImpl_AddRef (LPDIRECTMUSICGRAPH iface)
-{
-	ICOM_THIS(IDirectMusicGraphImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicGraphImpl_Release (LPDIRECTMUSICGRAPH iface)
-{
-	ICOM_THIS(IDirectMusicGraphImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicGraph Interface follow: */
-HRESULT WINAPI IDirectMusicGraphImpl_StampPMsg (LPDIRECTMUSICGRAPH iface, DMUS_PMSG* pPMSG)
-{
-	ICOM_THIS(IDirectMusicGraphImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pPMSG);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicGraphImpl_InsertTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool, DWORD* pdwPChannels, DWORD cPChannels, LONG lIndex)
-{
-        int i;
-	IDirectMusicTool8Impl* p;
-	IDirectMusicTool8Impl* toAdd = (IDirectMusicTool8Impl*) pTool;
-        ICOM_THIS(IDirectMusicGraphImpl,iface);
-
-	FIXME("(%p, %p, %p, %ld, %li): use of pdwPChannels\n", This, pTool, pdwPChannels, cPChannels, lIndex);
-
-	if (0 == This->num_tools) {
-	  This->first = This->last = toAdd;
-	  toAdd->prev = toAdd->next = NULL;
-	} else if (lIndex == 0 || lIndex <= -This->num_tools) {
-	  This->first->prev = toAdd;
-	  toAdd->next = This->first;
-	  toAdd->prev = NULL;
-	  This->first = toAdd;
-	} else if (lIndex < 0) {
-	  p = This->last;
-	  for (i = 0; i < -lIndex; ++i) {
-	    p = p->prev;
-	  }
-	  toAdd->next = p->next;
-	  if (p->next) p->next->prev = toAdd;
-	  p->next = toAdd;
-	  toAdd->prev = p;
-	} else if (lIndex >= This->num_tools) {
-	  This->last->next = toAdd;
-	  toAdd->prev = This->last;
-	  toAdd->next = NULL;
-	  This->last = toAdd;
-	} else if (lIndex > 0) {
-	  p = This->first;
-	  for (i = 0; i < lIndex; ++i) {
-	    p = p->next;
-	  }
-	  toAdd->prev = p->prev;
-	  if (p->prev) p->prev->next = toAdd;
-	  p->prev = toAdd;
-	  toAdd->next = p;
-	}
-	++This->num_tools;
-	return DS_OK;
-}
-
-HRESULT WINAPI IDirectMusicGraphImpl_GetTool (LPDIRECTMUSICGRAPH iface, DWORD dwIndex, IDirectMusicTool** ppTool)
-{
-        int i;
-        IDirectMusicTool8Impl* p = NULL;
-        ICOM_THIS(IDirectMusicGraphImpl,iface);
-	
-	FIXME("(%p, %ld, %p): stub\n", This, dwIndex, ppTool);
-
-	p = This->first;
-	for (i = 0; i < dwIndex && i < This->num_tools; ++i) {
-	  p = p->next;
-	}
-	*ppTool = (IDirectMusicTool*) p;
-	if (NULL != *ppTool) {
-	  IDirectMusicTool8Impl_AddRef((LPDIRECTMUSICTOOL8) *ppTool);
-	}
-	return DS_OK;
-}
-
-HRESULT WINAPI IDirectMusicGraphImpl_RemoveTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool)
-{
-	ICOM_THIS(IDirectMusicGraphImpl,iface);
-
-	FIXME("(%p, %p): stub\n", This, pTool);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicGraph) DirectMusicGraph_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicGraphImpl_QueryInterface,
-	IDirectMusicGraphImpl_AddRef,
-	IDirectMusicGraphImpl_Release,
-	IDirectMusicGraphImpl_StampPMsg,
-	IDirectMusicGraphImpl_InsertTool,
-	IDirectMusicGraphImpl_GetTool,
-	IDirectMusicGraphImpl_RemoveTool
-};
-
-
-/* IDirectMusicScript IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicScriptImpl_QueryInterface (LPDIRECTMUSICSCRIPT iface, REFIID riid, LPVOID *ppobj)
-{
-	ICOM_THIS(IDirectMusicScriptImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || 
-	    IsEqualGUID(riid, &IID_IDirectMusicScript))
-	{
-		IDirectMusicScriptImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
-	return E_NOINTERFACE;
-}
-
-ULONG WINAPI IDirectMusicScriptImpl_AddRef (LPDIRECTMUSICSCRIPT iface)
-{
-	ICOM_THIS(IDirectMusicScriptImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicScriptImpl_Release (LPDIRECTMUSICSCRIPT iface)
-{
-	ICOM_THIS(IDirectMusicScriptImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicScript Interface follow: */
-HRESULT WINAPI IDirectMusicScriptImpl_Init (LPDIRECTMUSICSCRIPT iface, IDirectMusicPerformance* pPerformance, DMUS_SCRIPT_ERRORINFO* pErrorInfo)
-{
-	ICOM_THIS(IDirectMusicScriptImpl,iface);
-
-	FIXME("(%p, %p, %p): stub\n", This, pPerformance, pErrorInfo);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicScriptImpl_CallRoutine (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszRoutineName, DMUS_SCRIPT_ERRORINFO* pErrorInfo)
-{
-	ICOM_THIS(IDirectMusicScriptImpl,iface);
-
-	FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszRoutineName), pErrorInfo);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicScriptImpl_SetVariableVariant (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, VARIANT varValue, BOOL fSetRef, DMUS_SCRIPT_ERRORINFO* pErrorInfo)
-{
-	ICOM_THIS(IDirectMusicScriptImpl,iface);
-
-	FIXME("(%p, %p, FIXME, %d, %p): stub\n", This, pwszVariableName,/* varValue,*/ fSetRef, pErrorInfo);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicScriptImpl_GetVariableVariant (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, VARIANT* pvarValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo)
-{
-	ICOM_THIS(IDirectMusicScriptImpl,iface);
-
-	FIXME("(%p, %p, %p, %p): stub\n", This, pwszVariableName, pvarValue, pErrorInfo);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicScriptImpl_SetVariableNumber (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, LONG lValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo)
-{
-	ICOM_THIS(IDirectMusicScriptImpl,iface);
-
-	FIXME("(%p, %p, %li, %p): stub\n", This, pwszVariableName, lValue, pErrorInfo);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicScriptImpl_GetVariableNumber (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, LONG* plValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo)
-{
-	ICOM_THIS(IDirectMusicScriptImpl,iface);
-
-	FIXME("(%p, %p, %p, %p): stub\n", This, pwszVariableName, plValue, pErrorInfo);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicScriptImpl_SetVariableObject (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, IUnknown* punkValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo)
-{
-	ICOM_THIS(IDirectMusicScriptImpl,iface);
-
-	FIXME("(%p, %p, %p, %p): stub\n", This, pwszVariableName, punkValue, pErrorInfo);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicScriptImpl_GetVariableObject (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, REFIID riid, LPVOID* ppv, DMUS_SCRIPT_ERRORINFO* pErrorInfo)
-{
-	ICOM_THIS(IDirectMusicScriptImpl,iface);
-
-	FIXME("(%p, %p, %s, %p, %p): stub\n", This, pwszVariableName, debugstr_guid(riid), ppv, pErrorInfo);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicScriptImpl_EnumRoutine (LPDIRECTMUSICSCRIPT iface, DWORD dwIndex, WCHAR* pwszName)
-{
-	ICOM_THIS(IDirectMusicScriptImpl,iface);
-
-	FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
-
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicScriptImpl_EnumVariable (LPDIRECTMUSICSCRIPT iface, DWORD dwIndex, WCHAR* pwszName)
-{
-	ICOM_THIS(IDirectMusicScriptImpl,iface);
-
-	FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
-
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicScript) DirectMusicScript_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicScriptImpl_QueryInterface,
-	IDirectMusicScriptImpl_AddRef,
-	IDirectMusicScriptImpl_Release,
-	IDirectMusicScriptImpl_Init,
-	IDirectMusicScriptImpl_CallRoutine,
-	IDirectMusicScriptImpl_SetVariableVariant,
-	IDirectMusicScriptImpl_GetVariableVariant,
-	IDirectMusicScriptImpl_SetVariableNumber,
-	IDirectMusicScriptImpl_GetVariableNumber,
-	IDirectMusicScriptImpl_SetVariableObject,
-	IDirectMusicScriptImpl_GetVariableObject,
-	IDirectMusicScriptImpl_EnumRoutine,
-	IDirectMusicScriptImpl_EnumVariable
-};
diff --git a/dlls/dmusic/dmusic_private.h b/dlls/dmusic/dmusic_private.h
index ed33eb5..4299b0a 100644
--- a/dlls/dmusic/dmusic_private.h
+++ b/dlls/dmusic/dmusic_private.h
@@ -43,30 +43,8 @@
 typedef struct IDirectMusicPortDownloadImpl IDirectMusicPortDownloadImpl;
 typedef struct IDirectMusicPortImpl IDirectMusicPortImpl;
 typedef struct IDirectMusicThruImpl IDirectMusicThruImpl;
-typedef struct IReferenceClockImpl IReferenceClockImpl;
-
-typedef struct IDirectMusicSynth8Impl IDirectMusicSynth8Impl;
-typedef struct IDirectMusicSynthSinkImpl IDirectMusicSynthSinkImpl;
-
-typedef struct IDirectMusicTool8Impl IDirectMusicTool8Impl;
-typedef struct IDirectMusicTrack8Impl IDirectMusicTrack8Impl;
-
-typedef struct IDirectMusicBandImpl IDirectMusicBandImpl;
 typedef struct IDirectMusicObjectImpl IDirectMusicObjectImpl;
-typedef struct IDirectMusicLoader8Impl IDirectMusicLoader8Impl;
-typedef struct IDirectMusicGetLoaderImpl IDirectMusicGetLoaderImpl;
-typedef struct IDirectMusicSegment8Impl IDirectMusicSegment8Impl;
-typedef struct IDirectMusicSegmentState8Impl IDirectMusicSegmentState8Impl;
-typedef struct IDirectMusicAudioPathImpl IDirectMusicAudioPathImpl;
-typedef struct IDirectMusicPerformance8Impl IDirectMusicPerformance8Impl;
-typedef struct IDirectMusicGraphImpl IDirectMusicGraphImpl;
-typedef struct IDirectMusicStyle8Impl IDirectMusicStyle8Impl;
-typedef struct IDirectMusicChordMapImpl IDirectMusicChordMapImpl;
-typedef struct IDirectMusicComposerImpl IDirectMusicComposerImpl;
-typedef struct IDirectMusicPatternTrackImpl IDirectMusicPatternTrackImpl;
-typedef struct IDirectMusicScriptImpl IDirectMusicScriptImpl;
-typedef struct IDirectMusicContainerImpl IDirectMusicContainerImpl;
-typedef struct IDirectMusicSongImpl IDirectMusicSongImpl;
+typedef struct IReferenceClockImpl IReferenceClockImpl;
 
 /*****************************************************************************
  * Predeclare the interface implementation structures
@@ -80,31 +58,8 @@
 extern ICOM_VTABLE(IDirectMusicPortDownload) DirectMusicPortDownload_Vtbl;
 extern ICOM_VTABLE(IDirectMusicPort) DirectMusicPort_Vtbl;
 extern ICOM_VTABLE(IDirectMusicThru) DirectMusicThru_Vtbl;
-extern ICOM_VTABLE(IReferenceClock) ReferenceClock_Vtbl;
-
-extern ICOM_VTABLE(IDirectMusicSynth8) DirectMusicSynth8_Vtbl;
-extern ICOM_VTABLE(IDirectMusicSynthSink) DirectMusicSynthSink_Vtbl;
-
-extern ICOM_VTABLE(IDirectMusicTool8) DirectMusicTool8_Vtbl;
-extern ICOM_VTABLE(IDirectMusicTrack8) DirectMusicTrack8_Vtbl;
-
-extern ICOM_VTABLE(IDirectMusicBand) DirectMusicBand_Vtbl;
 extern ICOM_VTABLE(IDirectMusicObject) DirectMusicObject_Vtbl;
-extern ICOM_VTABLE(IDirectMusicLoader8) DirectMusicLoader8_Vtbl;
-extern ICOM_VTABLE(IDirectMusicGetLoader) DirectMusicGetLoader_Vtbl;
-extern ICOM_VTABLE(IDirectMusicSegment8) DirectMusicSegment8_Vtbl;
-extern ICOM_VTABLE(IDirectMusicSegmentState8) DirectMusicSegmentState8_Vtbl;
-extern ICOM_VTABLE(IDirectMusicAudioPath) DirectMusicAudioPath_Vtbl;
-extern ICOM_VTABLE(IDirectMusicPerformance8) DirectMusicPerformance8_Vtbl;
-extern ICOM_VTABLE(IDirectMusicGraph) DirectMusicGraph_Vtbl;
-extern ICOM_VTABLE(IDirectMusicStyle8) DirectMusicStyle8_Vtbl;
-extern ICOM_VTABLE(IDirectMusicChordMap) DirectMusicChordMap_Vtbl;
-extern ICOM_VTABLE(IDirectMusicComposer) DirectMusicComposer_Vtbl;
-extern ICOM_VTABLE(IDirectMusicPatternTrack) DirectMusicPatternTrack_Vtbl;
-extern ICOM_VTABLE(IDirectMusicScript) DirectMusicScript_Vtbl;
-extern ICOM_VTABLE(IDirectMusicContainer) DirectMusicContainer_Vtbl;
-extern ICOM_VTABLE(IDirectMusicSong) DirectMusicSong_Vtbl;
-
+extern ICOM_VTABLE(IReferenceClock) ReferenceClock_Vtbl;
 
 /*****************************************************************************
  * Some stuff to make my life easier :=)
@@ -246,12 +201,51 @@
 
 /*****************************************************************************
  * ClassFactory
- *
- * can support IID_IDirectMusic and IID_IDirectMusic8
+ */
+/* can support IID_IDirectMusic, IID_IDirectMusic2 and IID_IDirectMusic8
  * return always an IDirectMusic8Impl
  */
-extern HRESULT WINAPI DMUSIC_CreateDirectMusic (LPCGUID lpcGUID, LPDIRECTMUSIC* ppDM, LPUNKNOWN pUnkOuter);
-
+extern HRESULT WINAPI DMUSIC_CreateDirectMusic (LPCGUID lpcGUID, LPDIRECTMUSIC8* ppDM, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicBuffer
+ * return always an IDirectMusicBufferImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicBuffer (LPCGUID lpcGUID, LPDIRECTMUSICBUFFER* ppDMBuff, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicInstrument
+ * return always an IDirectMusicInstrumentImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicInstrument (LPCGUID lpcGUID, LPDIRECTMUSICINSTRUMENT* ppDMInstr, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicDownloadedInstrument
+ * return always an IDirectMusicDownloadedInstrumentImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadedInstrument (LPCGUID lpcGUID, LPDIRECTMUSICDOWNLOADEDINSTRUMENT* ppDMDLInstrument, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicCollection
+ * return always an IDirectMusicCollectionImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollection (LPCGUID lpcGUID, LPDIRECTMUSICCOLLECTION* ppDMColl, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicDownload
+ * return always an IDirectMusicDownload
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownload (LPCGUID lpcGUID, LPDIRECTMUSICDOWNLOAD* ppDMDL, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicPortDownload
+ * return always an IDirectMusicPortDownload
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicPortDownload (LPCGUID lpcGUID, LPDIRECTMUSICPORTDOWNLOAD* ppDMPortDL, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicPort
+ * return always an IDirectMusicPortImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicPort (LPCGUID lpcGUID, LPDIRECTMUSICPORT* ppDMPort, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicThru
+ * return always an IDirectMusicThruImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicThru (LPCGUID lpcGUID, LPDIRECTMUSICTHRU* ppDMThru, LPUNKNOWN pUnkOuter);
+/* can support IID_IDirectMusicObject
+ * return always an IDirectMusicObjectImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateDirectMusicObject (LPCGUID lpcGUID, LPDIRECTMUSICOBJECT* ppDMObj, LPUNKNOWN pUnkOuter);
+/* can support IID_IReferenceClock
+ * return always an IReferenceClockImpl
+ */
+extern HRESULT WINAPI DMUSIC_CreateReferenceClock (LPCGUID lpcGUID, IReferenceClock** ppDM, LPUNKNOWN pUnkOuter);
 
 /*****************************************************************************
  * IDirectMusic8Impl implementation structure
@@ -263,7 +257,8 @@
   DWORD          ref;
 
   /* IDirectMusicImpl fields */
-  IDirectMusicPortImpl** ports;
+  IReferenceClockImpl* pMasterClock;
+  IDirectMusicPortImpl** ppPorts;
   int nrofports;
 };
 
@@ -284,7 +279,6 @@
 /* IDirectMusic8: */
 extern HRESULT WINAPI IDirectMusic8Impl_SetExternalMasterClock (LPDIRECTMUSIC8 iface, IReferenceClock* pClock);
 
-
 /*****************************************************************************
  * IDirectMusicBufferImpl implementation structure
  */
@@ -316,7 +310,6 @@
 extern HRESULT WINAPI IDirectMusicBufferImpl_SetStartTime (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt);
 extern HRESULT WINAPI IDirectMusicBufferImpl_SetUsedBytes (LPDIRECTMUSICBUFFER iface, DWORD cb);
 
-
 /*****************************************************************************
  * IDirectMusicInstrumentImpl implementation structure
  */
@@ -338,7 +331,6 @@
 extern HRESULT WINAPI IDirectMusicInstrumentImpl_GetPatch (LPDIRECTMUSICINSTRUMENT iface, DWORD* pdwPatch);
 extern HRESULT WINAPI IDirectMusicInstrumentImpl_SetPatch (LPDIRECTMUSICINSTRUMENT iface, DWORD dwPatch);
 
-
 /*****************************************************************************
  * IDirectMusicDownloadedInstrumentImpl implementation structure
  */
@@ -358,7 +350,6 @@
 /* IDirectMusicDownloadedInstrumentImpl: */
 /* none yet */
 
-
 /*****************************************************************************
  * IDirectMusicCollectionImpl implementation structure
  */
@@ -379,7 +370,6 @@
 HRESULT WINAPI IDirectMusicCollectionImpl_GetInstrument (LPDIRECTMUSICCOLLECTION iface, DWORD dwPatch, IDirectMusicInstrument** ppInstrument);
 HRESULT WINAPI IDirectMusicCollectionImpl_EnumInstrument (LPDIRECTMUSICCOLLECTION iface, DWORD dwIndex, DWORD* pdwPatch, LPWSTR pwszName, DWORD dwNameLen);
 
-
 /*****************************************************************************
  * IDirectMusicDownloadImpl implementation structure
  */
@@ -434,9 +424,11 @@
   DWORD          ref;
 
   /* IDirectMusicPortImpl fields */
-  BOOL active;
-  LPDMUS_PORTCAPS caps;
-  LPDMUS_PORTPARAMS params;
+  IDirectSound* pDirectSound;
+  IReferenceClock* pLatencyClock;
+  BOOL fActive;
+  LPDMUS_PORTCAPS pCaps;
+  LPDMUS_PORTPARAMS pParams;
   int nrofgroups;
   DMUSIC_PRIVATE_CHANNEL_GROUP group[1];
 };
@@ -445,7 +437,7 @@
 extern HRESULT WINAPI IDirectMusicPortImpl_QueryInterface (LPDIRECTMUSICPORT iface, REFIID riid, LPVOID *ppobj);
 extern ULONG WINAPI   IDirectMusicPortImpl_AddRef (LPDIRECTMUSICPORT iface);
 extern ULONG WINAPI   IDirectMusicPortImpl_Release (LPDIRECTMUSICPORT iface);
-/* IDirectMusicPortDownloadImpl: */
+/* IDirectMusicPortImpl: */
 extern HRESULT WINAPI IDirectMusicPortImpl_PlayBuffer (LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER pBuffer);
 extern HRESULT WINAPI IDirectMusicPortImpl_SetReadNotificationHandle (LPDIRECTMUSICPORT iface, HANDLE hEvent);
 extern HRESULT WINAPI IDirectMusicPortImpl_Read (LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER pBuffer);
@@ -463,7 +455,6 @@
 extern HRESULT WINAPI IDirectMusicPortImpl_SetDirectSound (LPDIRECTMUSICPORT iface, LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer);
 extern HRESULT WINAPI IDirectMusicPortImpl_GetFormat (LPDIRECTMUSICPORT iface, LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize, LPDWORD pdwBufferSize);
 
-
 /*****************************************************************************
  * IDirectMusicThruImpl implementation structure
  */
@@ -483,6 +474,27 @@
 /* IDirectMusicPortDownloadImpl: */
 extern HRESULT WINAPI ThruChannel (LPDIRECTMUSICTHRU iface, DWORD dwSourceChannelGroup, DWORD dwSourceChannel, DWORD dwDestinationChannelGroup, DWORD dwDestinationChannel, LPDIRECTMUSICPORT pDestinationPort);
 
+/*****************************************************************************
+ * IDirectMusicObjectImpl implementation structure
+ */
+struct IDirectMusicObjectImpl
+{
+  /* IUnknown fields */
+  ICOM_VFIELD(IDirectMusicObject);
+  DWORD          ref;
+
+  /* IDirectMusicObjectImpl fields */
+  LPDMUS_OBJECTDESC pDesc;
+};
+
+/* IUnknown: */
+extern HRESULT WINAPI IDirectMusicObjectImpl_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj);
+extern ULONG WINAPI   IDirectMusicObjectImpl_AddRef (LPDIRECTMUSICOBJECT iface);
+extern ULONG WINAPI   IDirectMusicObjectImpl_Release (LPDIRECTMUSICOBJECT iface);
+/* IDirectMusicObject: */
+extern HRESULT WINAPI IDirectMusicObjectImpl_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc);
+extern HRESULT WINAPI IDirectMusicObjectImpl_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc);
+extern HRESULT WINAPI IDirectMusicObjectImpl_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc);
 
 /*****************************************************************************
  * IReferenceClockImpl implementation structure
@@ -494,6 +506,8 @@
   DWORD          ref;
 
   /* IReferenceClockImpl fields */
+  REFERENCE_TIME rtTime;
+  DMUS_CLOCKINFO pClockInfo;
 };
 
 /* IUnknown: */
@@ -508,663 +522,8 @@
 
 
 /*****************************************************************************
- * IDirectMusicSynth8Impl implementation structure
- */
-struct IDirectMusicSynth8Impl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicSynth8);
-  DWORD          ref;
-
-  /* IDirectMusicSynth8 fields */
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicSynth8Impl_QueryInterface (LPDIRECTMUSICSYNTH8 iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicSynth8Impl_AddRef (LPDIRECTMUSICSYNTH8 iface);
-extern ULONG WINAPI   IDirectMusicSynth8Impl_Release (LPDIRECTMUSICSYNTH8 iface);
-/* IDirectMusicSynth: */
-extern HRESULT WINAPI IDirectMusicSynth8Impl_Open (LPDIRECTMUSICSYNTH8 iface, LPDMUS_PORTPARAMS pPortParams);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_Close (LPDIRECTMUSICSYNTH8 iface);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_SetNumChannelGroups (LPDIRECTMUSICSYNTH8 iface, DWORD dwGroups);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_Download (LPDIRECTMUSICSYNTH8 iface, LPHANDLE phDownload, LPVOID pvData, LPBOOL pbFree);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_Unload (LPDIRECTMUSICSYNTH8 iface, HANDLE hDownload, HRESULT (CALLBACK* lpFreeHandle)(HANDLE,HANDLE), HANDLE hUserData);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_PlayBuffer (LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME rt, LPBYTE pbBuffer, DWORD cbBuffer);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_GetRunningStats (LPDIRECTMUSICSYNTH8 iface, LPDMUS_SYNTHSTATS pStats);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_GetPortCaps (LPDIRECTMUSICSYNTH8 iface, LPDMUS_PORTCAPS pCaps);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_SetMasterClock (LPDIRECTMUSICSYNTH8 iface, IReferenceClock* pClock);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_GetLatencyClock (LPDIRECTMUSICSYNTH8 iface, IReferenceClock** ppClock);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_Activate (LPDIRECTMUSICSYNTH8 iface, BOOL fEnable);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_SetSynthSink (LPDIRECTMUSICSYNTH8 iface, IDirectMusicSynthSink* pSynthSink);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_Render (LPDIRECTMUSICSYNTH8 iface, short* pBuffer, DWORD dwLength, LONGLONG llPosition);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_SetChannelPriority (LPDIRECTMUSICSYNTH8 iface, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_GetChannelPriority (LPDIRECTMUSICSYNTH8 iface, DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_GetFormat (LPDIRECTMUSICSYNTH8 iface, LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSiz);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_GetAppend (LPDIRECTMUSICSYNTH8 iface, DWORD* pdwAppend);
-/* IDirectMusicSynth8: */
-extern HRESULT WINAPI IDirectMusicSynth8Impl_PlayVoice (LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME rt, DWORD dwVoiceId, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwDLId, long prPitch, long vrVolume, SAMPLE_TIME stVoiceStart, SAMPLE_TIME stLoopStart, SAMPLE_TIME stLoopEnd);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_StopVoice (LPDIRECTMUSICSYNTH8 iface, REFERENCE_TIME rt, DWORD dwVoiceId);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_GetVoiceState (LPDIRECTMUSICSYNTH8 iface, DWORD dwVoice[], DWORD cbVoice, DMUS_VOICE_STATE dwVoiceState[]);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_Refresh (LPDIRECTMUSICSYNTH8 iface, DWORD dwDownloadID, DWORD dwFlags);
-extern HRESULT WINAPI IDirectMusicSynth8Impl_AssignChannelToBuses (LPDIRECTMUSICSYNTH8 iface, DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwBuses, DWORD cBuses);
-
-
-/*****************************************************************************
- * IDirectMusicSynthSinkImpl implementation structure
- */
-struct IDirectMusicSynthSinkImpl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicSynthSink);
-  DWORD          ref;
-
-  /* IDirectMusicSynthSinkImpl fields */
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicSynthSinkImpl_QueryInterface (LPDIRECTMUSICSYNTHSINK iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicSynthSinkImpl_AddRef (LPDIRECTMUSICSYNTHSINK iface);
-extern ULONG WINAPI   IDirectMusicSynthSinkImpl_Release (LPDIRECTMUSICSYNTHSINK iface);
-/* IDirectMusicSynthSinkImpl: */
-extern HRESULT WINAPI IDirectMusicSynthSinkImpl_Init (LPDIRECTMUSICSYNTHSINK iface, IDirectMusicSynth* pSynth);
-extern HRESULT WINAPI IDirectMusicSynthSinkImpl_SetMasterClock (LPDIRECTMUSICSYNTHSINK iface, IReferenceClock* pClock);
-extern HRESULT WINAPI IDirectMusicSynthSinkImpl_GetLatencyClock (LPDIRECTMUSICSYNTHSINK iface, IReferenceClock** ppClock);
-extern HRESULT WINAPI IDirectMusicSynthSinkImpl_Activate (LPDIRECTMUSICSYNTHSINK iface, BOOL fEnable);
-extern HRESULT WINAPI IDirectMusicSynthSinkImpl_SampleToRefTime (LPDIRECTMUSICSYNTHSINK iface, LONGLONG llSampleTime, REFERENCE_TIME* prfTime);
-extern HRESULT WINAPI IDirectMusicSynthSinkImpl_RefTimeToSample (LPDIRECTMUSICSYNTHSINK iface, REFERENCE_TIME rfTime, LONGLONG* pllSampleTime);
-extern HRESULT WINAPI IDirectMusicSynthSinkImpl_SetDirectSound (LPDIRECTMUSICSYNTHSINK iface, LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer);
-extern HRESULT WINAPI IDirectMusicSynthSinkImpl_GetDesiredBufferSize (LPDIRECTMUSICSYNTHSINK iface, LPDWORD pdwBufferSizeInSamples);
-
-
-/*****************************************************************************
- * IDirectMusicTool8Impl implementation structure
- */
-struct IDirectMusicTool8Impl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicTool8);
-  DWORD          ref;
-
-  /* IDirectMusicTool8Impl fields */
-  IDirectMusicTool8Impl* prev;
-  IDirectMusicTool8Impl* next;
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicTool8Impl_QueryInterface (LPDIRECTMUSICTOOL8 iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicTool8Impl_AddRef (LPDIRECTMUSICTOOL8 iface);
-extern ULONG WINAPI   IDirectMusicTool8Impl_Release (LPDIRECTMUSICTOOL8 iface);
-/* IDirectMusicTool8Impl: */
-extern HRESULT WINAPI IDirectMusicTool8Impl_Init (LPDIRECTMUSICTOOL8 iface, IDirectMusicGraph* pGraph);
-extern HRESULT WINAPI IDirectMusicTool8Impl_GetMsgDeliveryType (LPDIRECTMUSICTOOL8 iface, DWORD* pdwDeliveryType);

-extern HRESULT WINAPI IDirectMusicTool8Impl_GetMediaTypeArraySize (LPDIRECTMUSICTOOL8 iface, DWORD* pdwNumElements);
-extern HRESULT WINAPI IDirectMusicTool8Impl_GetMediaTypes (LPDIRECTMUSICTOOL8 iface, DWORD** padwMediaTypes, DWORD dwNumElements);

-extern HRESULT WINAPI IDirectMusicTool8Impl_ProcessPMsg (LPDIRECTMUSICTOOL8 iface, IDirectMusicPerformance* pPerf, DMUS_PMSG* pPMSG);

-extern HRESULT WINAPI IDirectMusicTool8Impl_Flush (LPDIRECTMUSICTOOL8 iface, IDirectMusicPerformance* pPerf, DMUS_PMSG* pPMSG, REFERENCE_TIME rtTime);
-/* IDirectMusicToolImpl8: */
-extern HRESULT WINAPI IDirectMusicTool8Impl_Clone (LPDIRECTMUSICTOOL8 iface, IDirectMusicTool** ppTool);
-
-
-/*****************************************************************************
- * IDirectMusicTrack8Impl implementation structure
- */
-struct IDirectMusicTrack8Impl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicTrack8);
-  DWORD          ref;
-
-  /* IDirectMusicTrack8Impl fields */
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicTrack8Impl_QueryInterface (LPDIRECTMUSICTRACK8 iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicTrack8Impl_AddRef (LPDIRECTMUSICTRACK8 iface);
-extern ULONG WINAPI   IDirectMusicTrack8Impl_Release (LPDIRECTMUSICTRACK8 iface);
-/* IDirectMusicTrack: */
-extern HRESULT WINAPI IDirectMusicTrack8Impl_Init (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegment* pSegment);
-extern HRESULT WINAPI IDirectMusicTrack8Impl_InitPlay (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegmentState* pSegmentState, IDirectMusicPerformance* pPerformance, void** ppStateData, DWORD dwVirtualTrackID, DWORD dwFlags);
-extern HRESULT WINAPI IDirectMusicTrack8Impl_EndPlay (LPDIRECTMUSICTRACK8 iface, void* pStateData);
-extern HRESULT WINAPI IDirectMusicTrack8Impl_Play (LPDIRECTMUSICTRACK8 iface, void* pStateData, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, MUSIC_TIME mtOffset, DWORD dwFlags, IDirectMusicPerformance* pPerf, IDirectMusicSegmentState* pSegSt, DWORD dwVirtualID);
-extern HRESULT WINAPI IDirectMusicTrack8Impl_GetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam);
-extern HRESULT WINAPI IDirectMusicTrack8Impl_SetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, void* pParam);
-extern HRESULT WINAPI IDirectMusicTrack8Impl_IsParamSupported (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType);
-extern HRESULT WINAPI IDirectMusicTrack8Impl_AddNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType);
-extern HRESULT WINAPI IDirectMusicTrack8Impl_RemoveNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType);
-extern HRESULT WINAPI IDirectMusicTrack8Impl_Clone (LPDIRECTMUSICTRACK8 iface, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, IDirectMusicTrack** ppTrack);
-/* IDirectMusicTrack8: */
-extern HRESULT WINAPI IDirectMusicTrack8Impl_PlayEx (LPDIRECTMUSICTRACK8 iface, void* pStateData, REFERENCE_TIME rtStart, REFERENCE_TIME rtEnd, REFERENCE_TIME rtOffset, DWORD dwFlags, IDirectMusicPerformance* pPerf, IDirectMusicSegmentState* pSegSt, DWORD dwVirtualID);
-extern HRESULT WINAPI IDirectMusicTrack8Impl_GetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, REFERENCE_TIME* prtNext, void* pParam, void* pStateData, DWORD dwFlags);
-extern HRESULT WINAPI IDirectMusicTrack8Impl_SetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, void* pParam, void* pStateData, DWORD dwFlags);
-extern HRESULT WINAPI IDirectMusicTrack8Impl_Compose (LPDIRECTMUSICTRACK8 iface, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack);
-extern HRESULT WINAPI IDirectMusicTrack8Impl_Join (LPDIRECTMUSICTRACK8 iface, IDirectMusicTrack* pNewTrack, MUSIC_TIME mtJoin, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack);
-
-
-/*****************************************************************************
- * IDirectMusicBandImpl implementation structure
- */
-struct IDirectMusicBandImpl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicBand);
-  DWORD          ref;
-
-  /* IDirectMusicBandImpl fields */
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicBandImpl_QueryInterface (LPDIRECTMUSICBAND iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicBandImpl_AddRef (LPDIRECTMUSICBAND iface);
-extern ULONG WINAPI   IDirectMusicBandImpl_Release (LPDIRECTMUSICBAND iface);
-/* IDirectMusicBand: */
-extern HRESULT WINAPI IDirectMusicBandImpl_CreateSegment (LPDIRECTMUSICBAND iface, IDirectMusicSegment** ppSegment);
-extern HRESULT WINAPI IDirectMusicBandImpl_Download (LPDIRECTMUSICBAND iface, IDirectMusicPerformance* pPerformance);
-extern HRESULT WINAPI IDirectMusicBandImpl_Unload (LPDIRECTMUSICBAND iface, IDirectMusicPerformance* pPerformance);
-
-
-/*****************************************************************************
- * IDirectMusicObjectImpl implementation structure
- */
-struct IDirectMusicObjectImpl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicObject);
-  DWORD          ref;
-
-  /* IDirectMusicObjectImpl fields */
-  LPDMUS_OBJECTDESC desc;
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicObjectImpl_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicObjectImpl_AddRef (LPDIRECTMUSICOBJECT iface);
-extern ULONG WINAPI   IDirectMusicObjectImpl_Release (LPDIRECTMUSICOBJECT iface);
-/* IDirectMusicObject: */
-extern HRESULT WINAPI IDirectMusicObjectImpl_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc);
-extern HRESULT WINAPI IDirectMusicObjectImpl_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc);
-extern HRESULT WINAPI IDirectMusicObjectImpl_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc);
-
-
-/*****************************************************************************
- * IDirectMusicLoader8Impl implementation structure
- */
-struct IDirectMusicLoader8Impl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicLoader8);
-  DWORD          ref;
-
-  /* IDirectMusicLoader8Impl fields */
-  WCHAR          searchPath[MAX_PATH];
-  /* IDirectMusicLoader8Impl fields */ 
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicLoader8Impl_QueryInterface (LPDIRECTMUSICLOADER8 iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicLoader8Impl_AddRef (LPDIRECTMUSICLOADER8 iface);
-extern ULONG WINAPI   IDirectMusicLoader8Impl_Release (LPDIRECTMUSICLOADER8 iface);
-/* IDirectMusicLoader: */
-extern HRESULT WINAPI IDirectMusicLoader8Impl_GetObject (LPDIRECTMUSICLOADER8 iface, LPDMUS_OBJECTDESC pDesc, REFIID riid, LPVOID*ppv);
-extern HRESULT WINAPI IDirectMusicLoader8Impl_SetObject (LPDIRECTMUSICLOADER8 iface, LPDMUS_OBJECTDESC pDesc);
-extern HRESULT WINAPI IDirectMusicLoader8Impl_SetSearchDirectory (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, WCHAR* pwzPath, BOOL fClear);
-extern HRESULT WINAPI IDirectMusicLoader8Impl_ScanDirectory (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, WCHAR* pwzFileExtension, WCHAR* pwzScanFileName);
-extern HRESULT WINAPI IDirectMusicLoader8Impl_CacheObject (LPDIRECTMUSICLOADER8 iface, IDirectMusicObject* pObject);
-extern HRESULT WINAPI IDirectMusicLoader8Impl_ReleaseObject (LPDIRECTMUSICLOADER8 iface, IDirectMusicObject* pObject);
-extern HRESULT WINAPI IDirectMusicLoader8Impl_ClearCache (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass);
-extern HRESULT WINAPI IDirectMusicLoader8Impl_EnableCache (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, BOOL fEnable);
-extern HRESULT WINAPI IDirectMusicLoader8Impl_EnumObject (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClass, DWORD dwIndex, LPDMUS_OBJECTDESC pDesc);
-/* IDirectMusicLoader8: */
-extern void    WINAPI IDirectMusicLoader8Impl_CollectGarbage (LPDIRECTMUSICLOADER8 iface);
-extern HRESULT WINAPI IDirectMusicLoader8Impl_ReleaseObjectByUnknown (LPDIRECTMUSICLOADER8 iface, IUnknown* pObject);
-extern HRESULT WINAPI IDirectMusicLoader8Impl_LoadObjectFromFile (LPDIRECTMUSICLOADER8 iface, REFGUID rguidClassID, REFIID iidInterfaceID, WCHAR* pwzFilePath, void** ppObject);
-/* ClassFactory */
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicLoader8 (LPCGUID lpcGUID, LPDIRECTMUSICLOADER8 *ppDMLoad8, LPUNKNOWN pUnkOuter);
-
-
-/*****************************************************************************
- * IDirectMusicGetLoaderImpl implementation structure
- */
-struct IDirectMusicGetLoaderImpl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicGetLoader);
-  DWORD          ref;
-
-  /* IDirectMusicGetLoaderImpl fields */
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicGetLoaderImpl_QueryInterface (LPDIRECTMUSICGETLOADER iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicGetLoaderImpl_AddRef (LPDIRECTMUSICGETLOADER iface);
-extern ULONG WINAPI   IDirectMusicGetLoaderImpl_Release (LPDIRECTMUSICGETLOADER iface);
-/* IDirectMusicGetLoader: */
-extern HRESULT WINAPI IDirectMusicGetLoaderImpl_GetLoader (LPDIRECTMUSICGETLOADER iface, IDirectMusicLoader** ppLoader);
-
-
-/*****************************************************************************
- * IDirectMusicSegment8Impl implementation structure
- */
-struct IDirectMusicSegment8Impl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicSegment8);
-  DWORD          ref;
-
-  /* IDirectMusicSegment8Impl fields */
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicSegment8Impl_QueryInterface (LPDIRECTMUSICSEGMENT8 iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicSegment8Impl_AddRef (LPDIRECTMUSICSEGMENT8 iface);
-extern ULONG WINAPI   IDirectMusicSegment8Impl_Release (LPDIRECTMUSICSEGMENT8 iface);
-/* IDirectMusicSegment: */
-extern HRESULT WINAPI IDirectMusicSegment8Impl_GetLength (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME* pmtLength);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_SetLength (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtLength);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_GetRepeats (LPDIRECTMUSICSEGMENT8 iface, DWORD* pdwRepeats);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_SetRepeats (LPDIRECTMUSICSEGMENT8 iface, DWORD dwRepeats);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_GetDefaultResolution (LPDIRECTMUSICSEGMENT8 iface, DWORD* pdwResolution);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_SetDefaultResolution (LPDIRECTMUSICSEGMENT8 iface, DWORD dwResolution);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_GetTrack (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, IDirectMusicTrack** ppTrack);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_GetTrackGroup (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicTrack* pTrack, DWORD* pdwGroupBits);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_InsertTrack (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicTrack* pTrack, DWORD dwGroupBits);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_RemoveTrack (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicTrack* pTrack);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_InitPlay (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicSegmentState** ppSegState, IDirectMusicPerformance* pPerformance, DWORD dwFlags);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_GetGraph (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicGraph** ppGraph);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_SetGraph (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicGraph* pGraph);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_AddNotificationType (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidNotificationType);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_RemoveNotificationType (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidNotificationType);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_GetParam (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_SetParam (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, void* pParam);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_Clone (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, IDirectMusicSegment** ppSegment);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_SetStartPoint (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtStart);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_GetStartPoint (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME* pmtStart);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_SetLoopPoints (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtStart, MUSIC_TIME mtEnd);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_GetLoopPoints (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME* pmtStart, MUSIC_TIME* pmtEnd);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_SetPChannelsUsed (LPDIRECTMUSICSEGMENT8 iface, DWORD dwNumPChannels, DWORD* paPChannels);
-/* IDirectMusicSegment8: */
-extern HRESULT WINAPI IDirectMusicSegment8Impl_SetTrackConfig (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidTrackClassID, DWORD dwGroupBits, DWORD dwIndex, DWORD dwFlagsOn, DWORD dwFlagsOff);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_GetAudioPathConfig (LPDIRECTMUSICSEGMENT8 iface, IUnknown** ppAudioPathConfig);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_Compose (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtTime, IDirectMusicSegment* pFromSegment, IDirectMusicSegment* pToSegment, IDirectMusicSegment** ppComposedSegment);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_Download (LPDIRECTMUSICSEGMENT8 iface, IUnknown *pAudioPath);
-extern HRESULT WINAPI IDirectMusicSegment8Impl_Unload (LPDIRECTMUSICSEGMENT8 iface, IUnknown *pAudioPath);
-	
-/*****************************************************************************
- * IDirectMusicSegmentStateImpl implementation structure
- */
-struct IDirectMusicSegmentStateImpl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicSegmentState);
-  DWORD          ref;
-
-  /* IDirectMusicSegmentStateImpl fields */
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicSegmentStateImpl_QueryInterface (LPDIRECTMUSICSEGMENTSTATE iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicSegmentStateImpl_AddRef (LPDIRECTMUSICSEGMENTSTATE iface);
-extern ULONG WINAPI   IDirectMusicSegmentStateImpl_Release (LPDIRECTMUSICSEGMENTSTATE iface);
-/* IDirectMusicSegmentState: */
-extern HRESULT WINAPI IDirectMusicSegmentStateImpl_GetRepeats (LPDIRECTMUSICSEGMENTSTATE iface,  DWORD* pdwRepeats);
-extern HRESULT WINAPI IDirectMusicSegmentStateImpl_GetSegment (LPDIRECTMUSICSEGMENTSTATE iface, IDirectMusicSegment** ppSegment);
-extern HRESULT WINAPI IDirectMusicSegmentStateImpl_GetStartTime (LPDIRECTMUSICSEGMENTSTATE iface, MUSIC_TIME* pmtStart);
-extern HRESULT WINAPI IDirectMusicSegmentStateImpl_GetSeek (LPDIRECTMUSICSEGMENTSTATE iface, MUSIC_TIME* pmtSeek);
-extern HRESULT WINAPI IDirectMusicSegmentStateImpl_GetStartPoint (LPDIRECTMUSICSEGMENTSTATE iface, MUSIC_TIME* pmtStart);
-
-/*****************************************************************************
- * IDirectMusicSegmentState8Impl implementation structure
- */
-struct IDirectMusicSegmentState8Impl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicSegmentState8);
-  DWORD          ref;
-
-  /* IDirectMusicSegmentState8Impl fields */
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicSegmentState8Impl_QueryInterface (LPDIRECTMUSICSEGMENTSTATE8 iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicSegmentState8Impl_AddRef (LPDIRECTMUSICSEGMENTSTATE8 iface);
-extern ULONG WINAPI   IDirectMusicSegmentState8Impl_Release (LPDIRECTMUSICSEGMENTSTATE8 iface);
-/* IDirectMusicSegmentState: */
-extern HRESULT WINAPI IDirectMusicSegmentState8Impl_GetRepeats (LPDIRECTMUSICSEGMENTSTATE8 iface,  DWORD* pdwRepeats);
-extern HRESULT WINAPI IDirectMusicSegmentState8Impl_GetSegment (LPDIRECTMUSICSEGMENTSTATE8 iface, IDirectMusicSegment** ppSegment);
-extern HRESULT WINAPI IDirectMusicSegmentState8Impl_GetStartTime (LPDIRECTMUSICSEGMENTSTATE8 iface, MUSIC_TIME* pmtStart);
-extern HRESULT WINAPI IDirectMusicSegmentState8Impl_GetSeek (LPDIRECTMUSICSEGMENTSTATE8 iface, MUSIC_TIME* pmtSeek);
-extern HRESULT WINAPI IDirectMusicSegmentState8Impl_GetStartPoint (LPDIRECTMUSICSEGMENTSTATE8 iface, MUSIC_TIME* pmtStart);
-/* IDirectMusicSegmentState8: */
-extern HRESULT WINAPI IDirectMusicSegmentState8Impl_SetTrackConfig (LPDIRECTMUSICSEGMENTSTATE8 iface, REFGUID rguidTrackClassID, DWORD dwGroupBits, DWORD dwIndex, DWORD dwFlagsOn, DWORD dwFlagsOff);
-extern HRESULT WINAPI IDirectMusicSegmentState8Impl_GetObjectInPath (LPDIRECTMUSICSEGMENTSTATE8 iface, DWORD dwPChannel, DWORD dwStage, DWORD dwBuffer, REFGUID guidObject, DWORD dwIndex, REFGUID iidInterface, void** ppObject);
-
-/*****************************************************************************
- * IDirectMusicAudioPathImpl implementation structure
- */
-struct IDirectMusicAudioPathImpl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicAudioPath);
-  DWORD          ref;
-
-  /* IDirectMusicAudioPathImpl fields */
-  IDirectMusicPerformance8* perfo;
-  IDirectMusicGraph*        toolGraph;
-  IDirectSoundBuffer*       buffer;
-  IDirectSoundBuffer*       primary;
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicAudioPathImpl_QueryInterface (LPDIRECTMUSICAUDIOPATH iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicAudioPathImpl_AddRef (LPDIRECTMUSICAUDIOPATH iface);
-extern ULONG WINAPI   IDirectMusicAudioPathImpl_Release (LPDIRECTMUSICAUDIOPATH iface);
-/* IDirectMusicAudioPath: */
-extern HRESULT WINAPI IDirectMusicAudioPathImpl_GetObjectInPath (LPDIRECTMUSICAUDIOPATH iface, DWORD dwPChannel, DWORD dwStage, DWORD dwBuffer, REFGUID guidObject, WORD dwIndex, REFGUID iidInterface, void** ppObject);
-extern HRESULT WINAPI IDirectMusicAudioPathImpl_Activate (LPDIRECTMUSICAUDIOPATH iface, BOOL fActivate);
-extern HRESULT WINAPI IDirectMusicAudioPathImpl_SetVolume (LPDIRECTMUSICAUDIOPATH iface, long lVolume, DWORD dwDuration);
-extern HRESULT WINAPI IDirectMusicAudioPathImpl_ConvertPChannel (LPDIRECTMUSICAUDIOPATH iface, DWORD dwPChannelIn, DWORD* pdwPChannelOut);
-
-/*****************************************************************************
- * ClassFactory
- */
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicPerformance (LPCGUID lpcGUID, LPDIRECTMUSICPERFORMANCE *ppDMPerf, LPUNKNOWN pUnkOuter);
-
-/*****************************************************************************
- * IDirectMusicPerformance8Impl implementation structure
- */
-struct IDirectMusicPerformance8Impl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicPerformance8);
-  DWORD                  ref;
-
-  /* IDirectMusicPerformanceImpl fields */
-  IDirectMusic8*         dmusic;
-  IDirectSound*          dsound;
-  IDirectMusicGraph*     toolGraph;
-  DMUS_AUDIOPARAMS       params;
-
-  /* global parameters */
-  BOOL  AutoDownload;
-  char  MasterGrooveLevel;
-  float MasterTempo;
-  long  MasterVolume;
-	
-  /* performance channels */
-  DMUSIC_PRIVATE_PCHANNEL PChannel[1];
-
-   /* IDirectMusicPerformance8Impl fields */
-  IDirectMusicAudioPath* default_path;
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_QueryInterface (LPDIRECTMUSICPERFORMANCE8 iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicPerformance8Impl_AddRef (LPDIRECTMUSICPERFORMANCE8 iface);
-extern ULONG WINAPI   IDirectMusicPerformance8Impl_Release (LPDIRECTMUSICPERFORMANCE8 iface);
-/* IDirectMusicPerformance: */
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusic** ppDirectMusic, LPDIRECTSOUND pDirectSound, HWND hWnd);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_Stop (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, IDirectMusicSegmentState* pSegmentState, MUSIC_TIME mtTime, DWORD dwFlags);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetSegmentState (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegmentState** ppSegmentState, MUSIC_TIME mtTime);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_SetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwMilliSeconds);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetPrepareTime (LPDIRECTMUSICPERFORMANCE8 iface, DWORD* pdwMilliSeconds);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_SetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwMilliSeconds);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetBumperLength (LPDIRECTMUSICPERFORMANCE8 iface, DWORD* pdwMilliSeconds);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_SendPMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pPMSG);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_MusicToReferenceTime (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, REFERENCE_TIME* prtTime);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_ReferenceToMusicTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtTime, MUSIC_TIME* pmtTime);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_IsPlaying (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, IDirectMusicSegmentState* pSegState);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtNow, MUSIC_TIME* pmtNow);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_AllocPMsg (LPDIRECTMUSICPERFORMANCE8 iface, ULONG cb, DMUS_PMSG** ppPMSG);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_FreePMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pPMSG);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph** ppGraph);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_SetGraph (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicGraph* pGraph);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_SetNotificationHandle (LPDIRECTMUSICPERFORMANCE8 iface, HANDLE hNotification, REFERENCE_TIME rtMinimum);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetNotificationPMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_NOTIFICATION_PMSG** ppNotificationPMsg);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_AddNotificationType (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidNotificationType);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_RemoveNotificationType (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidNotificationType);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_AddPort (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicPort* pPort);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_RemovePort (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicPort* pPort);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannelBlock (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwBlockNum, IDirectMusicPort* pPort, DWORD dwGroup);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_AssignPChannel (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort* pPort, DWORD dwGroup, DWORD dwMChannel);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_PChannelInfo (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort** ppPort, DWORD* pdwGroup, DWORD* pdwMChannel);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_DownloadInstrument (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicInstrument* pInst, DWORD dwPChannel, IDirectMusicDownloadedInstrument** ppDownInst, DMUS_NOTERANGE* pNoteRanges, DWORD dwNumNoteRanges, IDirectMusicPort** ppPort, DWORD* pdwGroup, DWORD* pdwMChannel);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_Invalidate (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, DWORD dwFlags);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_SetParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, void* pParam);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, void* pParam, DWORD dwSize);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_SetGlobalParam (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, void* pParam, DWORD dwSize);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetLatencyTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtTime);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetQueueTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME* prtTime);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_AdjustTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtAmount);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_CloseDown (LPDIRECTMUSICPERFORMANCE8 iface);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_GetResolvedTime (LPDIRECTMUSICPERFORMANCE8 iface, REFERENCE_TIME rtTime, REFERENCE_TIME* prtResolved, DWORD dwTimeResolveFlags);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_MIDIToMusic (LPDIRECTMUSICPERFORMANCE8 iface, BYTE bMIDIValue, DMUS_CHORD_KEY* pChord, BYTE bPlayMode, BYTE bChordLevel, WORD* pwMusicValue);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_MusicToMIDI (LPDIRECTMUSICPERFORMANCE8 iface, WORD wMusicValue, DMUS_CHORD_KEY* pChord, BYTE bPlayMode, BYTE bChordLevel, BYTE* pbMIDIValue);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_TimeToRhythm (LPDIRECTMUSICPERFORMANCE8 iface, MUSIC_TIME mtTime, DMUS_TIMESIGNATURE* pTimeSig, WORD* pwMeasure, BYTE* pbBeat, BYTE* pbGrid, short* pnOffset);
-extern HRESULT WINAPI IDirectMusicPerformance8Impl_RhythmToTime (LPDIRECTMUSICPERFORMANCE8 iface, WORD wMeasure, BYTE bBeat, BYTE bGrid, short nOffset, DMUS_TIMESIGNATURE* pTimeSig, MUSIC_TIME* pmtTime);
-/* IDirectMusicPerformance8: */
-extern HRESULT WINAPI IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusic** ppDirectMusic, IDirectSound** ppDirectSound, HWND hWnd, DWORD dwDefaultPathType, DWORD dwPChannelCount, DWORD dwFlags, DMUS_AUDIOPARAMS* pParams);
-extern HRESULT WINAPI IDirectMusicPerformance8ImplPlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSource, WCHAR* pwzSegmentName, IUnknown* pTransition, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState, IUnknown* pFrom, IUnknown* pAudioPath);
-extern HRESULT WINAPI IDirectMusicPerformance8ImplStopEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pObjectToStop, __int64 i64StopTime, DWORD dwFlags);
-extern HRESULT WINAPI IDirectMusicPerformance8ImplClonePMsg (LPDIRECTMUSICPERFORMANCE8 iface, DMUS_PMSG* pSourcePMSG, DMUS_PMSG** ppCopyPMSG);
-extern HRESULT WINAPI IDirectMusicPerformance8ImplCreateAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSourceConfig, BOOL fActivate, IDirectMusicAudioPath** ppNewPath);
-extern HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath** ppNewPath);
-extern HRESULT WINAPI IDirectMusicPerformance8ImplSetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath* pAudioPath);
-extern HRESULT WINAPI IDirectMusicPerformance8ImplGetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath** ppAudioPath);
-extern HRESULT WINAPI IDirectMusicPerformance8ImplGetParamEx (LPDIRECTMUSICPERFORMANCE8 iface, REFGUID rguidType, DWORD dwTrackID, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam);
-/* ClassFactory */
-extern HRESULT WINAPI DMUSIC_CreateDirectMusicPerformance8 (LPCGUID lpcGUID, LPDIRECTMUSICPERFORMANCE8 *ppDMPerf8, LPUNKNOWN pUnkOuter);
-
-/*****************************************************************************
- * IDirectMusicGraphImpl implementation structure
- */
-struct IDirectMusicGraphImpl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicGraph);
-  DWORD          ref;
-
-  /* IDirectMusicGraphImpl fields */
-  IDirectMusicTool8Impl* first;
-  IDirectMusicTool8Impl* last;
-  WORD                  num_tools;
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicGraphImpl_QueryInterface (LPDIRECTMUSICGRAPH iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicGraphImpl_AddRef (LPDIRECTMUSICGRAPH iface);
-extern ULONG WINAPI   IDirectMusicGraphImpl_Release (LPDIRECTMUSICGRAPH iface);
-/* IDirectMusicGraph: */
-extern HRESULT WINAPI IDirectMusicGraphImpl_StampPMsg (LPDIRECTMUSICGRAPH iface, DMUS_PMSG* pPMSG);
-extern HRESULT WINAPI IDirectMusicGraphImpl_InsertTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool, DWORD* pdwPChannels, DWORD cPChannels, LONG lIndex);
-extern HRESULT WINAPI IDirectMusicGraphImpl_GetTool (LPDIRECTMUSICGRAPH iface, DWORD dwIndex, IDirectMusicTool** ppTool);
-extern HRESULT WINAPI IDirectMusicGraphImpl_RemoveTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool);
-
-/*****************************************************************************
- * IDirectMusicStyle8Impl implementation structure
- */
-struct IDirectMusicStyle8Impl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicStyle8);
-  DWORD          ref;
-
-  /* IDirectMusicStyle8Impl fields */
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicStyle8Impl_QueryInterface (LPDIRECTMUSICSTYLE8 iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicStyle8Impl_AddRef (LPDIRECTMUSICSTYLE8 iface);
-extern ULONG WINAPI   IDirectMusicStyle8Impl_Release (LPDIRECTMUSICSTYLE8 iface);
-/* IDirectMusicStyle: */
-extern HRESULT WINAPI IDirectMusicStyle8Impl_GetBand (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicBand** ppBand);
-extern HRESULT WINAPI IDirectMusicStyle8Impl_EnumBand (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName);
-extern HRESULT WINAPI IDirectMusicStyle8Impl_GetDefaultBand (LPDIRECTMUSICSTYLE8 iface, IDirectMusicBand** ppBand);
-extern HRESULT WINAPI IDirectMusicStyle8Impl_EnumMotif (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName);
-extern HRESULT WINAPI IDirectMusicStyle8Impl_GetMotif (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicSegment** ppSegment);
-extern HRESULT WINAPI IDirectMusicStyle8Impl_GetDefaultChordMap (LPDIRECTMUSICSTYLE8 iface, IDirectMusicChordMap** ppChordMap);
-extern HRESULT WINAPI IDirectMusicStyle8Impl_EnumChordMap (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName);
-extern HRESULT WINAPI IDirectMusicStyle8Impl_GetChordMap (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicChordMap** ppChordMap);
-extern HRESULT WINAPI IDirectMusicStyle8Impl_GetTimeSignature (LPDIRECTMUSICSTYLE8 iface, DMUS_TIMESIGNATURE* pTimeSig);
-extern HRESULT WINAPI IDirectMusicStyle8Impl_GetEmbellishmentLength (LPDIRECTMUSICSTYLE8 iface, DWORD dwType, DWORD dwLevel, DWORD* pdwMin, DWORD* pdwMax);
-extern HRESULT WINAPI IDirectMusicStyle8Impl_GetTempo (LPDIRECTMUSICSTYLE8 iface, double* pTempo);
-/* IDirectMusicStyle8: */
-extern HRESULT WINAPI IDirectMusicStyle8ImplEnumPattern (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, DWORD dwPatternType, WCHAR* pwszName);
-
-
-/*****************************************************************************
- * IDirectMusicChordMapImpl implementation structure
- */
-struct IDirectMusicChordMapImpl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicChordMap);
-  DWORD          ref;
-
-  /* IDirectMusicGetLoaderImpl fields */
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicChordMapImpl_QueryInterface (LPDIRECTMUSICCHORDMAP iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicChordMapImpl_AddRef (LPDIRECTMUSICCHORDMAP iface);
-extern ULONG WINAPI   IDirectMusicChordMapImpl_Release (LPDIRECTMUSICCHORDMAP iface);
-/* IDirectMusicChordMap: */
-extern HRESULT WINAPI IDirectMusicChordMapImpl_GetScale (LPDIRECTMUSICCHORDMAP iface, DWORD* pdwScale);
-
-
-/*****************************************************************************
- * IDirectMusicComposerImpl implementation structure
- */
-struct IDirectMusicComposerImpl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicComposer);
-  DWORD          ref;
-
-  /* IDirectMusicComposerImpl fields */
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicComposerImpl_QueryInterface (LPDIRECTMUSICCOMPOSER iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicComposerImpl_AddRef (LPDIRECTMUSICCOMPOSER iface);
-extern ULONG WINAPI   IDirectMusicComposerImpl_Release (LPDIRECTMUSICCOMPOSER iface);
-/* IDirectMusicComposer: */
-extern HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromTemplate (LPDIRECTMUSICCOMPOSER iface, IDirectMusicStyle* pStyle, IDirectMusicSegment* pTemplate, WORD wActivity, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppSegment);

-extern HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromShape (LPDIRECTMUSICCOMPOSER iface, IDirectMusicStyle* pStyle, WORD wNumMeasures, WORD wShape, WORD wActivity, BOOL fIntro, BOOL fEnd, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppSegment);

-extern HRESULT WINAPI IDirectMusicComposerImpl_ComposeTransition (LPDIRECTMUSICCOMPOSER iface, IDirectMusicSegment* pFromSeg, IDirectMusicSegment* pToSeg, MUSIC_TIME mtTime, WORD wCommand, DWORD dwFlags, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppTransSeg);

-extern HRESULT WINAPI IDirectMusicComposerImpl_AutoTransition (LPDIRECTMUSICCOMPOSER iface, IDirectMusicPerformance* pPerformance, IDirectMusicSegment* pToSeg, WORD wCommand, DWORD dwFlags, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppTransSeg, IDirectMusicSegmentState** ppToSegState, IDirectMusicSegmentState** ppTransSegState);

-extern HRESULT WINAPI IDirectMusicComposerImpl_ComposeTemplateFromShape (LPDIRECTMUSICCOMPOSER iface, WORD wNumMeasures, WORD wShape, BOOL fIntro, BOOL fEnd, WORD wEndLength, IDirectMusicSegment** ppTemplate);

-extern HRESULT WINAPI IDirectMusicComposerImpl_ChangeChordMap (LPDIRECTMUSICCOMPOSER iface, IDirectMusicSegment* pSegment, BOOL fTrackScale, IDirectMusicChordMap* pChordMap);
-
-/*****************************************************************************
- * IDirectMusicPatternTrackImpl implementation structure
- */
-struct IDirectMusicPatternTrackImpl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicPatternTrack);
-  DWORD          ref;
-
-  /* IDirectMusicComposerImpl fields */
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicPatternTrackImpl_QueryInterface (LPDIRECTMUSICPATTERNTRACK iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicPatternTrackImpl_AddRef (LPDIRECTMUSICPATTERNTRACK iface);
-extern ULONG WINAPI   IDirectMusicPatternTrackImpl_Release (LPDIRECTMUSICPATTERNTRACK iface);
-/* IDirectMusicPatternTrack: */
-extern HRESULT WINAPI IDirectMusicPatternTrackImpl_CreateSegment (LPDIRECTMUSICPATTERNTRACK iface, IDirectMusicStyle* pStyle, IDirectMusicSegment** ppSegment);
-extern HRESULT WINAPI IDirectMusicPatternTrackImpl_SetVariation (LPDIRECTMUSICPATTERNTRACK iface, IDirectMusicSegmentState* pSegState, DWORD dwVariationFlags, DWORD dwPart);
-extern HRESULT WINAPI IDirectMusicPatternTrackImpl_SetPatternByName (LPDIRECTMUSICPATTERNTRACK iface, IDirectMusicSegmentState* pSegState, WCHAR* wszName, IDirectMusicStyle* pStyle, DWORD dwPatternType, DWORD* pdwLength);
-
-
-/*****************************************************************************
- * IDirectMusicScriptImpl implementation structure
- */
-struct IDirectMusicScriptImpl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicScript);
-  DWORD          ref;
-
-  /* IDirectMusicScriptImpl fields */
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicScriptImpl_QueryInterface (LPDIRECTMUSICSCRIPT iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicScriptImpl_AddRef (LPDIRECTMUSICSCRIPT iface);
-extern ULONG WINAPI   IDirectMusicScriptImpl_Release (LPDIRECTMUSICSCRIPT iface);
-/* IDirectMusicScript: */
-extern HRESULT WINAPI IDirectMusicScriptImpl_Init (LPDIRECTMUSICSCRIPT iface, IDirectMusicPerformance* pPerformance, DMUS_SCRIPT_ERRORINFO* pErrorInfo);
-extern HRESULT WINAPI IDirectMusicScriptImpl_CallRoutine (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszRoutineName, DMUS_SCRIPT_ERRORINFO* pErrorInfo);
-extern HRESULT WINAPI IDirectMusicScriptImpl_SetVariableVariant (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, VARIANT varValue, BOOL fSetRef, DMUS_SCRIPT_ERRORINFO* pErrorInfo);
-extern HRESULT WINAPI IDirectMusicScriptImpl_GetVariableVariant (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, VARIANT* pvarValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo);
-extern HRESULT WINAPI IDirectMusicScriptImpl_SetVariableNumber (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, LONG lValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo);
-extern HRESULT WINAPI IDirectMusicScriptImpl_GetVariableNumber (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, LONG* plValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo);
-extern HRESULT WINAPI IDirectMusicScriptImpl_SetVariableObject (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, IUnknown* punkValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo);
-extern HRESULT WINAPI IDirectMusicScriptImpl_GetVariableObject (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, REFIID riid, LPVOID* ppv, DMUS_SCRIPT_ERRORINFO* pErrorInfo);
-extern HRESULT WINAPI IDirectMusicScriptImpl_EnumRoutine (LPDIRECTMUSICSCRIPT iface, DWORD dwIndex, WCHAR* pwszName);
-extern HRESULT WINAPI IDirectMusicScriptImpl_EnumVariable (LPDIRECTMUSICSCRIPT iface, DWORD dwIndex, WCHAR* pwszName);
-
-
-/*****************************************************************************
- * IDirectMusicContainerImpl implementation structure
- */
-struct IDirectMusicContainerImpl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicContainer);
-  DWORD          ref;
-
-  /* IDirectMusicContainerImpl fields */
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicContainerImpl_QueryInterface (LPDIRECTMUSICCONTAINER iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicContainerImpl_AddRef (LPDIRECTMUSICCONTAINER iface);
-extern ULONG WINAPI   IDirectMusicContainerImpl_Release (LPDIRECTMUSICCONTAINER iface);
-/* IDirectMusicContainer: */
-extern HRESULT WINAPI IDirectMusicContainerImpl_EnumObject (LPDIRECTMUSICCONTAINER iface, REFGUID rguidClass, DWORD dwIndex, LPDMUS_OBJECTDESC pDesc, WCHAR* pwszAlias);
-
-
-/*****************************************************************************
- * IDirectMusicSongImpl implementation structure
- */
-struct IDirectMusicSongImpl
-{
-  /* IUnknown fields */
-  ICOM_VFIELD(IDirectMusicSong);
-  DWORD          ref;
-
-  /* IDirectMusicSongImpl fields */
-};
-
-/* IUnknown: */
-extern HRESULT WINAPI IDirectMusicSongImpl_QueryInterface (LPDIRECTMUSICSONG iface, REFIID riid, LPVOID *ppobj);
-extern ULONG WINAPI   IDirectMusicSongImpl_AddRef (LPDIRECTMUSICSONG iface);
-extern ULONG WINAPI   IDirectMusicSongImpll_Release (LPDIRECTMUSICSONG iface);
-/* IDirectMusicContainer: */
-extern HRESULT WINAPI IDirectMusicSongImpl_Compose (LPDIRECTMUSICSONG iface);
-extern HRESULT WINAPI IDirectMusicSongImpl_GetParam (LPDIRECTMUSICSONG iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam);
-extern HRESULT WINAPI IDirectMusicSongImpl_GetSegment (LPDIRECTMUSICSONG iface, WCHAR* pwzName, IDirectMusicSegment** ppSegment);
-extern HRESULT WINAPI IDirectMusicSongImpl_GetAudioPathConfig (LPDIRECTMUSICSONG iface, IUnknown** ppAudioPathConfig);
-extern HRESULT WINAPI IDirectMusicSongImpl_Download (LPDIRECTMUSICSONG iface, IUnknown* pAudioPath);
-extern HRESULT WINAPI IDirectMusicSongImpl_Unload (LPDIRECTMUSICSONG iface, IUnknown* pAudioPath);
-extern HRESULT WINAPI IDirectMusicSongImpl_EnumSegment (LPDIRECTMUSICSONG iface, DWORD dwIndex, IDirectMusicSegment** ppSegment);
-
-
-/*****************************************************************************
  * Helper Functions
  */
 void register_waveport (LPGUID lpGUID, LPCSTR lpszDesc, LPCSTR lpszDrvName, LPVOID lpContext);
-/* Loader Helper Functions */
-HRESULT WINAPI DMUSIC_FillBandFromFileHandle (IDirectMusicBandImpl *band, HANDLE fd);
-HRESULT WINAPI DMUSIC_FillContainerFromFileHandle (IDirectMusicContainerImpl *container, HANDLE fd);
-HRESULT WINAPI DMUSIC_FillReferenceFromFileHandle (Reference reference, HANDLE fd);
-HRESULT WINAPI DMUSIC_FillScriptFromFileHandle (IDirectMusicScriptImpl *script, HANDLE fd);
-HRESULT WINAPI DMUSIC_FillSegmentFromFileHandle (IDirectMusicSegment8Impl *segment, HANDLE fd);
-HRESULT WINAPI DMUSIC_FillStyleFromFileHandle (IDirectMusicStyle8Impl *style, HANDLE fd);
-HRESULT WINAPI DMUSIC_FillTrackFromFileHandle (IDirectMusicTrack8Impl *segment, HANDLE fd);
-HRESULT WINAPI DMUSIC_FillUNFOFromFileHandle (UNFO_List UNFO, HANDLE fd);
 
 #endif	/* __WINE_DMUSIC_PRIVATE_H */
diff --git a/dlls/dmusic/download.c b/dlls/dmusic/download.c
new file mode 100644
index 0000000..e19574e
--- /dev/null
+++ b/dlls/dmusic/download.c
@@ -0,0 +1,103 @@
+/* IDirectMusicDownload Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "winerror.h"
+#include "mmsystem.h"
+#include "winternl.h"
+#include "mmddk.h"
+#include "wine/windef16.h"
+#include "wine/winbase16.h"
+#include "wine/debug.h"
+#include "dsound.h"
+
+#include "dmusic_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicDownload IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicDownloadImpl_QueryInterface (LPDIRECTMUSICDOWNLOAD iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicDownloadImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicDownload))
+	{
+		IDirectMusicDownloadImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicDownloadImpl_AddRef (LPDIRECTMUSICDOWNLOAD iface)
+{
+	ICOM_THIS(IDirectMusicDownloadImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicDownloadImpl_Release (LPDIRECTMUSICDOWNLOAD iface)
+{
+	ICOM_THIS(IDirectMusicDownloadImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicDownload Interface follow: */
+HRESULT WINAPI IDirectMusicDownloadImpl_GetBuffer (LPDIRECTMUSICDOWNLOAD iface, void** ppvBuffer, DWORD* pdwSize)
+{
+	ICOM_THIS(IDirectMusicDownloadImpl,iface);
+
+	FIXME("(%p,%p, %p): stub\n", This, ppvBuffer, pdwSize);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicDownload) DirectMusicDownload_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicDownloadImpl_QueryInterface,
+	IDirectMusicDownloadImpl_AddRef,
+	IDirectMusicDownloadImpl_Release,
+	IDirectMusicDownloadImpl_GetBuffer
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicDownload (LPCGUID lpcGUID, LPDIRECTMUSICDOWNLOAD* ppDMDL, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicDownload))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmusic/downloadedinstrument.c b/dlls/dmusic/downloadedinstrument.c
new file mode 100644
index 0000000..08bf7a7
--- /dev/null
+++ b/dlls/dmusic/downloadedinstrument.c
@@ -0,0 +1,86 @@
+/* IDirectMusicDownloadedInstrument Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmusic_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicDownloadedInstrument IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicDownloadedInstrumentImpl_QueryInterface (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicDownloadedInstrumentImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicDownloadedInstrument))
+	{
+		IDirectMusicDownloadedInstrumentImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_AddRef (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface)
+{
+	ICOM_THIS(IDirectMusicDownloadedInstrumentImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_Release (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface)
+{
+	ICOM_THIS(IDirectMusicDownloadedInstrumentImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicDownloadedInstrument Interface follow: */
+/* none at this time */
+
+ICOM_VTABLE(IDirectMusicDownloadedInstrument) DirectMusicDownloadedInstrument_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicDownloadedInstrumentImpl_QueryInterface,
+	IDirectMusicDownloadedInstrumentImpl_AddRef,
+	IDirectMusicDownloadedInstrumentImpl_Release
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadedInstrument (LPCGUID lpcGUID, LPDIRECTMUSICDOWNLOADEDINSTRUMENT* ppDMDLInstrument, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicDownloadedInstrument))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmusic/helper.c b/dlls/dmusic/helper.c
index 0614e58..f47b1a5 100644
--- a/dlls/dmusic/helper.c
+++ b/dlls/dmusic/helper.c
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
-
+#if 0
 #include "windef.h"
 #include "winbase.h"
 #include "winuser.h"
@@ -1604,3 +1604,5 @@
 
 	return S_OK;
 }
+
+#endif
diff --git a/dlls/dmusic/instrument.c b/dlls/dmusic/instrument.c
new file mode 100644
index 0000000..3386c46
--- /dev/null
+++ b/dlls/dmusic/instrument.c
@@ -0,0 +1,106 @@
+/* IDirectMusicInstrument Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmusic_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicInstrument IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicInstrumentImpl_QueryInterface (LPDIRECTMUSICINSTRUMENT iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicInstrumentImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicInstrument))
+	{
+		IDirectMusicInstrumentImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicInstrumentImpl_AddRef (LPDIRECTMUSICINSTRUMENT iface)
+{
+	ICOM_THIS(IDirectMusicInstrumentImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicInstrumentImpl_Release (LPDIRECTMUSICINSTRUMENT iface)
+{
+	ICOM_THIS(IDirectMusicInstrumentImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicInstrument Interface follow: */
+HRESULT WINAPI IDirectMusicInstrumentImpl_GetPatch (LPDIRECTMUSICINSTRUMENT iface, DWORD* pdwPatch)
+{
+	ICOM_THIS(IDirectMusicInstrumentImpl,iface);
+
+	TRACE("(%p, %p)\n", This, pdwPatch);
+	*pdwPatch = This->patch;
+	
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicInstrumentImpl_SetPatch (LPDIRECTMUSICINSTRUMENT iface, DWORD dwPatch)
+{
+	ICOM_THIS(IDirectMusicInstrumentImpl,iface);
+
+	TRACE("(%p, %ld)\n", This, dwPatch);
+	This->patch = dwPatch;
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicInstrument) DirectMusicInstrument_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicInstrumentImpl_QueryInterface,
+	IDirectMusicInstrumentImpl_AddRef,
+	IDirectMusicInstrumentImpl_Release,
+	IDirectMusicInstrumentImpl_GetPatch,
+	IDirectMusicInstrumentImpl_SetPatch
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicInstrument (LPCGUID lpcGUID, LPDIRECTMUSICINSTRUMENT* ppDMInstr, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicInstrument))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmusic/object.c b/dlls/dmusic/object.c
new file mode 100644
index 0000000..f0e5f05
--- /dev/null
+++ b/dlls/dmusic/object.c
@@ -0,0 +1,127 @@
+/* IDirectMusicObject Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "config.h"
+
+#include "windef.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "winerror.h"
+#include "mmsystem.h"
+#include "winternl.h"
+#include "mmddk.h"
+#include "wine/windef16.h"
+#include "wine/winbase16.h"
+#include "wine/debug.h"
+#include "dsound.h"
+
+#include "dmusic_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicObject IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicObjectImpl_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicObjectImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicObject))
+	{
+		IDirectMusicObjectImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicObjectImpl_AddRef (LPDIRECTMUSICOBJECT iface)
+{
+	ICOM_THIS(IDirectMusicObjectImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicObjectImpl_Release (LPDIRECTMUSICOBJECT iface)
+{
+	ICOM_THIS(IDirectMusicObjectImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicObject Interface follow: */
+HRESULT WINAPI IDirectMusicObjectImpl_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
+{
+	ICOM_THIS(IDirectMusicObjectImpl,iface);
+
+	TRACE("(%p, %p)\n", This, pDesc);
+	pDesc = This->pDesc;
+	
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicObjectImpl_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
+{
+	ICOM_THIS(IDirectMusicObjectImpl,iface);
+
+	TRACE("(%p, %p)\n", This, pDesc);
+	This->pDesc = pDesc;
+
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicObjectImpl_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc)
+{
+	ICOM_THIS(IDirectMusicObjectImpl,iface);
+
+	FIXME("(%p, %p, %p): stub\n", This, pStream, pDesc);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicObject) DirectMusicObject_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicObjectImpl_QueryInterface,
+	IDirectMusicObjectImpl_AddRef,
+	IDirectMusicObjectImpl_Release,
+	IDirectMusicObjectImpl_GetDescriptor,
+	IDirectMusicObjectImpl_SetDescriptor,
+	IDirectMusicObjectImpl_ParseDescriptor
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicObject (LPCGUID lpcGUID, LPDIRECTMUSICOBJECT* ppDMObj, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicObject))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmusic/dmusic_port.c b/dlls/dmusic/port.c
similarity index 69%
rename from dlls/dmusic/dmusic_port.c
rename to dlls/dmusic/port.c
index 7c0cc77..a2ed0ac 100644
--- a/dlls/dmusic/dmusic_port.c
+++ b/dlls/dmusic/port.c
@@ -1,5 +1,4 @@
 /* IDirectMusicPort Implementation
- * IDirectMusicPortDownloadImpl Implementation
  *
  * Copyright (C) 2003 Rok Mandeljc
  *
@@ -112,8 +111,10 @@
 {
 	ICOM_THIS(IDirectMusicPortImpl,iface);
 
-	FIXME("(%p, %p): stub\n", This, ppClock);
-
+	TRACE("(%p, %p)\n", This, ppClock);
+	*ppClock = This->pLatencyClock;
+	IReferenceClock_AddRef (*ppClock);
+	
 	return S_OK;
 }
 
@@ -131,7 +132,7 @@
 	ICOM_THIS(IDirectMusicPortImpl,iface);
 	
 	TRACE("(%p, %p)\n", This, pPortCaps);
-	pPortCaps = This->caps;
+	pPortCaps = This->pCaps;
 	
 	return S_OK;
 }
@@ -170,7 +171,7 @@
 	ICOM_THIS(IDirectMusicPortImpl,iface);
 
 	TRACE("(%p, %d)\n", This, fActive);
-	This->active = fActive;
+	This->fActive = fActive;
 	
 	return S_OK;
 }
@@ -242,106 +243,15 @@
 	IDirectMusicPortImpl_GetFormat
 };
 
-
-/* IDirectMusicPortDownload IUnknown parts follow: */
-HRESULT WINAPI IDirectMusicPortDownloadImpl_QueryInterface (LPDIRECTMUSICPORTDOWNLOAD iface, REFIID riid, LPVOID *ppobj)
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicPort (LPCGUID lpcGUID, LPDIRECTMUSICPORT* ppDMPort, LPUNKNOWN pUnkOuter)
 {
-	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
-
-	if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicPortDownload))
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicPort))
 	{
-		IDirectMusicPortDownloadImpl_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
 	}
-	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
-	return E_NOINTERFACE;
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
 }
-
-ULONG WINAPI IDirectMusicPortDownloadImpl_AddRef (LPDIRECTMUSICPORTDOWNLOAD iface)
-{
-	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
-	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
-	return ++(This->ref);
-}
-
-ULONG WINAPI IDirectMusicPortDownloadImpl_Release (LPDIRECTMUSICPORTDOWNLOAD iface)
-{
-	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
-	ULONG ref = --This->ref;
-	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-	return ref;
-}
-
-/* IDirectMusicPortDownload Interface follow: */
-HRESULT WINAPI IDirectMusicPortDownloadImpl_GetBuffer (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD dwDLId, IDirectMusicDownload** ppIDMDownload)
-{
-	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
-	
-	FIXME("(%p, %ld, %p): stub\n", This, dwDLId, ppIDMDownload);
-	
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicPortDownloadImpl_AllocateBuffer (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD dwSize, IDirectMusicDownload** ppIDMDownload)
-{
-	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
-	
-	FIXME("(%p, %ld, %p): stub\n", This, dwSize, ppIDMDownload);
-	
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicPortDownloadImpl_GetDLId (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD* pdwStartDLId, DWORD dwCount)
-{
-	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
-	
-	FIXME("(%p, %p, %ld): stub\n", This, pdwStartDLId, dwCount);
-	
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicPortDownloadImpl_GetAppend (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD* pdwAppend)
-{
-	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
-	
-	FIXME("(%p, %p): stub\n", This, pdwAppend);
-	
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicPortDownloadImpl_Download (LPDIRECTMUSICPORTDOWNLOAD iface, IDirectMusicDownload* pIDMDownload)
-{
-	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
-	
-	FIXME("(%p, %p): stub\n", This, pIDMDownload);
-	
-	return S_OK;
-}
-
-HRESULT WINAPI IDirectMusicPortDownloadImpl_Unload (LPDIRECTMUSICPORTDOWNLOAD iface, IDirectMusicDownload* pIDMDownload)
-{
-	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
-	
-	FIXME("(%p, %p): stub\n", This, pIDMDownload);
-	
-	return S_OK;
-}
-
-ICOM_VTABLE(IDirectMusicPortDownload) DirectMusicPortDownload_Vtbl =
-{
-    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
-	IDirectMusicPortDownloadImpl_QueryInterface,
-	IDirectMusicPortDownloadImpl_AddRef,
-	IDirectMusicPortDownloadImpl_Release,
-	IDirectMusicPortDownloadImpl_GetBuffer,
-	IDirectMusicPortDownloadImpl_AllocateBuffer,
-	IDirectMusicPortDownloadImpl_GetDLId,
-	IDirectMusicPortDownloadImpl_GetAppend,
-	IDirectMusicPortDownloadImpl_Download,
-	IDirectMusicPortDownloadImpl_Unload
-};
diff --git a/dlls/dmusic/portdownload.c b/dlls/dmusic/portdownload.c
new file mode 100644
index 0000000..27cd463
--- /dev/null
+++ b/dlls/dmusic/portdownload.c
@@ -0,0 +1,144 @@
+/* IDirectMusicPortDownloadImpl Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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 Library 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmusic_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicPortDownload IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicPortDownloadImpl_QueryInterface (LPDIRECTMUSICPORTDOWNLOAD iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicPortDownload))
+	{
+		IDirectMusicPortDownloadImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicPortDownloadImpl_AddRef (LPDIRECTMUSICPORTDOWNLOAD iface)
+{
+	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicPortDownloadImpl_Release (LPDIRECTMUSICPORTDOWNLOAD iface)
+{
+	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicPortDownload Interface follow: */
+HRESULT WINAPI IDirectMusicPortDownloadImpl_GetBuffer (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD dwDLId, IDirectMusicDownload** ppIDMDownload)
+{
+	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
+	
+	FIXME("(%p, %ld, %p): stub\n", This, dwDLId, ppIDMDownload);
+	
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicPortDownloadImpl_AllocateBuffer (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD dwSize, IDirectMusicDownload** ppIDMDownload)
+{
+	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
+	
+	FIXME("(%p, %ld, %p): stub\n", This, dwSize, ppIDMDownload);
+	
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicPortDownloadImpl_GetDLId (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD* pdwStartDLId, DWORD dwCount)
+{
+	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
+	
+	FIXME("(%p, %p, %ld): stub\n", This, pdwStartDLId, dwCount);
+	
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicPortDownloadImpl_GetAppend (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD* pdwAppend)
+{
+	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
+	
+	FIXME("(%p, %p): stub\n", This, pdwAppend);
+	
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicPortDownloadImpl_Download (LPDIRECTMUSICPORTDOWNLOAD iface, IDirectMusicDownload* pIDMDownload)
+{
+	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
+	
+	FIXME("(%p, %p): stub\n", This, pIDMDownload);
+	
+	return S_OK;
+}
+
+HRESULT WINAPI IDirectMusicPortDownloadImpl_Unload (LPDIRECTMUSICPORTDOWNLOAD iface, IDirectMusicDownload* pIDMDownload)
+{
+	ICOM_THIS(IDirectMusicPortDownloadImpl,iface);
+	
+	FIXME("(%p, %p): stub\n", This, pIDMDownload);
+	
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicPortDownload) DirectMusicPortDownload_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicPortDownloadImpl_QueryInterface,
+	IDirectMusicPortDownloadImpl_AddRef,
+	IDirectMusicPortDownloadImpl_Release,
+	IDirectMusicPortDownloadImpl_GetBuffer,
+	IDirectMusicPortDownloadImpl_AllocateBuffer,
+	IDirectMusicPortDownloadImpl_GetDLId,
+	IDirectMusicPortDownloadImpl_GetAppend,
+	IDirectMusicPortDownloadImpl_Download,
+	IDirectMusicPortDownloadImpl_Unload
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicPortDownload (LPCGUID lpcGUID, LPDIRECTMUSICPORTDOWNLOAD* ppDMPortDL, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicPortDownload))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmusic/regsvr.c b/dlls/dmusic/regsvr.c
index b35eb9c..d84ca94 100644
--- a/dlls/dmusic/regsvr.c
+++ b/dlls/dmusic/regsvr.c
@@ -501,51 +501,6 @@
 /***********************************************************************
  *		coclass list
  */
-
-/* FIXME: these CLSIDs should probably all be defined elsewhere */
-
-GUID const CLSID_DirectMusicSynthSink = {
-    0xAEC17CE3, 0xA514, 0x11D1, {0xAF,0xA6,0x00,0xAA,0x00,0x24,0xD8,0xB6} };
-
-GUID const CLSID_DirectMusicSection = {
-    0x3F037241, 0x414E, 0x11D1, {0xA7,0xCE,0x00,0xA0,0xC9,0x13,0xF7,0x3C} };
-
-GUID const CLSID_DirectMusicAuditionTrack = {
-    0xD2AC2897, 0xB39B, 0x11D1, {0x87,0x04,0x00,0x60,0x08,0x93,0xB1,0xBD} };
-
-GUID const CLSID_DirectMusicSegTriggerTrack = {
-    0xBAE4D665, 0x4EA1, 0x11D3, {0x8B,0xDA,0x00,0x60,0x08,0x93,0xB1,0xB6} };
-
-GUID const CLSID_DirectMusicAudioPath = {
-    0xEE0B9CA0, 0xA81E, 0x11D3, {0x9B,0xD1,0x00,0x80,0xC7,0x15,0x0A,0x74} };
-
-GUID const CLSID_DirectMusicTemplate = {
-    0xD30BCC65, 0x60E8, 0x11D1, {0xA7,0xCE,0x00,0xA0,0xC9,0x13,0xF7,0x3C} };
-
-GUID const CLSID_DirectMusicScriptAutoImpSegment = {
-    0x4062C116, 0x0270, 0x11D3, {0x8B,0xCB,0x00,0x60,0x08,0x93,0xB1,0xB6} };
-
-GUID const CLSID_AudioVBScript = {
-    0x4EE17959, 0x931E, 0x49E4, {0xA2,0xC6,0x97,0x7E,0xCF,0x36,0x28,0xF3} };
-
-GUID const CLSID_DirectMusicScriptAutoImpPerformance = {
-    0xA861C6E2, 0xFCFC, 0x11D2, {0x8B,0xC9,0x00,0x60,0x08,0x93,0xB1,0xB6} };
-
-GUID const CLSID_DirectMusicScripSourceCodeLoader = { /* [sic] */
-    0xC70EB77F, 0xEFD4, 0x4678, {0xA2,0x7B,0xBF,0x16,0x48,0xF3,0x0D,0x04} };
-
-GUID const CLSID_DirectMusicScriptAutoImpSegmentState = {
-    0xEBF2320A, 0x2502, 0x11D3, {0x8B,0xD1,0x00,0x60,0x08,0x93,0xB1,0xB6} };
-
-GUID const CLSID_DirectMusicScriptAutoImpAudioPathConfig = {
-    0x1CEBDE3E, 0x6B91, 0x484A, {0xAF,0x48,0x5E,0x4F,0x4E,0xD6,0xB1,0xE1} };
-
-GUID const CLSID_DirectMusicScriptAutoImpAudioPath = {
-    0x2C5F9B72, 0x7148, 0x4D97, {0xBF,0xC9,0x68,0xA0,0xE0,0x76,0xBE,0xBD} };
-
-GUID const CLSID_DirectMusicScriptAutoImpSong = {
-    0xA16F1761, 0xB6D8, 0x42EB, {0x8D,0x57,0x4A,0x44,0xFE,0xDD,0x3B,0xD2} };
-
 static struct regsvr_coclass const coclass_list[] = {
     {   &CLSID_DirectMusic,
 	"DirectMusic",
@@ -563,367 +518,6 @@
 	"Microsoft.DirectMusicCollection.1",
 	"Microsoft.DirectMusicCollection"
     },
-    {   &CLSID_DirectMusicSynth,
-	"DirectMusicSynth",
-	NULL,
-	"dmsynth.dll",
-	"Both",
-	"Microsoft.DirectMusicSynth.1",
-	"Microsoft.DirectMusicSynth",
-    },
-    {   &CLSID_DirectMusicSynthSink,
-	"DirectMusicSynthSink",
-	NULL,
-	"dmsynth.dll",
-	"Both",
-	"Microsoft.DirectMusicSynthSink.1",
-	"Microsoft.DirectMusicSynthSink"
-    },
-    {   &CLSID_DirectMusicLoader,
-        "DirectMusicLoader",
-	NULL,
-	"dmloader.dll",
-	"Both",
-	"Microsoft.DirectMusicLoader.1",
-	"Microsoft.DirectMusicLoader"
-    },
-    {   &CLSID_DirectMusicContainer,
-        "DirectMusicContainer",
-	NULL,
-	"dmloader.dll",
-	"Both",
-	"Microsoft.DirectMusicContainer.1",
-	"Microsoft.DirectMusicContainer"
-    },
-    {   &CLSID_DirectMusicSection,
-	"DirectMusicSection",
-	NULL,
-	"dmstyle.dll",
-	"Both",
-	"Microsoft.DirectMusicSection.1",
-	"Microsoft.DirectMusicSection"
-    },
-    {   &CLSID_DirectMusicStyle,
-	"DirectMusicStyle",
-	NULL,
-	"dmstyle.dll",
-	"Both",
-	"Microsoft.DirectMusicStyle.1",
-	"Microsoft.DirectMusicStyle"
-    },
-    {   &CLSID_DirectMusicChordTrack,
-	"DirectMusicChordTrack",
-	NULL,
-	"dmstyle.dll",
-	"Both",
-	"Microsoft.DirectMusicChordTrack.1",
-	"Microsoft.DirectMusicChordTrack"
-    },
-    {   &CLSID_DirectMusicCommandTrack,
-	"DirectMusicCommandTrack",
-	NULL,
-	"dmstyle.dll",
-	"Both",
-	"Microsoft.DirectMusicCommandTrack.1",
-	"Microsoft.DirectMusicCommandTrack"
-    },
-    {   &CLSID_DirectMusicStyleTrack,
-	"DirectMusicStyleTrack",
-	NULL,
-	"dmstyle.dll",
-	"Both",
-	"Microsoft.DirectMusicStyleTrack.1",
-	"Microsoft.DirectMusicStyleTrack"
-    },
-    {   &CLSID_DirectMusicMotifTrack,
-	"DirectMusicMotifTrack",
-	NULL,
-	"dmstyle.dll",
-	"Both",
-	"Microsoft.DirectMusicMotifTrack.1",
-	"Microsoft.DirectMusicMotifTrack"
-    },
-    {   &CLSID_DirectMusicAuditionTrack,
-	"DirectMusicAuditionTrack",
-	NULL,
-	"dmstyle.dll",
-	"Both",
-	"Microsoft.DirectMusicAuditionTrack.1",
-	"Microsoft.DirectMusicAuditionTrack"
-    },
-    {   &CLSID_DirectMusicMuteTrack,
-	"DirectMusicMuteTrack",
-	NULL,
-	"dmstyle.dll",
-	"Both",
-	"Microsoft.DirectMusicMuteTrack.1",
-	"Microsoft.DirectMusicMuteTrack"
-    },
-    {   &CLSID_DirectMusicMelodyFormulationTrack,
-	"DirectMusicMelodyFormulationTrack",
-	NULL,
-	"dmstyle.dll",
-	"Both",
-	"Microsoft.DirectMusicMelodyFormulationTrack.1",
-	"Microsoft.DirectMusicMelodyFormulationTrack"
-    },
-    {   &CLSID_DirectMusicPerformance,
-	"DirectMusicPerformance",
-	NULL,
-	"dmime.dll",
-	"Both",
-	"Microsoft.DirectMusicPerformance.1",
-	"Microsoft.DirectMusicPerformance"
-    },
-    {   &CLSID_DirectMusicSegment,
-	"DirectMusicSegment",
-	NULL,
-	"dmime.dll",
-	"Both",
-	"Microsoft.DirectMusicSegment.1",
-	"Microsoft.DirectMusicSegment"
-    },
-    {   &CLSID_DirectMusicSegmentState,
-	"DirectMusicSegmentState",
-	NULL,
-	"dmime.dll",
-	"Both",
-	"Microsoft.DirectMusicSegmentState.1",
-	"Microsoft.DirectMusicSegmentState"
-    },
-    {   &CLSID_DirectMusicGraph,
-	"DirectMusicGraph",
-	NULL,
-	"dmime.dll",
-	"Both",
-	"Microsoft.DirectMusicGraph.1",
-	"Microsoft.DirectMusicGraph"
-    },
-    {   &CLSID_DirectMusicTempoTrack,
-	"DirectMusicTempoTrack",
-	NULL,
-	"dmime.dll",
-	"Both",
-	"Microsoft.DirectMusicTempoTrack.1",
-	"Microsoft.DirectMusicTempoTrack"
-    },
-    {   &CLSID_DirectMusicSeqTrack,
-	"DirectMusicSeqTrack",
-	NULL,
-	"dmime.dll",
-	"Both",
-	"Microsoft.DirectMusicSeqTrack.1",
-	"Microsoft.DirectMusicSeqTrack"
-    },
-    {   &CLSID_DirectMusicSysExTrack,
-	"DirectMusicSysExTrack",
-	NULL,
-	"dmime.dll",
-	"Both",
-	"Microsoft.DirectMusicSysExTrack.1",
-	"Microsoft.DirectMusicSysExTrack"
-    },
-    {   &CLSID_DirectMusicTimeSigTrack,
-	"DirectMusicTimeSigTrack",
-	NULL,
-	"dmime.dll",
-	"Both",
-	"Microsoft.DirectMusicTimeSigTrack.1",
-	"Microsoft.DirectMusicTimeSigTrack"
-    },
-    {   &CLSID_DirectMusicParamControlTrack,
-	"DirectMusicParamControlTrack",
-	NULL,
-	"dmime.dll",
-	"Both",
-	"Microsoft.DirectMusicParamControlTrack.1",
-	"Microsoft.DirectMusicParamControlTrack"
-    },
-    {   &CLSID_DirectMusicMarkerTrack,
-	"DirectMusicMarkerTrack",
-	NULL,
-	"dmime.dll",
-	"Both",
-	"Microsoft.DirectMusicMarkerTrack.1",
-	"Microsoft.DirectMusicMarkerTrack"
-    },
-    {   &CLSID_DirectMusicLyricsTrack,
-	"DirectMusicLyricsTrack",
-	NULL,
-	"dmime.dll",
-	"Both",
-	"Microsoft.DirectMusicLyricsTrack.1",
-	"Microsoft.DirectMusicLyricsTrack"
-    },
-    {   &CLSID_DirectMusicSong,
-	"DirectMusicSong",
-	NULL,
-	"dmime.dll",
-	"Both",
-	"Microsoft.DirectMusicSong.1",
-	"Microsoft.DirectMusicSong"
-    },
-    {   &CLSID_DirectMusicSegTriggerTrack,
-	"DirectMusicSegTriggerTrack",
-	NULL,
-	"dmime.dll",
-	"Both",
-	"Microsoft.DirectMusicSegTriggerTrack.1",
-	"Microsoft.DirectMusicSegTriggerTrack"
-    },
-    {   &CLSID_DirectMusicAudioPath,
-	"DirectMusicAudioPath",
-	NULL,
-	"dmime.dll",
-	"Both",
-	"Microsoft.DirectMusicAudioPath.1",
-	"Microsoft.DirectMusicAudioPath"
-    },
-    {   &CLSID_DirectMusicWaveTrack,
-	"DirectMusicWaveTrack",
-	NULL,
-	"dmime.dll",
-	"Both",
-	"Microsoft.DirectMusicWaveTrack.1",
-	"Microsoft.DirectMusicWaveTrack"
-    },
-    {   &CLSID_DirectMusicChordMap,
-	"DirectMusicChordMap",
-	NULL,
-	"dmcompos.dll",
-	"Both",
-	"Microsoft.DirectMusicChordMap.1",
-	"Microsoft.DirectMusicChordMap"
-    },
-    {   &CLSID_DirectMusicComposer,
-	"DirectMusicComposer",
-	NULL,
-	"dmcompos.dll",
-	"Both",
-	"Microsoft.DirectMusicComposer.1",
-	"Microsoft.DirectMusicComposer"
-    },
-    {   &CLSID_DirectMusicChordMapTrack,
-	"DirectMusicChordMapTrack",
-	NULL,
-	"dmcompos.dll",
-	"Both",
-	"Microsoft.DirectMusicChordMapTrack.1",
-	"Microsoft.DirectMusicChordMapTrack"
-    },
-    {   &CLSID_DirectMusicTemplate,
-	"DirectMusicTemplate",
-	NULL,
-	"dmcompos.dll",
-	"Both",
-	"Microsoft.DirectMusicTemplate.1",
-	"Microsoft.DirectMusicTemplate"
-    },
-    {   &CLSID_DirectMusicSignPostTrack,
-	"DirectMusicSignPostTrack",
-	NULL,
-	"dmcompos.dll",
-	"Both",
-	"Microsoft.DirectMusicSignPostTrack.1",
-	"Microsoft.DirectMusicSignPostTrack"
-    },
-    {   &CLSID_DirectMusicBand,
-	"DirectMusicBand",
-	NULL,
-	"dmband.dll",
-	"Both",
-	"Microsoft.DirectMusicBand.1",
-	"Microsoft.DirectMusicBand"
-    },
-    {   &CLSID_DirectMusicBandTrack,
-	"DirectMusicBandTrack",
-	NULL,
-	"dmband.dll",
-	"Both",
-	"Microsoft.DirectMusicBandTrack.1",
-	"Microsoft.DirectMusicBandTrack"
-    },
-    {   &CLSID_DirectMusicScriptAutoImpSegment,
-        "DirectMusic Script AutoImp Segment",
-	NULL,
-	"dmscript.dll",
-	"Both",
-	"Microsoft.DirectMusicScriptAutoImpSegment.1",
-	"Microsoft.DirectMusicScriptAutoImpSegment"
-    },
-    {   &CLSID_DirectMusicScriptTrack,
-        "DirectMusicScriptTrack",
-	NULL,
-	"dmscript.dll",
-	"Both",
-	"Microsoft.DirectMusicScriptTrack.1",
-	"Microsoft.DirectMusicScriptTrack"
-    },
-    {   &CLSID_AudioVBScript,
-	"DirectMusic Audio VB Script Language",
-	NULL,
-	"dmscript.dll",
-	"Both",
-	"AudioVBScript.1",
-	"AudioVBScript",
-	"DMScript"
-    },
-    {   &CLSID_DirectMusicScript,
-        "DirectMusic Script Object",
-	NULL,
-	"dmscript.dll",
-	"Both",
-	"Microsoft.DirectMusicScript.1",
-	"Microsoft.DirectMusicScript"
-    },
-    {   &CLSID_DirectMusicScriptAutoImpPerformance,
-        "DirectMusic Script AutoImp Performance",
-	NULL,
-	"dmscript.dll",
-	"Both",
-	"Microsoft.DirectMusicScriptAutoImpPerformance.1",
-	"Microsoft.DirectMusicScriptAutoImpPerformance"
-    },
-    {   &CLSID_DirectMusicScripSourceCodeLoader,
-        "DirectMusic Script Source Code Loader",
-	NULL,
-	"dmscript.dll",
-	"Both",
-	"Microsoft.DirectMusicScripSourceCodeLoader.1",	/* [sic] */
-	"Microsoft.DirectMusicScripSourceCodeLoader"
-    },
-    {   &CLSID_DirectMusicScriptAutoImpSegmentState,
-        "DirectMusic Script AutoImp SegmentState",
-	NULL,
-	"dmscript.dll",
-	"Both",
-	"Microsoft.DirectMusicScriptAutoImpSegmentState.1",
-	"Microsoft.DirectMusicScriptAutoImpSegmentState"
-    },
-    {   &CLSID_DirectMusicScriptAutoImpAudioPathConfig,
-        "DirectMusic Script AutoImp AudioPathConfig",
-	NULL,
-	"dmscript.dll",
-	"Both",
-	"Microsoft.DirectMusicScriptAutoImpAudioPathConfig.1",
-	"Microsoft.DirectMusicScriptAutoImpAudioPathConfig"
-    },
-    {   &CLSID_DirectMusicScriptAutoImpAudioPath,
-        "DirectMusic Script AutoImp AudioPath",
-	NULL,
-	"dmscript.dll",
-	"Both",
-	"Microsoft.DirectMusicScriptAutoImpAudioPath.1",
-	"Microsoft.DirectMusicScriptAutoImpAudioPath"
-    },
-    {   &CLSID_DirectMusicScriptAutoImpSong,
-        "DirectMusic Script AutoImp Song",
-	NULL,
-	"dmscript.dll",
-	"Both",
-	"Microsoft.DirectMusicScriptAutoImpSong.1",
-	"Microsoft.DirectMusicScriptAutoImpSong"
-    },
     { NULL }			/* list terminator */
 };
 
@@ -938,7 +532,7 @@
 /***********************************************************************
  *		DllRegisterServer (DMUSIC.3)
  */
-HRESULT WINAPI DMUSIC_DllRegisterServer()
+HRESULT WINAPI DMUSIC_DllRegisterServer(void)
 {
     HRESULT hr;
 
@@ -953,7 +547,7 @@
 /***********************************************************************
  *		DllUnregisterServer (DMUSIC.4)
  */
-HRESULT WINAPI DMUSIC_DllUnregisterServer()
+HRESULT WINAPI DMUSIC_DllUnregisterServer(void)
 {
     HRESULT hr;
 
diff --git a/dlls/dmusic/thru.c b/dlls/dmusic/thru.c
new file mode 100644
index 0000000..7853857
--- /dev/null
+++ b/dlls/dmusic/thru.c
@@ -0,0 +1,95 @@
+/* IDirectMusicThru Implementation
+ *
+ * Copyright (C) 2003 Rok Mandeljc
+ *
+ * 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
+ * MERCHANTABILIY 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 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 "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wingdi.h"
+#include "wine/debug.h"
+
+#include "dmusic_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+
+/* IDirectMusicThru IUnknown parts follow: */
+HRESULT WINAPI IDirectMusicThruImpl_QueryInterface (LPDIRECTMUSICTHRU iface, REFIID riid, LPVOID *ppobj)
+{
+	ICOM_THIS(IDirectMusicThruImpl,iface);
+
+	if (IsEqualGUID(riid, &IID_IUnknown) || 
+	    IsEqualGUID(riid, &IID_IDirectMusicThru))
+	{
+		IDirectMusicThruImpl_AddRef(iface);
+		*ppobj = This;
+		return S_OK;
+	}
+	WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
+	return E_NOINTERFACE;
+}
+
+ULONG WINAPI IDirectMusicThruImpl_AddRef (LPDIRECTMUSICTHRU iface)
+{
+	ICOM_THIS(IDirectMusicThruImpl,iface);
+	TRACE("(%p) : AddRef from %ld\n", This, This->ref);
+	return ++(This->ref);
+}
+
+ULONG WINAPI IDirectMusicThruImpl_Release (LPDIRECTMUSICTHRU iface)
+{
+	ICOM_THIS(IDirectMusicThruImpl,iface);
+	ULONG ref = --This->ref;
+	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
+	if (ref == 0)
+	{
+		HeapFree(GetProcessHeap(), 0, This);
+	}
+	return ref;
+}
+
+/* IDirectMusicThru Interface follow: */
+HRESULT WINAPI IDirectMusicThruImpl_ThruChannel (LPDIRECTMUSICTHRU iface, DWORD dwSourceChannelGroup, DWORD dwSourceChannel, DWORD dwDestinationChannelGroup, DWORD dwDestinationChannel, LPDIRECTMUSICPORT pDestinationPort)
+{
+	ICOM_THIS(IDirectMusicThruImpl,iface);
+
+	FIXME("(%p, %ld, %ld, %ld, %ld, %p): stub\n", This, dwSourceChannelGroup, dwSourceChannel, dwDestinationChannelGroup, dwDestinationChannel, pDestinationPort);
+
+	return S_OK;
+}
+
+ICOM_VTABLE(IDirectMusicThru) DirectMusicThru_Vtbl =
+{
+    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	IDirectMusicThruImpl_QueryInterface,
+	IDirectMusicThruImpl_AddRef,
+	IDirectMusicThruImpl_Release,
+	IDirectMusicThruImpl_ThruChannel
+};
+
+/* for ClassFactory */
+HRESULT WINAPI DMUSIC_CreateDirectMusicThru (LPCGUID lpcGUID, LPDIRECTMUSICTHRU* ppDMThru, LPUNKNOWN pUnkOuter)
+{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicThru))
+	{
+		FIXME("Not yet\n");
+		return E_NOINTERFACE;
+	}
+	WARN("No interface found\n");
+	
+	return E_NOINTERFACE;	
+}
diff --git a/dlls/dmusic32/Makefile.in b/dlls/dmusic32/Makefile.in
index 7f76bd6..2ba9774 100644
--- a/dlls/dmusic32/Makefile.in
+++ b/dlls/dmusic32/Makefile.in
@@ -3,7 +3,8 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = dmusic32.dll
-IMPORTS   = dmusic kernel32
+IMPORTS   = winmm user32 advapi32 kernel32
+EXTRALIBS = $(LIBUUID)
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
diff --git a/include/dmusicc.h b/include/dmusicc.h
index d2d3af7..28088b5 100644
--- a/include/dmusicc.h
+++ b/include/dmusicc.h
@@ -638,7 +638,7 @@
 #ifndef __IReferenceClock_INTERFACE_DEFINED__
 #define __IReferenceClock_INTERFACE_DEFINED__
 
-DEFINE_GUID(IID_IReferenceClock,0x56a86897,0x0ad4,0x11ce,0xb0,0x3a,0x00,0x20,0xaf,0x0b,0xa7,0x70);
+DEFINE_GUID(IID_IReferenceClock, 0x56a86897,0x0ad4,0x11ce,0xb0,0x3a,0x00,0x20,0xaf,0x0b,0xa7,0x70);
 
 /*****************************************************************************
  * IReferenceClock interface
diff --git a/include/dmusici.h b/include/dmusici.h
index 7e2ef15..30c5da1 100644
--- a/include/dmusici.h
+++ b/include/dmusici.h
@@ -42,6 +42,7 @@
 /*****************************************************************************
  * Predeclare the interfaces
  */
+/* CLSIDs */
 DEFINE_GUID(CLSID_DirectMusicPerformance,					0xd2ac2881,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
 DEFINE_GUID(CLSID_DirectMusicSegment,						0xd2ac2882,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
 DEFINE_GUID(CLSID_DirectMusicSegmentState,					0xd2ac2883,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
@@ -57,69 +58,88 @@
 DEFINE_GUID(CLSID_DirectSoundWave,							0x8a667154,0xf9cb,0x11d2,0xad,0x8a,0x0,0x60,0xb0,0x57,0x5a,0xbc);
 DEFINE_GUID(CLSID_DirectMusicSong,							0xaed5f0a5,0xd972,0x483d,0xa3,0x84,0x64,0x9d,0xfe,0xb9,0xc1,0x81);
 DEFINE_GUID(CLSID_DirectMusicAudioPathConfig,				0xee0b9ca0,0xa81e,0x11d3,0x9b,0xd1,0x0,0x80,0xc7,0x15,0xa,0x74);
+/* these CLSIDs aren't officially declared in any dmusic header, but are used by regsvr implementations*/
+DEFINE_GUID(CLSID_DirectMusicSynthSink,						0xaec17ce3,0xa514,0x11d1,0xaf,0xa6,0x00,0xaa,0x00,0x24,0xd8,0xb6);
+DEFINE_GUID(CLSID_DirectMusicSection,						0x3f037241,0x414e,0x11d1,0xa7,0xce,0x00,0xa0,0xc9,0x13,0xf7,0x3c);
+DEFINE_GUID(CLSID_DirectMusicAuditionTrack,					0xd2ac2897,0xb39b,0x11d1,0x87,0x04,0x00,0x60,0x08,0x93,0xb1,0xbd);
+DEFINE_GUID(CLSID_DirectMusicSegTriggerTrack,				0xbae4d665,0x4ea1,0x11d3,0x8b,0xda,0x00,0x60,0x08,0x93,0xb1,0xb6);
+DEFINE_GUID(CLSID_DirectMusicAudioPath,						0xee0b9ca0,0xa81e,0x11d3,0x9b,0xd1,0x00,0x80,0xc7,0x15,0x0a,0x74);
+DEFINE_GUID(CLSID_DirectMusicTemplate,						0xd30bcc65,0x60e8,0x11d1,0xa7,0xce,0x00,0xa0,0xc9,0x13,0xf7,0x3c);
+DEFINE_GUID(CLSID_DirectMusicScriptAutoImpSegment,			0x4062c116,0x0270,0x11d3,0x8b,0xcb,0x00,0x60,0x08,0x93,0xb1,0xb6);
+DEFINE_GUID(CLSID_AudioVBScript,							0x4ee17959,0x931e,0x49e4,0xa2,0xc6,0x97,0x7e,0xcf,0x36,0x28,0xf3);
+DEFINE_GUID(CLSID_DirectMusicScriptAutoImpPerformance,		0xa861c6e2,0xfcfc,0x11d2,0x8b,0xc9,0x00,0x60,0x08,0x93,0xb1,0xb6);
+DEFINE_GUID(CLSID_DirectMusicScripSourceCodeLoader,			0xc70eb77f,0xefd4,0x4678,0xa2,0x7b,0xbf,0x16,0x48,0xf3,0x0d,0x04); /* [sic] */
+DEFINE_GUID(CLSID_DirectMusicScriptAutoImpSegmentState,		0xebf2320a,0x2502,0x11d3,0x8b,0xd1,0x00,0x60,0x08,0x93,0xb1,0xb6);
+DEFINE_GUID(CLSID_DirectMusicScriptAutoImpAudioPathConfig,	0x1cebde3e,0x6b91,0x484a,0xaf,0x48,0x5e,0x4f,0x4e,0xd6,0xb1,0xe1);
+DEFINE_GUID(CLSID_DirectMusicScriptAutoImpAudioPath,		0x2c5f9b72,0x7148,0x4d97,0xbf,0xc9,0x68,0xa0,0xe0,0x76,0xbe,0xbd);
+DEFINE_GUID(CLSID_DirectMusicScriptAutoImpSong,				0xa16f1761,0xb6d8,0x42eb,0x8d,0x57,0x4a,0x44,0xfe,0xdd,0x3b,0xd2);
 
-DEFINE_GUID(IID_IDirectMusicLoader,							0x2ffaaca2,0x5dca,0x11d2,0xaf,0xa6,0x0,0xaa,0x0,0x24,0xd8,0xb6);
-typedef struct IDirectMusicLoader IDirectMusicLoader, *LPDIRECTMUSICLOADER, *LPDMUS_LOADER;
-DEFINE_GUID(IID_IDirectMusicGetLoader,						0x68a04844,0xd13d,0x11d1,0xaf,0xa6,0x0,0xaa,0x0,0x24,0xd8,0xb6);
-#define IID_IDirectMusicGetLoader8 IID_IDirectMusicGetLoader
-typedef struct IDirectMusicGetLoader IDirectMusicGetLoader, *LPDIRECTMUSICGETLOADER, IDirectMusicGetLoader8, *LPDIRECTMUSICGETLOADER8;
-DEFINE_GUID(IID_IDirectMusicObject,							0xd2ac28b5,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
-#define IID_IDirectMusicObject8 IID_IDirectMusicObject
-typedef struct IDirectMusicObject IDirectMusicObject, *LPDIRECTMUSICOBJECT, IDirectMusicObject8, *LPDIRECTMUSICOBJECT8, *LPDMUS_OBJECT;
-DEFINE_GUID(IID_IDirectMusicSegment,						0xf96029a2,0x4282,0x11d2,0x87,0x17,0x0,0x60,0x8,0x93,0xb1,0xbd);
-typedef struct IDirectMusicSegment IDirectMusicSegment, *LPDIRECTMUSICSEGMENT;
-DEFINE_GUID(IID_IDirectMusicSegmentState,					0xa3afdcc7,0xd3ee,0x11d1,0xbc,0x8d,0x0,0xa0,0xc9,0x22,0xe6,0xeb);
-typedef struct IDirectMusicSegmentState IDirectMusicSegmentState, *LPDIRECTMUSICSEGMENTSTATE;
-DEFINE_GUID(IID_IDirectMusicPerformance,					0x7d43d03,0x6523,0x11d2,0x87,0x1d,0x0,0x60,0x8,0x93,0xb1,0xbd);
-typedef struct IDirectMusicPerformance IDirectMusicPerformance, *LPDIRECTMUSICPERFORMANCE;
-DEFINE_GUID(IID_IDirectMusicGraph,							0x2befc277,0x5497,0x11d2,0xbc,0xcb,0x0,0xa0,0xc9,0x22,0xe6,0xeb);
-#define IID_IDirectMusicGraph8 IID_IDirectMusicGraph
-typedef struct IDirectMusicGraph IDirectMusicGraph, *LPDIRECTMUSICGRAPH, IDirectMusicGraph8, *LPDIRECTMUSICGRAPH8;
-DEFINE_GUID(IID_IDirectMusicStyle,							0xd2ac28bd,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
-typedef struct IDirectMusicStyle IDirectMusicStyle, *LPDIRECTMUSICSTYLE;
-DEFINE_GUID(IID_IDirectMusicChordMap,						0xd2ac28be,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
-#define IID_IDirectMusicChordMap8 IID_IDirectMusicChordMap
-typedef struct IDirectMusicChordMap IDirectMusicChordMap, *LPDIRECTMUSICCHORDMAP, IDirectMusicChordMap8, *LPDIRECTMUSICCHORDMAP8;
-DEFINE_GUID(IID_IDirectMusicComposer,						0xd2ac28bf,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
-#define IID_IDirectMusicComposer8 IID_IDirectMusicComposer
-typedef struct IDirectMusicComposer IDirectMusicComposer, *LPDIRECTMUSICCOMPOSER;
-DEFINE_GUID(IID_IDirectMusicBand,							0xd2ac28c0,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
-#define IID_IDirectMusicBand8 IID_IDirectMusicBand
-typedef struct IDirectMusicBand IDirectMusicBand, *LPDIRECTMUSICBAND, IDirectMusicBand8, *LPDIRECTMUSICBAND8, *LPDMUS_BAND;
-DEFINE_GUID(IID_IDirectMusicPerformance2,					0x6fc2cae0,0xbc78,0x11d2,0xaf,0xa6,0x0,0xaa,0x0,0x24,0xd8,0xb6);
-typedef struct IDirectMusicPerformance2 IDirectMusicPerformance2, *LPDIRECTMUSICPERFORMANCE2;
-DEFINE_GUID(IID_IDirectMusicSegment2,						0xd38894d1,0xc052,0x11d2,0x87,0x2f,0x0,0x60,0x8,0x93,0xb1,0xbd);
-typedef struct IDirectMusicSegment2 IDirectMusicSegment2, *LPDIRECTMUSICSEGMENT2;
-DEFINE_GUID(IID_IDirectMusicLoader8,						0x19e7c08c,0xa44,0x4e6a,0xa1,0x16,0x59,0x5a,0x7c,0xd5,0xde,0x8c);
-typedef struct IDirectMusicLoader8 IDirectMusicLoader8, *LPDIRECTMUSICLOADER8;
-DEFINE_GUID(IID_IDirectMusicPerformance8,					0x679c4137,0xc62e,0x4147,0xb2,0xb4,0x9d,0x56,0x9a,0xcb,0x25,0x4c);
-typedef struct IDirectMusicPerformance8 IDirectMusicPerformance8, *LPDIRECTMUSICPERFORMANCE8;
-DEFINE_GUID(IID_IDirectMusicSegment8,						0xc6784488,0x41a3,0x418f,0xaa,0x15,0xb3,0x50,0x93,0xba,0x42,0xd4);
-typedef struct IDirectMusicSegment8 IDirectMusicSegment8, *LPDIRECTMUSICSEGMENT8;
-DEFINE_GUID(IID_IDirectMusicSegmentState8,					0xa50e4730,0xae4,0x48a7,0x98,0x39,0xbc,0x4,0xbf,0xe0,0x77,0x72);
-typedef struct IDirectMusicSegmentState8 IDirectMusicSegmentState8, *LPDIRECTMUSICSEGMENTSTATE8;
-DEFINE_GUID(IID_IDirectMusicStyle8,							0xfd24ad8a,0xa260,0x453d,0xbf,0x50,0x6f,0x93,0x84,0xf7,0x9,0x85);
-typedef struct IDirectMusicStyle8 IDirectMusicStyle8, *LPDIRECTMUSICSTYLE8;
-DEFINE_GUID(IID_IDirectMusicPatternTrack,					0x51c22e10,0xb49f,0x46fc,0xbe,0xc2,0xe6,0x28,0x8f,0xb9,0xed,0xe6);
-#define IID_IDirectMusicPatternTrack8 IID_IDirectMusicPatternTrack
-typedef struct IDirectMusicPatternTrack IDirectMusicPatternTrack, *LPDIRECTMUSICPATTERNTRACK, IDirectMusicPatternTrack8, *LPDIRECTMUSICPATTERNTRACK8;
-DEFINE_GUID(IID_IDirectMusicScript,							0x2252373a,0x5814,0x489b,0x82,0x9,0x31,0xfe,0xde,0xba,0xf1,0x37);
-#define IID_IDirectMusicScript8 IID_IDirectMusicScript
-typedef struct IDirectMusicScript IDirectMusicScript, *LPDIRECTMUSICSCRIPT, IDirectMusicScript8, *LPDIRECTMUSICSCRIPT8;
-DEFINE_GUID(IID_IDirectMusicContainer,						0x9301e386,0x1f22,0x11d3,0x82,0x26,0xd2,0xfa,0x76,0x25,0x5d,0x47);
-#define IID_IDirectMusicContainer8 IID_IDirectMusicContainer
-typedef struct IDirectMusicContainer IDirectMusicContainer, *LPDIRECTMUSICCONTAINER, IDirectMusicContainer8, *LPDIRECTMUSICCONTAINER8;
-DEFINE_GUID(IID_IDirectMusicSong,							0xa862b2ec,0x3676,0x4982,0x85,0xa,0x78,0x42,0x77,0x5e,0x1d,0x86);
-#define IID_IDirectMusicSong8 IID_IDirectMusicSong
-typedef struct IDirectMusicSong IDirectMusicSong, *LPDIRECTMUSICSONG, IDirectMusicSong8, *LPDIRECTMUSICSONG8;
+/* IIDs */
 DEFINE_GUID(IID_IDirectMusicAudioPath,						0xc87631f5,0x23be,0x4986,0x88,0x36,0x5,0x83,0x2f,0xcc,0x48,0xf9);
-#define IID_IDirectMusicAudioPath8 IID_IDirectMusicAudioPath
-typedef struct IDirectMusicAudioPath IDirectMusicAudioPath, *LPDIRECTMUSICAUDIOPATH, IDirectMusicAudioPath8, *LPDIRECTMUSICAUDIOPATH8;
+DEFINE_GUID(IID_IDirectMusicBand,							0xd2ac28c0,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
+DEFINE_GUID(IID_IDirectMusicChordMap,						0xd2ac28be,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
+DEFINE_GUID(IID_IDirectMusicComposer,						0xd2ac28bf,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
+DEFINE_GUID(IID_IDirectMusicContainer,						0x9301e386,0x1f22,0x11d3,0x82,0x26,0xd2,0xfa,0x76,0x25,0x5d,0x47);
+DEFINE_GUID(IID_IDirectMusicGetLoader,						0x68a04844,0xd13d,0x11d1,0xaf,0xa6,0x0,0xaa,0x0,0x24,0xd8,0xb6);
+DEFINE_GUID(IID_IDirectMusicGraph,							0x2befc277,0x5497,0x11d2,0xbc,0xcb,0x0,0xa0,0xc9,0x22,0xe6,0xeb);
+DEFINE_GUID(IID_IDirectMusicLoader,							0x2ffaaca2,0x5dca,0x11d2,0xaf,0xa6,0x0,0xaa,0x0,0x24,0xd8,0xb6);
+DEFINE_GUID(IID_IDirectMusicLoader8,						0x19e7c08c,0xa44,0x4e6a,0xa1,0x16,0x59,0x5a,0x7c,0xd5,0xde,0x8c);
+DEFINE_GUID(IID_IDirectMusicObject,							0xd2ac28b5,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
+DEFINE_GUID(IID_IDirectMusicPatternTrack,					0x51c22e10,0xb49f,0x46fc,0xbe,0xc2,0xe6,0x28,0x8f,0xb9,0xed,0xe6);
+DEFINE_GUID(IID_IDirectMusicPerformance,					0x7d43d03,0x6523,0x11d2,0x87,0x1d,0x0,0x60,0x8,0x93,0xb1,0xbd);
+DEFINE_GUID(IID_IDirectMusicPerformance2,					0x6fc2cae0,0xbc78,0x11d2,0xaf,0xa6,0x0,0xaa,0x0,0x24,0xd8,0xb6);
+DEFINE_GUID(IID_IDirectMusicPerformance8,					0x679c4137,0xc62e,0x4147,0xb2,0xb4,0x9d,0x56,0x9a,0xcb,0x25,0x4c);
+DEFINE_GUID(IID_IDirectMusicScript,							0x2252373a,0x5814,0x489b,0x82,0x9,0x31,0xfe,0xde,0xba,0xf1,0x37);
+DEFINE_GUID(IID_IDirectMusicSegment,						0xf96029a2,0x4282,0x11d2,0x87,0x17,0x0,0x60,0x8,0x93,0xb1,0xbd);
+DEFINE_GUID(IID_IDirectMusicSegment2,						0xd38894d1,0xc052,0x11d2,0x87,0x2f,0x0,0x60,0x8,0x93,0xb1,0xbd);
+DEFINE_GUID(IID_IDirectMusicSegment8,						0xc6784488,0x41a3,0x418f,0xaa,0x15,0xb3,0x50,0x93,0xba,0x42,0xd4);
+DEFINE_GUID(IID_IDirectMusicSegmentState,					0xa3afdcc7,0xd3ee,0x11d1,0xbc,0x8d,0x0,0xa0,0xc9,0x22,0xe6,0xeb);
+DEFINE_GUID(IID_IDirectMusicSegmentState8,					0xa50e4730,0xae4,0x48a7,0x98,0x39,0xbc,0x4,0xbf,0xe0,0x77,0x72);
+DEFINE_GUID(IID_IDirectMusicSong,							0xa862b2ec,0x3676,0x4982,0x85,0xa,0x78,0x42,0x77,0x5e,0x1d,0x86);
+DEFINE_GUID(IID_IDirectMusicStyle,							0xd2ac28bd,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
+DEFINE_GUID(IID_IDirectMusicStyle8,							0xfd24ad8a,0xa260,0x453d,0xbf,0x50,0x6f,0x93,0x84,0xf7,0x9,0x85);
 
+/* IIDs of unchanged interfaces */
+#define IID_IDirectMusicAudioPath8 IID_IDirectMusicAudioPath
+#define IID_IDirectMusicBand8 IID_IDirectMusicBand
+#define IID_IDirectMusicChordMap8 IID_IDirectMusicChordMap
+#define IID_IDirectMusicComposer8 IID_IDirectMusicComposer
+#define IID_IDirectMusicContainer8 IID_IDirectMusicContainer
+#define IID_IDirectMusicGetLoader8 IID_IDirectMusicGetLoader
+#define IID_IDirectMusicGraph8 IID_IDirectMusicGraph
+#define IID_IDirectMusicObject8 IID_IDirectMusicObject
+#define IID_IDirectMusicPatternTrack8 IID_IDirectMusicPatternTrack
+#define IID_IDirectMusicScript8 IID_IDirectMusicScript
+#define IID_IDirectMusicSong8 IID_IDirectMusicSong
+
+/* typedef definitions */
+typedef struct IDirectMusicAudioPath IDirectMusicAudioPath, *LPDIRECTMUSICAUDIOPATH, IDirectMusicAudioPath8, *LPDIRECTMUSICAUDIOPATH8;
+typedef struct IDirectMusicBand IDirectMusicBand, *LPDIRECTMUSICBAND, IDirectMusicBand8, *LPDIRECTMUSICBAND8, *LPDMUS_BAND;
+typedef struct IDirectMusicChordMap IDirectMusicChordMap, *LPDIRECTMUSICCHORDMAP, IDirectMusicChordMap8, *LPDIRECTMUSICCHORDMAP8;
+typedef struct IDirectMusicComposer IDirectMusicComposer, *LPDIRECTMUSICCOMPOSER;
+typedef struct IDirectMusicContainer IDirectMusicContainer, *LPDIRECTMUSICCONTAINER, IDirectMusicContainer8, *LPDIRECTMUSICCONTAINER8;
+typedef struct IDirectMusicGetLoader IDirectMusicGetLoader, *LPDIRECTMUSICGETLOADER, IDirectMusicGetLoader8, *LPDIRECTMUSICGETLOADER8;
+typedef struct IDirectMusicGraph IDirectMusicGraph, *LPDIRECTMUSICGRAPH, IDirectMusicGraph8, *LPDIRECTMUSICGRAPH8;
+typedef struct IDirectMusicLoader IDirectMusicLoader, *LPDIRECTMUSICLOADER, *LPDMUS_LOADER;
+typedef struct IDirectMusicLoader8 IDirectMusicLoader8, *LPDIRECTMUSICLOADER8;
+typedef struct IDirectMusicObject IDirectMusicObject, *LPDIRECTMUSICOBJECT, IDirectMusicObject8, *LPDIRECTMUSICOBJECT8, *LPDMUS_OBJECT;
+typedef struct IDirectMusicPatternTrack IDirectMusicPatternTrack, *LPDIRECTMUSICPATTERNTRACK, IDirectMusicPatternTrack8, *LPDIRECTMUSICPATTERNTRACK8;
+typedef struct IDirectMusicPerformance IDirectMusicPerformance, *LPDIRECTMUSICPERFORMANCE;
+typedef struct IDirectMusicPerformance2 IDirectMusicPerformance2, *LPDIRECTMUSICPERFORMANCE2;
+typedef struct IDirectMusicPerformance8 IDirectMusicPerformance8, *LPDIRECTMUSICPERFORMANCE8;
+typedef struct IDirectMusicScript IDirectMusicScript, *LPDIRECTMUSICSCRIPT, IDirectMusicScript8, *LPDIRECTMUSICSCRIPT8;
+typedef struct IDirectMusicSegment IDirectMusicSegment, *LPDIRECTMUSICSEGMENT;
+typedef struct IDirectMusicSegment2 IDirectMusicSegment2, *LPDIRECTMUSICSEGMENT2;
+typedef struct IDirectMusicSegment8 IDirectMusicSegment8, *LPDIRECTMUSICSEGMENT8;
+typedef struct IDirectMusicSegmentState IDirectMusicSegmentState, *LPDIRECTMUSICSEGMENTSTATE;
+typedef struct IDirectMusicSegmentState8 IDirectMusicSegmentState8, *LPDIRECTMUSICSEGMENTSTATE8;
+typedef struct IDirectMusicSong IDirectMusicSong, *LPDIRECTMUSICSONG, IDirectMusicSong8, *LPDIRECTMUSICSONG8;
+typedef struct IDirectMusicStyle IDirectMusicStyle, *LPDIRECTMUSICSTYLE;
+typedef struct IDirectMusicStyle8 IDirectMusicStyle8, *LPDIRECTMUSICSTYLE8;
 /* Imported from dmplugin.h */
-typedef struct IDirectMusicTrack IDirectMusicTrack, *LPDIRECTMUSICTRACK;
 typedef struct IDirectMusicTool IDirectMusicTool, *LPDIRECTMUSICTOOL;
 typedef struct IDirectMusicTool8 IDirectMusicTool8, *LPDIRECTMUSICTOOL8;
+typedef struct IDirectMusicTrack IDirectMusicTrack, *LPDIRECTMUSICTRACK;
 typedef struct IDirectMusicTrack8 IDirectMusicTrack8, *LPDIRECTMUSICTRACK8;
 
 DEFINE_GUID(GUID_DirectMusicAllTypes,						0xd2ac2893,0xb39b,0x11d1,0x87,0x4,0x0,0x60,0x8,0x93,0xb1,0xbd);
diff --git a/include/dmusics.h b/include/dmusics.h
index 5192ee8..112434f 100644
--- a/include/dmusics.h
+++ b/include/dmusics.h
@@ -36,11 +36,13 @@
  */
 
 DEFINE_GUID(IID_IDirectMusicSynth, 			0x9823661,0x5c85,0x11d2,0xaf,0xa6,0x0,0xaa,0x0,0x24,0xd8,0xb6);
-typedef struct IDirectMusicSynth IDirectMusicSynth, *LPDIRECTMUSICSYNTH;
 DEFINE_GUID(IID_IDirectMusicSynth8,			0x53cab625,0x2711,0x4c9f,0x9d,0xe7,0x1b,0x7f,0x92,0x5f,0x6f,0xc8);
-typedef struct IDirectMusicSynth8 IDirectMusicSynth8, *LPDIRECTMUSICSYNTH8;
 DEFINE_GUID(IID_IDirectMusicSynthSink,		0x9823663,0x5c85,0x11d2,0xaf,0xa6,0x0,0xaa, 0x0,0x24,0xd8,0xb6);
-typedef struct IDirectMusicSynthSink IDirectMusicSynthSink, *LPDIRECTMUSICSYNTHSINK;
+
+typedef struct IDirectMusicSynth IDirectMusicSynth, *LPDIRECTMUSICSYNTH;
+typedef struct IDirectMusicSynth8 IDirectMusicSynth8, *LPDIRECTMUSICSYNTH8;
+typedef struct IDirectMusicSynthSink IDirectMusicSynthSink, *LPDIRECTMUSICSYNTHSINK;	
+
 DEFINE_GUID(GUID_DMUS_PROP_SetSynthSink,	0x0a3a5ba5,0x37b6,0x11d2,0xb9,0xf9,0x00,0x00,0xf8,0x75,0xac,0x12);
 DEFINE_GUID(GUID_DMUS_PROP_SinkUsesDSound,	0xbe208857,0x8952,0x11d2,0xba,0x1c,0x00,0x00,0xf8,0x75,0xac,0x12);