示例#1
0
	  void MAGNITUDEOBJ::load(HANDLE hFile) 
	  {
		char sztemp[30];
		char szorder[5];

		load_object_basics(this);
		load_property("type",P_INT,&filtertype);
		load_property("order",P_INT,&order);
		load_property("center",P_FLOAT,&center);
		load_property("width",P_FLOAT,&wid);
		load_property("gain",P_INT,&gain);
		
		strcpy(sztemp,PASSTYPE[filtertype].init);
		sprintf(szorder,"%d",order);
		strcat(sztemp,szorder);

		if (lp1fbuf!=NULL)	 fid_run_freebuf(lp1fbuf);
		if (lp1filt!=NULL)   fid_run_free(lp1filt);
		if (lp2fbuf!=NULL)	 fid_run_freebuf(lp2fbuf);
		if (lp2filt!=NULL)   fid_run_free(lp2filt);
		lp1filt= fid_design(sztemp, PACKETSPERSECOND, (double)wid, 0, 0, 0);
		lp1run= fid_run_new(lp1filt, &(lp1funcp));
		lp1fbuf=fid_run_newbuf(lp1run);
		lp2filt= fid_design(sztemp, PACKETSPERSECOND,(double)wid, 0, 0, 0);
		lp2run= fid_run_new(lp2filt, &(lp2funcp));
		lp2fbuf=fid_run_newbuf(lp2run);
	  }
示例#2
0
  FidlibFilter(const char *spec, int f0, int f1)
  {

    filt = fid_design((char*)spec, f0, f1, 0,0,0);
    run = fid_run_new(filt, &funcp);
    fbuf = fid_run_newbuf(run);
  }
示例#3
0
FidFilter * do_filt_design(HWND hDlg, int ftype)
{
	char sztemp[30];
	char szorder[5];
	int p0;
	float p1,p2;

    BOOL trans;

	p0=GetDlgItemInt(hDlg, IDC_FILTERPAR0, &trans, 0); if (!trans) p0=0;

	GetDlgItemText(hDlg,IDC_FILTERPAR1,sztemp,sizeof(sztemp)); 
	sscanf(sztemp,"%f",&p1);
	GetDlgItemText(hDlg,IDC_FILTERPAR2,sztemp,sizeof(sztemp)); 
	sscanf(sztemp,"%f",&p2);

	if (test_filterparams(ftype,p0,p1,p2)) 
	{
	    strcpy(sztemp,FILTERTYPE[ftype].init);
	    GetDlgItemText(hDlg, IDC_FILTERPAR0,  szorder, sizeof(szorder));
		strcat(sztemp,szorder);
        return (fid_design(sztemp, PACKETSPERSECOND, p1,p2,0,0));
	}
	return (NULL);
}
示例#4
0
MAGNITUDEOBJ::MAGNITUDEOBJ(int num) : BASE_CL()	
	  {
	    outports = 1;
		inports = 1;
		width=65;
		strcpy(in_ports[0].in_name,"in");
		strcpy(out_ports[0].out_name,"out");
		out_ports[0].get_range=-1;
		out_ports[0].out_min=0;
		out_ports[0].out_max=100;
		strcpy(out_ports[0].out_dim,"uV");
		
				
		lp1filt= fid_design("LpBu4", PACKETSPERSECOND, 2, 0, 0, 0);
		lp1run= fid_run_new(lp1filt, &(lp1funcp));
		lp1fbuf=fid_run_newbuf(lp1run);

		lp2filt= fid_design("LpBu4", PACKETSPERSECOND, 2, 0, 0, 0);
		lp2run= fid_run_new(lp2filt, &(lp2funcp));
		lp2fbuf=fid_run_newbuf(lp2run);

		filtertype=1; order=4; gain=100; center=10.0f; wid=2.0f;
	  }
示例#5
0
FILTEROBJ::FILTEROBJ(int num) : BASE_CL()	
	  {
	    outports = 1;
		inports = 1;
		strcpy(in_ports[0].in_name,"in");
		strcpy(out_ports[0].out_name,"out");

		filtertype=3;
		par0=8;
		par1=8;
		par2=12;
		dispfrom=4;
		dispto=15;
		filt= fid_design("BpBe8", PACKETSPERSECOND, 8, 12, 0, 0);
		run= fid_run_new(filt, &(funcp));
		fbuf=fid_run_newbuf(run);
		strcpy(name,"Alpha Bessel");
	  }
