Platform SDK: DirectX

Using Authored Segments

An authored segment is a file or resource that contains all the data for a piece of music. It can be based on a MIDI file or on a style and a chord map. Unlike a simple MIDI file or resource, it can contain band changes and variations.

Note  A template is an authored segment as well, but it does not represent a self-contained piece of music. For more information, see Using Templates.

[C++]

Create a segment in your application by loading the segment as an object and obtaining the IDirectMusicSegment interface, as in the following code example, in which the segment is loaded from a DirectMusic Producer file:

/* It is assumed that pLoader is a valid pointer to 
   an IDirectMusicLoader interface and that the search
   directory has been properly set. */
 
DMUS_OBJECTDESC ObjectDescript;
IDirectMusicSegment* pSegment;
 
ObjectDescript.dwSize = sizeof(DMUS_OBJECTDESC);
ObjectDescript.idClass = CLSID_DirectMusicSegment;
strcpy(ObjectDescript.wszFileName, L"Dance.sgt");
ObjectDescript.dwValidData = DMOBJ_CLASS | DMOBJ_PATH ;
pLoader->GetObject(&ObjectDescript, IID_IDirectMusicSegment2,
    (void**) pSegment)))

You can now pass pSegment to the IDirectMusicPerformance::PlaySegment method.

[Visual Basic]

Create a segment in your application by using the DirectMusicLoader.LoadSegment or the DirectMusicLoader.LoadSegmentFromResource method, as in the following code example, in which the segment is loaded from a DirectMusic Producer file:

' loader is the DirectMusicLoader object.
Dim seg As DirectMusicSegment
Set seg = loader.LoadSegment("Sample.sgt")

You can now pass seg to the DirectMusicPerformance.PlaySegment method.