IltmmAudioFormats::get_Count Example for C

void IltmmAudioFormats_get_Count_Example (IltmmCapture* pCapture) 
{ 
   IltmmAudioFormats *pAudioFormats; 
   IltmmAudioFormat *pAudioFormat; 
   long   lCount; 
   long lFreq, lBits, lChannels; 
   long lFoundAt; 
   long lSelection; 
   VARIANT_BOOL bSelected; 
   int i; 
// get the audio formats collection: 
   IltmmCapture_get_AudioCaptureFormats(pCapture, &pAudioFormats); 
   IltmmAudioFormats_get_Count(pAudioFormats, &lCount); 
   for( i=0; i<lCount; i++ ) 
   { 
      // get the item at index I 
      IltmmAudioFormats_Item(pAudioFormats, i, &pAudioFormat); 
// do something with this item, like viewing its information: 
      IltmmAudioFormat_get_SampleFrequency(pAudioFormat, &lFreq); 
      IltmmAudioFormat_get_BitsPerSample(pAudioFormat, &lBits); 
      IltmmAudioFormat_get_Channels(pAudioFormat, &lChannels); 
      IltmmAudioFormat_get_Selected(pAudioFormat, &bSelected); 
      // view information 
// you may select the format if it matches some criteria: 
      if( lFreq == 8000 && lBits == 8 && lChannels == 1 ) 
         IltmmAudioFormat_put_Selected(pAudioFormat, VARIANT_TRUE); 
      // free the item 
      IUnknown_Release(pAudioFormat); 
   } 
// you might use the Find method to search for a specific format: 
   IltmmAudioFormats_Find(pAudioFormats, 16000, 16, 2, &lFoundAt); 
   if( lFoundAt != -1 ) 
   { 
// do something with it: 
// check if it is already selected, and if not, select it: 
      IltmmAudioFormats_get_Selection(pAudioFormats, &lSelection); 
      if( lSelection != lFoundAt ) 
      { 
         IltmmAudioFormats_put_Selection(pAudioFormats, lFoundAt); 
      } 
   } 
   // free the audio formats collection 
   IUnknown_Release(pAudioFormats); 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Multimedia C API Help