示例#6
0
	  void FILTEROBJ::load(HANDLE hFile) 
	  {	
		char sztemp[30];
		char szorder[5];

		  load_object_basics(this);
		  load_property("name",P_STRING,name);
		  load_property("type",P_INT,&filtertype);
		  load_property("order",P_INT,&par0);
		  load_property("display-from",P_INT,&dispfrom);
		  load_property("display-to",P_INT,&dispto);
		  load_property("par1",P_FLOAT,&par1);
		  load_property("par2",P_FLOAT,&par2);
		
		  if (fbuf!=NULL) fid_run_freebuf(fbuf);
		  if (filt!=NULL) fid_run_free(filt);
 		  strcpy(sztemp,FILTERTYPE[filtertype].init);
		  wsprintf(szorder,"%d",par0);
		  strcat(sztemp,szorder);			
		  filt=fid_design(sztemp, PACKETSPERSECOND, par1, par2, 0, 0);
		  run= fid_run_new(filt, &(funcp));
		  fbuf=fid_run_newbuf(run);
	  }
示例#7
0
EngineFilter::EngineFilter(char * conf, int predefinedType)
        : iir(0),
          fir(0),
          tmp(0),
          ff(NULL),
          funcp(NULL),
          run(NULL)
{
    switch(predefinedType)
    {
    case PREDEF_BP:
        processSample = &processSampleBp;
        fbuf1 = buf1;
        fbuf2 = buf2;
        break;
    case PREDEF_HP:
        processSample = &processSampleHp;
        fbuf1 = buf1;
        fbuf2 = buf2;
        break;
    case PREDEF_LP:
        processSample = &processSampleLp;
        fbuf1 = buf1;
        fbuf2 = buf2;
        break;
    default:
        ff = fid_design(conf, 44100., -1., -1., 1, NULL);
        qDebug() << "Filter " << conf << " Setup: 0x" << ff;
        run = fid_run_new(ff, &funcp);
        fbuf1 = fid_run_newbuf(run);
        fbuf2 = fid_run_newbuf(run);
        processSample = funcp;
    }
    int i;
    for(i=0; i < FILTER_BUF_SIZE; i++)
        buf1[i] = buf2[i] = 0;
}
示例#8
0
LRESULT CALLBACK MagnitudeDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
	int t; // ,z;
	static int tempfilt=0,acttype=0;
	static int dinit=FALSE;
	char sztemp[30];
    
	MAGNITUDEOBJ * st;
	
	st = (MAGNITUDEOBJ *) actobject;
    if ((st==NULL)||(st->type!=OB_MAGNITUDE)) return(FALSE);


	switch( message )
	{
		case WM_INITDIALOG:
			{
				SCROLLINFO lpsi;
				
				SendMessage(GetDlgItem(hDlg, IDC_PASSTYPECOMBO), CB_RESETCONTENT,0,0);
			    for (t = 0; t < PASSTYPES; t++) 
					SendMessage( GetDlgItem(hDlg, IDC_PASSTYPECOMBO), CB_ADDSTRING, 0,  (LPARAM) (LPSTR) PASSTYPE[t].tname) ;
				SetDlgItemText(hDlg,IDC_PASSTYPECOMBO, PASSTYPE[st->filtertype].tname);
				acttype=st->filtertype;

				SetDlgItemInt(hDlg,IDC_ORDER, st->order,0);
				SetDlgItemInt(hDlg,IDC_GAIN, st->gain,0);

				lpsi.cbSize=sizeof(SCROLLINFO);
				lpsi.fMask=SIF_RANGE|SIF_POS;
				
				lpsi.nMin=1; lpsi.nMax=1280;
				SetScrollInfo(GetDlgItem(hDlg,IDC_CENTERBAR),SB_CTL,&lpsi,TRUE);
				lpsi.nMin=1; lpsi.nMax=200;
				SetScrollInfo(GetDlgItem(hDlg,IDC_WIDTHBAR),SB_CTL,&lpsi,TRUE);

				SetScrollPos(GetDlgItem(hDlg,IDC_CENTERBAR), SB_CTL,(int)(st->center*10.0f),TRUE);
				sprintf(sztemp,"%.4f",st->center);
				SetDlgItemText(hDlg,IDC_CENTER, sztemp);

				SetScrollPos(GetDlgItem(hDlg,IDC_WIDTHBAR), SB_CTL,(int)(st->wid*10.0f),TRUE);
				sprintf(sztemp,"%.4f",st->wid);
				SetDlgItemText(hDlg,IDC_WIDTH, sztemp);
			}
			return TRUE;
		case WM_CLOSE:		
			    EndDialog(hDlg, LOWORD(wParam));
				return TRUE;
				break;
		case WM_COMMAND:
			switch (LOWORD(wParam)) 
			{
			
			case IDC_PASSTYPECOMBO:
				  acttype=SendMessage( GetDlgItem(hDlg, IDC_PASSTYPECOMBO), CB_GETCURSEL, 0, 0 ) ;
				break;
			case IDC_CENTER:
				if (HIWORD(wParam) == EN_KILLFOCUS)
                    {
						GetDlgItemText(hDlg, IDC_CENTER, sztemp, 20);
						st->center = (float)atof(sztemp);
						if (st->center<0) { st->center=0; SetDlgItemText(hDlg,IDC_CENTER,"0");}
						if (st->center>PACKETSPERSECOND/2) { st->center=(float)(PACKETSPERSECOND/2); SetDlgItemInt(hDlg,IDC_CENTER,PACKETSPERSECOND/2,0);}
//						SendMessage (hDlg,WM_COMMAND,IDC_STORE,0);
					}
				break;
			case IDC_WIDTH:
				if (HIWORD(wParam) == EN_KILLFOCUS)
                    {
						GetDlgItemText(hDlg, IDC_WIDTH, sztemp, 20);
						st->wid = (float)atof(sztemp);
						if (st->wid<0.0001) { st->wid=1; SetDlgItemText(hDlg,IDC_CENTER,"0.0001");}
						if (st->wid>PACKETSPERSECOND/2) { st->wid=(float)(PACKETSPERSECOND/2); SetDlgItemInt(hDlg,IDC_WIDTH,PACKETSPERSECOND/2,0);}
//						SendMessage (hDlg,WM_COMMAND,IDC_STORE,0);
					}
				break;
			case IDC_STORE:
				{
					char sztemp[30];
					char szorder[5];
					int test;
					
					test=GetDlgItemInt(hDlg,IDC_ORDER, NULL, 0);
					if ((test<1)||((test>10)&&(acttype==0))||((test>60)&&(acttype==1))) 
					{ SetDlgItemInt(hDlg,IDC_ORDER,st->order,0); return(TRUE); }
					st->filtertype=acttype;
					st->order=test; 
					st->gain=GetDlgItemInt(hDlg,IDC_GAIN, NULL, 0);

					strcpy(sztemp,PASSTYPE[st->filtertype].init);
					GetDlgItemText(hDlg, IDC_ORDER,  szorder, sizeof(szorder));
					strcat(sztemp,szorder);
	
					st->lp1filt= fid_design(sztemp, PACKETSPERSECOND, (double)st->wid, 0, 0, 0);
					st->lp1run= fid_run_new(st->lp1filt, &(st->lp1funcp));
					if (st->lp1fbuf!=NULL)
					{
						fid_run_freebuf(st->lp1fbuf);
	   				    st->lp1fbuf=fid_run_newbuf(st->lp1run);
					}

					st->lp2filt= fid_design(sztemp, PACKETSPERSECOND,(double)st->wid, 0, 0, 0);
					st->lp2run= fid_run_new(st->lp2filt, &(st->lp2funcp));
					if (st->lp2fbuf!=NULL)
					{
						fid_run_freebuf(st->lp2fbuf);
   					    st->lp2fbuf=fid_run_newbuf(st->lp2run);
					}
					return TRUE;
				}
				break;
			}
			return (TRUE);
		case WM_HSCROLL:
		{
			int nNewPos;
  		    if((nNewPos=get_scrollpos(wParam,lParam))>=0)
			{
			  
			  if (lParam == (long) GetDlgItem(hDlg,IDC_CENTERBAR))  
			  {   
				  st->center=(float)nNewPos/10.0f;
				  sprintf(sztemp,"%.2f",st->center);
				  SetDlgItemText(hDlg, IDC_CENTER,sztemp);
			      
			  }
			  if (lParam == (long) GetDlgItem(hDlg,IDC_WIDTHBAR)) 
			  {
				  st->wid=(float)nNewPos/10.0f;
				  sprintf(sztemp,"%.2f",st->wid);
				  SetDlgItemText(hDlg, IDC_WIDTH,sztemp);
			  }

			} 
		}
		break;
		case WM_SIZE:
		case WM_MOVE:  update_toolbox_position(hDlg);
		break;
		return(TRUE);
		
	}
    return FALSE;
}
示例#9
0
void update_samplingrate(int newrate)
{
	int t,error=0;
	char sztemp[30],szorder[5];

	for (t=0;t<GLOBAL.objects;t++)
 	switch (objects[t]->type)
	{ 
	   case OB_FILTER:
		   {
			   FILTEROBJ * st = (FILTEROBJ *) objects[t];

			   if (st->par1>newrate/2) { error=1; break;}
 			   if ((FILTERTYPE[st->filtertype].param==2) && (st->par2>newrate/2)) { error=1; break;}
		   }
		   break;
	   case OB_MAGNITUDE:
		   {
   			    MAGNITUDEOBJ * st = (MAGNITUDEOBJ *) objects[t];
			   if ((st->wid>newrate/2) ||(st->center>newrate/2))  { error=1; break;}
		   }
		   break;
	   case OB_EEG:
		   {
			switch (TTY.devicetype) {
					case DEV_IBVA:
						if (TTY.COMDEV!=INVALID_HANDLE_VALUE)
						{
							char str[15];
							wsprintf(str,"SR %d\r",TTY.samplingrate);
							write_string_to_comport(str);
						}
						break;
					case DEV_MONOLITHEEG_P21:
						update_p21state();
						break;
				}
		   }
		   break;
	}

	if (error) {report_error ("Cannot change Sampling Rate, please check corner frequencies of filter- or magnitude elements"); return;}

	PACKETSPERSECOND=newrate;
	for (t=0;t<GLOBAL.objects;t++)
 	switch (objects[t]->type)
	{ 
	   case OB_FILTER:
		   {
			   FILTEROBJ * st = (FILTEROBJ *) objects[t];

			   if (st->fbuf!=NULL) fid_run_freebuf(st->fbuf);
			   if (st->filt!=NULL) fid_run_free(st->filt);
 			   strcpy(sztemp,FILTERTYPE[st->filtertype].init);
			   wsprintf(szorder,"%d",st->par0);
			   strcat(sztemp,szorder);			
			   st->filt=fid_design(sztemp, PACKETSPERSECOND, st->par1, st->par2, 0, 0);
			   st->run= fid_run_new(st->filt, &(st->funcp));
			   st->fbuf=fid_run_newbuf(st->run);
		   }
		   break;
	   case OB_MAGNITUDE:
		   {
   			    MAGNITUDEOBJ * st = (MAGNITUDEOBJ *) objects[t];

		   		strcpy(sztemp,PASSTYPE[st->filtertype].init);
				sprintf(szorder,"%d",st->order);
				strcat(sztemp,szorder);

				if (st->lp1fbuf!=NULL)	 fid_run_freebuf(st->lp1fbuf);
				if (st->lp1filt!=NULL)   fid_run_free(st->lp1filt);
				if (st->lp2fbuf!=NULL)	 fid_run_freebuf(st->lp2fbuf);
				if (st->lp2filt!=NULL)   fid_run_free(st->lp2filt);
				st->lp1filt= fid_design(sztemp, PACKETSPERSECOND, (double)st->wid, 0, 0, 0);
				st->lp1run= fid_run_new(st->lp1filt, &(st->lp1funcp));
				st->lp1fbuf=fid_run_newbuf(st->lp1run);
				st->lp2filt= fid_design(sztemp, PACKETSPERSECOND,(double)st->wid, 0, 0, 0);
				st->lp2run= fid_run_new(st->lp2filt, &(st->lp2funcp));
				st->lp2fbuf=fid_run_newbuf(st->lp2run);
		   }

	}
	init_system_time();
	get_session_length();
}