Specific destinations, sources and controls can be found using the FindDest, FindSource and FindControl methods. These methods allow you to specify the types of destination, source and control to find and if found they set the DestNumber, SourceNumber and ControlNumber properties appropriately.
For more information about the parameter values that may be specified, see the reference information for the methods.
For example, suppose we wish to find a destination commonly used for playback. We might do the following:
' Find the destination associated with the speakers, if that is not found try to find the wave out destination target
errorCode = MC.FindDest( MSSMIX_DEST_SPEAKERS, MSSMIX_TARGET_WAVEOUT )
If errorCode<>MSSMERR_NOERROR Then ' That failed, so try to find the destination associated with headphones:
errorCode = MC.FindDest( MSSMIX_DEST_HEADPHONES, MSSMIX_TARGET_IGNORE )
If errorCode<>MSSMERR_NOERROR Then ' I've run out of ideas, so give up and handle error EndIf EndIf
' If the method succeeded, the DestNumber property will now be set correctly.
Finding a source is similar to finding destinations, except that the target types are normally not very useful. Note in this example (to find the Microphone source) that we want to find a source in the currently-selected destination:
errorCode = MC.FindSource( MSSMIX_DEST_CURRENT, MSSMIX_TARGET_IGNORE, MSSMIX_SOURCE_MICROPHONE, MSSMIX_TARGET_IGNORE )
If errorCode<>MSSMERR_NOERROR Then ' Handle the error EndIf ' If the method succeeded, the SourceNumber property will now be set correctly.
And finding a control is much the same. Let us see (in a fairly unsophisticated way) if there is a microphone volume control in a recording destination:
errorCode = MC.FindControl( MSSMIX_DEST_WAVEIN, MSSMIX_TARGET_WAVEIN, MSSMIX_SOURCE_MICROPHONE, MSSMIX_TARGET_IGNORE, MSSMIX_CONTROL_TYPE_VOLUME )
If errorCode<>MSSMERR_NOERROR Then ' That failed, so handle the error here EndIf
Much more sophisticated algorithms for locating particular controls can of course be built using these simple methods as building blocks.