www.pudn.com > hmmPlatform.rar > SectionDlg.cpp


// SectionDlg.cpp : 实现文件 
// 
 
#include "stdafx.h" 
#include "Platform.h" 
#include "SectionDlg.h" 
#include ".\sectiondlg.h" 
#include "VQ.h" 
 
 
// CSectionDlg 对话框 
 
IMPLEMENT_DYNAMIC(CSectionDlg, CDialog) 
CSectionDlg::CSectionDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CSectionDlg::IDD, pParent) 
	, m_strUnSection(_T("")) 
	, m_strSection(_T("")) 
	, m_ctlSection(CWnd::GetSafeHwnd()) 
	, m_ctlUnSection(CWnd::GetSafeHwnd()) 
{ 
	this->m_nRawLen = 0; 
	this->m_pRawData = NULL; 
	this->m_nSectionLen = 0; 
	this->m_pSectionData = NULL; 
 
	// 设定空间显示 
	this->m_ctlUnSection.SetPrecision(128); 
	this->m_ctlSection.SetPrecision(128); 
	this->m_ctlSection.SetXMetrics(2); 
	this->m_ctlUnSection.SetXMetrics(2); 
} 
 
CSectionDlg::~CSectionDlg() 
{ 
	this->ReleaseData(); 
} 
 
void CSectionDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	DDX_Control(pDX, IDC_STATIC_SHOW_UNSECTION, m_ctlUnSection); 
	DDX_Text(pDX, IDC_STATIC_UNSECTION, m_strUnSection); 
	DDX_Text(pDX, IDC_STATIC_SECTION, m_strSection); 
	DDX_Control(pDX, IDC_STATIC_SHOW_SECTION, m_ctlSection); 
} 
 
 
BEGIN_MESSAGE_MAP(CSectionDlg, CDialog) 
	ON_WM_SHOWWINDOW() 
	ON_WM_MOUSEWHEEL() 
END_MESSAGE_MAP() 
 
////////////////////////////////////////////////////////////////////////// 
// 设定显示数据 
void CSectionDlg::SetDisplayData( 
								 double* pRawData,				// 原始数据 
								 unsigned int nRawDataLen,		// 原是数据长度 
								 unsigned int nFrameSize,		// 分帧长度 
								 SectionDisplayType displayType	// 显示类型 
								 ) 
{ 
	// 加窗后的原始数据 
	double* pWinData = NULL; 
 
	this->m_displayType = displayType; 
	this->m_nRawLen = nRawDataLen; 
	this->m_pRawData = pRawData; 
	 
	// 显示端点检测 
	if (this->m_displayType == SectionEnd) 
	{ 
		// 对原始数据进行加窗处理 
		pWinData = new double[this->m_nRawLen]; 
		CSpeech::AddWindow( 
			nFrameSize, this->m_pRawData, this->m_nRawLen, pWinData); 
		// 初始端点检测后的数据 
		this->m_pSectionData = new double[this->m_nRawLen]; 
 
		// 求端点检测后序列 
		this->m_nSectionLen = CSpeech::SubSection( 
			this->m_pRawData, this->m_nRawLen,  
			nFrameSize, this->m_pSectionData); 
	} 
	// 显示声韵切割 
	else 
	{ 
		 
	} 
 
	// 释放资源 
 
	if (pWinData != NULL) 
	{ 
		delete[] pWinData; 
	} 
} 
 
////////////////////////////////////////////////////////////////////////// 
// 释放显示数据 
void CSectionDlg::ReleaseData() 
{ 
	if (this->m_pSectionData != NULL) 
	{ 
		delete[] this->m_pSectionData; 
 
		this->m_pSectionData = NULL; 
		this->m_nSectionLen = 0; 
	} 
 
	if (this->m_pRawData != NULL) 
	{ 
		delete[] this->m_pRawData; 
 
		this->m_pRawData = NULL; 
		this->m_nRawLen = 0; 
	} 
} 
void CSectionDlg::OnShowWindow(BOOL bShow, UINT nStatus) 
{ 
	CDialog::OnShowWindow(bShow, nStatus); 
 
	// TODO: 在此处添加消息处理程序代码 
	if (bShow) 
	{	 
		// 显示端点检测 
		if (this->m_displayType == SectionEnd) 
		{ 
			// 设定窗体标题 
			CWnd::SetWindowText("显示端点检测结果"); 
 
			this->m_strSection = "端点检测后时域波形"; 
			this->m_strUnSection = "原始时域波形"; 
		} 
		else 
		{ 
			// 设定窗体标题 
			CWnd::SetWindowText("显示声韵切割结果"); 
 
			this->m_strSection = "声韵分割后时域波形"; 
			this->m_strUnSection = "原始时域波形"; 
		} 
 
		// 设定显示数据 
		CWnd::UpdateData(FALSE); 
		this->m_ctlSection.LoadData(this->m_pSectionData, this->m_nSectionLen); 
		this->m_ctlUnSection.LoadData(this->m_pRawData, this->m_nRawLen); 
	} 
} 
 
BOOL CSectionDlg::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) 
{ 
	// TODO: 在此添加消息处理程序代码和/或调用默认值 
	this->m_ctlSection.OnMouseWheel(nFlags, zDelta, pt); 
 
	return this->m_ctlUnSection.OnMouseWheel(nFlags, zDelta, pt); 
}