home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / sound / sbutil / source.exe / BNKTB.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-04-25  |  3.5 KB  |  152 lines

  1. {**************************************************************************
  2.  
  3.                                  BNKTB
  4.                          ROL Bank File ToolBox
  5.  
  6.                              Date: 4/4/91
  7.                               Version: 1
  8.  
  9. ***************************************************************************
  10.  
  11.                    Copyright (c) 1991, Zackzon Labs.
  12.  
  13.                        Author: Anthony Rumble
  14.  
  15. ==========
  16. Addresses:
  17. ==========
  18. InterNet: c9106510@cc.newcastle.edu
  19. SIGNet: 28:2200/108
  20.  
  21. Snail Mail:
  22.  32 Woolwich Rd.
  23.  Hunters Hill, NSW, 2110
  24.  Australia
  25.  
  26. -------------------------------------------------------------------------
  27.                               HISTORY
  28. -------------------------------------------------------------------------
  29. 1.0 - Works fine so far
  30. *************************************************************************}
  31. unit bnktb; {BNK ToolBox}
  32.  
  33. interface
  34.  
  35. uses misc;
  36.  
  37. const
  38.  max_size=78;
  39.  
  40. type
  41.  Instrument = array[1..26] of integer;
  42.  
  43.  header_record = record
  44.   vers_Major:byte;
  45.   vers_Minor:byte;
  46.   signature:array[1..6] of char; {= ADLIB-}
  47.   Num_list_used:word;
  48.   num_list:word;
  49.   offset_names:longint;
  50.   offset_data:longint;
  51.   filler:byte;
  52.  end;
  53.  
  54.  inst_name_record = record
  55.   index:word;
  56.   isused:byte;
  57.   name:array[1..8] of char;
  58.   bytenull:byte;
  59.  end;
  60.  
  61.  inst_data_record = record
  62.   mode:byte;
  63.   voice_no:byte;
  64.   modr:array[1..13] of shortint;
  65.   car:array[1..13] of shortint;
  66.   wave_mod:byte;
  67.   wave_car:byte;
  68.  end;
  69.  
  70. var
  71.  bnkF:file;
  72.  inr:inst_name_record;
  73.  idr:inst_data_record;
  74.  headr:header_record;
  75.  numread:word;
  76.  recno:longint;
  77.  x, err:integer;
  78.  tname:string;
  79.  ofst:longint;
  80.  lastinst:string;
  81.  lastdata:instrument;
  82.  bnk_file_name:string;
  83.  
  84. function load_bnk(nme:string;var ins:instrument):boolean;
  85.  
  86. implementation
  87.  
  88. {****************************************************************************
  89.                                LOAD_BNK
  90. ----------------------------------------------------------------------------
  91. Loads an instrument into the string INS of name nme from the
  92. bnk file name of BNK_FILE_NAME variable.. Which is by default 'STANDARD.BNK'
  93. ****************************************************************************}
  94. function load_bnk(nme:string;var ins:instrument):boolean;
  95. begin
  96.  {Check if the last instriment loaded is the same}
  97.  {This is to speed things up}
  98.  nme:=upper(nme);
  99.  if nme<>upper(lastinst) then
  100.  begin
  101.   assign(bnkF, bnk_file_name);
  102.   {$I-}
  103.   reset(bnkF,1);
  104.   {$I+}
  105.   err:=IORESULT;
  106.   load_bnk:=false;
  107.   if err<>0 then exit;
  108.   recno:=0;
  109.   {Read the Header}
  110.   blockread(bnkF, headr, sizeof(headr), numread);
  111.   {Seek to the start of the Inst Names}
  112.   seek(bnkf, headr.offset_names);
  113.   {Search for the Instrument name}
  114.   repeat;
  115.   inc(recno);
  116.   blockread(bnkF, inr, sizeof(inr), numread);
  117.   with inr do
  118.   begin
  119.    tname:='';
  120.    for x:=1 to 8 do
  121.    begin
  122.     if name[x]<>#00 then tname:=tname+name[x];
  123.    end;
  124.    if upper(tname)=nme then
  125.    begin
  126.     ofst:=headr.offset_data;
  127.     ofst:=ofst+(sizeof(idr)*inr.index);
  128.     seek(bnkf, ofst);
  129.     blockread(bnkF, idr, sizeof(idr), numread);
  130.     close(bnkF);
  131.     for x:=1 to 13 do
  132.     begin
  133.      ins[x]:=idr.modr[x];
  134.     end;
  135.     for x:=1 to 13 do
  136.     begin
  137.      ins[x+13]:=idr.car[x];
  138.     end;
  139.     load_bnk:=true;
  140.     lastinst:=upper(tname);
  141.     lastdata:=ins;
  142.     exit;
  143.    end;
  144.   end;
  145.   until ((eof(bnkF)) or (recno >= headr.num_list_used));
  146.  end else ins:=lastdata;
  147. end;
  148.  
  149. begin
  150.  lastinst:='';
  151.  bnk_file_name:='standard.bnk';
  152. end.