Download Pokcet PC Programming Manual - ECE
Transcript
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.lpstrFilter=_T("Audio Files:*.wav\0*.wav\0All Files:*.*\0*.*\0\0"); // required file ext
ofn.lpstrInitialDir=NULL;
if(GetOpenFileName(&ofn)==TRUE){ // Show up the Open File Dialog Box
InDataBuf=new BYTE[MAXINSIZE];
iRetn=ReadWav(in_filename,&WavFileFmt,&TotInSamples,InDataBuf); // file in filewav.cpp
if(iRetn!=0){
MessageBox(_T("Fail to load data"));
return; }
NumSample=TotInSamples;
if( m_bOneFileExist == TRUE ){ // if there already exists a file, redefine the memory
delete[] Sample; }
m_bOneFileExist = TRUE;
// set up the flag to indicate a file is in this application
Sample=new int[NumSample];
for(i=0;i<NumSample;i++){
Sample[i]=(int)InDataBuf[i];}
delete[] InDataBuf;
m_bOneFileExist = TRUE; }
//Å
}
// ####### Save a File #############
void CSpeechProcPPCView::OnFileSave()
{
// TODO: Add your command handler code here
// put your codes here to deal with the reaction for this item Æ
long i;
OPENFILENAME ofn;
if( m_bOneFileExist == FALSE ){
MessageBox(_T("No data exist for saving out")); }
else{ // if there is a file in application, then we allow saving files
memset(&ofn,0,sizeof(ofn)); // Allocate memory for ofn
ofn.lStructSize=sizeof(ofn); // Initial setting for ofn
ofn.lpstrFile=out_filename;
ofn.nMaxFile=255;
ofn.lpstrFilter=_T("Audio Files:*.wav\0*.wav\0All Files:*.*\0*.*\0\0"); // required file ext
ofn.lpstrInitialDir=NULL;
BYTE* OutBuffer;
OutBuffer = new BYTE[NumSample];
for( i = 0; i < NumSample; i++){
OutBuffer[i] = (BYTE)Sample[i]; }
if(GetSaveFileName(&ofn)==TRUE){ // Show up the Save File Dialog Box
WriteWav(&RecordWavFileFmt, NumSample, OutBuffer, out_filename); }} // call WriteWav to save wave file
// Å
}
// ####### 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 codes here to deal with the reaction for this item Æ
ENEE408G Fall 2003 (Update 07/06/2003)
Mobile Computing and Pocket PC Programming
56