Huazhong University of Science and Technology
Visual Sound Instrument (Version 3.2)

Design Method of CGI Program by Visual C++
To extend the function of VSI32, a CGI like function is supplied. You can design a Win32 Console Application to do you special work and integrate it to VSI32. To communicate between CGI and VSI32, a group of API is used:
HANDLE GetProcessHandle(void);
Get Process ID of VSI32

void PostExit(void);
Inform VSI32 the CGI exit.

long ReadLen(HANDLE id);
Read sample data length of VSI32

long ReadFS(HANDLE id);
Read sample frequency of VSI32

int WriteLen(HANDLE id,long len);
Write sample data length of VSI32

int WriteFS(HANDLE id,long FS);
Write sample frequency of VSI32

int ReadCH1(HANDLE id,short *wave,int size);
Read CH1 sample data of VSI32

int ReadCH2(HANDLE id,short *wave,int size);
Read CH1 sample data of VSI32

int writeCH1(HANDLE process,short *wave,int size);
Read CH1 sample data of VSI32

int writeCH2(HANDLE process,short *wave,int size);
Read CH1 sample data of VSI32

Visual Sample 1:  Read Sample Data from VSI32
#include "stdafx.h"
#include "ReadData.h"
#include "CGILib.h"

CWinApp theApp;
using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{HANDLE id;
 long len,Fs;
 short wave1[2048],wave2[2048];
 id=GetProcessHandle();
 if (id==0) {AfxMessageBox("Error !");return 0;}
 len=ReadLen(id);
 Fs=ReadFS(id);
 ReadCH1(id,wave1,2048);
 ReadCH2(id,wave2,2048);
 return 0;
}
 

Visual Sample21: Write Sample Data to VSI32
#include "stdafx.h"
#include "writedata.h"
#include "CGILib.h"

CWinApp theApp;
using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{HANDLE id;
 short wave1[2048],wave2[2048];
 id=GetProcessHandle();
 if (id==0) {AfxMessageBox("Error !");return 0;}
 for (int i=0;i<2048;i++)
 {wave1[i]=2*i;
  wave2[i]=-2*i;
 }
 writeCH1(id,wave1,2048);
 writeCH2(id,wave2,2048);
 WriteLen(id,2048);
 WriteFS(id,5120);
 PostExit();
 return 0;
}
 



Steps of using visual c++ to design CGI program:

1.Start Visual C++, Use Project Wizard to build a Win32 Console Application project, as show below.
¡£
2.Input project name and select MFC support,, as show below.

3. Add CGILib.cpp and CGILib.h to project, and use APIs to communicate with VSI32, as shown below.

¡£
[Return]

.

 

2004.1.10