home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / sharew / musik / spectrum / spektrum.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-06  |  14.6 KB  |  604 lines

  1. #include<gemfast.h>
  2. #include<aesbind.h>
  3. #include<vdibind.h>
  4. #include<stdio.h>
  5. #include<math.h>
  6. #include<string.h>
  7. #include<unistd.h>
  8. #include<stdlib.h>
  9. #include<signal.h>
  10. #include<sound.h>
  11. #include<osbind.h>
  12.  
  13. #define TRUE 1
  14. #define FALSE 0
  15.  
  16. #define RL 20
  17. #define RO 10
  18. #define RR 10
  19. #define RU 10
  20. #define N 128
  21. #define LODBUFFSIZE 2048
  22. #define DMABUFFSIZE 4096
  23.  
  24. void draw_fft(int flag, int x, int y, int w, int h);
  25.  
  26. typedef struct
  27. {
  28.   long playbufptr;
  29.   long recbufptr;
  30.   long res1;
  31.   long res2;
  32. } bufptrtype;
  33.  
  34. typedef struct
  35. {
  36.   short li,re;
  37. } STEREO;
  38.  
  39. typedef struct
  40. {
  41.   int grid[46];
  42.   int rahmen[10];
  43.   char txth[5][5];
  44.   int thx[5], thy[5];
  45.   char txtv[5][5];
  46.   int tvx[5], tvy[5];
  47. } FFTGRID;
  48.  
  49. long _stksize=-50000L;
  50.  
  51. int gl_wbox, gl_hbox, gl_wchar, gl_hchar;
  52. int g_handle, gl_xmax, gl_ymax;
  53. int w_handle=-1,w_open=FALSE,w_ontop=FALSE;
  54. int work_in[11], work_out[57];
  55. int ap_id;
  56. int max_polyline_xy;
  57. int abtastfrequenz,clk;
  58. GRECT win;
  59. FFTGRID fftgrid;
  60. int lispec1[256],lispec2[256],respec1[256],respec2[256];
  61. int *lispectrum,*lialtspectrum,*respectrum,*realtspectrum;
  62. STEREO dmadata[DMABUFFSIZE];
  63. int lodbuffer[LODBUFFSIZE];
  64. bufptrtype bufptr;
  65. int wordsize,xmem,ymem,ability,flag,max_dspval,min_dspval;
  66. int sigende=FALSE;
  67.  
  68. void init_fft()
  69. {
  70.   int i,rw,rh,f;
  71.   double rast;
  72.  
  73.   rw=win.g_w-RL-RR; rh=win.g_h/2-RO-RU;
  74.   fftgrid.rahmen[0]=RL; fftgrid.rahmen[1]=RO;
  75.   fftgrid.rahmen[2]=RL+rw; fftgrid.rahmen[3]=RO;
  76.   fftgrid.rahmen[4]=RL+rw; fftgrid.rahmen[5]=RO+rh;
  77.   fftgrid.rahmen[6]=RL; fftgrid.rahmen[7]=RO+rh;
  78.   fftgrid.rahmen[8]=RL; fftgrid.rahmen[9]=RO;
  79.   rast=(double)((double)abtastfrequenz/1000)/((int)(abtastfrequenz/1000));
  80.   rast=(double)rw/rast/8;
  81.   for(i=0;i<8;i++)
  82.   {
  83.     fftgrid.grid[i*4]=RL+(int)(rast*(i+1));
  84.     fftgrid.grid[i*4+2]=fftgrid.grid[i*4];
  85.     if((i%2)==0)
  86.     {
  87.       fftgrid.grid[i*4+1]=RO;
  88.       fftgrid.grid[i*4+3]=RO+rh;
  89.     }
  90.     else
  91.     {
  92.       fftgrid.grid[i*4+1]=RO+rh;
  93.       fftgrid.grid[i*4+3]=RO;
  94.     }
  95.   }
  96.   for(i=0;i<5;i++)
  97.   {
  98.     fftgrid.thy[i]=RO-2;
  99.     f=abtastfrequenz/4000*i;
  100.     if(f%2)
  101.       sprintf(&fftgrid.txth[i][0],"%4.1f",(double)f/2);
  102.     else
  103.       sprintf(&fftgrid.txth[i][0],"%d",f/2);
  104.     fftgrid.thx[i]=RL+(int)(rast*i*2)-strlen(&fftgrid.txth[i][0])*2;
  105.   }
  106.   rast=(double)rh/4.0;
  107.   fftgrid.grid[32]=RL+rw; fftgrid.grid[33]=RO;
  108.   for(i=0;i<3;i++)
  109.   {
  110.     if((i%2)==0)
  111.     {
  112.       fftgrid.grid[i*4+34]=RL+rw;
  113.       fftgrid.grid[i*4+36]=RL;
  114.     }
  115.     else
  116.     {
  117.       fftgrid.grid[i*4+34]=RL;
  118.       fftgrid.grid[i*4+36]=RL+rw;
  119.     }
  120.     fftgrid.grid[i*4+35]=RO+(int)(rast*(i+1));
  121.     fftgrid.grid[i*4+37]=fftgrid.grid[i*4+35];
  122.   }
  123.   for(i=0;i<5;i++)
  124.   {
  125.     fftgrid.tvx[i]=2;
  126.     fftgrid.tvy[i]=RO+2+(int)(rast*i);
  127.     sprintf(&fftgrid.txtv[i][0],"%3d",i*(-20));
  128.   }
  129.   for(i=0;i<256;i+=2)
  130.   {
  131.     lispec1[i]=lispec2[i]=respec1[i]=respec2[i]=RL+i*rw/256+1;
  132.     lispec1[i+1]=lispec2[i+1]=respec1[i+1]=respec2[i+1]=RO+rh;
  133.   }
  134.   lispectrum=lispec1;
  135.   lialtspectrum=lispec2;
  136.   respectrum=respec1;
  137.   realtspectrum=respec2;
  138. }
  139.  
  140. void clear_connections()
  141. {
  142.   Devconnect(0,0,0,0,1);
  143.   Devconnect(1,0,0,0,1);
  144.   Devconnect(2,0,0,0,1);
  145.   Devconnect(3,0,0,0,1);
  146. }
  147.  
  148. int init_sound()
  149. {
  150.   if (Locksnd()>0)
  151.   {
  152.     clear_connections();
  153.     Soundcmd(LTATTEN,0x60);
  154.     Soundcmd(RTATTEN,0x60);
  155.     Soundcmd(LTGAIN,0xf0);
  156.     Soundcmd(RTGAIN,0xf0);
  157.     Soundcmd(ADDRIN,0x02);
  158.     Soundcmd(ADCINPUT,0x00);
  159.     Setsndmode(1);
  160.     Setbuffer(1,dmadata,dmadata+DMABUFFSIZE);
  161.     Setmontrack(0);
  162.     Settrack(0,0);
  163.     Dsptristate(1,1);
  164.     Devconnect(ADC,DSPREC | DAC,0,clk,1);
  165.     Devconnect(DSPXMIT,DMAREC,0,clk,1);
  166.     return(TRUE);
  167.   }
  168.   else
  169.   {
  170.     Unlocksnd();
  171.     return(FALSE);
  172.   }
  173. }
  174.  
  175. void restore_soundsystem()
  176. {
  177.   Unlocksnd();
  178.   Buffoper(0);
  179.   flag=Dsp_Hf0(0);
  180.   Dsptristate(0,0);
  181.   clear_connections();
  182.   Devconnect(3,0,0,CLK50K,1);
  183.   Soundcmd(LTATTEN,0x80);
  184.   Soundcmd(RTATTEN,0x70);
  185.   Soundcmd(LTGAIN,0xb0);
  186.   Soundcmd(RTGAIN,0x40);
  187.   Soundcmd(ADDRIN,0x01);
  188.   Soundcmd(ADCINPUT,0x03);
  189.   Dsp_Unlock();
  190. }
  191.  
  192. int dsp_init()
  193. {
  194.   int state;
  195.   char cwd_spec[256];
  196.  
  197.   if(!(state=Dsp_Lock()))
  198.   {
  199.     wordsize=Dsp_GetWordSize();
  200.     max_dspval=((1<<(8*wordsize))>>1)-1;
  201.     min_dspval=-max_dspval-1;
  202.     Dsp_Available(&xmem,&ymem);
  203.     if(!(state=Dsp_Reserve(xmem,ymem)))
  204.     {
  205.       ability=Dsp_RequestUniqueAbility();
  206.       flag=Dsp_Hf0(0);
  207.       Dgetpath(cwd_spec,0);
  208.       strcat(cwd_spec,"\\spektrum.lod");
  209.       state=Dsp_LoadProg(cwd_spec,ability,lodbuffer);
  210.       if(state)
  211.       {
  212.         form_alert(1,"[1][Wo ist die Datei|SPEKTRUM.LOD][ Ende ]");
  213.         Dsp_Unlock();
  214.         return(FALSE);
  215.       }
  216.       return(TRUE);
  217.     }
  218.     else
  219.     {
  220.       Dsp_Unlock();
  221.       return(FALSE);
  222.     }
  223.   }
  224.   return(FALSE);
  225. }
  226.  
  227. int start_soundsystem()
  228. {
  229.   int state;
  230.  
  231.   if(state=init_sound())
  232.   {
  233.     if(state&=dsp_init())
  234.     {
  235.       flag=Dsp_Hf0(1);
  236.       Buffoper(0x0c);
  237.     }
  238.     else
  239.       Unlocksnd();
  240.   }
  241.   if(!state)
  242.   {
  243.     form_alert(1,"[3][Fehler beim Start des|Soundsystems.][ Ende ]");
  244.   }
  245.   return(state);
  246. }
  247.  
  248. int open_fftwindow(int x, int y, int w, int h)
  249. {
  250.   int dummy,fx,fy,fw,fh;
  251.  
  252.   wind_get(0,WF_FULLXYWH,&fx,&fy,&fw,&fh);
  253.   w_handle=wind_create(NAME | CLOSER | MOVER,fx,fy,fw,fh);
  254.   if(w_handle>0)
  255.   {
  256.     wind_set(w_handle,WF_NAME,"Spektrum",dummy,dummy,dummy);
  257.     if(x<fx) x=fx;
  258.     if(y<fy) y=fy;
  259.     if(w>fw) w=fw;
  260.     if(h>fh) h=fh;
  261.     v_hide_c(g_handle);
  262.     graf_growbox(x+w/2-w/40,y+h/2-h/40,w/20,h/20,x,y,w,h);
  263.     wind_open(w_handle,x,y,w,h);
  264.     wind_get(w_handle,WF_WORKXYWH,&win.g_x,&win.g_y,&win.g_w,&win.g_h);
  265.     v_show_c(g_handle,1);
  266.     w_open=TRUE; w_ontop=TRUE;
  267.     init_fft();
  268.     return(TRUE);
  269.   }
  270.   else
  271.   {
  272.     form_alert(1,"[1][Es sind zu viele Fenster offen.|Schließen Sie zuerst welche.][ Ende ]");
  273.     w_open=FALSE; w_ontop=FALSE;
  274.     return(FALSE);
  275.   }
  276. }
  277.  
  278. void fft_moved(int x, int y, int w, int h)
  279. {
  280.   wind_set(w_handle,WF_CURRXYWH,x,y,w,h);
  281.   wind_get(w_handle,WF_WORKXYWH,&win.g_x,&win.g_y,&win.g_w,&win.g_h);
  282. }
  283.  
  284. void fft_topped()
  285. {
  286.   int dummy;
  287.   wind_set(w_handle,WF_TOP,dummy,dummy,dummy,dummy);
  288. }
  289.  
  290. void fft_closed()
  291. {
  292.   int x,y,w,h;
  293.  
  294.   wind_get(w_handle,WF_CURRXYWH,&x,&y,&w,&h);
  295.   graf_shrinkbox(x+w/2-w/40,y+h/2-h/40,w/20,h/20,x,y,w,h);
  296.   wind_close(w_handle);
  297.   w_open=FALSE; w_ontop=FALSE; w_handle=-1;
  298. }
  299.  
  300. void fft_redraw(int x, int y, int w, int h)
  301. {
  302.   GRECT r1,r2;
  303.   int pxy1[46],pxy2[46],pxy3[10],pxy4[10],pxyarray[4];
  304.   int thx[5],thy1[5],thy2[5],tvx[5],tvy1[5],tvy2[5];
  305.   int dummy,i,h2,cx,cy;
  306.  
  307.   r2.g_x=x; r2.g_y=y; r2.g_w=w; r2.g_h=h;
  308.   wind_get(w_handle,WF_FIRSTXYWH,&r1.g_x,&r1.g_y,&r1.g_w,&r1.g_h);
  309.   vswr_mode(g_handle,MD_REPLACE);
  310.   vsl_width(g_handle,1);
  311.   vsl_color(g_handle,BLACK);
  312.   vst_alignment(g_handle,0,0,&dummy,&dummy);
  313.   vst_height(g_handle,4,&dummy,&dummy,&dummy,&dummy);
  314.   vst_color(g_handle,BLACK);
  315.   vst_effects(g_handle,0);
  316.   vsf_style(g_handle,3);
  317.   vsf_perimeter(g_handle,TRUE);
  318.   vsf_interior(g_handle,1);
  319.   vsf_color(g_handle,WHITE);
  320.   h2=win.g_h/2;
  321.   for(i=0;i<46;i+=2)
  322.   {
  323.     pxy1[i]=fftgrid.grid[i]+win.g_x;
  324.     pxy2[i]=pxy1[i];
  325.     pxy1[i+1]=fftgrid.grid[i+1]+win.g_y;
  326.     pxy2[i+1]=pxy1[i+1]+h2;
  327.   }
  328.   for(i=0;i<10;i+=2)
  329.   {
  330.     pxy3[i]=fftgrid.rahmen[i]+win.g_x;
  331.     pxy4[i]=pxy3[i];
  332.     pxy3[i+1]=fftgrid.rahmen[i+1]+win.g_y;
  333.     pxy4[i+1]=pxy3[i+1]+h2;
  334.   }
  335.   for(i=0;i<5;i++)
  336.   {
  337.     thx[i]=fftgrid.thx[i]+win.g_x;
  338.     thy1[i]=fftgrid.thy[i]+win.g_y;
  339.     thy2[i]=thy1[i]+h2;
  340.   }
  341.   for(i=0;i<5;i++)
  342.   {
  343.     tvx[i]=fftgrid.tvx[i]+win.g_x;
  344.     tvy1[i]=fftgrid.tvy[i]+win.g_y;
  345.     tvy2[i]=tvy1[i]+h2;
  346.   }
  347.   cx=win.g_x+50; cy=win.g_y+win.g_h/2;
  348.   v_hide_c(g_handle);
  349.   wind_update(BEG_UPDATE);
  350.   while (r1.g_w && r1.g_h)       /* solange es was zu restaurieren gibt */
  351.   {
  352.     if (rc_intersect(&r2,&r1)) /* zu restaurierende Fläche */
  353.     {
  354.       grect_to_array(&r1,pxyarray);    /* AES in VDI Rechteck umrechnen */
  355.       vs_clip(g_handle,TRUE,pxyarray); /* clipping setzen */
  356.       vr_recfl(g_handle,pxyarray);     /* Hintergrund zeichnen */
  357.       vsl_type(g_handle,3);
  358.       v_pline(g_handle,23,pxy1);
  359.       v_pline(g_handle,23,pxy2);
  360.       vsl_type(g_handle,1);
  361.       v_pline(g_handle,5,pxy3);
  362.       v_pline(g_handle,5,pxy4);
  363.       for(i=0;i<5;i++)
  364.       {
  365.         v_gtext(g_handle,thx[i],thy1[i],fftgrid.txth[i]);
  366.         v_gtext(g_handle,thx[i],thy2[i],fftgrid.txth[i]);
  367.       }
  368.       for(i=0;i<5;i++)
  369.       {
  370.         v_gtext(g_handle,tvx[i],tvy1[i],fftgrid.txtv[i]);
  371.         v_gtext(g_handle,tvx[i],tvy2[i],fftgrid.txtv[i]);
  372.       }
  373.       v_gtext(g_handle,cx,cy,"(c) 1993 Thomas Gerner");
  374.     }
  375.     wind_get(w_handle,WF_NEXTXYWH,&r1.g_x,&r1.g_y,&r1.g_w,&r1.g_h);
  376.   }
  377.   wind_update(END_UPDATE);
  378.   v_show_c(g_handle,1);
  379.   draw_fft(FALSE,x,y,w,h);
  380. }
  381.  
  382. void draw_fft(int flag, int x, int y, int w, int h)
  383. {
  384.   GRECT r1,r2;
  385.   int lipxy1[256],lipxy2[256],repxy1[256],repxy2[256],pxyarray[4],*sa;
  386.   int dummy,mx,my,m_aus,i;
  387.  
  388.   r2.g_x=x; r2.g_y=y; r2.g_w=w; r2.g_h=h;
  389.   for(i=0;i<256;)
  390.   {
  391.     lipxy1[i]=repxy1[i]=lialtspectrum[i]+win.g_x;
  392.     lipxy2[i]=repxy2[i]=lispectrum[i]+win.g_x; i++;
  393.     lipxy1[i]=lialtspectrum[i]+win.g_y;
  394.     repxy1[i]=realtspectrum[i]+win.g_y;
  395.     lipxy2[i]=lispectrum[i]+win.g_y;
  396.     repxy2[i]=respectrum[i]+win.g_y; i++;
  397.   }
  398.   if(flag)
  399.   { sa=lispectrum; lispectrum=lialtspectrum; lialtspectrum=sa;
  400.     sa=respectrum; respectrum=realtspectrum; realtspectrum=sa; }
  401.   vsl_type(g_handle,1);
  402.   vsl_width(g_handle,1);
  403.   vsl_color(g_handle,BLACK);
  404.   vswr_mode(g_handle,MD_XOR);
  405.   graf_mkstate(&mx,&my,&dummy,&dummy);
  406.   m_aus=(mx>(r2.g_x-8))&&(mx<(r2.g_x+r2.g_w))&&(my>(r2.g_y-16))&&(my<(r2.g_y+r2.g_h));
  407.   wind_get(w_handle,WF_FIRSTXYWH,&r1.g_x,&r1.g_y,&r1.g_w,&r1.g_h);
  408.   if(m_aus) v_hide_c(g_handle);
  409.   if(wind_update(BEG_UPDATE))
  410.   while (r1.g_w && r1.g_h)
  411.   {
  412.     if (rc_intersect(&r2,&r1))
  413.     {
  414.       grect_to_array(&r1,pxyarray);
  415.       vs_clip(g_handle,TRUE,pxyarray);
  416.       v_pline(g_handle,128,lipxy1);
  417.       if(flag)
  418.         v_pline(g_handle,128,lipxy2);
  419.       v_pline(g_handle,128,repxy1);
  420.       if(flag)
  421.         v_pline(g_handle,128,repxy2);
  422.     }
  423.     wind_get(w_handle,WF_NEXTXYWH,&r1.g_x,&r1.g_y,&r1.g_w,&r1.g_h);
  424.   }
  425.   wind_update(END_UPDATE);
  426.   if(m_aus) v_show_c(g_handle,1);
  427. }
  428.  
  429. void get_fftdata(int startindex)
  430. {
  431.   int i,si,rh,h2,a;
  432.   STEREO *data;
  433.  
  434.   i=0; data=dmadata+startindex;
  435.   while((i<DMABUFFSIZE/4)&&(data->li!=0xffff8000)) { i++; data++; }
  436.   if(i<DMABUFFSIZE/4)
  437.   {
  438.     si=(startindex+i-129)%DMABUFFSIZE;
  439.     if(si<0) si+=DMABUFFSIZE;
  440.     data=dmadata;
  441.     h2=win.g_h/2;
  442.     rh=h2-RO-RU;
  443.     a=((data[si].li)>0) ? (-rh)*(log10(data[si].li)-4.5154)/4 : rh-1;
  444.     if(a>rh) a=rh-1;
  445.     lispectrum[1]=a+RO;
  446.     a=((data[si].re)>0) ? (-rh)*(log10(data[si].re)-4.5154)/4 : rh-1;
  447.     if(a>rh) a=rh-1;
  448.     respectrum[1]=a+RO+h2;
  449.     si=(si+1)%DMABUFFSIZE;
  450.     for(i=3;i<256;i+=2)
  451.     {
  452.       a=((-rh)*data[si].li)>>11;
  453.       if(a>rh) a=rh-1;
  454.       lispectrum[i]=a+RO;
  455.       a=((-rh)*data[si].re)>>11;
  456.       if(a>rh) a=rh-1;
  457.       respectrum[i]=a+RO+h2;
  458.       si=(si+1)%DMABUFFSIZE;
  459.     }
  460.     draw_fft(TRUE,win.g_x,win.g_y,win.g_w,win.g_h);
  461. /*    printf("\033H\n\nStart %5d\n",si); */
  462.   }
  463. }
  464.  
  465. void get_next_fft()
  466. {
  467.   Buffptr(&bufptr);
  468.   if((STEREO *)bufptr.recbufptr>(dmadata+DMABUFFSIZE*3/4))
  469.     get_fftdata(DMABUFFSIZE/2);
  470.   else if((STEREO *)bufptr.recbufptr>(dmadata+DMABUFFSIZE/2))
  471.     get_fftdata(DMABUFFSIZE/4);
  472.   else if((STEREO *)bufptr.recbufptr>(dmadata+DMABUFFSIZE/4))
  473.     get_fftdata(0);
  474.   else
  475.     get_fftdata(DMABUFFSIZE*3/4);
  476. }
  477.  
  478. void fft_event()
  479. {
  480.   int ende=FALSE;
  481.   int msg[8];
  482.   int event;
  483.   int mausx,mausy,mausbutton,mausclicks;
  484.   int tastenstatus,taste;
  485.   do
  486.   {
  487.     event=evnt_multi(MU_MESAG | MU_TIMER,0,0,0,0,0,0,0,0,0,0,0,0,0,                 /* Rechteck 2 */
  488.                      msg,100,&mausx,&mausy,&mausbutton,
  489.                      &tastenstatus,&taste,&mausclicks);
  490.     if(event & MU_MESAG)
  491.       switch(msg[0])
  492.       {
  493.         case WM_REDRAW:
  494.           fft_redraw(msg[4],msg[5],msg[6],msg[7]);
  495.           break;
  496.         case WM_TOPPED:
  497.           fft_topped(); break;
  498.         case WM_CLOSED:
  499.           fft_closed(); ende=TRUE; break;
  500.         case WM_MOVED:
  501.           fft_moved(msg[4],msg[5],msg[6],msg[7]); break;
  502.         case WM_NEWTOP:
  503.           break;
  504.         case WM_UNTOPPED:
  505.           break;
  506.         case WM_ONTOP:
  507.           break;
  508.         case AP_TERM:
  509.           fft_closed(); ende=TRUE; break;
  510.         default:
  511.       }
  512.     if(event & MU_TIMER)
  513.       get_next_fft();
  514.     if(sigende)
  515.     {
  516.       fft_closed(); ende=TRUE;
  517.     }
  518.   } while(!ende);
  519. }
  520.  
  521. int gemstart(void)
  522. {
  523.    int i;
  524.  
  525.    if(ap_id=appl_init()!=-1)
  526.    {
  527.       for (i=1;i<10;work_in[i++]=1);                     /* Workstation öffnen */
  528.       work_in[10]=2;
  529.       g_handle=graf_handle(&gl_wchar,&gl_hchar,&gl_wbox,&gl_hbox);
  530.       work_in[0]=g_handle;
  531.       v_opnvwk(work_in,&g_handle,work_out);
  532.       gl_xmax=work_out[0]; gl_ymax=work_out[1];
  533.       if (!g_handle) return(FALSE);
  534.       vq_extnd(g_handle,1,work_out);
  535.       max_polyline_xy=work_out[14];
  536.       return(TRUE);
  537.    }
  538.    return(FALSE);
  539. }
  540.  
  541. void get_frequenz(char *str)
  542. {
  543.   switch(strtol(str,NULL,0))
  544.   {
  545.     case 50: abtastfrequenz=49170; clk=CLK50K; break;
  546.     case 33: abtastfrequenz=33880; clk=CLK33K; break;
  547.     case 25: abtastfrequenz=24585; clk=CLK25K; break;
  548.     case 20: abtastfrequenz=20770; clk=CLK20K; break;
  549.     case 16: abtastfrequenz=16490; clk=CLK16K; break;
  550.     case 12: abtastfrequenz=12292; clk=CLK12K; break;
  551.     case 10: abtastfrequenz=9834;  clk=CLK10K; break;
  552.     case  8: abtastfrequenz=8195;  clk=CLK8K;  break;
  553.     default:
  554.   }
  555. }
  556.  
  557. void signalhandler(int sig)
  558. {
  559.   sigende=TRUE;
  560. }
  561.  
  562. int main(int argc, char **argv)
  563. {
  564.   extern char *optarg;
  565.   extern int optind;
  566.   char c;
  567.  
  568.   abtastfrequenz=49170;
  569.   clk=CLK50K;
  570.   if(argc>1)
  571.     while((c=getopt(argc,argv,"f:b:h:"))!=EOF)
  572.       switch (c)
  573.       {
  574.         case 'f':
  575.           get_frequenz(optarg);
  576.           break;
  577.         case 'b':
  578.           ;
  579.           break;
  580.         case 'h':
  581.           ;
  582.           break;
  583.         default:
  584.       }
  585.   if(gemstart())
  586.   {
  587.     graf_mouse(ARROW,NULL);
  588.     shel_write(9,0,1,NULL,NULL);
  589.     if(max_polyline_xy<N)
  590.       form_alert(1,"[3][Es sind nicht genug Polyline-|elemente möglich. Benutzen|Sie ein anderes VDI.][ Ende ]");
  591.     else
  592.       if(start_soundsystem())
  593.       {
  594.         signal(SIGINT,&signalhandler);
  595.         signal(SIGTERM,&signalhandler);
  596.         if(open_fftwindow(gl_xmax/2-9*gl_wbox,gl_ymax/2-6*gl_hbox,18*gl_wbox,12*gl_hbox))
  597.           fft_event();
  598.         restore_soundsystem();
  599.       }
  600.   }
  601.   v_clsvwk(g_handle);
  602.   appl_exit();
  603.   return(0);
  604. }