-
大小: 17.71MB文件類型: .rar金幣: 1下載: 0 次發布日期: 2023-06-18
- 語言: C/C++
- 標簽: Directsound??音頻采集??
資源簡介
應用Directshow SDK 用c++語言實現音頻采集功能
代碼片段和文件信息
//?AudioFormat.cpp?:?implementation?file
//
#include?“stdafx.h“
#include?“Recorder.h“
#include?“AudioFormat.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//?CAudioFormat?dialog
extern?CRecorderApp?theApp;
//-----------------------------------------------------------------------------
//?Function-prototypes
//-----------------------------------------------------------------------------
HRESULT?ScanAvailableInputFormats();
VOID????GetWaveFormatFromIndex(?INT?nIndex?WAVEFORMATEX*?pwfx?);
HRESULT?FillFormatListBox(?HWND?hListBox?BOOL*?aFormatSupported?);
VOID????ConvertWaveFormatToString(?WAVEFORMATEX*?pwfx?TCHAR*?strFormatName?);
HRESULT?CreateCaptureBuffer(?WAVEFORMATEX*?pwfxInput?);
HRESULT?InitNotifications();
//-----------------------------------------------------------------------------
//?Name:?GetWaveFormatFromIndex()
//?Desc:?Returns?20?different?wave?formats?based?on?nIndex
//-----------------------------------------------------------------------------
VOID?GetWaveFormatFromIndex(?INT?nIndex?WAVEFORMATEX*?pwfx?)
{
????INT?iSampleRate?=?nIndex?/?4;
????INT?iType?=?nIndex?%?4;
????
????switch(?iSampleRate?)
????{
????case?0:?pwfx->nSamplesPerSec?=?48000;?break;
????case?1:?pwfx->nSamplesPerSec?=?44100;?break;
????case?2:?pwfx->nSamplesPerSec?=?22050;?break;
????case?3:?pwfx->nSamplesPerSec?=?11025;?break;
????case?4:?pwfx->nSamplesPerSec?=??8000;?break;
????}
????
????switch(?iType?)
????{
????case?0:?pwfx->wBitsPerSample?=??8;?pwfx->nChannels?=?1;?break;
????case?1:?pwfx->wBitsPerSample?=?16;?pwfx->nChannels?=?1;?break;
????case?2:?pwfx->wBitsPerSample?=??8;?pwfx->nChannels?=?2;?break;
????case?3:?pwfx->wBitsPerSample?=?16;?pwfx->nChannels?=?2;?break;
????}
????
????pwfx->nBlockAlign?=?pwfx->nChannels?*?(?pwfx->wBitsPerSample?/?8?);
????pwfx->nAvgBytesPerSec?=?pwfx->nBlockAlign?*?pwfx->nSamplesPerSec;
}
//-----------------------------------------------------------------------------
//?Name:?ConvertWaveFormatToString()
//?Desc:?Converts?a?wave?format?to?a?text?string
//-----------------------------------------------------------------------------
VOID?ConvertWaveFormatToString(?WAVEFORMATEX*?pwfx?TCHAR*?strFormatName?)
{
????wsprintf(?strFormatName?
????????TEXT(“%u?Hz?%u-bit?%s“)?
????????pwfx->nSamplesPerSec?
????????pwfx->wBitsPerSample?
????????(?pwfx->nChannels?==?1?)???TEXT(“Mono“)?:?TEXT(“Stereo“)?);
}
//-----------------------------------------------------------------------------
//?Name:?FillFormatListBox()
//?Desc:?Fills?the?format?list?box?based?on?the?availible?formats
//-----------------------------------------------------------------------------
HRESULT?FillFormatListBox(?HWND?hListBox?BOOL*?aFormatSupported?)
{
????TCHAR????????strFormatName[255];
????WAVEFORMATEX?wfx;
????DWORD????????dw
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????272820??2002-12-04?01:07??CaptureSound\Recorder\amstrmid.lib
?????文件??????10763??2008-11-17?18:48??CaptureSound\Recorder\AudioFormat.cpp
?????文件???????1318??2008-11-17?18:26??CaptureSound\Recorder\AudioFormat.h
?????文件???????3748??2008-11-16?21:53??CaptureSound\Recorder\CaptureDevices.cpp
?????文件???????1335??2008-11-16?21:52??CaptureSound\Recorder\CaptureDevices.h
?????文件???????2466??2002-12-04?01:25??CaptureSound\Recorder\d3d8.lib
?????文件???????3010??2002-12-04?01:22??CaptureSound\Recorder\d3d9.lib
?????文件?????614522??2002-12-04?01:31??CaptureSound\Recorder\d3dx.lib
?????文件????2151212??2002-12-04?01:26??CaptureSound\Recorder\d3dx8.lib
?????文件??????53414??2002-12-04?01:28??CaptureSound\Recorder\d3dx8d.lib
?????文件????2679888??2002-12-04?01:28??CaptureSound\Recorder\d3dx8dt.lib
?????文件????4383332??2002-12-10?22:25??CaptureSound\Recorder\d3dx9.lib
?????文件??????72100??2002-12-10?22:25??CaptureSound\Recorder\d3dx9d.lib
?????文件????5146120??2002-12-10?22:25??CaptureSound\Recorder\d3dx9dt.lib
?????文件?????615364??2002-12-04?01:34??CaptureSound\Recorder\d3dxd.lib
?????文件???????1722??2002-11-12?20:15??CaptureSound\Recorder\d3dxof.lib
?????文件???????4540??2002-12-04?01:11??CaptureSound\Recorder\ddraw.lib
?????文件?????126296??2009-05-08?11:11??CaptureSound\Recorder\Debug\AudioFormat.obj
?????文件???????8796??2009-05-08?11:13??CaptureSound\Recorder\Debug\BuildLog.htm
?????文件?????114713??2009-05-08?11:11??CaptureSound\Recorder\Debug\CaptureDevices.obj
?????文件?????103351??2009-05-08?11:11??CaptureSound\Recorder\Debug\dsutil.obj
?????文件??????74389??2009-05-08?11:11??CaptureSound\Recorder\Debug\dxutil.obj
?????文件?????????67??2009-05-08?11:13??CaptureSound\Recorder\Debug\mt.dep
?????文件?????798208??2009-05-08?11:13??CaptureSound\Recorder\Debug\Recorder.exe
?????文件????????920??2009-05-08?11:13??CaptureSound\Recorder\Debug\Recorder.exe.em
?????文件????????984??2009-05-08?11:13??CaptureSound\Recorder\Debug\Recorder.exe.em
?????文件????????861??2009-05-08?11:13??CaptureSound\Recorder\Debug\Recorder.exe.intermediate.manifest
?????文件????2983064??2009-05-08?11:13??CaptureSound\Recorder\Debug\Recorder.ilk
?????文件?????121739??2009-05-08?11:11??CaptureSound\Recorder\Debug\Recorder.obj
?????文件???25231360??2009-05-08?11:10??CaptureSound\Recorder\Debug\Recorder.pch
............此處省略62個文件信息
評論
共有 條評論