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. Question about playing .wav files using mmio functions

Question about playing .wav files using mmio functions

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++helptutorial
2 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.
  • N Offline
    N Offline
    novicedude
    wrote on last edited by
    #1

    I am trying to code a program to play wave files using the low level functions provided by VC++ such as the "MMIO" functions. I encountered problems in "waveOutOpen","waveOutWrite","waveOutPrepareHeader" functions. A handle was passed as the first parameter to each of the function calls.The error i got was "waveOutOpen cannot convert parameter one from void ** to struct HWaveout_ **".the same error was shown for each of the other function calls(i.e for waveOutPrepareHeader etc),subsequently i typecasted the handle as (HWAVEOUT*).While this caused the errors to stop the program did not run as the header was not being prepared. The code is as shown below. HANDLE hWaveOut; MMRESULT ReturnCode = waveOutOpen((HWAVEOUT*)&hWaveOut,WAVE_MAPPER,(tWAVEFORMATEX*)&PCMWaveFmtRecord,NULL,NULL,NULL); if(ReturnCode) { AfxMessageBox("Could Not Open Wave Device",MB_OK | MB_ICONSTOP,NULL); return(FALSE); } ReturnCode=waveOutPrepareHeader((HWAVEOUT)&hWaveOut,&WaveHeader,sizeof(WaveHeader)); if(ReturnCode) { AfxMessageBox("Could Not Prepare Header",MB_OK | MB_ICONSTOP,NULL); waveOutClose((HWAVEOUT)hWaveOut); return(FALSE); } ReturnCode = waveOutWrite((HWAVEOUT)&hWaveOut,&WaveHeader,sizeof(WaveHeader)); if(ReturnCode) { AfxMessageBox("Error Writing to Wave Device",MB_OK | MB_ICONSTOP,NULL); waveOutClose((HWAVEOUT)hWaveOut); return(FALSE); } Could anyone let me know how to proceed? novicedude

    C 1 Reply Last reply
    0
    • N novicedude

      I am trying to code a program to play wave files using the low level functions provided by VC++ such as the "MMIO" functions. I encountered problems in "waveOutOpen","waveOutWrite","waveOutPrepareHeader" functions. A handle was passed as the first parameter to each of the function calls.The error i got was "waveOutOpen cannot convert parameter one from void ** to struct HWaveout_ **".the same error was shown for each of the other function calls(i.e for waveOutPrepareHeader etc),subsequently i typecasted the handle as (HWAVEOUT*).While this caused the errors to stop the program did not run as the header was not being prepared. The code is as shown below. HANDLE hWaveOut; MMRESULT ReturnCode = waveOutOpen((HWAVEOUT*)&hWaveOut,WAVE_MAPPER,(tWAVEFORMATEX*)&PCMWaveFmtRecord,NULL,NULL,NULL); if(ReturnCode) { AfxMessageBox("Could Not Open Wave Device",MB_OK | MB_ICONSTOP,NULL); return(FALSE); } ReturnCode=waveOutPrepareHeader((HWAVEOUT)&hWaveOut,&WaveHeader,sizeof(WaveHeader)); if(ReturnCode) { AfxMessageBox("Could Not Prepare Header",MB_OK | MB_ICONSTOP,NULL); waveOutClose((HWAVEOUT)hWaveOut); return(FALSE); } ReturnCode = waveOutWrite((HWAVEOUT)&hWaveOut,&WaveHeader,sizeof(WaveHeader)); if(ReturnCode) { AfxMessageBox("Error Writing to Wave Device",MB_OK | MB_ICONSTOP,NULL); waveOutClose((HWAVEOUT)hWaveOut); return(FALSE); } Could anyone let me know how to proceed? novicedude

      C Offline
      C Offline
      chifor
      wrote on last edited by
      #2

      Your first function, waveOutOpen((HWAVEOUT*)&hWaveOut,WAVE_MAPPER,(tWAVEFORMATEX*)&PCMWaveFmtRecord,NULL,NULL,NULL); seems to be correctly, but more correctly is to use function like that: HWAVEOUT hWaveOut; waveOutOpen(&hWaveOut,WAVE_MAPPER,(LPWAVEFORMATEX)&PCMWaveFmtRecord,NULL,NULL,NULL); (where PCMWaveFmtRecord identifies the format of the waveform-audio data to be sent to the device). The second and third function: waveOutPrepareHeader((HWAVEOUT)&hWaveOut,&WaveHeader,sizeof(WaveHeader)); waveOutWrite((HWAVEOUT)&hWaveOut,&WaveHeader,sizeof(WaveHeader)); is not correctly because the first parrametter pased is need to be a HWAVEOUT handle and not a reference. Correctly is: waveOutPrepareHeader(hWaveOut,&WaveHeader,sizeof(WAVEHDR)); waveOutWrite(hWaveOut,&WaveHeader,sizeof(WAVEHDR));

      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