home *** CD-ROM | disk | FTP | other *** search
/ Boot Disc 8 / boot-disc-1997-04.iso / PDA_Soft / Psion / sounds / TSMP.C < prev    next >
C/C++ Source or Header  |  1994-04-06  |  2KB  |  92 lines

  1. /*    Written By Jason and DavidW, March 1994
  2.     Demo SYS$SAMP.LDD the sound sampling ldd
  3. */
  4.  
  5. #include <p_std.h>
  6. #include <p_file.h>
  7. #include <epoc.h>
  8. #include <wlib.h>
  9.  
  10. #include "Sampler.h"
  11.  
  12. GLREF_D VOID *DatCommandPtr;
  13.  
  14. LOCAL_D WORD Buf[240];
  15. LOCAL_D VOID *pcb;
  16.  
  17. LOCAL_C VOID Panic(INT err,TEXT *msg)
  18.     {
  19.     p_notifyerr(err,msg,0,0,0);
  20.     p_exit(0);
  21.     }
  22.  
  23. LOCAL_C VOID DeleteDriver(VOID)
  24.     {   /* ignore error since could be in use by other program */
  25.     p_devdel("SMP",E_LDD);
  26.     }
  27.  
  28. LOCAL_C VOID CheckContinueOrNot(VOID)
  29.     {
  30.     if (!p_notify("SMP: deleted","Start sampling?","Exit","Continue",0))
  31.         p_exit(0);
  32.     }
  33.  
  34. LOCAL_C VOID LoadDriver(VOID)
  35.     {
  36.     INT ret;
  37.     TEXT buf[P_FNAMESIZE];
  38.  
  39.     p_fparse("\\sys$samp.LDD",DatCommandPtr,&buf[0],NULL);
  40.     ret=p_loadldd(&buf[0]);
  41.     if (ret && ret!=E_FILE_EXIST)
  42.         Panic(ret,"Failed to load SYS$SAMP.LDD");
  43.     }
  44.  
  45. LOCAL_C VOID OpenChannel(VOID)
  46.     {
  47.     INT ret;
  48.  
  49.     ret=p_open(&pcb,"SMP:",-1);
  50.     if (ret)
  51.         Panic(ret,"Failed to open channel to SMP");
  52.     }
  53.  
  54. LOCAL_C VOID DisplayInputSound(VOID)
  55.     {
  56.     INT x,yold,y;
  57.     WORD *pb;
  58.     P_RECT box;
  59.  
  60.     box.tl.x=0;
  61.     box.tl.y=0;
  62.     box.br.x=240;
  63.     box.br.y=80;
  64.     FOREVER
  65.         {
  66.         x=(-1);
  67.         yold=40;
  68.         pb=(&Buf[0]);
  69.         p_read(pcb,pb,240);
  70.         gClrRect(&box,G_TRMODE_CLR);
  71.         while(x++<240)
  72.             {
  73.             y=40+(*pb++)/128;
  74.             gDrawLine(x,yold,x+1,y);
  75.             yold=y;
  76.             }
  77.         wFlush();
  78.         }
  79.     }
  80.  
  81. GLDEF_C VOID main(VOID)
  82.     {
  83.     DeleteDriver();
  84.     CheckContinueOrNot();
  85.     LoadDriver();
  86.     OpenChannel();
  87.     wStartup();
  88.     DisplayInputSound();
  89.     p_close(pcb);
  90.     }
  91.  
  92.