如何应用MCI捕获C中的麦克风输入和进程

时间:2015-12-16 13:56:22

标签: c windows audio microphone

我想通过C中的麦克风捕获和处理音频输入。我无法找到处理输入设备的特定功能。所以我转而使用Windows的MCI来不使用其他开源工具/软件。 在尝试将特定于MCI的函数应用于记录,处理和保存为.WAV文件时,我遇到了许多引用其他内置库的错误。例如,这是我通过网络获取的一个示例代码:

#include <windows.h>
#include <mmsystem.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
 {
  HWAVEOUT hWaveOut;
  WAVEFORMATEX wfx; 
  MMRESULT result;

    wfx.nSamplesPerSec = 44100; 
    wfx.wBitsPerSample = 16; 
    wfx.nChannels = 2;
    wfx.cbSize = 0; 
    wfx.wFormatTag = WAVE_FORMAT_PCM;
    wfx.nBlockAlign = (wfx.wBitsPerSample >> 3) * wfx.nChannels;
    wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec;

    if(waveOutOpen(&hWaveOut,        WAVE_MAPPER,&wfx,0,0,CALLBACK_NULL)     !=  MMSYSERR_NOERROR)
    {
     fprintf(stderr, "unable to open WAVE_MAPPER device\n");
      ExitProcess(1);
    }
    printf("The Wave Mapper device was opened successfully!\n");
    waveOutClose(hWaveOut);
    return 0;
   }

0 个答案:

没有答案
相关问题