WAVEX.CPP
资源名称:tapi3.zip [点击查看]
上传用户:chinamans
上传日期:2013-03-17
资源大小:202k
文件大小:14k
源码类别:
TAPI编程
开发平台:
Visual C++
- // Source for wave functions for the talker32 app
- // (c) Dialogic corp 1995, 1996
- #include "stdafx.h"
- #include <mmsystem.h>
- #include <mmreg.h>
- #include "wavstate.h"
- #include "wavex.h"
- IMPLEMENT_DYNAMIC(CTapiWave, CObject)
- // Do initialization as needed
- WAVEFORMATEX CTapiWave::wfDialogicFormats[] = {{WAVE_FORMAT_DIALOGIC_OKI_ADPCM, 1, 6000, 3000, 1,4},
- {WAVE_FORMAT_DIALOGIC_OKI_ADPCM, 1, 8000, 4000, 1,4},
- {WAVE_FORMAT_MULAW, 1, 6000, 6000, 1,8},
- {WAVE_FORMAT_MULAW, 1, 8000, 8000, 1,8},
- {WAVE_FORMAT_MULAW, 1, 11025, 11025, 1,8},
- {WAVE_FORMAT_ALAW, 1, 6000, 6000, 1,8},
- {WAVE_FORMAT_ALAW, 1, 8000, 8000, 1,8},
- {WAVE_FORMAT_ALAW, 1, 11025, 11025, 1,8},
- {WAVE_FORMAT_PCM, 1, 6000, 6000, 1,8},
- {WAVE_FORMAT_PCM, 1, 8000, 8000, 1,8},
- {WAVE_FORMAT_PCM, 1, 11025, 11025, 1,8},
- {0,0,0,0,0,0}};
- CTapiWave::CTapiWave()
- {
- m_hWaveIn = NULL;
- m_hWaveOut = NULL;
- m_lpvLine = NULL;
- m_lpvCall = NULL;
- ctwSetState(WAVE_IDLE);
- }
- // Constructor
- CTapiWave::CTapiWave(LPVOID lpvLine, LPVOID lpvCall, DWORD dwLineID)
- {
- // Note that there is no direct reference to any of the TAPI-related classes
- m_lpvLine = lpvLine;
- m_lpvCall = lpvCall;
- m_dwLineID = dwLineID;
- if(m_lpvLine != NULL) // one file name per line ONLY
- sprintf(m_szRecFileName, "record%.2d.wav", m_dwLineID);
- else
- sprintf(m_szRecFileName, "%8.8x.wav", (LPVOID) this);
- m_hWaveIn = NULL;
- m_hWaveOut = NULL;
- m_lpvLine = NULL;
- m_lpvCall = NULL;
- m_dwVolume = MAX_ABS_VOLUME; //default=full volume
- ctwSetState(WAVE_IDLE);
- }
- // Public wrapper around the real play
- BOOL CTapiWave::ctwPlay(HWND hWnd, UINT nID, LPSTR lpFileName)
- {
- if(WAVE_IDLE != ctwGetState()) return FALSE;
- ctwSetState(PREPARING_TO_PLAY);
- m_hWaveOut = WavexPlay(hWnd, nID, lpFileName);
- if(m_hWaveOut != NULL) ctwSetState(PLAYING);
- else ctwSetState(WAVE_IDLE);
- return (m_hWaveOut != NULL);
- }
- // Play the WAVE file specified on input
- HWAVEOUT CTapiWave::WavexPlay(HWND hWnd, UINT nID, LPSTR lpFileName)
- {
- WAVEFORMATEX *lpwfWaveFormat = NULL;
- WAVEHDR *lpwhWaveHdr = NULL;
- HMMIO hmmH;
- HWAVEOUT hWave = NULL;
- MMCKINFO mmParent, mmSubchunk;
- DWORD dwFmtSize, dwDataSize, dwFlags;
- HPSTR lpWaveData = NULL;
- char szErr[128];
- MMRESULT mmrc;
- TRACE("*** TALKER32 ***: enter Playn");
- // Open wave file
- hmmH = mmioOpen(lpFileName, NULL, MMIO_READ); //| MMIO_ALLOCBUF);
- if(!hmmH)
- {
- MessageBox(NULL, "Input WAVE file open failed", NULL, MB_ICONSTOP);
- return FALSE;
- }
- // Locate a 慠IFF