Previous Next

IDirectMusicSynthSink

The IDirectMusicSynthSink interface is now largely obsolete and is supported only by versions of DirectMusic before DirectX 8. This interface represents a streaming wave device that pulls audio from the DirectMusic software synthesizer. By separating the functionality of IDirectMusicSynth from that of IDirectMusicSynthSink, a DirectMusic application can take the output of any synthesizer and feed it to an audio device of its choosing. IDirectMusicSynthSink inherits from the IUnknown interface.

By default, the wave data generated by the software synth is handled by DirectMusic's internal synth sink, which feeds the wave data into DirectSound.

In DirectX 6.1 and DirectX 7, however, you are free to implement your own IDirectMusicSynthSink and use it to manage the audio-output stream in any way you like. For example, you might feed the wave data into DirectShow or the Windows Multimedia waveOutXxx API. If you create a wave-stream object, it should have an IDirectMusicSynthSink interface to plug into the IDirectMusicSynth.

In DirectX 8 and later, DirectMusic always uses its internal synth sink. These later versions of DirectMusic do not support custom implementations of IDirectMusicSynthSink.

In addition to managing the wave stream, the sink owns the timing for the synthesizer. It receives the master clock by a call to IDirectMusicSynth::SetMasterClock, which passes the master time source on with an identical call to IDirectMusicSynthSink::SetMasterClock. Because the master clock cannot be from the same crystal as the streaming wave, the sink must keep them synchronized.

Additionally, so that the synthesizer can keep track of time appropriately, it provides two calls to convert from master clock time to sample time and back:

IDirectMusicSynthSink::RefTimeToSample

IDirectMusicSynthSink::SampleToRefTime

The sink generates the latency clock because it actually manages the times at which samples get written by calls to IDirectMusicSynth::Render. When DirectMusic calls IDirectMusicSynth::GetLatencyClock on the DirectMusic "port", it simply turns around and calls IDirectMusicSynthSink::GetLatencyClock.

When a software synthesizer is first opened, it is given a sample rate and number of channels (stereo or mono) in the DMUS_PORTPARAMS structure. It then converts these into a standard WAVEFORMATEX structure that it passes to the sink when the sink calls the IDirectMusicSynth::GetFormat method.

In addition to the methods that IDirectMusicSynthSink inherits from the IUnknown interface, IDirectMusicSynthSink supports the methods shown in the following table, which organizes them into functional groups.

Group Method Names
Initialization IDirectMusicSynthSink::Activate

IDirectMusicSynthSink::GetDesiredBufferSize

IDirectMusicSynthSink::Init

IDirectMusicSynthSink::SetDirectSound

Timing IDirectMusicSynthSink::GetLatencyClock

IDirectMusicSynthSink::RefTimeToSample

IDirectMusicSynthSink::SampleToRefTime

IDirectMusicSynthSink::SetMasterClock