ReactOS 0.4.17-dev-966-gf06eace
dmusic_private.h File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winnt.h"
#include "wingdi.h"
#include "winuser.h"
#include "wine/debug.h"
#include "wine/list.h"
#include "winreg.h"
#include "objbase.h"
#include "dmusici.h"
#include "dmusicf.h"
#include "dmusics.h"
#include "dmksctrl.h"
#include "dmobject.h"
#include "dmusic_wave.h"
Include dependency graph for dmusic_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  DMUSIC_PRIVATE_MCHANNEL_
 
struct  DMUSIC_PRIVATE_CHANNEL_GROUP_
 
struct  port_info
 
struct  IDirectMusic8Impl
 
struct  IDirectMusicBufferImpl
 
struct  IReferenceClockImpl
 
struct  _DMUS_PRIVATE_POOLCUE
 
struct  flag_info
 

Macros

#define COBJMACROS
 
#define FE(x)   { x, #x }
 

Typedefs

typedef struct IDirectMusic8Impl IDirectMusic8Impl
 
typedef struct IDirectMusicBufferImpl IDirectMusicBufferImpl
 
typedef struct IReferenceClockImpl IReferenceClockImpl
 
typedef struct DMUSIC_PRIVATE_MCHANNEL_ DMUSIC_PRIVATE_MCHANNEL
 
typedef struct DMUSIC_PRIVATE_MCHANNEL_ * LPDMUSIC_PRIVATE_MCHANNEL
 
typedef struct DMUSIC_PRIVATE_CHANNEL_GROUP_ DMUSIC_PRIVATE_CHANNEL_GROUP
 
typedef struct DMUSIC_PRIVATE_CHANNEL_GROUP_ * LPDMUSIC_PRIVATE_CHANNEL_GROUP
 
typedef struct port_info port_info
 
typedef struct _DMUS_PRIVATE_POOLCUE DMUS_PRIVATE_POOLCUE
 
typedef struct _DMUS_PRIVATE_POOLCUE * LPDMUS_PRIVATE_POOLCUE
 

Functions

void collection_internal_addref (struct collection *collection)
 
void collection_internal_release (struct collection *collection)
 
HRESULT collection_get_wave (struct collection *collection, DWORD index, IDirectMusicObject **out)
 
HRESULT music_create (IUnknown **ret_iface)
 
HRESULT collection_create (IUnknown **ret_iface)
 
HRESULT DMUSIC_CreateDirectMusicBufferImpl (LPDMUS_BUFFERDESC desc, LPVOID *ret_iface)
 
HRESULT DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter)
 
HRESULT download_create (DWORD size, IDirectMusicDownload **ret_iface)
 
HRESULT instrument_create_from_soundfont (struct soundfont *soundfont, UINT index, struct collection *collection, DMUS_OBJECTDESC *desc, IDirectMusicInstrument **ret_iface)
 
HRESULT instrument_create_from_chunk (IStream *stream, struct chunk_entry *parent, struct collection *collection, DMUS_OBJECTDESC *desc, IDirectMusicInstrument **ret_iface)
 
HRESULT instrument_download_to_port (IDirectMusicInstrument *iface, IDirectMusicPortDownload *port, IDirectMusicDownloadedInstrument **downloaded)
 
HRESULT instrument_unload_from_port (IDirectMusicDownloadedInstrument *iface, IDirectMusicPortDownload *port)
 
HRESULT synth_port_create (IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params, DMUS_PORTCAPS *port_caps, IDirectMusicPort **port)
 
HRESULT midi_out_port_create (IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params, DMUS_PORTCAPS *port_caps, IDirectMusicPort **port)
 
HRESULT midi_in_port_create (IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params, DMUS_PORTCAPS *port_caps, IDirectMusicPort **port)
 
void dmusic_remove_port (IDirectMusic8Impl *dmusic, IDirectMusicPort *port)
 
DWORD MIDILOCALE2Patch (const MIDILOCALE *pLocale)
 
void Patch2MIDILOCALE (DWORD dwPatch, LPMIDILOCALE pLocale)
 
void dump_DMUS_PORTPARAMS (LPDMUS_PORTPARAMS params)
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 27 of file dmusic_private.h.

◆ FE

#define FE (   x)    { x, #x }

Definition at line 169 of file dmusic_private.h.

Typedef Documentation

◆ DMUS_PRIVATE_POOLCUE

◆ DMUSIC_PRIVATE_CHANNEL_GROUP

◆ DMUSIC_PRIVATE_MCHANNEL

◆ IDirectMusic8Impl

Definition at line 50 of file dmusic_private.h.

◆ IDirectMusicBufferImpl

◆ IReferenceClockImpl

Definition at line 52 of file dmusic_private.h.

◆ LPDMUS_PRIVATE_POOLCUE

◆ LPDMUSIC_PRIVATE_CHANNEL_GROUP

◆ LPDMUSIC_PRIVATE_MCHANNEL

◆ port_info

Function Documentation

◆ collection_create()

HRESULT collection_create ( IUnknown **  ret_iface)

Definition at line 749 of file collection.c.

