📄 vcdemo_prodlg.cpp
字号:
// VcDemo_proDlg.cpp : implementation file
//
#include "stdafx.h"
#include "VcDemo_pro.h"
#include "VcDemo_proDlg.h"
#include "DlgTransferSettings.h"
#include "dlgBufferSetting.h"
#include "dlgSpeech.h"
#include "voiceprompttrain.h"
#include <mmsystem.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CDlgTransferSettings DlgTranSet;
extern CDlgBufferSetting DlgBufferSet;
extern CDlgSpeech DlgSpeech;
extern CDlgVoicePromptTrain DlgPromptTrain;
extern long CurLineIndex;
CString appPath;
/////////////////////////////////////////////////////////////////////////////
// CVcDemo_proDlg dialog
CVcDemo_proDlg::CVcDemo_proDlg(CWnd* pParent /*=NULL*/)
: CDialog(CVcDemo_proDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CVcDemo_proDlg)
m_TelNum = _T("");
m_DigitCount = 0;
m_EndDigit = _T("");
m_InterTimeout = 0;
m_tmSilence = 0;
m_FirstTimeout = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CVcDemo_proDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CVcDemo_proDlg)
DDX_Control(pDX, IDC_CK_ECM, m_ckECM);
DDX_Control(pDX, IDC_EDT_FAX_NUM, m_edtFaxNum);
DDX_Control(pDX, IDC_EDT_FAX_DOC, m_edtFaxDoc);
DDX_Control(pDX, IDC_BTN_SPEECH, m_btnSpeech);
DDX_Control(pDX, IDC_CK_RECORD_RINGBACK_TONE, m_ckRecordRingBackToneToFile);
DDX_Control(pDX, IDC_BTN_TRAIN_VOICE_PROMPT, m_btnTrainVoicePrompt);
DDX_Control(pDX, IDC_BTN_SIMULATE_CALL_PROGRESS, m_btnSimulateOutgoingCallProgress);
DDX_Control(pDX, IDC_EDT_WAVE_FILE_TO_RECORD_RINGBACK_TONE, m_edtWaveFileToRecordRingBackTone);
DDX_Control(pDX, IDC_CK_ANALYZE_RINGBACK_TONE, m_ckAnalyzeRingBackTone);
DDX_Control(pDX, IDC_BTN_GENERATE_DIGITS, m_btnGenerateDigits);
DDX_Control(pDX, IDC_EDT_DIGITS_TO_GENERATE, m_edtDigitsToGenerate);
DDX_Control(pDX, IDC_EDT_NUM_TRANSFER, m_edtNumToTransfer);
DDX_Control(pDX, IDC_BTN_UNHOLD, m_btnUnHold);
DDX_Control(pDX, IDC_BTN_SWAP_HOLD, m_btnSwapHold);
DDX_Control(pDX, IDC_BTN_START_TRANSFER, m_btnStartTransfer);
DDX_Control(pDX, IDC_BTN_HOLD, m_btnHold);
DDX_Control(pDX, IDC_BTN_COMPLETE_TRANSFER, m_btnCompleteTransfer);
DDX_Control(pDX, IDC_BTN_BLIND_TRANSFER, m_btnBlindTransfer);
DDX_Control(pDX, IDC_BTN_CANCEL_TRANSFER, m_btnCancelTransfer);
DDX_Control(pDX, IDC_SLIDER1, m_bar);
DDX_Control(pDX, IDC_CMB_WAVEFORMATS, m_cmbWaveFormats);
DDX_Control(pDX, IDC_BTN_CANCELFAX, m_btnCancelFax);
DDX_Control(pDX, IDC_EDT_MSG, m_edtMsg);
DDX_Control(pDX, IDC_BTN_RECEIVEFAX, m_btnReceiveFax);
DDX_Control(pDX, IDC_BTN_SENDFAX, m_btnSendFax);
DDX_Control(pDX, IDC_CK_SPEAKERPHONE, m_ckSpeakerphone);
DDX_Control(pDX, IDC_BTN_GATHER_DIGITS, m_btnGatherDigits);
DDX_Control(pDX, IDC_CK_MONITOR_SILENCE, m_ckMonitorSilence);
DDX_Control(pDX, IDC_CK_MONITOR_DIGITS, m_ckMonitorDigit);
DDX_Control(pDX, IDC_BTN_STOP, m_btnStop);
DDX_Control(pDX, IDC_BTN_RECORD, m_btnRecord);
DDX_Control(pDX, IDC_BTN_PLAY, m_btnPlay);
DDX_Control(pDX, IDC_EDT_TELNUM, m_edtTelnum);
DDX_Control(pDX, IDC_BTN_DROP, m_btnDrop);
DDX_Control(pDX, IDC_BTN_DIAL, m_btnDial);
DDX_Control(pDX, IDC_BTN_ANSWER, m_btnAnswer);
DDX_Control(pDX, IDC_CMB_LINES, m_cmbLines);
DDX_Text(pDX, IDC_EDT_TELNUM, m_TelNum);
DDX_Text(pDX, IDC_EDT_DIGITS_COUNT, m_DigitCount);
DDX_Text(pDX, IDC_EDT_END_DIGIT, m_EndDigit);
DDX_Text(pDX, IDC_EDT_INTER_TIMEOUT, m_InterTimeout);
DDX_Text(pDX, IDC_EDT_SILENCE_TIME, m_tmSilence);
DDX_Text(pDX, IDC_EDT_FIRST_TIMEOUT, m_FirstTimeout);
DDX_Control(pDX, IDC_ANGEL, m_Va);
DDX_Control(pDX, IDC_DOCTOTIFFCTRL1, m_docToTif);
DDX_Control(pDX, IDC_COMMONDIALOG1, m_dlg);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CVcDemo_proDlg, CDialog)
//{{AFX_MSG_MAP(CVcDemo_proDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BTN_ANSWER, OnBtnAnswer)
ON_WM_CREATE()
ON_BN_CLICKED(IDC_BTN_PLAY, OnBtnPlay)
ON_BN_CLICKED(IDC_BTN_DIAL, OnBtnDial)
ON_BN_CLICKED(IDC_BTN_RECORD, OnBtnRecord)
ON_BN_CLICKED(IDC_BTN_DROP, OnBtnDrop)
ON_BN_CLICKED(IDC_BTN_STOP, OnBtnStop)
ON_EN_CHANGE(IDC_EDT_TELNUM, OnChangeEdtTelnum)
ON_BN_CLICKED(IDC_CK_SPEAKERPHONE, OnCkSpeakerphone)
ON_BN_CLICKED(IDC_CK_MONITOR_SILENCE, OnCkMonitorSilence)
ON_BN_CLICKED(IDC_CK_MONITOR_DIGITS, OnCkMonitorDigits)
ON_BN_CLICKED(IDC_BTN_GATHER_DIGITS, OnBtnGatherDigits)
ON_BN_CLICKED(IDC_BTN_SENDFAX, OnBtnSendfax)
ON_BN_CLICKED(IDC_BTN_RECEIVEFAX, OnBtnReceivefax)
ON_CBN_SELCHANGE(IDC_CMB_LINES, OnSelchangeCmbLines)
ON_BN_CLICKED(IDC_BTN_CANCELFAX, OnBtnCancelfax)
ON_BN_CLICKED(IDC_OPT_RECORDED, OnOptRecorded)
ON_BN_CLICKED(IDC_OPT_MULTI_FILES, OnOptMultiFiles)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BTN_TRANSFER_SETTINGS, OnBtnTransferSettings)
ON_BN_CLICKED(IDC_BTN_START_TRANSFER, OnBtnStartTransfer)
ON_BN_CLICKED(IDC_BTN_COMPLETE_TRANSFER, OnBtnCompleteTransfer)
ON_BN_CLICKED(IDC_BTN_CANCEL_TRANSFER, OnBtnCancelTransfer)
ON_BN_CLICKED(IDC_BTN_BLIND_TRANSFER, OnBtnBlindTransfer)
ON_BN_CLICKED(IDC_BTN_HOLD, OnBtnHold)
ON_BN_CLICKED(IDC_BTN_UNHOLD, OnBtnUnhold)
ON_BN_CLICKED(IDC_BTN_SWAP_HOLD, OnBtnSwapHold)
ON_BN_CLICKED(IDC_BTN_GENERATE_DIGITS, OnBtnGenerateDigits)
ON_BN_CLICKED(IDC_CK_ANALYZE_RINGBACK_TONE, OnCkAnalyzeRingbackTone)
ON_BN_CLICKED(IDC_BTN_SIMULATE_CALL_PROGRESS, OnBtnSimulateCallProgress)
ON_EN_CHANGE(IDC_EDT_WAVE_FILE_TO_RECORD_RINGBACK_TONE, OnChangeEdtWaveFileToRecordRingbackTone)
ON_BN_CLICKED(IDC_BTN_BUFFER_SETTING, OnBtnBufferSetting)
ON_BN_CLICKED(IDC_BTN_SPEECH, OnBtnSpeech)
ON_BN_CLICKED(IDC_BTN_TRAIN_VOICE_PROMPT, OnBtnTrainVoicePrompt)
ON_EN_CHANGE(IDC_EDT_NUM_TRANSFER, OnChangeEdtNumTransfer)
ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
ON_EN_CHANGE(IDC_EDT_FAX_NUM, OnChangeEdtFaxNum)
ON_EN_CHANGE(IDC_EDT_FAX_DOC, OnChangeEdtFaxDoc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVcDemo_proDlg message handlers
extern CVcDemo_proApp theApp;
BOOL CVcDemo_proDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
/***Show some introduction here.********************/
CString sMsg;
CString s=13,s1=10;
s=s+s1;
sMsg=" Welcome to use VoiceAngel.VoiceAngel can work in both TAPI and AT COMMAND mode. If OperateMode is set 0 , VoiceAngel works in TAPI mode. If operatemode is set 1,2 or 3, it will work in AT COMMAND mode. In AT COMMAND mode, it can only control modems.";
m_edtMsg.SetWindowText(sMsg.GetBuffer(10));
m_edtDigitsToGenerate.SetWindowText("12,3");
/***************************************************/
m_cmbLines.SetWindowText("Please select a line here.");
m_Va.Initialize("");
m_cmbLines.AddString("Sound Card");
if (m_Va.GetErrorNumber()!=0)
ShowMsg(m_Va.GetErrorDescribe());
else
ShowMsg("VoiceAngel initialized.");
for (int i=0 ;i<m_Va.GetLineCount(); i++)
{ m_Va.SetCurrentLineIndex(i);
m_cmbLines.AddString( m_Va.GetCurrentLineName());
}
m_Device=0;
m_sWaveFile="Welcome.wav";
CButton * pBtn=(CButton *) GetDlgItem(IDC_OPT_RECORDED);
pBtn->SetCheck(1);
m_sWaveFile="Recorded.wav";
m_tmSilence=4000;
m_FirstTimeout=6000;
m_InterTimeout=4000;
m_EndDigit='#';
m_DigitCount=5;
UpdateData(false);
m_cmbWaveFormats.SetCurSel(0);
if (m_Va.GetOperateMode()==0)
{ m_btnSendFax.EnableWindow(false);
m_btnReceiveFax.EnableWindow(false);
CString sCaption;
this->GetWindowText(sCaption);
this->SetWindowText(sCaption+" --TAPI MODE");
}
else
{ m_btnReceiveFax.EnableWindow(true);
m_btnReceiveFax.EnableWindow(true);
}
m_edtWaveFileToRecordRingBackTone.SetWindowText("RingBackTone.wav");
m_cmbLines.SetCurSel(0); OnSelchangeCmbLines() ;
m_edtFaxDoc.SetWindowText("hello.tif");
m_Va.LoadVoicePromptLibrary("VoicePrompts.inf");
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CVcDemo_proDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CVcDemo_proDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CVcDemo_proDlg::OnBtnAnswer()
{
m_Va.SetCurrentLineIndex(CurLineIndex);
m_Va.Answer();
if (m_Va.GetErrorNumber()!=0) ShowMsg(m_Va.GetErrorDescribe());
UpdateControls();
}
BEGIN_EVENTSINK_MAP(CVcDemo_proDlg, CDialog)
//{{AFX_EVENTSINK_MAP(CVcDemo_proDlg)
ON_EVENT(CVcDemo_proDlg, IDC_ANGEL, 1 /* PlayDone */, OnPlayDoneAngel, VTS_I4)
ON_EVENT(CVcDemo_proDlg, IDC_ANGEL, 2 /* DigitDetected */, OnDigitDetectedAngel, VTS_I4 VTS_BSTR)
ON_EVENT(CVcDemo_proDlg, IDC_ANGEL, 5 /* GatherDigits */, OnDigitsGatheredAngel, VTS_I4 VTS_BSTR VTS_I4)
ON_EVENT(CVcDemo_proDlg, IDC_ANGEL, 6 /* Silence */, OnSilenceAngel, VTS_I4)
ON_EVENT(CVcDemo_proDlg, IDC_ANGEL, 13 /* CallStatus */, OnCallStatusAngel, VTS_I4 VTS_I4 VTS_I4 VTS_BSTR)
ON_EVENT(CVcDemo_proDlg, IDC_ANGEL, 7 /* FaxStatus */, OnFaxStatusAngel, VTS_I4 VTS_I2 VTS_I4 VTS_BSTR)
ON_EVENT(CVcDemo_proDlg, IDC_ANGEL, 11 /* SrEvent */, OnSrEventAngel, VTS_I4 VTS_I4 VTS_BSTR)
ON_EVENT(CVcDemo_proDlg, IDC_ANGEL, 12 /* TtsEvent */, OnTtsEventAngel, VTS_I4 VTS_I4 VTS_I4 VTS_I4)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
int CVcDemo_proDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
// TODO: Add your specialized creation code here
}
void CVcDemo_proDlg::OnBtnPlay()
{m_Va.SetCurrentLineIndex(CurLineIndex);
CString WaveFilesDir;
WaveFilesDir="..\\wavefiles";
if ((m_cmbWaveFormats.GetCurSel()==0) || (m_cmbWaveFormats.GetCurSel()==-1))
WaveFilesDir=WaveFilesDir+"\\wave_8000_16_1";
else if (m_cmbWaveFormats.GetCurSel()==1)
WaveFilesDir=WaveFilesDir+"\\wave_8000_8_1";
else if (m_cmbWaveFormats.GetCurSel()==2 )
WaveFilesDir=WaveFilesDir+"\\wave_11025_8_1";
m_Va.CloseWaveFile();
if ( m_sWaveFile=="Recorded.wav")
m_Va.OpenWaveFile(WaveFilesDir+"\\Recorded.wav") ;
else
{
m_Va.NewWaveFile(WaveFilesDir+"\\mergedFiles.wav",0,0,0);
m_Va.AppendWaveFile(WaveFilesDir+"\\TheScoreIs.wav");
m_Va.AppendWaveFile(WaveFilesDir+"\\ninety.wav");
m_Va.AppendWaveFile(WaveFilesDir+"\\eight.wav");
m_Va.SeekWaveFile(0);
}
m_bar.SetRangeMax(m_Va.GetWaveFileLen() / 1024);
m_bar.SetPos(0);
m_Va.StartPlaying(m_Device,FALSE);
if (m_Va.GetErrorNumber()!=0 )
ShowMsg(m_Va.GetErrorDescribe());
else
m_dwTimer=SetTimer(1, 400,NULL);
UpdateControls();
}
void CVcDemo_proDlg::OnBtnDial()
{
// TODO: Add your control notification handler code here
m_Va.SetCurrentLineIndex(CurLineIndex);
UpdateData(true);
CString WaveFileToRecordRingBackTone;
if(m_ckRecordRingBackToneToFile.GetCheck())
m_edtWaveFileToRecordRingBackTone.GetWindowText(WaveFileToRecordRingBackTone);
else WaveFileToRecordRingBackTone="";
m_Va.Dial(m_TelNum,30,m_ckAnalyzeRingBackTone.GetCheck(), WaveFileToRecordRingBackTone.GetBuffer(30),false);
if (m_Va.GetErrorNumber()!=0) ShowMsg(m_Va.GetErrorDescribe());
UpdateControls();
}
void CVcDemo_proDlg::OnBtnRecord()
{
m_Va.SetCurrentLineIndex(CurLineIndex);
m_bar.SetRangeMax(m_Va.GetWaveFileLen() / 1024);
m_bar.SetPos(0);
CString WaveFilesDir;
WaveFilesDir="..\\wavefiles";
if ((m_cmbWaveFormats.GetCurSel()==0) || (m_cmbWaveFormats.GetCurSel()==-1))
WaveFilesDir=WaveFilesDir+"\\wave_8000_16_1";
else if (m_cmbWaveFormats.GetCurSel()==1)
WaveFilesDir=WaveFilesDir+"\\wave_8000_8_1";
else if (m_cmbWaveFormats.GetCurSel()==2 )
WaveFilesDir=WaveFilesDir+"\\wave_11025_8_1";
m_Va.NewWaveFile(WaveFilesDir+"\\Recorded.wav",0,0,0);
m_Va.StartRecording(0 ,FALSE);
if (m_Va.GetErrorNumber()!=0 )
ShowMsg(m_Va.GetErrorDescribe());
else
m_dwTimer=SetTimer(1, 400,NULL);
UpdateControls();
}
void CVcDemo_proDlg::OnBtnDrop()
{
m_Va.SetCurrentLineIndex(CurLineIndex);
m_Va.Drop();
if (m_Va.GetErrorNumber()!=0) ShowMsg(m_Va.GetErrorDescribe());
UpdateControls();
}
void CVcDemo_proDlg::OnOptWelcomewords()
{
// TODO: Add your control notification handler code here
m_sWaveFile="Welcome.wav";
}
void CVcDemo_proDlg::ShowMsg(CString msg)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -