ENEE408G Multimedia Signal Processing Mobile Computing and Pocket PC Programming Manual Guan-Ming Su Min Wu K. J.
Contents Part I. A Brief Introduction to Pocket PC 2 1. Compaq iPAQ Pocket PC H3760 Series 2. Operating Pocket PC 3. Microsoft ActiveSync 2 3 3 Part II. Microsoft Windows® Platform SDK for Pocket PC 1. Desktop WinCE Emulation 2. Desktop Pocket PC 2002 Emulation Part III. Microsoft eMbedded Visual Basic 3.0 (eVB) 1. Design Environment and Programming 2. Build A Simple Program 3. Prepare for the Distribution of An eMbedded Visual Basic Program 4. Install the Software Program in Pocket PC 5.
Part I. A Brief Introduction to Pocket PC 1. Compaq iPAQ Pocket PC H3760 Series1 Front Panel Top panel Bottom Panel 1 From Compaq iPAQ Pocket PC H3700 Series reference Guide from iPAQ H3760 Package CD.
2. Operating Pocket PC A useful document explaining how to operate and use the iPAQ can be found in the CD of your iPAQ package. Under the directory, COMPAQ/Docs/, you can find a file named PPC PDF H3700.pdf. You can start with reading this reference. You can check out the eBook, How to do everything with your Pocket PC at www.netlibrary.com. This eBook gives many examples explaining how to use Pocket PC in our daily life. 3.
Part II. Microsoft Windows® Platform SDK for Pocket PC2 1. Desktop WinCE Emulation The WinCE emulator can be executed from Start Æ Programs Æ 408g Æ Microsoft Windows Platform SDK for Pocket PC Æ Desktop Pocket PC Emulation. You will see a window shown in the left figure below. We can use this emulator to test our applications without the physical device. However, this emulator doesn’t support all Pocket PC’s functionalities.
Part III. Microsoft embedded Visual Basic 3.0 1.Design Environment and Programming (a) Integrated Development Environment (IDE) The figure below shows the eMbedded Visual Basic (eVB) IDE. The left part is the Toolbox Window. This window offers several components for building graphical user interface in most applications. The lower right part is the Properties Window. We can set the properties of each component, such as the height, width, caption, and background color.
Choose Pocket PC (Default Device) or Pocket PC 2002 (Default Device) by double clicking that item. Another window called Device Properties as shown in the right figure below will pop up. There are three different ways to build connection. The first transport component, Microsoft ActiveSync, usually works well. If not, try the TCP/IP and PPP transport. (2) Windows CE Control Manager Another useful tool is the Control Manager, in which we can add ActiveX Controls4 (.dll, .ocx).
Pocket PC or Pocket PC emulator. To import/export files, you can use the yellow arrows in the toolbar. (4) Zoom Zoom is a tool for capturing a screen display. (c) Choosing device While running the eVB program, we can choose to run it under an emulator or the physical device from the following list box. (d) Reference and Component Except the components shown in the Toolbox Window, we could add more components from Project Æ Reference and Components in the eVB menu bar.
2. Build A Simple Program In this sub-section, we implement a simple eVB program. Programming under eMbedded Visual Basic is similar to Programming using Visual Basic under PC ‘s Visual Studio environment (a) Click File Æ New Project from the eVB menu bar and choose Windows CE for the Pocket PC Project. (b) From the Toolbox Window, drag 6 four CommandButton objects and one Label object to the form. The layout is shown as follows.
Private Sub bnG_Click() ImageCtl1.Picture = "flower_g.BMP" ImageCtl1.Refresh End Sub Private Sub bnB_Click() ImageCtl1.Picture = "flower_b.BMP" ImageCtl1.Refresh End Sub Private Sub Form_Load() ImageCtl1.Picture = "flower.BMP" ImageCtl1.Refresh End Sub Private Sub Form_OKClick() App.End End Sub The last sub-function is for terminating the program when we click the OK button in the upper-right side of the form. (e) Put the files flower.BMP, flower_r.BMP, flower_g.BMP and flower_b.
3. Distribute eMbedded Visual Basic Application Step 1. Make the project by File Æ Make projectname.vb… Then use the Application Install Wizard by ToolsÆRemote ToolsÆApplication Install Wizard, Step 2. Enter the full path to the eMbedded Basic Project (.EBP) file. Step 3. Enter the full path to the compiled eMbedded Basic Application file (.VB) Step 4. Enter the directory in which all output files will be created. Step 5. Select the processors you would like to support.
5. Add More Components to A Project In this section, we continue with the previous RGB example to explain how to add various components in eVB. We will move the functions implemented by buttons to menu items, create a simple text editor, and learn how to open and save files. (a) Create a new Pocket PC project. From Project Æ Components, check the Pocket PC MenuBar Control 3.0, Microsoft CE File System Control 3.0, and Microsoft CE Image Control 3.0. Then click OK.
mnuDropMenu.Items.Add , "mnuOpen", "Open" mnuDropMenu.Items.Add , "mnuNew", "New" ImageCtl1.Picture = "flower.BMP" ImageCtl1.Refresh Text1.Visible = False Text1.Text = "" Text2.Visible = False Text2.Text = "" End Sub Private Sub Form_OKClick() App.End End Sub (e) Then, we should write a Select statement to respond to different menu event. In each Case, we call a sub-function to react to each event. Private Sub MenuBar1_MenuClick(ByVal Item As MenuBarLib.Item) Select Case Item.
Text1.Visible = txt1B bnSave.Visible = True bnSave.Caption = bnCaption bnSave.Enabled = True Label1.Visible = True ImageCtl1.Visible = False Text2.Visible = txt2B Text2.Enabled = txt2B Text2.Text = "" SIPVisible = True End Sub Private Sub aCreate_NewFile() Text1.Visible = True ImageCtl1.Visible = False Text1.Text = "" Text1.Enabled = True SIPVisible = True End Sub Private Sub bnSave_Click() If InStr(bnSave.Caption, "Save") Then File1.Open Text2.Text, fsModeOutput, fsAccessWrite, fsLockWrite File1.
The left figure below shows the result after selecting Text Æ Open. The right figure shows the result of a file after we enter a file name and click the Open button. 6. Winsock – TCP/IP and InfraRed Communication Mobility is one of the most important characteristics of Pocket PC. It provides the versatile capabilities for Pocket PC to communicate with other devices. eMbedded Visual Basic offers Winsock control to set up sockets8 between devices.
Component Name Caption/Text Scrollbars Winsock commandButton TextBox TextBox TextBox Winsock1 btnRequest txtServer txtResource txtOutput Request “server name” “/test.html” “” 0-vbSBNone 0-vbSBNone 2-vbVertical Set the Protocol property of Winsock1 as 0-sckTCPProtocol. (3) Codes: Option Explicit Private Sub btnRequest_Click() Dim s On Error Resume Next WinSock1.Close WinSock1.RemoteHost = txtServer.Text WinSock1.RemotePort = 80 WinSock1.Connect txtOutput.Text = "" If Err.
If Err.Number <> 0 Then MsgBox "Error:" & Err.Number & vbCrLf & Err.Description Else txtOutput.Text = sRecieveDate WinSock1.Close End If End Sub We set the Winsock1.RemoteHost as the server’s name9 and RemotePort as the default port 80 for HTTP. Winsock1.Connect sets up a connection between two devices. If the connection is successfully established, the client and server can transfer data to each other through Winsock1.SendData and Winsock1.Getdata.
Microsoft Win32 API. Those API’s are a collection of dynamic-link libraries (DLLs10) containing many procedures used by Windows-based desktop platforms. With these DLLs, we can expand the eVB capability, such as displaying windows and graphics, managing memory and power, and accessing persistent storage, which cannot be done by built-in controls. Windows CE platform SDK for Pocket PC provides a text file, Winceapi.
(2) From File Æ Open on the API Viewer menu bar, select winceapi.txt file from the directory C:\Windows CE Tools\ Bin . (3) Choose the desired API Type and pick an item in the Available Items list box. Click the Add button and the syntax of the selected item will appear in the bottom textbox. We can copy those declarations and paste them in our eVB program. (4) To use those APIs, we must put the corresponding declarations in a module (.
Part IV. Microsoft eMbedded Visual C++ 3.0 (eVC) 11 1. Integrated Design Environment (IDE) Microsoft eMbedded Visual C++ (eVC) has almost the same appearance as the IDE of VC. The window to the left is the Project Workspace Window, which shows the current classes, resources12, and files used in your project. The window to the right is the Edit Window and you may do coding and edit menus, dialog boxes here.
2. eVC Demo Project-1: Digital Image Processing – Handheld Image Processor In this demo project, you will design a handheld image processor and learn (1) how to build a dialog based Application by Microsoft eMbedded Visual C++, (2) how to install a control (e.g. button) on a dialog box, (3) how to use Device Independent Bitmap (DIB) in WinCE environment, (4) how to perform digital image processing. (a) Create a new project by File Æ New from eVC menu bar.
(2) Set title as “ImageProcPPC” and disable other check items. Then click “Next”. (3) Check “Yes, please” and “As a shared DLL”. Click “Next”. (4) Click “Finish” to finish the initial setting. i.
(5) AppWizard will summarize the features and files of new project you created. Click “OK” to close the AppWizard. (c)Design Dialog Box (1) Overview: The following figure shows the IDE that we will use in this demo project. Click the ResourceView tap in the Project Workspace Window and open the Dialog folder. You will see IDD_IMAGEPROCPPC_DIALOG. Click it and you will see another dialog box with text “TODO: Place dialog controls here” shown in the Edit Window. We will design our own GUI on this dialog box.
(2) Edit the Dialog Box. Click the “TODO: Place dialog controls here” and delete it. Drag and drop four Buttons and one Static Text from Controls toolbar to the dialog box. Adjust the width and height of this dialog box. (3) Modify the properties of “Button1”,“Button2”, “Button3”, and “Button4” in the Push Button Properties dialog box by right clicking each button and choosing the “Properties”. Change ID and Caption according to the following table.
(5) Add Member Map and Function using ClassWizard We need to put the messages of controls in a Message Map14. We can use ClassWizard to help us. There are three ways to open ClassWizard window. You can right click on the dialog box that we are designing and select the ClassWizard, or click ViewÆ ClassWizard from the eVC menu bar, or Ctrl-w. The following dialog window will pop up. Let’s work on the Open button first. Choose IDC_BUTTON_OPENFILE in the Object IDs window.
establish. Repeat the same procedures described above. The Object ID’s, corresponding Messages, and Message Functions are shown in the following table.
(2) Add existing files to this project. The fundamental image structure used in Windows and Windows CE is BITMAP. To facilitate using BITMAPs, several programmers have wrapped sufficient functions into a class (C++). In this project, we use the existing classes (DIBSectionLite) developed by Mr. Chris Maunder15. (i) Download files, copy and paste the following two files to your current working directory: DIBSectionLite.cpp, DIBSectionLite.h. (ii) Click Project Æ Add to Project Æ Files from the eVC menu bar.
(e)Edit ImageProcPPCDlg.h16 // ImageProcPPCDlg.h : header file // Author: Guan-Ming Su // Date: 9/23/2003 #if !defined(AFX_IMAGEPROCPPCDLG_H__50A20CED_5408_4999_9422_3B87C2F19B2F__INCLUDED_) #define AFX_IMAGEPROCPPCDLG_H__50A20CED_5408_4999_9422_3B87C2F19B2F__INCLUDED_ #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000 // Add your own required header Æ #include "DIBSectionLite.
//{{AFX_INSERT_LOCATION}} // Microsoft eMbedded Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_IMAGEPROCPPCDLG_H__50A20CED_5408_4999_9422_3B87C2F19B2F__INCLUDED_) (f)Edit ImageProcPPCDlg.cpp // ImageProcPPCDlg.cpp : implementation file // Use DIBsectionLite http://www.codeproject.com/bitmap/dibsection.asp // // Author: Guan-Ming Su // Date: 9/23/2003 #include "stdafx.h" #include "ImageProcPPC.h" #include "ImageProcPPCDlg.
// TODO: Add extra initialization here // Add you own initialization here Æ bExistFile = FALSE; //Å return TRUE; // return TRUE unless you set the focus to a control } // ############################################# // ## Open File ## // ############################################# void CImageProcPPCDlg::OnButtonOpenfile() { // TODO: Add your control notification handler code here // Add your own codes here Æ // Construct the Open File Window CString strFilter = "Bitmap Files (*.bmp)|*.
dibit = (BYTE*)m_pDib.GetDIBits(); // set pointer to access the bitmap for(i=0; i < 3*sz.cx*sz.cy ; i=i+3){ // set blue and green component as zero, i.e.
the Platform as Pocket PC 2002, Win32 [WCE x86] Debug, and Pocket PC 2002 Emulation, which is shown as follows. Click the compile icon and then execute icon . You can load an image by clicking “Open” button. An open file dialog box will pop up ( as shown in the below left figure). Select “Inframe.BMP”. You will see the picture by clicking “Show” button ( as shown in the below middle figure).
3. eVC Demo Project-2:Digital Video Processing – Video Player In this part, we will design a video player and learn (1) how to build an application with single document by eVC, (2) how to put RGB data into DIB (Device Independent Bitmap) directly, (3) how to add List Box, Edit Box, and Slider Control and initialize them, and (4) how to set a timer to display video periodically. (a) Create a new Project by File Æ New (1) Select “WCE Pocket PC 2002 MFC AppWizard (exe)” on the Projects tap.
(2) Check “Basic MenuBar” on Control bar type and disable all features on the top part. Click “Next”. (3) Check “Yes, please” and “As a shared DLL”. Click “Next”. (4) Select the Base Class of CVideoProcPPCView as “CFormView”. Click “Finish”.
(5) AppWizard will summarize the features and files of the new project you just created. Click “OK” to close the AppWizard. (c) Edit Menu Bar (1) Overview: In this section, we design the GUI of our application program. The figure below shows the IDE that we will use to work on this demo project. Click the ResourceView tap in the Project Workspace Window. (2) Double click the Menubar on the ResourceView tap and then double click IDR_MAINFRAME. You will see the menu bar as follows.
(d) Edit Dialog Box (1) In this section, we will design a dialog box that provides an interface between Pocket PC and users. Double click Dialog on the ResourceView tap. Choose IDD_VIDEOPROCPPC_FORM. Delete the label “TODO: Place form controls on this dialog.” Drag three Buttons, one Edit Box, one List Box, one Static, and one Slider from Controls Toolbar to the dialog box and arrange them as shown in the above figure. (2) Edit Properties: Right click on each control and choose “Properties”.
(3) Initialize the Slider, Edit Box, and List Box: Right click the Slider button and click “ClassWizard”. Click the “Member Variables” tap. Double click IDC_SLIDER_FRAME_INDEX on the Control IDs Box. An Add Member Variable dialog box will show up. Type “m_Slider_Frame_Index” in the Member variable name edit box,. Choose “Control” in the Category list box and “CSliderCtrl” in the Variable type list box. Likewise, for the List Box, double click IDC_LIST_RATE in the Control IDs edit box.
We can add more required messages and member functions using ClassWizard, which is shown in the figure above. Make sure the Project is set to “VideoProcPPC” and Class name is “CViewProcPPCView”.
(2) Click on VideoProcPPCDoc.h20 // VideoProcPPCDoc.h : interface of the CVideoProcPPCDoc class // Author : Guan-Ming Su // Date: Aug 2002 // update: July 5 2003 ///////////////////////////////////////////////////////////////////////////// #if !defined(AFX_VIDEOPROCPPCDOC_H__5B9D8AFA_3247_4263_82D7_15053107F9CB__INCLUDED_) #define AFX_VIDEOPROCPPCDOC_H__5B9D8AFA_3247_4263_82D7_15053107F9CB__INCLUDED_ #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000 // Put DIBSectionLite.
virtual void Serialize(CArchive& ar); //}}AFX_VIRTUAL // Implementation public: virtual ~CVideoProcPPCDoc(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // Generated message map functions protected: //{{AFX_MSG(CVideoProcPPCDoc) // NOTE - the ClassWizard will add and remove member functions here.
// Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CVideoProcPPCView) public: virtual BOOL PreCreateWindow(CREATESTRUCT& cs); virtual void OnInitialUpdate(); protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual void OnDraw(CDC* pDC); //}}AFX_VIRTUAL // Implementation public: virtual ~CVideoProcPPCView(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // Put Use
//{{AFX_INSERT_LOCATION}} // Microsoft eMbedded Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_VIDEOPROCPPCVIEW_H__21B7E638_7D17_40EC_85FA_2599C0D7BD34__INCLUDED_) (g) Edit VideoProcPPCView.cpp // VideoProcPPCView.cpp : implementation of the CVideoProcPPCView class // Author: Guan-Ming Su // Date: Aug 2002 // update: July 5 2003 #include "stdafx.h" #include "VideoProcPPC.h" #include "VideoProcPPCDoc.h" #include "VideoProcPPCView.
DDX_Control(pDX, IDC_LIST_RATE, m_List_Rate); DDX_Control(pDX, IDC_SLIDER_FRAME_INDEX, m_Slider_Frame_Index); DDX_Text(pDX, IDC_EDIT_FRAME, m_Edit_Frame); //}}AFX_DATA_MAP } BOOL CVideoProcPPCView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CFormView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CVideoProcPPCView diagnostics #ifdef _DEBUG void CVideoProcPPCView::Asse
ASSERT_VALID(pDoc); CClientDC aDC(&m_showBITMAP); YUVFileOffSet=VideoStartIndex*VideoBytes; pInputFile=_wfopen(filenamein,_T("rb")); // open file if(pInputFile!=NULL){ // open file successfully fseek(pInputFile,YUVFileOffSet,SEEK_SET); fread(YFrameData,sizeof(BYTE),VideoPixel,pInputFile); fread(CbFrameData,sizeof(BYTE),CVideoPixel,pInputFile); fread(CrFrameData,sizeof(BYTE),CVideoPixel,pInputFile); fclose(pInputFile); } // Convert YUV(YCbCr) data into RGB (in dibits) by YUV2RGB function in DVP.
else{ pDoc->m_DIBSection.SetBitmap(&bmInfo,dibits); this->OnDraw(&aDC); } // Button Stop is pressed TimerStep = 0; KillTimer(TimerID); } // Å CFormView::OnTimer(nIDEvent); } void CVideoProcPPCView::OnBtnOpenfile() { // TODO: Add your control notification handler code here // Put your own code here Æ FILE *pInputFile; OPENFILENAME ofn; TimerStep=0; VideoStartIndex=0; // initial start display frame index memset(&ofn,0,sizeof(ofn)); ofn.lStructSize=sizeof(ofn); ofn.lpstrFile=filenamein; ofn.
// TODO: Add your control notification handler code here // Puy your own code here Æ int nCount; nCount=m_List_Rate.
bmiHeader.biBitCount =24; bmiHeader.biCompression= BI_RGB;; bmiHeader.biSizeImage= 3*VideoPixel; bmiHeader.biClrUsed = 16777216; bmiHeader.biClrImportant = 16777216; bmInfo.bmiHeader=bmiHeader; // Å } When compiling, some error messages on precompiled header may show up. Please refer to section IV.6.1 for solutions. (i) Run your program on the emulator: In the eVC IDE, select the Platform as Pocket PC 2002, Win32 [WCE x86] Debug, and Pocket PC 2002 Emulation, which is shown in the figure below.
(j) Run your program on the Pocket PC21 You can to compile and run this program in the real device. From the eVC IDE, choose Platform as Pocket PC 2002, Win32[WCE ARM] Debug, and Pocket PC 2002[Default Device]. Then click the compile and execute buttons. Enjoy your new pocket video player. 21 This demo project is not optimized for real Pocket PC. You will observe that the refresh rate of video is slow.
4. eVC Demo Project-3:Digital Speech Processing – Spectrum Analyzer In this demo project, you will design a spectrum analyzer and learn (1) how to load, save, and record a wave file and, (2) how to design a Menu Bar and Open File Window dialog box, (3) how to draw data on screen, and (4) how to perform digital speech processing, such as Fast Fourier Transform.
(2) Disable all features and choose “Basic MenuBar” on Control bar type. (c) Choose “generate source file comments” and “As a shared DLL”. Click “Next”. (d) Select the Base class of CSpeechProcPPCView as CView. Click “Finish”.
(g) AppWizard will summarize the features and files of new project you created. Click “OK” to close the AppWizard. (c) Edit Menu (1) Overview: The following figure shows the IDE we will use in this demo project. Click the ResourceView tap in the IDE. (2) Design Menu Double click IDR_MAINFRAME under Menubar in the ResourceView tap. A default menu will show up in the Edit Window. We do not need “Edit”, thus, right click it and cut it. For “Tools”, we only reserve “About SpeechProcPPC”.
So far, we have already created the File main menu item. We need to add four sub items, Open File, Save File, Record Start, Record Stop, and Play, under this main menu item. Let’s work on the first item, Open File. Right click the dashed rectangular above the File menu item and choose “Properties”. You will see another dialog box shown below. Modify ID as ID_FILE_OPEN and Caption as “&Open”. Make the other three items by the same procedures.
(3) Set Message After setting up the menu bar, we need to add messages and their corresponding reactions if users click those items. We can use ClassWizard (from View Æ ClassWizard in eVC IDE) to edit the messages in Windows. Make sure the “Class name” is set to “CSpeechProcPPCView”. Double click “ID_FILE_OPEN” in the Object IDs box and “COMMAND” in the Messages box. An “Add Member Function” dialog box will show up. Press “OK”.
(2) We add some variables used in this project in the header file24. // SpeechProcPPCView.
// Put your own protected data here Æ int show_spectrum_type; // display type of figure long int NumSample; // number of sample int* Sample; // sample data int FigureWidth; // width of figure int FigureHeight; // height of figure bool m_bOneFileExist; // indicator for a existing file in application MMRESULT mr; // return value for access WAVE function HWAVEIN hWaveIn; // handel for microphone input HWAVEOUT hWaveOut; // handel for speaker output WAVEHDR MICbuffer; // buffer for microphone input WAVEFORMATEX
#include #include "PlotXY.h" #include "filewav.h" #include "spectrum.
// CSpeechProcPPCView drawing void CSpeechProcPPCView::OnDraw(CDC* pDC) { CSpeechProcPPCDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here // Put your own Digital Signal Processing codec here --> if(show_spectrum_type==1){ // plot waveform // call drawing funtion in PlotXY.cpp and PlotXY.
BYTE* InDataBuf; // buffer for read in data ULONG TotInSamples; // number of sample OPENFILENAME ofn; // This structure contains information the operating system uses // to initialize the system-defined Open or Save As dialog box. // After the user closes the dialog box, the system returns // information about the user's selection in this structure memset(&ofn,0,sizeof(ofn)); // Allocate memory for ofn ofn.lStructSize=sizeof(ofn); // Initial setting for ofn ofn.lpstrFile=in_filename; ofn.nMaxFile=255; ofn.
} // ####### Start to record ########## // function was provided by Fall 2002 Group 4 iTalk5000: Josh Merti, Pall Kunchai, and Vijay Kumar void CSpeechProcPPCView::OnFILEStartRecord() { // TODO: Add your command handler code here // Put your own codes here Æ DWORD callback = 0; DWORD instance = 0; DWORD open = 0; //Open microphone for recording if( (mr = waveInOpen(&hWaveIn, 0, &RecordWavFileFmt, callback, instance, open)) != MMSYSERR_NOERROR ){ MessageBox(_T("Fail in waveInOpen")); return; } //prepare th
{ // TODO: Add your command handler code here // put your codes here to deal with reaction for this item --> show_spectrum_type =2; // FFT CClientDC aDC(this); this->OnDraw(&aDC); // Å } // ####### Plot waveform ######### void CSpeechProcPPCView::OnSpectrumWaveform() { // TODO: Add your command handler code here // put your codes here to deal with reaction for this item --> show_spectrum_type=1; // waveform CClientDC aDC(this); this->OnDraw(&aDC); // Å } void CSpeechProcPPCView::OnFILEPlay() { // TODO:
You will see the GUI on the emulator. You can select a wave file by File Æ Open. To observe the waveform, you can click Spectrum Æ Waveform. To observe the FFT, click Spectrum Æ FFT. Waveform FFT You can start to record a sound clip by clicking File->REC start and stop by File -> REC stop. The recorded sound or opened wave file can be played by using File>Play. You can view the waveform and FFT of this recorded sound. Also, you can save it as a wave file through File -> Save.
5. eVC Demo Project-4: Digital Audio Processing – Digital Piano In this demo project, you will design a digital piano and learn (1) how to import external .wav file as internal resource, and (2) how to use PlaySound.dll API. (a). Create a New Project by File Æ New (1) Select “WCE Pocket PC 2002 MFC AppWizard (exe)” on the Projects tap (2) Key in “AudioProcPPC” on Project name edit box and select a Location for this project. Also check “Create new workspace”.
(2) Disable all features and set title as “AudioProcPPC”. Click “Next”. (5) Choose “Generate source file comment” and ” As a shared DLL” (4) Click “Finish” to finish the initial setting.
(5) AppWizard will summarize the features and files of new project you created. Click “OK” to close the AppWizard. (c) Edit Resource: There are two ways to read .wav files. One way is to read external wave file using the _fopen function. The other way is to import wave files during the compiling period and treat them as internal resources. In this project, we adopt the second approach. (1) ResourceView: To import .
Thus, we create a WAVE resource. (3) Import .wav file: Put all .wav files under \AudioProc\res directory. Right click “WAVE” on the ResourceView tap and choose “Import”. Select all wave files. After importing, the ResourceView becomes the figure below. Delete the “IDR_WAVE1”. Right click each “IDR_WAVE” and choose “Properties”. A Custom Resource Properties dialog box will pop up.
Change the text in the ID list box into the text in the File name edit box. For example, if we import file A.wav, and we will observe a string, res\A.wav, in the File name edit box. Change its ID into “A”. (It includes quotation marks). We can check the result of importing from the ResourceView and FileView tap. (d). Interface Design: (1) Double click DialogÆIDO_AUDIOPROCPPC_DIALOG on the ResourceView tap. (2) Controls: Delete the “TODO: Place dialog controls here”.
(3) Messages and Member Functions: We can set up Messages and Member functions using ClassWizard. We can use View Æ ClassWizard from eVC IDE menu bar to open it. Click each “IDC_btn” item in the “Object IDs” window and click “BN_CLICKED” in the “Message” window. An “Add Member Function” box will show up. Click “OK” to add those member functions. After setting up the required member functions, we can add our own codes.
(e) Edit AudioProcPPCDlg.cpp26 // AudioProcPPCDlg.cpp : implementation file // Author: Guan-Ming Su // Date: Aug 2002 #include "stdafx.h" #include "AudioProcPPC.h" #include "AudioProcPPCDlg.
return TRUE; // return TRUE unless you set the focus to a control } void CAudioProcPPCDlg::OnbtnA() { // TODO: Add your control notification handler code here PlaySound(_T("A"), :: AfxGetInstanceHandle(), SND_RESOURCE | SND_SYNC ); } void CAudioProcPPCDlg::OnbtnB() { // TODO: Add your control notification handler code here PlaySound(_T("B"), :: AfxGetInstanceHandle(), SND_RESOURCE | SND_SYNC ); } void CAudioProcPPCDlg::OnbtnC() { // TODO: Add your control notification handler code here PlaySound(_T("C"), :
Click the compile icon to compile your program and then click the execute icon to run it. You will see the Capstone Piano! Remember to turn on your Pocket PC’s speaker. You can click each button and play this piano.
6. Troubleshooting (a) Q: How to solve the problem while eVC compiles a project after importing new files and the Output Window shows a message shown below. C:\temp\VideoProcPPC\DVP.cpp(64) : fatal error C1010: unexpected end of file while looking for precompiled header directive Generating Code... Error executing cl.exe. VideoProcPPC.exe - 1 error(s), 0 warning(s) A: This is a problem with the precompiled header. eVC will generate precompiled headers to save some time when you recompile this project.
Step-2: Choose Memory on the System tap of the Settings Window. Another window will show up. Step-3: Click on the Running Programs tap, and we will see a Running Program List. Click on the executing program *.exe and press the Stop button to terminate it. Step 1 Step 2 Step 3 (c) Q: How can I transfer (import/export) files to emulator? A: We need to handle WinCE emulator and Pocket PC 2002 emulator differently.
(1) WinCE uses Unicode by which each character is represented by 2 bytes. The easiest way to convert char to Unicode is to use the _T() function. For example, to convert “filenamein” to Unicode, you can simply use _T(“filenamein”). To declare a Unicode array, you should use TCHAR instead of char. (2) You also can convert string between ANSI character and Unicode by calling C run-time functions.
(1) Use the MessageBox function. E.g. MessageBox(_T(“Cannot Open files”),MB_OK). (2) Use the eVC Debugger. (i) In the Edit Window, right click the line where you want to set a breakpoint, and click Insert/Remove Breakpoint. Here is an example. After setting a breakpoint for the line, NumSample=TotInSamples, you will see a red dot in front of it. (ii) Run the debugger by BuildÆ Start Debug from the eVC menu bar. You will see the debug toolbar. (iii) Execute your program.
Part V. Further Reference 1.eMbedded Visual Tools’ built-in Help Both eVB and eVC have built-in Help accessible from their menu bars. It offers a lot of useful material about Pocket PC programming. 2.Books: (a) Nick Grattan: Pocket PC, Handheld PC Developer’s Guide with Microsoft eMbedded Visual Basic, Prentice Hall PTR, 2001. (b) Chris Tacke and Timothy Bassett, EMbedded Visual Basic: Windows CE and Pocket PC Mobile Applications, Sams, 2001.