Previous Next

Synthesizers and Wave Sinks

The rendering engine has two parts:

By default, a DirectMusic application uses the Microsoft Software Synthesizer (dmsynth.dll) as the synthesizer and DirectSound as the wave-output device.

In DirectX® 6.1 and DirectX® 7, a DirectMusic application can override these defaults. For example, the application might use the Microsoft Software Synthesizer but direct the output to a .wav file, or it might implement a custom synthesizer that works with the default wave sink. The latter scenario is more likely because the default wave sink should work well for most synthesizers.

In DirectX® 8 and later, DirectMusic always uses its built-in wave sink to output data from a user-mode synth, but an application can override the default software synth. This means that a DirectMusic application can implement a custom user-mode synthesizer, but the synthesizer must use DirectMusic's built-in wave sink.

The figure below shows how the DirectMusic architecture incorporates user-mode synthesizers and wave sinks. Note that the block labeled "Port" in the following figure represents a DirectMusic port, which should not be confused with a WDM audio port driver. For more information about DirectMusic ports, see the Platform SDK documentation.

DirectMusic Architecture for User-Mode Synthesizers and Wave Sinks

In the figure above, the application sends data to the user-mode DirectMusic port, which passes the data (MIDI or DLS) down to the software synth (dmsynth.dll by default) so that it can render the notes into wave data. The synth sink manages the timing and hands the synth a buffer to fill when it is ready to receive a burst of data. The synth fills up the buffer (an IDirectSoundBuffer object by default) with data so that it can be passed to DirectSound. DirectSound either plays the data through the KMixer system driver or plays it through a DirectSound hardware-accelerated rendering pin on the audio device, if one is available (see DirectSound Hardware Acceleration in WDM Audio).

This same basic architecture also applies to kernel-mode implementations, with the exception that the sink hands the data buffer directly to the hardware or to the KMixer system driver. For more information about kernel-mode architecture, see Kernel Mode Hardware Acceleration DDI.

In user mode, a custom software synthesizer is created by implementing the IDirectMusicSynth interface. This interface is supported in DirectX 6.1 and later.

Only DirectX 6.1 and DirectX 7 support the implementation of a custom user-mode synth sink with an IDirectMusicSynthSink interface. Before the synthesizer can be activated, the wave sink should be created and connected to the synth by a call to IDirectMusicSynth::SetSynthSink. This call should be the very first call after creating the synth, because many of the timing-related calls are actually passed through to equivalent calls on IDirectMusicSynthSink. In DirectX 8 and later, custom wave sinks are not supported.

When these steps are completed, the user-mode DirectMusic port should be open and activated for use. As soon as this much of the driver code is working, you can start implementing features. Use the source code for the user-mode Microsoft Software Synthesizer as a template and begin adding the new functionality.

See IDirectMusicSynth for a discussion of how to create an instance of the DirectMusic default user-mode synthesizer, connect it to an instance of the default user-mode wave sink, open the user-mode DirectMusic port, and activate it for use.

The ddksynth sample source code that ships as part of the DDK can serve as the template for your synth implementation. For more information, see Sample Audio Drivers. This sample synth is similar to the default software synth for DirectMusic, but lacks certain advanced features such as reverb.