home *** CD-ROM | disk | FTP | other *** search
/ Dave Lowe: S5 Stereo Sound Sampler / Lowe_S5StereoSoundSampler.adf / Doc / S5.EntryPoints.txt < prev   
Encoding:
Text File  |  1986-12-10  |  16.5 KB  |  406 lines

  1.  
  2.  
  3.  
  4.  
  5. Part of the S5 manual ....
  6.  
  7. Entry Points
  8. ------------
  9.  
  10. EP 1 : S5Base = OpenLibrary("s5.library",revision)
  11.        D0                   A1           D0
  12.  
  13. Mandatory call before any other  routine  in  this library can be
  14. used. Returns the address  of  the  library  node if successfully
  15. opened. If NULL,  do  not  proceed  to  use  any of these library
  16. routines. Reasons for not  opening  might include failure to find
  17. the file LIBS:S5.Library,  or  insufficient  memory,  or  library
  18. already open for use by another  program.  Possibly  an unrelated
  19. program has allocated the parallel printer port, and since the S5
  20. requires access  to  this,  if  the  initialisation  code  cannot
  21. perform all of its functions, then  a CloseLibrary() call is made
  22. automatically. The usual  name  for  the  global  address pointer
  23. variable is S5Base. 
  24.  
  25. EP 2 : CloseLibrary(S5Base)
  26.                     A1
  27. A call to inform  the  system  that  this  library  is  no longer
  28. needed, and that the memory that it is using can be reclaimed for
  29. other programs. During  the  course  of  the  call, any resources
  30. claimed  by  the   OpenLibrary   routine   are  freed,  including
  31. deallocating the parallel device.
  32. EP 3 : Expunge(S5Base)
  33. Used by CloseLibrary(). Do not use.
  34. Remove library from memory.
  35. EP 4 : Null()
  36. Do not use.
  37. Reserved entry  point.  (Reserved  for  system use rather than S5
  38. use.)
  39.  
  40. EP 5 : Success = S5StartWave(Frequency,type)
  41.                              A0        A1
  42. Begin to play a waveform of  Frequency  Hz, of shape Type (0=Sine
  43. 1=Square  2=Triangular  3=Ramp).  Note  that  Frequency  must not
  44. exceed 1800 Hz since each  waveform  is made from 16 samples, and
  45. the Amiga is hardware limited  to  playing sounds at a maximum of
  46. about 30,000 samples/sec. This function  can be used to provide a
  47. simple signal generator  for  your  program.  e.g.  for tuning or
  48. testing some audio equipment. Success is a standard return code.
  49.  
  50. EP 6 : Success = S5StopWave()
  51.  
  52. Stop playing the sound started by S5StartSound().
  53.  
  54. EP 7 : Success = S5StereoStart(LeftFrag,RightFrag,Deviate)
  55.        D0                      A0       A1        D0
  56. This is the main sound  player  routine  in  the  S5 library. The
  57. parameters  LeftFrag   and   RightFrag   are  pointers  to  sound
  58. fragments. These fragments are used  extensively in the S5 system
  59. and are described in a previous section.  Each normally points to
  60. a structure which holds  pointers  to  the actual data buffers to
  61. play and the play rate, repeat count, and several other important
  62. factors. This routine  also  performs  the  envelope operation if
  63. these have been set up.  The  Deviate  parameter  is only used to
  64. change playback pitch during  the  Preview play mode. i.e. if you
  65. hit a key when the mode  is  enabled,  the  key code is passed to
  66. this routine. For normal operation just use a value of 0. Success
  67. is normally E_OK. Occasionally there  might be a port conflict or
  68. insufficient   memory,   but   this   is   unusual.  Under  those
  69. circumstances a  particular  error  code  might  be returned. See
  70. 'Return Codes' above.
  71.  
  72. EP 8 : Success = S5StereoStop(LeftFrag,RightFrag)
  73.        D0                     A0       A1
  74. Stop the sound playing,  even  if  this  means breaking in during
  75. play. Note that  if  either  channel  is  running  with envelopes
  76. enabled,  then   the   S5StereoStart()   routine  will  still  be
  77. executing,   rather   than   exiting   -   so  S5StereoStop()  is
  78. inappropriate in this  circumstance.  Success is the conventional
  79. return value.
  80.  
  81. EP 9 : Boolean = S5CheckPlaying(Select)
  82.        D0                       A0
  83. Returns TRUE if the selected  channel  is actually playing still,
  84. and FALSE if it is not. Select is 0 for left, 1 for right.
  85.  
  86. EP 10 : S5WaitForEnd(Select)
  87.                      A0
  88. Waits for the selected channel  to  complete playing. Select is 0
  89. for left, and 1 for right.
  90.  
  91. EP 11 : Success = S5SoundStartup(Size,LeftFrag,RightFrag)
  92.         D0                       A0   A1       D0
  93. Allocates and initializes the data buffers for these two channels
  94. to the specified number of  bytes  (samples).  Both normally have
  95. the same size. Returns standard success  codes. Equivalent to two
  96. S5AllocateSampleBuffer() calls.
  97.  
  98. EP 12 : Success = S5AllocateSampleBuffer(Size,Frag)
  99.         D0                               A0   A1
  100. Initialize just one  Frag.  Standard  Success  return. The memory
  101. could be CHIP or  FAST  depending  on  how the Frag was allocated
  102. (S5AllocateFrag()).
  103. (Refer to Frag structure definition.)
  104. Sets up the members of the structure:-
  105. buffer set to address of block of memory;
  106. buffer size set to Size;
  107. Cursors ([ I ]) set to start, mid and end of buffer;
  108. Zoom view set to end points of buffer;
  109. Play and Record enable switches turned on;
  110. Playing(SIC) switch off;
  111. Set initial sample and play rate to 10000;
  112. Set volume to maximum (64);
  113. Set left side preference;
  114. Name cleared;
  115. Envelopes cleared.
  116.  
  117. EP 13 : S5SoundShutDown(LeftFrag,RightFrag)
  118.                         A0       A1
  119. Deallocates  the  sample  buffers  of  the  two  frags.  Use  two
  120. S5DeallocateFrag() calls to kill the frags entirely.
  121.  
  122. EP 14 : Success = S5ConfigureHardware()
  123.         D0
  124. Called by the OpenLibrary()  routine.  Attempts  to configure any
  125. hardware registers necessary for use by the S5 recording system.
  126. If used separately don't forget to  S5Seize() the parallel device
  127. first, otherwise there might be big trouble.
  128.  
  129. EP 15 : Success = S5DeConfigureHardware()
  130.         D0
  131. Called by CloseLibrary() to restore  hardware to the state before
  132. OpenLibrary() (because of S5ConfigureHardware()). Don't forget to 
  133. S5Release() the parallel device. 
  134. (Users might like  to  claw  back  the  parallel  device during a
  135. program run if they need  to  use  the  printer etc. In that case
  136. call this routine, and later call  S5ConfigureHardware() again to
  137. reallocate the hardware.)
  138.  
  139. EP 16 : Success = S5RecordSamples(LeftFrag,RightFrag)
  140.         D0                        A0       A1
  141. The  main  routine  for  recording.   Assumes  that  buffers  are
  142. allocated and a sampling rate is set up in each channel fragment.
  143. One important note is that  if  a  stereo  recording is made, the
  144. sample rate will be the  same  for  both  channels, i.e. the left
  145. channel rate. This is because  recording  rates  are usually very
  146. fast, and it is not  possible  to  record  accurately  at any two
  147. rates  simultaneously  with  this  hardware.  Also,  the system's
  148. interrupts are turned off during a  recording, so the screen will
  149. blank and multi-tasking stop.  It  is  not a good idea to run any
  150. other task while making a  recording.  When recording, the buffer
  151. cursors are ignored. Also,  the  number  of  samples taken is the
  152. shorter of the two. When buffer  lengths  are  different, use the
  153. mono record  method  i.e.  turn  off  one  of  the  sample enable
  154. switches. (Part of the Frag structure.)
  155.  
  156. EP 17 : Value = S5ADC(Select)
  157.         D0            A0
  158. Read a single value from the  specified  channel. Select is 0 for
  159. left, 1 for right. The value returned is between -128 and +127.
  160.  
  161. EP 18 : S5Read1LR(LeftPtr,RightPtr)
  162.                   A0      A1
  163. Read a single value from each of the  two channels and store them
  164. in the bytes pointed to by the  parameters.  (Byte pointers. i.e.
  165. Not Frag pointers!).
  166. EP 19 : S5ClearTracks(LeftFrag,RightFrag)
  167.                       A0       A1
  168. Fill each entire buffer with zeroes.
  169.  
  170. EP 20 : Bool = S5ValidRange(Frag)
  171.         D0                  A0
  172. Returns TRUE if the start  cursor  ([)  of the fragment is placed
  173. before the finish cursor (]).
  174.  
  175. EP 21 : Success = S5BuildEnvelopeTable(Frag,Select)
  176.         D0                             A0   A1
  177. Creates the volume or  period  values  needed  during an envelope
  178. play operation. If Select is 0 create the volume values, else the
  179. period values.
  180.  
  181. EP 22 : int = S5FreqToPlayRate(Frequency)
  182.         D0                     A0
  183. Convert the play rate in samples/second  into the necessary 'tick
  184. rate'.  i.e.  the  number  required  by  the  lowest  level  play
  185. routines. Each tick would last  about  30nS,  and there MUST be a
  186. minimum of 124  of  these  between  each  sample.  This  function
  187. ensures this happens. i.e. if  you  wish  to play back a sound at
  188. 60KHz, you cannot!
  189.  
  190. EP 23 : int = S5FreqToSamRateStereo(Frequency)
  191.         D0                          A0
  192. Convert the desired sample rate  in  samples/second into a number
  193. of delay loops to perform, assuming this is a stereo sample. Used
  194. by lowest level recording software.
  195.  
  196. EP 24 : int = S5FreqToSamRateMono(Frequency)
  197.         D0                        A0
  198. Convert the desired sample rate  in  samples/second into a number
  199. of delay loops to  perform,  assuming  this  is  a mono recording
  200. (either left or right). Used by lowest level recording software.
  201.  
  202. EP 25 : S5SetTiming(con1,con2,con3)
  203.                     A0   A1   D0
  204. Do not use.
  205. Sets some constants used by the recording software to determine
  206. the number  of  software  delay  loops  needed  at  a  particular
  207. recording rate.
  208.  
  209. EP 26 : S5GetTiming(con1Ptr,con2Ptr,con3Ptr)
  210.                     A0      A1      D0
  211. Do not use.
  212. Returns values  into  pointers  for  the  three  values mentioned
  213. above.
  214.  
  215. EP 27 : Success = S5LoadIFF(Frag,FileName,Options)
  216.         D0                  A0   A1       D0
  217. Loads a file from disk to  a  fragment  buffer.  Frag  must be an
  218. initialized fragment. Filename is  the full DOS filename. Options
  219. are as follows:-
  220.  
  221. 0 : Load up in default mode. The buffer  is reallocated to be the
  222. length of data required. Highest octave only is loaded.
  223. 1 : Load up  into  existing  cursor  range.  If  cursor  range is
  224. smaller than that in the file,  only  load  a part of it. Highest
  225. octave only is loaded.
  226.  
  227. EP 28 : Success = S5SaveIFF(Frag,FileName,Option1,Option2)
  228.         D0                  A0   A1       D0      D1
  229. Saves a region between cursors  as  a  standard IFF file. Options
  230. are as follows: If Option1  is  0  only  a single octave of a One
  231. Shot section is to be created. i.e. a sound effect rather than an
  232. instrument. If Option1 is in the range  1 to 5 then it represents
  233. the number of  octaves  to  create.  Option2  is  composed of two
  234. quantities (sorry about this !) : the number of octaves above the
  235. current one PLUS 10 times the  number  of samples per high cycle.
  236. For example:  Option1=4  and  Option2=1  means  create  an octave
  237. higher than the current one; the current  octave; and two octaves
  238. below. We recommend that you do  not  have many octaves above the
  239. current one. 
  240. When an instrument is  being  created  both  One-Shot  and Repeat
  241. sections are determined by the  three  cursor positions ([ I ]) -
  242. even though you might not  be  using  the  S5  control panel, the
  243. cursors positions  are  still  important.  (Remember  that  the I
  244. cursor separates the One-Shot part from the Repeat part.)
  245. Typical usage:-
  246. S5SaveIFF(LeftFrag,"chickens",0,0); /* one shot FX */
  247. S5SaveIFF(LeftFrag,"clucks",3,1);   /* 3-octave instrument */
  248. S5SaveIFF(LeftFrag,"clucks2",3,482); /* 3-octaves instrument with
  249. 2 higher octaves, and SamplesPerHiCycle of 48.
  250.  
  251. EP 29 : Success = S5LoadSOP2(Left,Right,FileName,Option)
  252.         D0                   A0   A1    D0       D1
  253. Load a standard SOP2 file  into  each  of  the frags (Left,Right)
  254. from  a  single  file  FileName.  A  load  is  only  made  if the
  255. corresponding play enable flag is  set in that Frag. If Option is
  256. 0 then the buffer is adjusted  to  an appropriate size. If Option
  257. is 1 then the data is loaded into  the cursor area, truncating if
  258. this is necessary.
  259.  
  260. EP 30 : Success = S5SaveSOP2(Left,Right,FileName,Option)
  261.         D0                   A0   A1    D0       D1
  262. Save an area identified  by  a  region  possibly  for  two  Frags
  263. (Left,Right) depending  on  whether  their  play enable flags are
  264. set. Save both to the same file, FileName. Option should be 0.
  265.  
  266. EP 31 : Success = S5LoadSOP3(Frag,FileName,Option)
  267.         D0                   A0   A1       D0
  268. Load a SOP3 file. See notes  in  appendix  for  format.  Standard
  269. success return code. If Option  is  0  then reallocate the buffer
  270. according to the file size.  Otherwise  load  between the [ and ]
  271. cursors.
  272.  
  273. EP 32 : Success = S5SaveSOP3(Frag,FileName,Option)
  274.         D0                   A0   A1       D0
  275. Save sample data to a  SOP3  file.  Option  is unused. Success is
  276. standard return code.
  277.  
  278. EP 33 : FragPtr = S5AllocateFrag(Size,Type)
  279.         D0                       A0   A1
  280. Allocate and initialize a Frag structure,  allocating  Size bytes
  281. for the sample buffer. Return  zero  if insufficient memory. Type
  282. is FRAG_CHIP (=0) for  normal  operation  of  FRAG_FAST  (=1) for
  283. fragments with data buffers placed in FAST memory.
  284. EP 34 : S5DeallocateFrag(Frag)
  285.                          A0
  286. Undoes  the   AllocateFrag()   operation,   freeing   any  memory
  287. associated.
  288.  
  289. EP 35 : Success = S5LoadEnvelope(EnvPtr,FileName)
  290.         D0                       A0     A1
  291. Reads in a text file and sets  up  the Envelope pointed to by the
  292. parameter.
  293. EP 36 : Success = S5SaveEnvelope(EnvPtr,FileName)
  294.         D0                       A0     A1
  295. Write out an envelope as a text file.
  296.  
  297. EP 37 : S5KillEnvelope(Env)
  298.                        A0
  299. Deallocate and clear structures within the envelope, but does not 
  300. deallocate the envelope structure itself.
  301.  
  302. EP 38 : Success = S5FastMemRecord(Frag)
  303.         D0                        A0
  304. Record into FAST memory. See section 'Extended Memory'. This is a
  305. mono recording, on  the  Left  physical  channel.  Note  that the
  306. ordinary record above will also record into FAST memory.
  307.  
  308. EP 39 : Success = S5FastMemPlay(Frag)
  309.         D0                      A0
  310. Play a sample buffer from  FAST  memory.  See  section  `Extended
  311. Memory`. CHIP memory  will  be  allocated  at  the  start of this
  312. routine. If two large  buffers  already  exist,  there may not be
  313. enough CHIP memory left, or not in  contiguous blocks. Be sure to
  314. check the Success code.
  315.  
  316. EP 40 : Success = S5Seize()
  317.         D0
  318. Grabs the Parallel device from  the  system. Stops other programs
  319. from using it accidentally.  This  routine  might fail if another
  320. program is already using the parallel device.
  321.  
  322. EP 41 : Success = S5Release()
  323.         D0
  324. Release the Parallel device so that other programs may use it.
  325.  
  326. EP 42 : S5SetPlay(Frag,Option,Value)
  327.                   A0   A1     D0
  328. Change one item  of  the  specified  fragment  depending  on  the
  329. Option.
  330. Option Element changed
  331.   1      Play rate
  332.   2      Volume
  333.   3      Repeat count
  334.   4      Play enable flag. 1=on 0=off
  335.   5      Record enable flag. 1=on 0=off
  336.   6      Record rate. (same as S5SetRecord()).
  337. Useful when called from Basic, where structures are unavailable.
  338.  
  339. EP 43 : S5SetRecord(Frag,rate)
  340.                     A0   A1
  341. Change record rate.
  342.  
  343. EP 44 : int = S5FragSize()
  344.         D0
  345. Returns size  (in  bytes)  of  the  Frag  structure.  Useful  for
  346. languages which do not have a  STRUCTURE  construct,  but need to
  347. allocate memory dynamically.
  348.  
  349. EP 45 : S5STEREOSAMPLE(LeftBuf,RightBuf,Length,Delay)
  350.                        A0      A1       D0     D1
  351. The main stereo recording  routine.  LeftBuf and Rightbuf are the
  352. bases of two byte arrays where  the  data will be written to, for
  353. Length bytes. Delay is a software  loop count per sample computed
  354. from S5FreqToSamRateStereo(frag->Fr_sampHz).
  355.  
  356. EP 46 : S5LEFTSAMPLE(LeftBuf,Length,Delay)
  357.                      A0      A1     D0
  358. Record on left physical channel only. See S5STEREOSAMPLE().
  359.  
  360. EP 47 : S5RIGHTSAMPLE(RightBuf,Length,delay)
  361.                       A0       A1     D0
  362. Record on right physical channel only. See S5STEREOSAMPLE().
  363.  
  364. EP 48 : S5DUMMYREAD(Length)
  365.                   A0
  366. Exercises recording hardware. Only useful for testing hardware.
  367. Do not use.
  368.  
  369. EP 49 : S5FILL(Buffer,Length,FillByte)
  370.              A0     A1     D0
  371. Copy FillByte Length times to Buffer.
  372.  
  373. EP 50 : S5MOVE(Source,Destination,Length)
  374.                A0     A1          D0
  375. Block copy from Source to Destination for Length bytes.
  376.  
  377. EP 51 : S5GetStatus(VariableAddress)
  378.                     A0
  379. Used in Basic to set a LONG  INTEGER  variable  to the error code
  380. returned from the previous S5  routine  which  returned a Success
  381. code - or any other value, such as a pointer or boolean result.
  382.  
  383. An example portion of an Amiga Basic program :
  384.  
  385. Succ& = 0 : REM Defines a variable. Most important to do this !!!
  386. f$="plop.sop2"+chr$(0)
  387. CALL S5Player(SADD(f$))
  388. S5GetStatus(VARPTR(Succ&))
  389. IF Succ&<>EOK THEN GOSUB ReportError
  390. REM should have loaded, played, and deallocated OK
  391.  
  392. EP 52 : Success = S5Player(Filename)
  393.         D0                   A0
  394. Simply  load  and  play   the   sound   in  the  specified  file.
  395. Automatically works out whether  its  IFF,  SOP2, or SOP3 format.
  396. Allocates sufficient space  and  resources  to  do  the job. When
  397. finished, cleans up  accordingly.  This uses the resources of the
  398. rest of the library, so it is not a good idea to use this routine 
  399. with the S5StereoStart() routine.
  400.  
  401. EP 53 : S5LatticeIO(inf,outf,errf)
  402.                     A0  A1   D0
  403. Redundant.
  404. Do not use.
  405. `
  406.