Many DirectMusic objects have to be loaded from a file or resource before they can be incorporated into a music performance. The IDirectMusicLoader interface is used to manage the loading of such objects, as well as for finding and enumerating objects and caching them so that they are not loaded more than once.
An application should have only one instance of the loader in existence at any time. It is a good idea to create a single global loader object and not free it until there is no more loading to be done. This strategy will ensure that the finding and caching of objects is done efficiently.
The DirectMusic implementation of IStream streams the data from the source. The parsing of the data is handled by the various objects themselves, through their implementations of IPersistStream. As long as you are dealing only with standard DirectMusic data, you don't need to use these interfaces directly.
Loading of objects referenced by other objects is handled transparently. For example, suppose a style being loaded from a DirectMusic Producer file contains a reference to a band whose data is in another file. When the style's IPersistStream comes across the reference, it obtains the IDirectMusicGetLoader interface from the IStream that passed it the data stream. Using this interface, it obtains a pointer to the DirectMusicLoader. Then it calls IDirectMusicLoader::GetObject to load the band.
More information on using the DirectMusicLoader is contained in the following topics: