MRI 2.11.1997


Playing samples using Midas
---------------------------

The following script functions are directly dependent on the capabilities 
of Midas. If you want more info you should read the Midas manual.

Midas uses channels to output sound. To output a sample, you have to
first open a few channels, then allocate a channel and output the 
sample using that channel. Later you can free the channel and close
all opened channels. This is all great! The problem is playing a module
in the background and fiddling with the channels at the same time...
This is because MIDASplayModule and MIDASstopModule are highlevel functions
that takes care of all channel handling automatically.

Also, Midas 1.1.1 can only load samples from disk. Next version of Midas
will support RAM loading, i.e. DSYS filesystem loading.

Anyways, the following functions are awailable in DSYS:


    xxx xxx  OpenChannels  n
          Open sound channels used by module and sample playback.
           n - number of channels to open

    xxx xxx  CloseChannels 
          Close all sound channels.

    xxx xxx  AllocEffectChannels  n
          Allocate auto effect channels for sample playback.
           n - number of auto channels to allocate 

    xxx xxx  FreeEffectChannels
          Free all auto effect channels

    xxx xxx  LoadWaveSample  handle  filename  mode
          Load a uncompressed .WAV sample (from disk!!!).
           handle   - sample handle
           filename - filename
           mode     - LOOP or NOLOOP

    xxx xxx  FreeSample  handle
          Free a sample
           handle   - sample handle

    xxx xxx  PlaySample  handle  pri  rate  vol  pan
          Start playing a sample.
           handle   - sample handle
           pri      - sample playing priority (integer)
           rate     - playback rate (Hz ?)
           vol      - initial sample volume (0...64)
           pan      - sample panning (-64...0...64)

    xxx xxx  StopSample  handle
          Stop playing a sample.
           handle   - sample handle



Example
-------

     xxx xxx  SetVesaMode           320 200 16
     xxx xxx  TimeScreenMode        0
     xxx xxx  InitModulePlayer
     xxx xxx  SyncScreenMode        0
    
     xxx xxx  OpenChannels          16
     xxx xxx  AllocEffectChannels   2
    
     xxx xxx  LoadModule            0  yah.xm

     xxx xxx  LoadWaveSample        0  tada.wav   loop
     xxx xxx  LoadWaveSample        1  chord.wav  loop
    
     xxx xxx  InitAnim              sumea/efu.ini  sumea/efu.3ds
    
     xxx xxx  StartModule           0  noloop
    
     001 000  DoAnim                0 90 0.2 Camera01 -
     xxx xxx  PlaySample            0  10  20000  64  0
     001 032  DoAnim                - - - - -
     xxx xxx  PlaySample            1  10  20000  64  0
     xxx xxx  StopSample            0
     002 000  DoAnim                - - - - -
    
     xxx xxx  ExitAnim
    
     xxx xxx  FreeEffectChannels
    
     xxx xxx  StopModule            0
     xxx xxx  FreeModule            0
    
    # xxx xxx  CloseChannels
    
     xxx xxx  ExitModulePlayer


Note! Make sure you open enough channels using OpenChannel for both the
      module and samples.

Note! CloseChannels is not called to close the channels as it seems that
      StopModule does this.

