home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: delta / whiteline CD Series - delta.iso / tools / falc_uti / dsp_tool / dsp_unit / dsp.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-11-25  |  2.2 KB  |  74 lines

  1. { ----------------------------------------------------------
  2.   |                     UNIT DSP                           |
  3.   |                                                        |
  4.   | Hilfsfunktionen zur DSP-Programmierung für Pure Pascal |
  5.   |                                                        |
  6.   | Autor: Dirk Hohmann                                    |
  7.   |        An der Etzequelle 6                             |
  8.   |        37130 Gleichen/Etzenborn                        |
  9.   |                                                        |
  10.   ----------------------------------------------------------}
  11.  
  12. unit dsp;
  13.  
  14. INTERFACE
  15.  
  16. type dspword = array[0..2] of byte;
  17.  
  18. var word_size :integer;                          {Länge eines DSP-Wortes}
  19.     x_free,y_free :longint;               {freier XY-Speicher}
  20.     
  21. function r_frac(a:real):longint;        { REAL -> DSP-Format }
  22. function to_real(a:longint):real;        { DSP-Format -> REAL }
  23. function e_frac(a:extended):longint;  { EXTENDED -> DSP-Format }
  24. function to_ext(a:longint):extended;  { DSP-Format -> EXTENDED }
  25. function s_frac(a:single):longint;    { SINGLE -> DSP-Format }
  26. function to_single(a:longint):single; { DSP-Format -> SINGLE }
  27. function dsp_init: boolean;        
  28. procedure dsp_exit;
  29. procedure l_to_dspword(a:longint;var b:dspword); { Konvertierungen }
  30. function dspword_to_l(a:dspword):longint;
  31.  
  32. IMPLEMENTATION
  33. uses tos;
  34.  
  35. function r_frac(a:real):longint;external; 
  36. function to_real(a:longint):real;external; 
  37. function e_frac(a:extended):longint;external; 
  38. function to_ext(a:longint):extended;external;
  39. function s_frac(a:single):longint;external; 
  40. function to_single(a:longint):single;external;
  41.  
  42. {$L C:\DSP_TOOL\DSP_UNIT\DSP_CONV.O }
  43.  
  44.     
  45. function dsp_init: boolean;        
  46. begin
  47.     dsp_init:=false;
  48.     word_size:=dsp_getwordsize;
  49.     if word_size<>3 then exit;
  50.     if dsp_lock<>0 then exit;
  51.     dsp_available(x_free,y_free);
  52.     dsp_init:=true;
  53. end;
  54.  
  55. procedure dsp_exit;
  56. begin
  57.     dsp_unlock;
  58. end;
  59.  
  60. procedure l_to_dspword(a:longint;var b:dspword);
  61. begin
  62.     b[0]:=(a shr 16) and 255;
  63.     b[1]:=(a shr 8) and 255;
  64.     b[2]:=a and 255;
  65. end;
  66.  
  67. function dspword_to_l(a:dspword):longint;
  68. begin
  69.     dspword_to_l:=(a[0] shl 16) or (a[1] shl 8) or a[2];
  70. end;
  71.  
  72. begin
  73. end.
  74.