750{
751 struct collection *collection;
752
753 *ret_iface = NULL;
754 if (!(collection = calloc(1, sizeof(*collection)))) return E_OUTOFMEMORY;
757 collection->ref = 1;
758 dmobject_init(&collection->dmobj, &CLSID_DirectMusicCollection,
760 collection->dmobj.IDirectMusicObject_iface.lpVtbl = &collection_object_vtbl;
761 collection->dmobj.IPersistStream_iface.lpVtbl = &collection_stream_vtbl;
764
765 TRACE("Created DirectMusicCollection %p\n", collection);
767 return S_OK;
768}
static void list_init(struct list_entry *head)
Definition: list.h:51
static const IDirectMusicCollectionVtbl collection_vtbl
Definition: collection.c:222
static const IPersistStreamVtbl collection_stream_vtbl
Definition: collection.c:737
static const IDirectMusicObjectVtbl collection_object_vtbl
Definition: collection.c:666
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
void dmobject_init(struct dmobject *dmobj, const GUID *class, IUnknown *outer_unk)
Definition: dmobject.c:749
#define S_OK
Definition: intsafe.h:52
#define calloc
Definition: rosglue.h:14
#define TRACE(s)
Definition: solgame.cpp:4
struct list instruments
Definition: collection.c:62
IDirectMusicCollection IDirectMusicCollection_iface
Definition: collection.c:55
LONG internal_ref
Definition: collection.c:57
struct dmobject dmobj
Definition: collection.c:56
struct list waves
Definition: collection.c:63
LONG ref
Definition: collection.c:58

◆ collection_get_wave()

HRESULT collection_get_wave ( struct collection *  collection,
DWORD  index,
IDirectMusicObject **  out 
)

Definition at line 81 of file collection.c.

82{
83 struct wave_entry *wave_entry;
85
86 if (index >= collection->pool->table.cCues) return E_INVALIDARG;
87 offset = collection->pool->cues[index].ulOffset;
88
90 {
91 if (offset == wave_entry->offset)
92 {
94 IUnknown_AddRef(wave_entry->wave);
95 return S_OK;
96 }
97 }
98
99 return E_FAIL;
100}
#define index(s, c)
Definition: various.h:29
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
GLintptr offset
Definition: glext.h:5920
GLuint index
Definition: glext.h:6031
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:236
struct pool * pool
Definition: collection.c:61
Definition: collection.c:47
IDirectMusicObject * wave
Definition: collection.c:49
DWORD offset
Definition: collection.c:50
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

Referenced by instrument_download_to_port().

◆ collection_internal_addref()

void collection_internal_addref ( struct collection *  collection)

Definition at line 66 of file collection.c.

67{
69 TRACE( "collection %p, internal ref %lu.\n", collection, ref );
70}
#define InterlockedIncrement
Definition: armddk.h:53
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

Referenced by instrument_create().

◆ collection_internal_release()

void collection_internal_release ( struct collection *  collection)

Definition at line 72 of file collection.c.

73{
75 TRACE( "collection %p, internal ref %lu.\n", collection, ref );
76
77 if (!ref)
79}
#define InterlockedDecrement
Definition: armddk.h:52
#define free
Definition: debug_ros.c:5

Referenced by collection_Release(), and instrument_Release().

◆ DMUSIC_CreateDirectMusicBufferImpl()

HRESULT DMUSIC_CreateDirectMusicBufferImpl ( LPDMUS_BUFFERDESC  desc,
LPVOID *  ret_iface 
)

Definition at line 293 of file buffer.c.

294{
295 IDirectMusicBufferImpl* dmbuffer;
296
297 TRACE("(%p, %p)\n", desc, ret_iface);
298
299 *ret_iface = NULL;
300
301 dmbuffer = calloc(1, sizeof(IDirectMusicBufferImpl));
302 if (!dmbuffer)
303 return E_OUTOFMEMORY;
304
306 dmbuffer->ref = 1;
307
308 if (IsEqualGUID(&desc->guidBufferFormat, &GUID_NULL))
310 else
311 dmbuffer->format = desc->guidBufferFormat;
312 dmbuffer->size = (desc->cbBuffer + 3) & ~3; /* Buffer size must be multiple of 4 bytes */
313
314 dmbuffer->data = malloc(dmbuffer->size);
315 if (!dmbuffer->data) {
316 free(dmbuffer);
317 return E_OUTOFMEMORY;
318 }
319
320 *ret_iface = &dmbuffer->IDirectMusicBuffer_iface;
321
322 return S_OK;
323}
#define malloc
Definition: debug_ros.c:4
static const IDirectMusicBufferVtbl DirectMusicBuffer_Vtbl
Definition: buffer.c:274
#define GUID_NULL
Definition: ks.h:106
#define KSDATAFORMAT_SUBTYPE_MIDI
Definition: ksmedia.h:1016
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
IDirectMusicBuffer IDirectMusicBuffer_iface

Referenced by IDirectMusic8Impl_CreateMusicBuffer().

◆ DMUSIC_CreateReferenceClockImpl()

HRESULT DMUSIC_CreateReferenceClockImpl ( LPCGUID  lpcGUID,
LPVOID *  ppobj,
LPUNKNOWN  pUnkOuter 
)

Definition at line 116 of file clock.c.

117{
119 HRESULT hr;
120
121 TRACE("(%s, %p, %p)\n", debugstr_guid(riid), ret_iface, unkouter);
122
123 clock = calloc(1, sizeof(IReferenceClockImpl));
124 if (!clock) {
125 *ret_iface = NULL;
126 return E_OUTOFMEMORY;
127 }
128
129 clock->IReferenceClock_iface.lpVtbl = &ReferenceClock_Vtbl;
130 clock->ref = 1;
131 clock->rtTime = 0;
132 clock->pClockInfo.dwSize = sizeof (DMUS_CLOCKINFO);
133
134 hr = IReferenceClockImpl_QueryInterface(&clock->IReferenceClock_iface, riid, ret_iface);
135 IReferenceClock_Release(&clock->IReferenceClock_iface);
136
137 return hr;
138}
HRESULT hr
Definition: delayimp.cpp:582
static HRESULT WINAPI IReferenceClockImpl_QueryInterface(IReferenceClock *iface, REFIID riid, LPVOID *ppobj)
Definition: clock.c:31
static const IReferenceClockVtbl ReferenceClock_Vtbl
Definition: clock.c:105
_ACRTIMP clock_t __cdecl clock(void)
Definition: time.c:698
DMUS_CLOCKINFO8 DMUS_CLOCKINFO
Definition: dmusicc.h:278
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35

Referenced by midi_port_create().

◆ dmusic_remove_port()

void dmusic_remove_port ( IDirectMusic8Impl *  dmusic,
IDirectMusicPort *  port 
)

Definition at line 291 of file dmusic.c.

292{
293 BOOL found = FALSE;
294 int i;
295
296 TRACE("Removing port %p.\n", port);
297
298 for (i = 0; i < dmusic->num_ports; i++)
299 {
300 if (dmusic->ports[i] == port) {
301 found = TRUE;
302 break;
303 }
304 }
305
306 if (!found)
307 {
308 ERR("Port %p not found in ports array.\n", port);
309 return;
310 }
311
312 if (!--dmusic->num_ports) {
313 free(dmusic->ports);
314 dmusic->ports = NULL;
315 return;
316 }
317
318 memmove(&dmusic->ports[i], &dmusic->ports[i + 1],
319 (dmusic->num_ports - i) * sizeof(*dmusic->ports));
320 dmusic->ports = realloc(dmusic->ports, sizeof(*dmusic->ports) * dmusic->num_ports);
321}
#define ERR(fmt,...)
Definition: precomp.h:57
#define realloc
Definition: debug_ros.c:6
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
USHORT port
Definition: uri.c:210
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
IDirectMusicPort ** ports

Referenced by synth_port_Release().

◆ download_create()

HRESULT download_create ( DWORD  size,
IDirectMusicDownload **  ret_iface 
)

Definition at line 106 of file download.c.

107{
108 struct download *download;
109
110 *ret_iface = NULL;
111 if (!(download = malloc(offsetof(struct download, data[size])))) return E_OUTOFMEMORY;
113 download->ref = 1;
114 download->size = size;
115
116 TRACE("Created DirectMusicDownload %p\n", download);
118 return S_OK;
119}
static const IDirectMusicDownloadVtbl download_vtbl
Definition: download.c:98
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
#define offsetof(TYPE, MEMBER)
IDirectMusicDownload IDirectMusicDownload_iface
Definition: download.c:27
DWORD size
Definition: download.c:30
LONG ref
Definition: download.c:28

Referenced by synth_port_download_AllocateBuffer().

◆ dump_DMUS_PORTPARAMS()

void dump_DMUS_PORTPARAMS ( LPDMUS_PORTPARAMS  params)

Definition at line 203 of file dmusic_main.c.

204{
205 TRACE("DMUS_PORTPARAMS (%p):\n", params);
206 TRACE(" - dwSize = %ld\n", params->dwSize);
207 TRACE(" - dwValidParams = %s\n", debugstr_DMUS_PORTPARAMS_FLAGS(params->dwValidParams));
208 if (params->dwValidParams & DMUS_PORTPARAMS_VOICES) TRACE(" - dwVoices = %lu\n", params->dwVoices);
209 if (params->dwValidParams & DMUS_PORTPARAMS_CHANNELGROUPS) TRACE(" - dwChannelGroup = %lu\n", params->dwChannelGroups);
210 if (params->dwValidParams & DMUS_PORTPARAMS_AUDIOCHANNELS) TRACE(" - dwAudioChannels = %lu\n", params->dwAudioChannels);
211 if (params->dwValidParams & DMUS_PORTPARAMS_SAMPLERATE) TRACE(" - dwSampleRate = %lu\n", params->dwSampleRate);
212 if (params->dwValidParams & DMUS_PORTPARAMS_EFFECTS) TRACE(" - dwEffectFlags = %lx\n", params->dwEffectFlags);
213 if (params->dwValidParams & DMUS_PORTPARAMS_SHARE) TRACE(" - fShare = %u\n", params->fShare);
214}
static const char * debugstr_DMUS_PORTPARAMS_FLAGS(DWORD flagmask)
Definition: dmusic_main.c:189
#define DMUS_PORTPARAMS_CHANNELGROUPS
Definition: dmusicc.h:206
#define DMUS_PORTPARAMS_SAMPLERATE
Definition: dmusicc.h:208
#define DMUS_PORTPARAMS_AUDIOCHANNELS
Definition: dmusicc.h:207
#define DMUS_PORTPARAMS_SHARE
Definition: dmusicc.h:210
#define DMUS_PORTPARAMS_VOICES
Definition: dmusicc.h:205
#define DMUS_PORTPARAMS_EFFECTS
Definition: dmusicc.h:209
GLenum const GLfloat * params
Definition: glext.h:5645

Referenced by IDirectMusic8Impl_CreatePort().

◆ instrument_create_from_chunk()

HRESULT instrument_create_from_chunk ( IStream *  stream,
struct chunk_entry *  parent,
struct collection *  collection,
DMUS_OBJECTDESC *  desc,
IDirectMusicInstrument **  ret_iface 
)

Definition at line 417 of file instrument.c.

419{
420 IDirectMusicInstrument *iface;
421 struct instrument *This;
422 HRESULT hr;
423
424 TRACE("(%p, %p, %p, %p, %p)\n", stream, parent, collection, desc, ret_iface);
425
426 if (FAILED(hr = instrument_create(collection, &iface))) return hr;
428
430 {
433 }
434
435 if (TRACE_ON(dmusic))
436 {
437 struct region *region;
438 UINT i;
439
440 TRACE("Created DirectMusicInstrument %p\n", This);
441 TRACE(" - header:\n");
442 TRACE(" - regions: %ld\n", This->header.cRegions);
443 TRACE(" - locale: {bank: %#lx, instrument: %#lx} (patch %#lx)\n",
444 This->header.Locale.ulBank, This->header.Locale.ulInstrument,
445 MIDILOCALE2Patch(&This->header.Locale));
446 if (desc->dwValidData & DMUS_OBJ_OBJECT) TRACE(" - guid: %s\n", debugstr_dmguid(&desc->guidObject));
447 if (desc->dwValidData & DMUS_OBJ_NAME) TRACE(" - name: %s\n", debugstr_w(desc->wszName));
448
449 TRACE(" - regions:\n");
450 LIST_FOR_EACH_ENTRY(region, &This->regions, struct region, entry)
451 {
452 TRACE(" - region:\n");
453 TRACE(" - header: {key: %u - %u, vel: %u - %u, options: %#x, group: %#x}\n",
457 TRACE(" - wave_link: {options: %#x, group: %u, channel: %lu, index: %lu}\n",
460 TRACE(" - wave_sample: {size: %lu, unity_note: %u, fine_tune: %d, attenuation: %ld, options: %#lx, loops: %lu}\n",
464 for (i = 0; i < region->wave_sample.cSampleLoops; i++)
465 TRACE(" - wave_loop[%u]: {size: %lu, type: %lu, start: %lu, length: %lu}\n", i,
468 }
469 }
470
471 *ret_iface = iface;
472 return S_OK;
473}
#define TRACE_ON(x)
Definition: compat.h:75
#define DMUS_E_UNSUPPORTED_STREAM
Definition: dmerror.h:100
const char * debugstr_dmguid(const GUID *id)
Definition: dmobject.c:36
DWORD MIDILOCALE2Patch(const MIDILOCALE *pLocale)
Definition: dmusic_main.c:150
#define IDirectMusicInstrument_Release(p)
Definition: dmusicc.h:527
#define DMUS_OBJ_NAME
Definition: dmusici.h:267
#define DMUS_OBJ_OBJECT
Definition: dmusici.h:265
r parent
Definition: btrfs.c:3010
unsigned int UINT
Definition: sysinfo.c:13
static HRESULT instrument_create(struct collection *collection, IDirectMusicInstrument **ret_iface)
Definition: instrument.c:234
static struct instrument * impl_from_IDirectMusicInstrument(IDirectMusicInstrument *iface)
Definition: instrument.c:87
static HRESULT parse_ins_chunk(struct instrument *This, IStream *stream, struct chunk_entry *parent, DMUS_OBJECTDESC *desc)
Definition: instrument.c:375
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_w
Definition: kernel32.h:32
USHORT usKeyGroup
Definition: dls1.h:128
RGNRANGE RangeVelocity
Definition: dls1.h:126
USHORT fusOptions
Definition: dls1.h:127
RGNRANGE RangeKey
Definition: dls1.h:125
USHORT usHigh
Definition: dls1.h:120
USHORT usLow
Definition: dls1.h:119
ULONG cbSize
Definition: dls1.h:133
ULONG ulLength
Definition: dls1.h:136
ULONG ulType
Definition: dls1.h:134
ULONG ulStart
Definition: dls1.h:135
LONG lAttenuation
Definition: dls1.h:144
SHORT sFineTune
Definition: dls1.h:143
ULONG fulOptions
Definition: dls1.h:145
ULONG cSampleLoops
Definition: dls1.h:146
ULONG cbSize
Definition: dls1.h:141
USHORT usUnityNote
Definition: dls1.h:142
WAVELINK wave_link
Definition: instrument.c:55
RGNHEADER header
Definition: instrument.c:54
WSMPL wave_sample
Definition: instrument.c:56
WLOOP wave_loop
Definition: instrument.c:57
Definition: parse.h:23

Referenced by parse_lins_list().

◆ instrument_create_from_soundfont()

HRESULT instrument_create_from_soundfont ( struct soundfont *  soundfont,
UINT  index,
struct collection *  collection,
DMUS_OBJECTDESC *  desc,
IDirectMusicInstrument **  ret_iface 
)

Definition at line 620 of file instrument.c.

622{
623 struct sf_preset *preset = soundfont->phdr + index;
624 struct sf_generators global_generators = {0};
625 IDirectMusicInstrument *iface;
626 struct instrument *This;
627 HRESULT hr;
628 UINT i;
629
630 TRACE("(%p, %u, %p, %p, %p)\n", soundfont, index, collection, desc, ret_iface);
631
632 if (FAILED(hr = instrument_create(collection, &iface))) return hr;
634
635 This->header.Locale.ulBank = (preset->bank & 0x7f) | ((preset->bank << 1) & 0x7f00);
636 This->header.Locale.ulInstrument = preset->preset;
637 MultiByteToWideChar(CP_ACP, 0, preset->name, strlen(preset->name) + 1,
638 desc->wszName, sizeof(desc->wszName));
639
640 for (i = preset->bag_ndx; SUCCEEDED(hr) && i < (preset + 1)->bag_ndx; i++)
641 {
642 struct sf_generators generators = global_generators;
644
645 if (parse_soundfont_generators(soundfont, i, NULL, &generators))
646 {
647 if (i > preset->bag_ndx)
648 WARN("Ignoring preset zone without an instrument\n");
649 else
650 global_generators = generators;
651 continue;
652 }
653
656 }
657
658 if (FAILED(hr))
659 {
661 return hr;
662 }
663
664 if (TRACE_ON(dmusic))
665 {
666 struct region *region;
667 UINT i;
668
669 TRACE("Created DirectMusicInstrument %p\n", This);
670 TRACE(" - header:\n");
671 TRACE(" - regions: %ld\n", This->header.cRegions);
672 TRACE(" - locale: {bank: %#lx, instrument: %#lx} (patch %#lx)\n",
673 This->header.Locale.ulBank, This->header.Locale.ulInstrument,
674 MIDILOCALE2Patch(&This->header.Locale));
675 if (desc->dwValidData & DMUS_OBJ_OBJECT) TRACE(" - guid: %s\n", debugstr_dmguid(&desc->guidObject));
676 if (desc->dwValidData & DMUS_OBJ_NAME) TRACE(" - name: %s\n", debugstr_w(desc->wszName));
677
678 TRACE(" - regions:\n");
679 LIST_FOR_EACH_ENTRY(region, &This->regions, struct region, entry)
680 {
681 TRACE(" - region:\n");
682 TRACE(" - header: {key: %u - %u, vel: %u - %u, options: %#x, group: %#x}\n",
686 TRACE(" - wave_link: {options: %#x, group: %u, channel: %lu, index: %lu}\n",
689 TRACE(" - wave_sample: {size: %lu, unity_note: %u, fine_tune: %d, attenuation: %ld, options: %#lx, loops: %lu}\n",
693 for (i = 0; i < region->wave_sample.cSampleLoops; i++)
694 TRACE(" - wave_loop[%u]: {size: %lu, type: %lu, start: %lu, length: %lu}\n", i,
697 }
698 }
699
700 *ret_iface = iface;
701 return S_OK;
702}
#define WARN(fmt,...)
Definition: precomp.h:61
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
static BOOL parse_soundfont_generators(struct soundfont *soundfont, UINT index, struct sf_generators *preset_generators, struct sf_generators *generators)
Definition: instrument.c:506
static HRESULT instrument_add_soundfont_instrument(struct instrument *This, struct soundfont *soundfont, UINT index, struct sf_generators *preset_generators)
Definition: instrument.c:593
#define SUCCEEDED(hr)
Definition: intsafe.h:50
@ SF_GEN_INSTRUMENT
Definition: soundfont.h:99
union sf_amount amount[SF_GEN_END_OPER]
Definition: instrument.c:477
WORD bank
Definition: soundfont.h:224
char name[20]
Definition: soundfont.h:222
WORD bag_ndx
Definition: soundfont.h:225
WORD preset
Definition: soundfont.h:223
struct sf_preset * phdr
Definition: soundfont.h:309
WORD value
Definition: soundfont.h:40

Referenced by parse_sfbk_chunk().

◆ instrument_download_to_port()

HRESULT instrument_download_to_port ( IDirectMusicInstrument *  iface,
IDirectMusicPortDownload *  port,
IDirectMusicDownloadedInstrument **  downloaded 
)

Definition at line 752 of file instrument.c.

754{
757 struct download_buffer *buffer;
758 IDirectMusicDownload *download;
759 DWORD size, offset_count;
760 struct region *region;
761 IDirectMusicObject *wave;
762 HRESULT hr;
763
764 if (This->download) goto done;
765
766 size = sizeof(DMUS_DOWNLOADINFO);
767 size += sizeof(ULONG) + sizeof(DMUS_INSTRUMENT);
768 offset_count = 1;
769
770 LIST_FOR_EACH_ENTRY(articulation, &This->articulations, struct articulation, entry)
771 {
772 size += sizeof(ULONG) + sizeof(DMUS_ARTICULATION2);
773 size += sizeof(ULONG) + sizeof(CONNECTIONLIST);
775 offset_count += 2;
776 }
777
778 LIST_FOR_EACH_ENTRY(region, &This->regions, struct region, entry)
779 {
780 size += sizeof(ULONG) + sizeof(DMUS_REGION);
781 offset_count++;
782
784 {
785 size += sizeof(ULONG) + sizeof(DMUS_ARTICULATION2);
786 size += sizeof(ULONG) + sizeof(CONNECTIONLIST);
788 offset_count += 2;
789 }
790 }
791
793
796 {
797 BYTE *ptr = (BYTE *)&buffer->offsets[offset_count];
798 DMUS_INSTRUMENT *dmus_instrument;
799 DMUS_REGION *dmus_region = NULL;
800 UINT index = 0;
801
802 buffer->info.dwDLType = DMUS_DOWNLOADINFO_INSTRUMENT2;
803 buffer->info.dwNumOffsetTableEntries = offset_count;
804 buffer->info.cbSize = size;
805
806 buffer->offsets[index++] = ptr - (BYTE *)buffer;
807 dmus_instrument = (DMUS_INSTRUMENT *)ptr;
808 ptr += sizeof(DMUS_INSTRUMENT);
809
810 dmus_instrument->ulPatch = MIDILOCALE2Patch(&This->header.Locale);
811 dmus_instrument->ulFirstRegionIdx = 0;
812 dmus_instrument->ulCopyrightIdx = 0;
813 dmus_instrument->ulGlobalArtIdx = 0;
814
815 write_articulation_download(&This->articulations, buffer->offsets, &ptr, index,
816 &dmus_instrument->ulGlobalArtIdx, &index);
817
818 LIST_FOR_EACH_ENTRY(region, &This->regions, struct region, entry)
819 {
820 if (dmus_region) dmus_region->ulNextRegionIdx = index;
821 else dmus_instrument->ulFirstRegionIdx = index;
822
823 buffer->offsets[index++] = ptr - (BYTE *)buffer;
824 dmus_region = (DMUS_REGION *)ptr;
825 ptr += sizeof(DMUS_REGION);
826
827 dmus_region->RangeKey = region->header.RangeKey;
828 dmus_region->RangeVelocity = region->header.RangeVelocity;
829 dmus_region->fusOptions = region->header.fusOptions;
830 dmus_region->usKeyGroup = region->header.usKeyGroup;
831 dmus_region->ulRegionArtIdx = 0;
832 dmus_region->ulNextRegionIdx = 0;
833 dmus_region->ulFirstExtCkIdx = 0;
834 dmus_region->WaveLink = region->wave_link;
835 dmus_region->WSMP = region->wave_sample;
836 dmus_region->WLOOP[0] = region->wave_loop;
837
839 {
840 hr = wave_download_to_port(wave, port, &dmus_region->WaveLink.ulTableIndex);
842 }
843 if (FAILED(hr)) goto failed;
844
846 &dmus_region->ulRegionArtIdx, &index);
847 }
848
850 }
851
852 This->download = download;
853
854done:
855 *downloaded = &This->IDirectMusicDownloadedInstrument_iface;
857 return S_OK;
858
859failed:
860 WARN("Failed to download instrument to port, hr %#lx\n", hr);
862 return hr;
863}
HRESULT collection_get_wave(struct collection *collection, DWORD index, IDirectMusicObject **out)
Definition: collection.c:81
struct _CONNECTION CONNECTION
#define DMUS_DOWNLOADINFO_INSTRUMENT2
Definition: dmdls.h:8
struct _DMUS_DOWNLOADINFO DMUS_DOWNLOADINFO
struct _DMUS_REGION DMUS_REGION
struct _DMUS_INSTRUMENT DMUS_INSTRUMENT
HRESULT wave_download_to_port(IDirectMusicObject *iface, IDirectMusicPortDownload *port, DWORD *id)
Definition: wave.c:437
#define IDirectMusicDownload_Release(p)
Definition: dmusicc.h:604
#define IDirectMusicPortDownload_GetDLId(p, a, b)
Definition: dmusicc.h:638
#define IDirectMusicPortDownload_Download(p, a)
Definition: dmusicc.h:640
#define IDirectMusicDownload_GetBuffer(p, a, b)
Definition: dmusicc.h:606
#define IDirectMusicPortDownload_AllocateBuffer(p, a, b)
Definition: dmusicc.h:637
#define IDirectMusicDownloadedInstrument_AddRef(p)
Definition: dmusicc.h:551
#define IDirectMusicObject_Release(p)
Definition: dmusici.h:844
GLuint buffer
Definition: glext.h:5915
static void write_articulation_download(struct list *articulations, ULONG *offsets, BYTE **ptr, UINT index, DWORD *first, UINT *end)
Definition: instrument.c:704
static PVOID ptr
Definition: dispmode.c:27
ULONG cConnections
Definition: dls1.h:73
CONNECTIONLIST list
Definition: instrument.c:40
struct list articulations
Definition: instrument.c:53
Definition: wave.c:37
unsigned char BYTE
Definition: xxhash.c:193

Referenced by synth_port_DownloadInstrument().

◆ instrument_unload_from_port()

HRESULT instrument_unload_from_port ( IDirectMusicDownloadedInstrument *  iface,
IDirectMusicPortDownload *  port 
)

Definition at line 865 of file instrument.c.

866{
868 struct download_buffer *buffer;
869 DWORD size;
870 HRESULT hr;
871
872 if (!This->download) return DMUS_E_NOT_DOWNLOADED_TO_PORT;
873
875 WARN("Failed to unload instrument download buffer, hr %#lx\n", hr);
876 else if (SUCCEEDED(hr = IDirectMusicDownload_GetBuffer(This->download, (void **)&buffer, &size)))
877 {
878 IDirectMusicDownload *wave_download;
880 BYTE *ptr = (BYTE *)buffer;
882 UINT index;
883
884 instrument = (DMUS_INSTRUMENT *)(ptr + buffer->offsets[0]);
885 for (index = instrument->ulFirstRegionIdx; index; index = region->ulNextRegionIdx)
886 {
887 region = (DMUS_REGION *)(ptr + buffer->offsets[index]);
888
889 if (FAILED(hr = IDirectMusicPortDownload_GetBuffer(port, region->WaveLink.ulTableIndex, &wave_download)))
890 WARN("Failed to get wave download with id %#lx, hr %#lx\n", region->WaveLink.ulTableIndex, hr);
891 else
892 {
893 if (FAILED(hr = IDirectMusicPortDownload_Unload(port, wave_download)))
894 WARN("Failed to unload wave download buffer, hr %#lx\n", hr);
895 IDirectMusicDownload_Release(wave_download);
896 }
897 }
898 }
899
901 This->download = NULL;
902
903 return hr;
904}
#define DMUS_E_NOT_DOWNLOADED_TO_PORT
Definition: dmerror.h:68
#define IDirectMusicPortDownload_GetBuffer(p, a, b)
Definition: dmusicc.h:636
#define IDirectMusicPortDownload_Unload(p, a)
Definition: dmusicc.h:641
static struct instrument * impl_from_IDirectMusicDownloadedInstrument(IDirectMusicDownloadedInstrument *iface)
Definition: instrument.c:194

Referenced by synth_port_UnloadInstrument().

◆ midi_in_port_create()

HRESULT midi_in_port_create ( IDirectMusic8Impl *  parent,
DMUS_PORTPARAMS *  port_params,
DMUS_PORTCAPS *  port_caps,
IDirectMusicPort **  port 
)

Definition at line 1072 of file port.c.

1074{
1075 TRACE("(%p, %p, %p, %p)\n", parent, params, caps, port);
1076
1077 return midi_port_create(parent, params, caps, port);
1078}
static HRESULT midi_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *params, DMUS_PORTCAPS *caps, IDirectMusicPort **port)
Definition: port.c:1040

Referenced by create_system_ports_list().

◆ midi_out_port_create()

HRESULT midi_out_port_create ( IDirectMusic8Impl *  parent,
DMUS_PORTPARAMS *  port_params,
DMUS_PORTCAPS *  port_caps,
IDirectMusicPort **  port 
)

Definition at line 1064 of file port.c.

1066{
1067 TRACE("(%p, %p, %p, %p)\n", parent, params, caps, port);
1068
1069 return midi_port_create(parent, params, caps, port);
1070}

Referenced by create_system_ports_list().

◆ MIDILOCALE2Patch()

DWORD MIDILOCALE2Patch ( const MIDILOCALE *  pLocale)

Definition at line 150 of file dmusic_main.c.

150 {
151 DWORD dwPatch = 0;
152 if (!pLocale) return 0;
153 dwPatch |= (pLocale->ulBank & F_INSTRUMENT_DRUMS); /* set drum bit */
154 dwPatch |= ((pLocale->ulBank & 0x00007F7F) << 8); /* set MIDI bank location */
155 dwPatch |= (pLocale->ulInstrument & 0x0000007F); /* set PC value */
156 return dwPatch;
157}
#define F_INSTRUMENT_DRUMS
Definition: dls1.h:51
ULONG ulInstrument
Definition: dls1.h:97
ULONG ulBank
Definition: dls1.h:96

Referenced by instrument_create_from_chunk(), instrument_create_from_soundfont(), instrument_download_to_port(), and instrument_GetPatch().

◆ music_create()

HRESULT music_create ( IUnknown **  ret_iface)

Definition at line 579 of file dmusic.c.

580{
581 IDirectMusic8Impl *dmusic;
582 HRESULT ret;
583
584 TRACE("(%p)\n", ret_iface);
585
586 *ret_iface = NULL;
587 if (!(dmusic = calloc(1, sizeof(*dmusic)))) return E_OUTOFMEMORY;
588 dmusic->IDirectMusic8_iface.lpVtbl = &DirectMusic8_Vtbl;
589 dmusic->ref = 1;
591 if (FAILED(ret)) {
592 free(dmusic);
593 return ret;
594 }
595
597
598 TRACE("Created DirectMusic %p\n", dmusic);
599 *ret_iface = (IUnknown *)&dmusic->IDirectMusic8_iface;
600 return S_OK;
601}
static const IDirectMusic8Vtbl DirectMusic8_Vtbl
Definition: dmusic.c:469
static HRESULT master_clock_create(IReferenceClock **clock)
Definition: dmusic.c:128
static void create_system_ports_list(IDirectMusic8Impl *object)
Definition: dmusic.c:485
return ret
Definition: mutex.c:147
IReferenceClock * master_clock
IDirectMusic8 IDirectMusic8_iface

◆ Patch2MIDILOCALE()

void Patch2MIDILOCALE ( DWORD  dwPatch,
LPMIDILOCALE  pLocale 
)

Definition at line 160 of file dmusic_main.c.

160 {
161 memset (pLocale, 0, sizeof(MIDILOCALE));
162
163 pLocale->ulInstrument = (dwPatch & 0x7F); /* get PC value */
164 pLocale->ulBank = ((dwPatch & 0x007F7F00) >> 8); /* get MIDI bank location */
165 pLocale->ulBank |= (dwPatch & F_INSTRUMENT_DRUMS); /* get drum bit */
166}
#define memset(x, y, z)
Definition: compat.h:39

Referenced by instrument_SetPatch().

◆ synth_port_create()

HRESULT synth_port_create ( IDirectMusic8Impl *  parent,
DMUS_PORTPARAMS *  port_params,
DMUS_PORTCAPS *  port_caps,
IDirectMusicPort **  port 
)

Internal factory

Definition at line 686 of file port.c.

688{
689 struct synth_port *obj;
690 HRESULT hr = E_FAIL;
691 int i;
692
693 TRACE("(%p, %p)\n", port_params, port);
694
695 *port = NULL;
696
697 obj = calloc(1, sizeof(*obj));
698 if (!obj)
699 return E_OUTOFMEMORY;
700
701 obj->IDirectMusicPort_iface.lpVtbl = &synth_port_vtbl;
702 obj->IDirectMusicPortDownload_iface.lpVtbl = &synth_port_download_vtbl;
703 obj->IDirectMusicThru_iface.lpVtbl = &synth_port_thru_vtbl;
704 obj->IKsControl_iface.lpVtbl = &ikscontrol_vtbl;
705 obj->ref = 1;
706 obj->parent = parent;
707 obj->active = FALSE;
708 obj->params = *port_params;
709 list_init(&obj->downloads);
710
711 hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth,
712 (void **)&obj->synth);
713
714 if (SUCCEEDED(hr))
715 hr = CoCreateInstance(&CLSID_DirectMusicSynthSink, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynthSink, (void**)&obj->synth_sink);
716
717 if (SUCCEEDED(hr))
718 hr = IDirectMusicSynth_SetSynthSink(obj->synth, obj->synth_sink);
719
720 if (SUCCEEDED(hr))
721 hr = IDirectMusicSynth_SetMasterClock(obj->synth, obj->parent->master_clock);
722
723 if (SUCCEEDED(hr))
724 hr = IDirectMusicSynthSink_SetMasterClock(obj->synth_sink, obj->parent->master_clock);
725
726 if (SUCCEEDED(hr))
727 hr = IDirectMusicSynth_Open(obj->synth, port_params);
728
729 if (0)
730 {
731 if (port_params->dwValidParams & DMUS_PORTPARAMS_CHANNELGROUPS) {
732 obj->nrofgroups = port_params->dwChannelGroups;
733 /* Setting default priorities */
734 for (i = 0; i < obj->nrofgroups; i++) {
735 TRACE ("Setting default channel priorities on channel group %i\n", i + 1);
736 obj->group[i].channel[0].priority = DAUD_CHAN1_DEF_VOICE_PRIORITY;
737 obj->group[i].channel[1].priority = DAUD_CHAN2_DEF_VOICE_PRIORITY;
738 obj->group[i].channel[2].priority = DAUD_CHAN3_DEF_VOICE_PRIORITY;
739 obj->group[i].channel[3].priority = DAUD_CHAN4_DEF_VOICE_PRIORITY;
740 obj->group[i].channel[4].priority = DAUD_CHAN5_DEF_VOICE_PRIORITY;
741 obj->group[i].channel[5].priority = DAUD_CHAN6_DEF_VOICE_PRIORITY;
742 obj->group[i].channel[6].priority = DAUD_CHAN7_DEF_VOICE_PRIORITY;
743 obj->group[i].channel[7].priority = DAUD_CHAN8_DEF_VOICE_PRIORITY;
744 obj->group[i].channel[8].priority = DAUD_CHAN9_DEF_VOICE_PRIORITY;
745 obj->group[i].channel[9].priority = DAUD_CHAN10_DEF_VOICE_PRIORITY;
746 obj->group[i].channel[10].priority = DAUD_CHAN11_DEF_VOICE_PRIORITY;
747 obj->group[i].channel[11].priority = DAUD_CHAN12_DEF_VOICE_PRIORITY;
748 obj->group[i].channel[12].priority = DAUD_CHAN13_DEF_VOICE_PRIORITY;
749 obj->group[i].channel[13].priority = DAUD_CHAN14_DEF_VOICE_PRIORITY;
750 obj->group[i].channel[14].priority = DAUD_CHAN15_DEF_VOICE_PRIORITY;
751 obj->group[i].channel[15].priority = DAUD_CHAN16_DEF_VOICE_PRIORITY;
752 }
753 }
754 }
755
756 if (SUCCEEDED(hr)) {
757 *port = &obj->IDirectMusicPort_iface;
758 return S_OK;
759 }
760
761 if (obj->synth)
763 if (obj->synth_sink)
765 free(obj);
766
767 return hr;
768}
static const IDirectMusicPortDownloadVtbl synth_port_download_vtbl
Definition: port.c:556
static const IDirectMusicThruVtbl synth_port_thru_vtbl
Definition: port.c:608
static const IDirectMusicPortVtbl synth_port_vtbl
Definition: port.c:385
static const IKsControlVtbl ikscontrol_vtbl
Definition: port.c:677
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
#define IDirectMusicSynth_Release(p)
Definition: dmusics.h:108
#define IDirectMusicSynth_SetSynthSink(p, a)
Definition: dmusics.h:121
#define IDirectMusicSynthSink_Release(p)
Definition: dmusics.h:225
#define IDirectMusicSynth_Open(p, a)
Definition: dmusics.h:110
#define IDirectMusicSynth_SetMasterClock(p, a)
Definition: dmusics.h:118
#define IDirectMusicSynthSink_SetMasterClock(p, a)
Definition: dmusics.h:228
#define DAUD_CHAN16_DEF_VOICE_PRIORITY
Definition: dmusprop.h:182
#define DAUD_CHAN4_DEF_VOICE_PRIORITY
Definition: dmusprop.h:170
#define DAUD_CHAN13_DEF_VOICE_PRIORITY
Definition: dmusprop.h:179
#define DAUD_CHAN9_DEF_VOICE_PRIORITY
Definition: dmusprop.h:175
#define DAUD_CHAN14_DEF_VOICE_PRIORITY
Definition: dmusprop.h:180
#define DAUD_CHAN5_DEF_VOICE_PRIORITY
Definition: dmusprop.h:171
#define DAUD_CHAN7_DEF_VOICE_PRIORITY
Definition: dmusprop.h:173
#define DAUD_CHAN6_DEF_VOICE_PRIORITY
Definition: dmusprop.h:172
#define DAUD_CHAN10_DEF_VOICE_PRIORITY
Definition: dmusprop.h:176
#define DAUD_CHAN8_DEF_VOICE_PRIORITY
Definition: dmusprop.h:174
#define DAUD_CHAN3_DEF_VOICE_PRIORITY
Definition: dmusprop.h:169
#define DAUD_CHAN1_DEF_VOICE_PRIORITY
Definition: dmusprop.h:167
#define DAUD_CHAN2_DEF_VOICE_PRIORITY
Definition: dmusprop.h:168
#define DAUD_CHAN15_DEF_VOICE_PRIORITY
Definition: dmusprop.h:181
#define DAUD_CHAN11_DEF_VOICE_PRIORITY
Definition: dmusprop.h:177
#define DAUD_CHAN12_DEF_VOICE_PRIORITY
Definition: dmusprop.h:178
DWORD dwValidParams
Definition: dmusicc.h:316
DWORD dwChannelGroups
Definition: dmusicc.h:318

Referenced by create_system_ports_list().