Skip to main content

How do we call sounds drivers:

(20200416: )
How do we call sounds drivers?
---
Call Driver:
---
(source code )
---
Write WaveData :  https://docs.microsoft.com/en-us/windows/win32/multimedia/example-of-writing-waveform-data
---
// Global variables.

HANDLE hData  = NULL;  // handle of waveform data memory
HPSTR  lpData = NULL;  // pointer to waveform data memory

void WriteWaveData(void)
{
    HWAVEOUT    hWaveOut;
    HGLOBAL     hWaveHdr;
    LPWAVEHDR   lpWaveHdr;
    HMMIO       hmmio;
    UINT        wResult;
    HANDLE      hFormat;
    WAVEFORMAT  *pFormat;
    DWORD       dwDataSize;

    // Open a waveform device for output using window callback.

    if (waveOutOpen((LPHWAVEOUT)&hWaveOut, WAVE_MAPPER,
                    (LPWAVEFORMAT)pFormat,
                    (LONG)hwndApp, 0L, CALLBACK_WINDOW))
    {
        MessageBox(hwndApp,
                   "Failed to open waveform output device.",
                   NULL, MB_OK | MB_ICONEXCLAMATION);
        LocalUnlock(hFormat);
        LocalFree(hFormat);
        mmioClose(hmmio, 0);
        return;
    }

    // Allocate and lock memory for the waveform data.

    hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, dwDataSize );
    if (!hData)
    {
        MessageBox(hwndApp, "Out of memory.",
                   NULL, MB_OK | MB_ICONEXCLAMATION);
        mmioClose(hmmio, 0);
        return;
    }
    if ((lpData = GlobalLock(hData)) == NULL)
    {
        MessageBox(hwndApp, "Failed to lock memory for data chunk.",
                   NULL, MB_OK | MB_ICONEXCLAMATION);
        GlobalFree(hData);
        mmioClose(hmmio, 0);
        return;
    }

    // Read the waveform data subchunk.

    if(mmioRead(hmmio, (HPSTR) lpData, dwDataSize) != (LRESULT)dwDataSize)
    {
        MessageBox(hwndApp, "Failed to read data chunk.",
                   NULL, MB_OK | MB_ICONEXCLAMATION);
        GlobalUnlock(hData);
        GlobalFree(hData);
        mmioClose(hmmio, 0);
        return;
    }

    // Allocate and lock memory for the header.

    hWaveHdr = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE,
        (DWORD) sizeof(WAVEHDR));
    if (hWaveHdr == NULL)
    {
        GlobalUnlock(hData);
        GlobalFree(hData);
        MessageBox(hwndApp, "Not enough memory for header.",
            NULL, MB_OK | MB_ICONEXCLAMATION);
        return;
    }

    lpWaveHdr = (LPWAVEHDR) GlobalLock(hWaveHdr);
    if (lpWaveHdr == NULL)
    {
        GlobalUnlock(hData);
        GlobalFree(hData);
        MessageBox(hwndApp,
            "Failed to lock memory for header.",
            NULL, MB_OK | MB_ICONEXCLAMATION);
        return;
    }

    // After allocation, set up and prepare header.

    lpWaveHdr->lpData = lpData;
    lpWaveHdr->dwBufferLength = dwDataSize;
    lpWaveHdr->dwFlags = 0L;
    lpWaveHdr->dwLoops = 0L;
    waveOutPrepareHeader(hWaveOut, lpWaveHdr, sizeof(WAVEHDR));

    // Now the data block can be sent to the output device. The
    // waveOutWrite function returns immediately and waveform
    // data is sent to the output device in the background.

    wResult = waveOutWrite(hWaveOut, lpWaveHdr, sizeof(WAVEHDR));
    if (wResult != 0)
    {
        waveOutUnprepareHeader(hWaveOut, lpWaveHdr,
                               sizeof(WAVEHDR));
        GlobalUnlock( hData);
        GlobalFree(hData);
        MessageBox(hwndApp, "Failed to write block to device",
                   NULL, MB_OK | MB_ICONEXCLAMATION);
        return;
    }
}
---

Comments

Popular posts from this blog

ffmpeg: compilation: Makefile

1. Find sub-directory and ... 2. Care of the literature and ... * Parameter print - - - - CONFIG_POSTPROC - - - .PHONY ...  there is a file named  clean . ... - - - - - - - - - - - - .\Makefile File changed time Fri Jun 04 12:29:06 2021 1 :MAIN_MAKEFILE=1 2 :include config.mak 3 : 4 :vpath %.c $(SRC_PATH) 5 :vpath %.cpp $(SRC_PATH) 6 :vpath %.h $(SRC_PATH) 7 :vpath %.inc $(SRC_PATH) 8 :vpath %.m $(SRC_PATH) 9 :vpath %.S $(SRC_PATH) 10 :vpath %.asm $(SRC_PATH) 11 :vpath %.rc $(SRC_PATH) 12 :vpath %.v $(SRC_PATH) 13 :vpath %.texi $(SRC_PATH) 14 :vpath %/fate_config.sh.template $(SRC_PATH) 15 : 16 :AVPROGS-$(CONFIG_FFMPEG) += ffmpeg 17 :AVPROGS-$(CONFIG_FFPLAY) += ffplay 18 :AVPROGS-$(CONFIG_FFPROBE) += ffprobe 19 :AVPROGS-$(CONFIG_FFSERVER) += ffserver 20 : 21 :AVPROGS := $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF)) 22 :INSTPROGS = $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF)) ...

Big Leaves:

They are growing this year.Dirt is well for any leaves.Weirds are cut by the machine on the line. 2022/10/09 10:24:08 *

cmake-gui

We could yum-search cmake-gui, install it and boot it so that easily create project files for compilation, which means almost make files as configured: cmake-gui can use VERSION 3.6.1 if you add entry: message is the below: CMake Error: The source directory "...../read_005/src" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI. We must create CMakeLists.txt but we can select "from UNIX makefile" as "Configure". "cmake-gui" itself is CMake 2.8.12.2 displayed. We could see CmakeCache.txt like the below so that we could not create tags by use of cmak-gui. ######################## # EXTERNAL cache entries ######################## cmake_minimum_required:STRING=VERSION 3.6.1 We'd rather love: cmake_minimum_required(VERSION 3.6.1) cmake-gui version itself must be higher, at least, we think.  (20200911: cmake3-gui) Configured and Generator: Now they are same. --- CMake Error: The source dir...