设为首页  
联系我们  
加入收藏  
网页制作 冲浪宝典 图形图像 操作系统 软件教学 编程开发 认证考试 安全技术 站长专区 文学驿站 娱乐天地 游戏天地 办公软件
文章搜索
您的位置: 首页 >> 文章首页 >> 编程开发 >> Visual C++ >> Windows环境下的麦克风录音系统(6)
精品推荐
Visual C++点击TOP10
·用WINSOCK实现聊天室的VC++程序设计
·利用mfc编写activex控件
·用vc实现生产者消费者问题
·DirectX8.0
·C/C++ 大量经典编程书籍下载
·VC快捷键大全
·CreateFileMapping的MSDN翻译和使用心得
·Windows环境下的麦克风录音系统
·挂钩Windows API
·如何开发OPC Server
编程开发点击TOP10
·数字小键盘指法练习
·用C语言编通讯录程序(初学者级别的)
·ASP.NET 程序中常用的三十三种代码
·我写的Java学生成绩管理系统源代码
·CHK文件恢复工具
·java笔试题
·Modem 常用AT指令集
·异常java.sql.SQLException: Io exception:The Network Adapter could not establish connection
·单片机模拟I2C总线及24C02(I2C EEPROM)读写实例(源代码)
·C++经典电子书下载
精选专题

Windows环境下的麦克风录音系统(6)

作者: 来源:网络文章 时间:2005-12-13 17:18:56

Windows环境下的麦克风录音系统(6)(1)

对于录音来说最重要的就是CSoundIn,下面就是该类的定义:

namespace perdubug {  // prevent the name-space pollution XML:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

class CSoundIn 

{

public:   

                BOOL     __initMic(); // get the best wave format supported by your sound card

                                                    // and then i will use the format to capture sound.

 

                void     __closeMic();

 

               

                BOOL     __openMic(); // open device and begin to capture with the best format(when

                                                       // invoke __initMic function then you will get the best format

                                                       // supported by host's sound card

               

                //

                // if your want to capture sound and eXPort into a wav file please invoke this function

                // to tell me the full path then i will create the wav file.

                //

                void     __createOutputWaveFile(const TCHAR * lpszFileName);

               

                // if you invoke any member function return error/false please

                // use this function to get the result...

                DWord    __getLastError();

 

                //

                // when the capture buffer is filled please invoke this function to 'add buffer'(Actually

                // you should create two-circular buffers,when 1st buffer is filled then switch to 2st,1st

                // buffer will be wrote into wav file.

                //

                void AddBuffer();

               

                virtual ~CSoundIn();

               

                friend CSoundIn & theSoundCapture();

private:

 

                BOOL  GetBestWaveFormat(WAVEFORMATEX & waveFormatEx);

               

                // because sound card is one and only so i must limit the number of CSoundIn object,

                // but how to limit the class object nums?maybe put constrUCtor into private scope is

                // a good idea,:-)

                CSoundIn();         

 

private:

                WAVEINCAPS                    m_WaveInDevCaps;

                HWAVEIN                            m_WaveIn;

                WAVEHDR                           m_WaveHeader;

                WAVEFORMATEX            m_WaveFormat; 

               

                UINT    m_WaveInSampleRate;

                int         m_NbMaxSamples;

                UINT    m_SizeRecord;

 

                DWORD   m_dwLastError;

 

                enum { MAX_SIZE_INPUT_BUFFER = 1 * 2 * 1024 }; // samples * voie * size_samples

 

public:

                SHORT  InputBuffer[MAX_SIZE_INPUT_BUFFER];   // used for int FFT,many GUI application

                                                                                                          // want to display sound peak so..

                BOOL   m_bTerminateThread;                   //  to 'kill' waveCallback function

                BOOL   m_bImportToWaveFile;

               

                CWaveFile       m_waveFile;

};

 

} // end namespace perdubug

 

对于将录音保存在WAV文件的工作主要是由CwaveFile类来完成.下面是该类的定义:

//

// Encapsulates reading or writing sound data to or from a wave file

//-----------------------------------------------------------------------------

class CWaveFile

{

public:

    WAVEFORMATEX* m_pwfx;        // Pointer to WAVEFORMATEX structure

    HMMIO              m_hmmio;              // MM I/O handle for the WAVE

    MMCKINFO      m_ck;                      // Multimedia RIFF chunk

    MMCKINFO      m_ckRiff;               // Use in opening a WAVE file

    DWORD             m_dwSize;             // The size of the wave file

    MMIOINFO       m_mmioinfoOut;

    DWORD             m_dwFlags;

    BOOL                 m_bIsReadingFromMemory;

    BYTE*               m_pbData;

    BYTE*               m_pbDataCur;

    ULONG              m_ulDataSize;

    CHAR*              m_pResourceBuffer;   

protected:

    HRESULT ReadMMIO();

    HRESULT WriteMMIO( WAVEFORMATEX *pwfxDest );

 

public:

    CWaveFile();

    ~CWaveFile();

 

    HRESULT Open( LPCTSTR strFileName, WAVEFORMATEX* pwfx, DWORD dwFlags );

    HRESULT OpenFromMemory( BYTE* pbData, ULONG ulDataSize,

                                                        WAVEFORMATEX* pwfx, DWORD dwFlags );

    HRESULT Close();

 

    HRESULT Read( BYTE* pBuffer, DWORD dwSizeToRead, DWORD* pdwSizeRead );

    HRESULT Write( UINT nSizeToWrite, BYTE* pbData, UINT* pnSizeWrote );

 

    DWORD   GetSize();

    HRESULT ResetFile();

    WAVEFORMATEX* GetFormat() { return m_pwfx; };

};

 

共2页 9 7 [1] [28 :>

Windows环境下的麦克风录音系统(6) 相关文章:
Windows环境下的麦克风录音系统(6) 相关软件:
特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
转载请注明来源:http://www.xgdown.com