资源简介
wave底层接口的简单应用
代码片段和文件信息
#include “StdAfx.h“
#include “GWaveIn.h“
GWaveIn::GWaveIn(void)
{
}
GWaveIn::~GWaveIn(void)
{
}
bool GWaveIn::IfWaveIn()
{
MMRESULT mmresult = 0;
mmresult = waveInGetNumDevs();
if(mmresult == 0) return false;
WAVEINCAPS waveincaps = {0};
unsigned int i = 0;
unsigned int num = mmresult;
for( ; i {
mmresult = waveInGetDevCaps(i&waveincapssizeof(WAVEINCAPS));
if(mmresult != MMSYSERR_NOERROR)
return false;
if((waveincaps.dwFormats & WAVE_FORMAT_1M08) == 0)
continue;
else
{
m_iWaveInID = i;
return true;
}
}
return false;
}
bool GWaveIn::PrepareWaveIn(HWND hwnd BYTE* pbuf1 BYTE* pbuf2)
{
WAVEFORMATEX waveformatex = {0};
waveformatex.wFormatTag = WAVE_FORMAT_PCM;
waveformatex.nChannels = 1;
waveformatex.nSamplesPerSec = 11025;
waveformatex.nAvgBytesPerSec = 11025*1*8/8;
waveformatex.nBlockAlign = 8*1/8;
waveformatex.wBitsPerSample = 8;
waveformatex.cbSize = 0;
MMRESULT mmresult = 0;
mmresult = waveInOpen(&m_hWaveInm_iWaveInID&waveformatex(DWORD)hwnd0CALLBACK_WINDOW);
if(mmresult != MMSYSERR_NOERROR) return false;
m_head1.lpData = (LPSTR)pbuf1;
m_head1.dwBufferLength = 20480;
m_head1.dwBytesRecorded = 0;
m_head1.dwUser = 0;
m_head1.dwFlags = 0;
m_head1.dwLoops = 1;
m_head1.lpNext = NULL;
m_head1.reserved = 0;
mmresult = waveInPrepareHeader(m_hWaveIn&m_head1sizeof(WAVEHDR));
if(mmresult != MMSYSERR_NOERROR) return false;
m_head2.lpData = (LPSTR)pbuf2;
m_head2.dwBufferLength = 20480;
m_head2.dwBytesRecorded = 0;
m_head2.dwUser = 0;
m_head2.dwFlags = 0;
m_head2.dwLoops = 1;
m_head2.lpNext = NULL;
m_head2.reserved = 0;
mmresult = waveInPrepareHeader(m_hWaveIn&m_head2sizeof(WAVEHDR));
if(mmresult != MMSYSERR_NOERROR) return false;
return true;
}
bool GWaveIn::AddBuffer(PWAVEHDR pwavehdr)
{
MMRESULT mmresult = 0;
mmresult = waveInAddBuffer(m_hWaveInpwavehdrsizeof(WAVEHDR));
if(mmresult != MMSYSERR_NOERROR) return false;
return true;
}
bool GWaveIn::StartRec()
{
MMRESULT mmresult = 0;
mmresult = waveInStart(m_hWaveIn);
if(mmresult != MMSYSERR_NOERROR) return false;
return true;
}
bool GWaveIn::CloseWaveIn()
{
MMRESULT mmresult = 0;
waveInStop(m_hWaveIn);
waveInReset(m_hWaveIn);
waveInClose(m_hWaveIn);
if(m_head1.lpData != NULL) free(m_head1.lpData);
waveInUnprepareHeader(m_hWaveIn&m_head1sizeof(WAVEHDR));
if(m_head2.lpData != NULL) free(m_head2.lpData);
waveInUnprepareHeader(m_hWaveIn&m_head2sizeof(WAVEHDR));
return true;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5604864 2016-11-10 15:22 wave底层接口\Debug\wave底层接口.exe
文件 13427164 2016-11-10 15:22 wave底层接口\Debug\wave底层接口.ilk
文件 22522880 2016-11-10 15:22 wave底层接口\Debug\wave底层接口.pdb
文件 1729024 2016-11-10 10:53 wave底层接口\Release\wave底层接口.exe
文件 13896704 2016-11-10 10:53 wave底层接口\Release\wave底层接口.pdb
文件 6260 2016-11-10 15:22 wave底层接口\wave底层接口\Debug\BuildLog.htm
文件 6656 2016-11-09 14:15 wave底层接口\wave底层接口\Debug\GWave.obj
文件 13846 2016-11-10 15:22 wave底层接口\wave底层接口\Debug\GWaveIn.obj
文件 12952 2016-11-10 09:45 wave底层接口\wave底层接口\Debug\GWaveOut.obj
文件 65 2016-11-10 15:22 wave底层接口\wave底层接口\Debug\mt.dep
文件 612295 2016-11-09 14:10 wave底层接口\wave底层接口\Debug\stdafx.obj
文件 1895424 2016-11-10 15:22 wave底层接口\wave底层接口\Debug\vc90.idb
文件 3182592 2016-11-10 15:22 wave底层接口\wave底层接口\Debug\vc90.pdb
文件 406 2016-11-09 14:11 wave底层接口\wave底层接口\Debug\wave底层接口.exe.em
文件 472 2016-11-09 14:11 wave底层接口\wave底层接口\Debug\wave底层接口.exe.em
文件 381 2016-11-10 15:22 wave底层接口\wave底层接口\Debug\wave底层接口.exe.intermediate.manifest
文件 25746 2016-11-10 15:22 wave底层接口\wave底层接口\Debug\wave底层接口.obj
文件 41091072 2016-11-09 14:10 wave底层接口\wave底层接口\Debug\wave底层接口.pch
文件 79440 2016-11-10 10:22 wave底层接口\wave底层接口\Debug\wave底层接口.res
文件 79988 2016-11-10 15:22 wave底层接口\wave底层接口\Debug\wave底层接口Dlg.obj
文件 2601 2016-11-10 09:45 wave底层接口\wave底层接口\GWaveIn.cpp
文件 473 2016-11-10 15:22 wave底层接口\wave底层接口\GWaveIn.h
文件 2442 2016-11-10 09:45 wave底层接口\wave底层接口\GWaveOut.cpp
文件 404 2016-11-10 09:42 wave底层接口\wave底层接口\GWaveOut.h
文件 2819 2016-11-09 14:10 wave底层接口\wave底层接口\ReadMe.txt
文件 6150 2016-11-10 10:53 wave底层接口\wave底层接口\Release\BuildLog.htm
文件 34171 2016-11-10 10:46 wave底层接口\wave底层接口\Release\GWaveIn.obj
文件 33632 2016-11-10 10:46 wave底层接口\wave底层接口\Release\GWaveOut.obj
文件 65 2016-11-10 10:53 wave底层接口\wave底层接口\Release\mt.dep
文件 4530485 2016-11-10 10:46 wave底层接口\wave底层接口\Release\stdafx.obj
............此处省略34个文件信息
- 上一篇:magnet电磁场分析软件 part2
- 下一篇:机器学习_周志华.zip
评论
共有 条评论