Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How do i use acmFormatEnum? All help is appreciated!

How do i use acmFormatEnum? All help is appreciated!

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    redeemer
    wrote on last edited by
    #1

    I'm trying to enumerate all the different formats of a specific driver but acmFormatEnum keeps returning MMSYSERR_INVALPARAM (At least one parameter is invalid.). Anyone have an example of how to do this? Here's my code (id is a valid driver identifier of a driver):

    ACMFORMATTAGDETAILS acmTagDetails;

    void StartEnum()
    {
    HACMDRIVER hAcm;

    acmDriverOpen(&hAcm, id, 0);
    
    acmTagDetails.cbStruct = sizeof(ACMFORMATTAGDETAILS);
    acmFormatTagEnum(hAcm, &acmTagDetails, acmTagCallback, NULL, 0);
    
    acmDriverClose(hAcm, 0);
    

    }

    BOOL WINAPI acmTagCallback(HACMDRIVERID hadid, LPACMFORMATTAGDETAILS paftd, DWORD dwInstance,DWORD fdwSupport)
    {
    ACMFORMATDETAILS acmFormat;
    HACMDRIVER hAcm;

    memset(&acmFormat, 0, sizeof acmFormat);
    acmFormat.cbStruct = sizeof(ACMFORMATDETAILS);
    acmMetrics(NULL, ACM\_METRIC\_MAX\_SIZE\_FORMAT, &acmFormat.cbwfx);
    acmFormat.pwfx = (WAVEFORMATEX \*)malloc(acmFormat.cbwfx);
    
    acmDriverOpen(&hAcm, hadid, 0);
    acmFormatEnum(hAcm, &acmFormat, formatCallback, NULL, ACM\_FORMATENUMF\_WFORMATTAG);
    acmDriverClose(hAcm, 0);
    
    return TRUE;
    

    }

    BOOL WINAPI formatCallback(HACMDRIVERID hadid, LPACMFORMATDETAILS pafd, DWORD dwInstance, DWORD fdwSupport)
    {
    ACMDRIVERDETAILS details;

    details.cbStruct = sizeof(details);
    
    acmDriverDetails(hadid, &details, NULL);
    
    SendMessage(GetDlgItem(ghWnd, IDC\_FORMATS), LB\_INSERTSTRING, 0, (LPARAM)details.szLongName);
    
    return TRUE;
    

    }

    Thanks for your help! -Rune Svendsen

    E 2 Replies Last reply
    0
    • R redeemer

      I'm trying to enumerate all the different formats of a specific driver but acmFormatEnum keeps returning MMSYSERR_INVALPARAM (At least one parameter is invalid.). Anyone have an example of how to do this? Here's my code (id is a valid driver identifier of a driver):

      ACMFORMATTAGDETAILS acmTagDetails;

      void StartEnum()
      {
      HACMDRIVER hAcm;

      acmDriverOpen(&hAcm, id, 0);
      
      acmTagDetails.cbStruct = sizeof(ACMFORMATTAGDETAILS);
      acmFormatTagEnum(hAcm, &acmTagDetails, acmTagCallback, NULL, 0);
      
      acmDriverClose(hAcm, 0);
      

      }

      BOOL WINAPI acmTagCallback(HACMDRIVERID hadid, LPACMFORMATTAGDETAILS paftd, DWORD dwInstance,DWORD fdwSupport)
      {
      ACMFORMATDETAILS acmFormat;
      HACMDRIVER hAcm;

      memset(&acmFormat, 0, sizeof acmFormat);
      acmFormat.cbStruct = sizeof(ACMFORMATDETAILS);
      acmMetrics(NULL, ACM\_METRIC\_MAX\_SIZE\_FORMAT, &acmFormat.cbwfx);
      acmFormat.pwfx = (WAVEFORMATEX \*)malloc(acmFormat.cbwfx);
      
      acmDriverOpen(&hAcm, hadid, 0);
      acmFormatEnum(hAcm, &acmFormat, formatCallback, NULL, ACM\_FORMATENUMF\_WFORMATTAG);
      acmDriverClose(hAcm, 0);
      
      return TRUE;
      

      }

      BOOL WINAPI formatCallback(HACMDRIVERID hadid, LPACMFORMATDETAILS pafd, DWORD dwInstance, DWORD fdwSupport)
      {
      ACMDRIVERDETAILS details;

      details.cbStruct = sizeof(details);
      
      acmDriverDetails(hadid, &details, NULL);
      
      SendMessage(GetDlgItem(ghWnd, IDC\_FORMATS), LB\_INSERTSTRING, 0, (LPARAM)details.szLongName);
      
      return TRUE;
      

      }

      Thanks for your help! -Rune Svendsen

      E Offline
      E Offline
      Ernest Laurentin
      wrote on last edited by
      #2

      You have to many members not initialized in acmTagCallback. MSDN says that for ACM_FORMATENUMF_WFORMATTAG, you must initialized dwFormatTag member of the ACMFORMATDETAILS structure must be equal to the wFormatTag member of WAVEFORMATEX. By the way, you need to free the memory you allocate with malloc or you may want to use a local variable : WAVEFORMATEX waveFormat = { 0 }; and assign it to acmFormat.pwfx = &wafeFormat; You still need to initialize wafeFormat with the format that you are looking for. An 8Khz, 8-bit, 1 channel may be your starting point. Sorry if I don't have code to show you right now! Good luck VOTD:"5. The Lord loves righteousness and justice; the Earth is full of his unfailing love. "-Psalm 33:5

      1 Reply Last reply
      0
      • R redeemer

        I'm trying to enumerate all the different formats of a specific driver but acmFormatEnum keeps returning MMSYSERR_INVALPARAM (At least one parameter is invalid.). Anyone have an example of how to do this? Here's my code (id is a valid driver identifier of a driver):

        ACMFORMATTAGDETAILS acmTagDetails;

        void StartEnum()
        {
        HACMDRIVER hAcm;

        acmDriverOpen(&hAcm, id, 0);
        
        acmTagDetails.cbStruct = sizeof(ACMFORMATTAGDETAILS);
        acmFormatTagEnum(hAcm, &acmTagDetails, acmTagCallback, NULL, 0);
        
        acmDriverClose(hAcm, 0);
        

        }

        BOOL WINAPI acmTagCallback(HACMDRIVERID hadid, LPACMFORMATTAGDETAILS paftd, DWORD dwInstance,DWORD fdwSupport)
        {
        ACMFORMATDETAILS acmFormat;
        HACMDRIVER hAcm;

        memset(&acmFormat, 0, sizeof acmFormat);
        acmFormat.cbStruct = sizeof(ACMFORMATDETAILS);
        acmMetrics(NULL, ACM\_METRIC\_MAX\_SIZE\_FORMAT, &acmFormat.cbwfx);
        acmFormat.pwfx = (WAVEFORMATEX \*)malloc(acmFormat.cbwfx);
        
        acmDriverOpen(&hAcm, hadid, 0);
        acmFormatEnum(hAcm, &acmFormat, formatCallback, NULL, ACM\_FORMATENUMF\_WFORMATTAG);
        acmDriverClose(hAcm, 0);
        
        return TRUE;
        

        }

        BOOL WINAPI formatCallback(HACMDRIVERID hadid, LPACMFORMATDETAILS pafd, DWORD dwInstance, DWORD fdwSupport)
        {
        ACMDRIVERDETAILS details;

        details.cbStruct = sizeof(details);
        
        acmDriverDetails(hadid, &details, NULL);
        
        SendMessage(GetDlgItem(ghWnd, IDC\_FORMATS), LB\_INSERTSTRING, 0, (LPARAM)details.szLongName);
        
        return TRUE;
        

        }

        Thanks for your help! -Rune Svendsen

        E Offline
        E Offline
        Ernest Laurentin
        wrote on last edited by
        #3

        Try to initialize your WAVEFORMATEX struct with this function:

        void InitFormat(LPWAVEFORMATEX pwfx, WORD wChannel, DWORD dwSamplesPerSec, WORD wBitsPerSample)
        {
        _ASSERTE( NULL != pwfx );
        pwfx->cbSize = sizeof(WAVEFORMATEX);
        pwfx->wFormatTag = WAVE_FORMAT_PCM;
        pwfx->nChannels = wChannel;
        pwfx->nSamplesPerSec = dwSamplesPerSec;
        pwfx->nAvgBytesPerSec = dwSamplesPerSec * wChannel * (wBitsPerSample>>3);
        pwfx->wBitsPerSample = wBitsPerSample;
        pwfx->nBlockAlign = wChannel * (wBitsPerSample>>3);
        }

        VOTD:"5 I know that the Lord is great, that our Lord is greater than all gods. 6 The Lord does whatever pleases him, in the heavens and on the earth, in the seas and all their depths."- Psalm 135:5-6

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups