LFile::GetExtensionAudio

Summary

Gets the embedded audio data from the specified extension list.

Syntax

#include "ltwrappr.h"

virtual L_INT LFile::GetExtensionAudio(pExtensionList, nStream, ppBuffer, puSize)

Parameters

pEXTENSIONLIST pExtensionList

Pointer to the EXTENSIONLIST structure that contains the audio data to get.

L_INT nStream

Index of the audio stream to retrieve. The extensions may have more than one audio stream. This index is 0-based. Therefore, the first stream is stream 0, the second stream is stream 1, etc. To retrieve all the audio streams, retrieve the streams one by one until an error is returned.

L_UCHAR ** ppBuffer

Pointer to be updated with a pointer to the retrieved audio data. This pointer will point into the pExtensionList. Therefore, this pointer will be valid as long as pExtensionList is valid. The memory will be freed when LFile::FreeExtensions is called, so do not try to free this memory.

L_SIZE_T *puSize

Pointer to a variable to be updated with the size of the audio data.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

The audio data is stored inside extensions in the WAVE format. The audio data can be played directly from memory, or the data can be written to a disk file and played from the disk. When writing the audio data to a disk file, give the file a .WAV extension.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

#include <stdio.h> 
 
L_INT LFile__GetExtensionAudioExample(L_TCHAR * pszFile, L_TCHAR * pszAudioFile) 
{ 
   L_INT nRet; 
   LFile File; 
   pEXTENSIONLIST pExtensionList; 
   DWORD wWriteByte; 
 
   File.SetFileName(pszFile); 
   nRet = File.ReadFileExtensions(&pExtensionList); 
   if(nRet != SUCCESS) 
   { 
      MessageBox(NULL, TEXT("Error getting extensions!"), TEXT("Testing"), MB_OK); 
      return nRet; 
   } 
    
   if (pExtensionList->uFlags & EXTENSION_AUDIO) 
   { 
      L_UCHAR * pData; 
      L_SIZE_T uSize; 
 
      nRet = File.GetExtensionAudio (pExtensionList, 0, &pData, &uSize); 
      if(nRet != SUCCESS) 
      { 
         MessageBox(NULL, TEXT("Error getting the audio data!"), TEXT("Testing"), MB_OK); 
 
         return nRet; 
      } 
      else 
      { 
         HANDLE fd; 
 
         fd = CreateFile(pszAudioFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); // pszAudioFile: .wav file 
 
         if (fd) 
         { 
            WriteFile(fd, pData, (DWORD) uSize, &wWriteByte, NULL); 
            CloseHandle(fd); 
         } 
      } 
   } 
 
   nRet = File.FreeExtensions(pExtensionList); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   return SUCCESS; 
} 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.