SectionDlg.cpp
上传用户:goak128
上传日期:2013-07-17
资源大小:155k
文件大小:4k
源码类别:

控制台编程

开发平台:

C/C++

  1. // SectionDlg.cpp : 实现文件
  2. //
  3. #include "stdafx.h"
  4. #include "Platform.h"
  5. #include "SectionDlg.h"
  6. #include ".sectiondlg.h"
  7. #include "VQ.h"
  8. // CSectionDlg 对话框
  9. IMPLEMENT_DYNAMIC(CSectionDlg, CDialog)
  10. CSectionDlg::CSectionDlg(CWnd* pParent /*=NULL*/)
  11. : CDialog(CSectionDlg::IDD, pParent)
  12. , m_strUnSection(_T(""))
  13. , m_strSection(_T(""))
  14. , m_ctlSection(CWnd::GetSafeHwnd())
  15. , m_ctlUnSection(CWnd::GetSafeHwnd())
  16. {
  17. this->m_nRawLen = 0;
  18. this->m_pRawData = NULL;
  19. this->m_nSectionLen = 0;
  20. this->m_pSectionData = NULL;
  21. // 设定空间显示
  22. this->m_ctlUnSection.SetPrecision(128);
  23. this->m_ctlSection.SetPrecision(128);
  24. this->m_ctlSection.SetXMetrics(2);
  25. this->m_ctlUnSection.SetXMetrics(2);
  26. }
  27. CSectionDlg::~CSectionDlg()
  28. {
  29. this->ReleaseData();
  30. }
  31. void CSectionDlg::DoDataExchange(CDataExchange* pDX)
  32. {
  33. CDialog::DoDataExchange(pDX);
  34. DDX_Control(pDX, IDC_STATIC_SHOW_UNSECTION, m_ctlUnSection);
  35. DDX_Text(pDX, IDC_STATIC_UNSECTION, m_strUnSection);
  36. DDX_Text(pDX, IDC_STATIC_SECTION, m_strSection);
  37. DDX_Control(pDX, IDC_STATIC_SHOW_SECTION, m_ctlSection);
  38. }
  39. BEGIN_MESSAGE_MAP(CSectionDlg, CDialog)
  40. ON_WM_SHOWWINDOW()
  41. ON_WM_MOUSEWHEEL()
  42. END_MESSAGE_MAP()
  43. //////////////////////////////////////////////////////////////////////////
  44. // 设定显示数据
  45. void CSectionDlg::SetDisplayData(
  46.  double* pRawData, // 原始数据
  47.  unsigned int nRawDataLen, // 原是数据长度
  48.  unsigned int nFrameSize, // 分帧长度
  49.  SectionDisplayType displayType // 显示类型
  50.  )
  51. {
  52. // 加窗后的原始数据
  53. double* pWinData = NULL;
  54. this->m_displayType = displayType;
  55. this->m_nRawLen = nRawDataLen;
  56. this->m_pRawData = pRawData;
  57. // 显示端点检测
  58. if (this->m_displayType == SectionEnd)
  59. {
  60. // 对原始数据进行加窗处理
  61. pWinData = new double[this->m_nRawLen];
  62. CSpeech::AddWindow(
  63. nFrameSize, this->m_pRawData, this->m_nRawLen, pWinData);
  64. // 初始端点检测后的数据
  65. this->m_pSectionData = new double[this->m_nRawLen];
  66. // 求端点检测后序列
  67. this->m_nSectionLen = CSpeech::SubSection(
  68. this->m_pRawData, this->m_nRawLen, 
  69. nFrameSize, this->m_pSectionData);
  70. }
  71. // 显示声韵切割
  72. else
  73. {
  74. }
  75. // 释放资源
  76. if (pWinData != NULL)
  77. {
  78. delete[] pWinData;
  79. }
  80. }
  81. //////////////////////////////////////////////////////////////////////////
  82. // 释放显示数据
  83. void CSectionDlg::ReleaseData()
  84. {
  85. if (this->m_pSectionData != NULL)
  86. {
  87. delete[] this->m_pSectionData;
  88. this->m_pSectionData = NULL;
  89. this->m_nSectionLen = 0;
  90. }
  91. if (this->m_pRawData != NULL)
  92. {
  93. delete[] this->m_pRawData;
  94. this->m_pRawData = NULL;
  95. this->m_nRawLen = 0;
  96. }
  97. }
  98. void CSectionDlg::OnShowWindow(BOOL bShow, UINT nStatus)
  99. {
  100. CDialog::OnShowWindow(bShow, nStatus);
  101. // TODO: 在此处添加消息处理程序代码
  102. if (bShow)
  103. {
  104. // 显示端点检测
  105. if (this->m_displayType == SectionEnd)
  106. {
  107. // 设定窗体标题
  108. CWnd::SetWindowText("显示端点检测结果");
  109. this->m_strSection = "端点检测后时域波形";
  110. this->m_strUnSection = "原始时域波形";
  111. }
  112. else
  113. {
  114. // 设定窗体标题
  115. CWnd::SetWindowText("显示声韵切割结果");
  116. this->m_strSection = "声韵分割后时域波形";
  117. this->m_strUnSection = "原始时域波形";
  118. }
  119. // 设定显示数据
  120. CWnd::UpdateData(FALSE);
  121. this->m_ctlSection.LoadData(this->m_pSectionData, this->m_nSectionLen);
  122. this->m_ctlUnSection.LoadData(this->m_pRawData, this->m_nRawLen);
  123. }
  124. }
  125. BOOL CSectionDlg::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
  126. {
  127. // TODO: 在此添加消息处理程序代码和/或调用默认值
  128. this->m_ctlSection.OnMouseWheel(nFlags, zDelta, pt);
  129. return this->m_ctlUnSection.OnMouseWheel(nFlags, zDelta, pt);
  130. }