home *** CD-ROM | disk | FTP | other *** search
/ Groovy Bytes: Behind the Moon / groovybytes.iso / GROOVY / SND_TOOL / CRYS250.ZIP / CRYSENG.DOC < prev    next >
Encoding:
Text File  |  1995-01-11  |  19.8 KB  |  605 lines

  1.  
  2.                ──────────────────────────────────
  3.  
  4.                CRYSTAL PLAYER Version 2.50
  5.  
  6.             ────────────────────────────────────────
  7.  
  8.               (C)opyright 1994 Sébastien GRANJOUX
  9.  
  10.                  ────────────
  11.  
  12.  
  13.  
  14.  WARNING: You are using this software at your own risks! In no events should
  15.  I be liable for any damage or loss resulting from the use, misuse or
  16.  inability to use Crystal Player. There are no warranties, except that this
  17.  program will occupy disk place.
  18.  
  19.  
  20.  
  21.  Table of contents │
  22. ───────────────────┘
  23.  
  24.   I ........................................... Licence
  25.   II .................................. Archive content
  26.  
  27.   III ........................................ Features
  28.   IV ................................... The MOD player
  29.   V ........................ Using Crystal Sound System
  30.  
  31.   VI ....................... Frequently Asked Questions
  32.   VII ......................................... History
  33.   VIII ......................................... Thanks
  34.   IX ............................. Contact informations
  35.   X ................................Distributions Sites
  36.  
  37.  
  38.  
  39.  
  40.  I - Licence │
  41. ─────────────┘
  42.  
  43.    This program enables you to play music files in the MOD format and
  44.    can be included in your own programs, as long as these terms are
  45.    respected:
  46.  
  47.    You can freely include Crystal Player in any public domain software
  48.    (freeware), if you credit me as the author of the sound system.
  49.    For any commercial use (including shareware), contact me to discuss
  50.    about further terms and to obtain my agreement.
  51.  
  52.    This program is provided with its full sources in order to enable you to
  53.    modify and adapt them in order to fit your particular needs. These
  54.    modifications should be kept personnal, but I'll be glad to receive any
  55.    improvement to Crystal Player. I just want to keep Crystal Player under
  56.    control, in order to prevent bugged versions from floating around.
  57.  
  58.    You can freely distribute this program, as long as you don't charge more
  59.    than 5 US dollars for shipping fees and you keep all the original
  60.    files in the archive.
  61.  
  62.    Contact informations are located at the end of this file.
  63.  
  64.  
  65.  
  66.  III - Archive Content │
  67. ───────────────────────┘
  68.  
  69.   The archive should be called CRYSxxxl, where xxx is the version (for
  70.   instance 240 means version 2.40). The letter l doesn't exist in public
  71.   releases. B means that it is a beta version, some files may be missing,
  72.   and some bugs could be present.
  73.  
  74.   The usual archive contains these 15 files:
  75.  
  76.      C0MULTI.ASM contains starting code for Crystal Player in asm.
  77.  
  78.      CRYS.EXE    is an executable version of the modplayer.
  79.  
  80.      CRYS26.ASM  contains all routines to play a MOD file.
  81.  
  82.      CRYS26.OBJ  is an object file generated by Turbo Assembleur of the
  83.          previous file. That's the file you need to include in your
  84.          C or ASM source to use Crystal Player routines.
  85.  
  86.      CRYSEXP.CPP is an example of the use of Crystal Player routines in
  87.          Turbo C++
  88.  
  89.      CRYSEXP.PAS same as above, but for Turbo Pascal.
  90.  
  91.      CRYSTAL.ASM is the main code of the MOD player. You may consider it as
  92.          an example for asm.
  93.  
  94.      CRYSENG.DOC is the file you are now reading.
  95.  
  96.      CRYSFR.DOC  same as above, but in french.
  97.  
  98.      CRYSTAL.INC contains some constants definitions for an asm program,
  99.          like error codes and soundcards number.
  100.  
  101.      CRYSTAL.PAS contains the source of the Turbo Pascal unit needed to use
  102.          Crystal Player routines.
  103.  
  104.      CRYSTAL.TPU contains the unit for Turbo Pascal programs.
  105.  
  106.      FILE_ID.DIZ description for BBSes.
  107.  
  108.      STINTER.ASM contains some routines to get some variables from CRYS26
  109.          like current track number.
  110.  
  111.      STMODE3.ASM contains routines for text mode 3 (80x25 16 colors)
  112.  
  113.  
  114.  
  115.  
  116.  II - Features │
  117. ───────────────┘
  118.  
  119.    This program is entirely coded in asm and contains 386 instructions.
  120.    It don't works on XT and 286 based PCs. It supports four sound devices:
  121.    the internal speaker, a DAC (digital to analog convertor) on a parallel
  122.    port (like Covox), a Sound Blaster card, and a Gravis UltraSound card
  123.    (GUS). Be aware that the Sound Blaster needs to use the DMA channel 1 and
  124.    an IRQ inferior or equal to 7.
  125.  
  126.    It only plays MOD files with 15 or 31 instruments and 4, 6 or 8 channels.
  127.    Moreover, it only accept 64 patterns and each sample should be smaller
  128.    than 63 Kb. The following effects aren't recognized: E3,E4,E5,E7,EF.
  129.    On the other hand, it uses 8 octaves like MOD files tracked with
  130.    Scream Tracker 3.
  131.  
  132.    As you will notice by reading the history, this program has been
  133.    constantly evolving, so it isn't very easy to understand. It contains
  134.    a few bugs, and if something don't works, maybe you've just discovered
  135.    a new one. ;)  In this case, contact me. Usually, I correct bugs rather
  136.    quickly. If it's a particular MOD file which don't work, I would like
  137.    you to send it to me (at least the name and the place where I cand find
  138.    it).
  139.  
  140.  
  141.  
  142.  IV - The MOD player │
  143. ─────────────────────┘
  144.  
  145.   The MOD player contained in the archive isn't meant to concurrence other
  146.   MOD players, and it has only few options. It is provided so that you can
  147.   easily see the qualities (and lacks) of the sound routines. It also gives
  148.   you an example to use them in asm. It uses internal informations of
  149.   the routines, so you can look how to use them if you really need them.
  150.   You can code a new MOD player with these routines but they doesn't
  151.   really be made for that.
  152.  
  153.   It can be easily used, and if you run it without any parameter, it will
  154.   display a help page. You should at least give the name of a .MOD file.
  155.   It will then choose itself the best sound device that it will find in your
  156.   environment variables. You can force a sound device, even if it doesn't
  157.   exist in your environment variables, or change the default mixing frequency
  158.   (18.6 kHz) by using these options:
  159.  
  160.      /FRxxx  Mixing frequency in hundreds of Hertz
  161.  
  162.      /SK     Internal Speaker
  163.  
  164.      /DCp    DAC on port p (1 to 4)
  165.  
  166.      /SBp,i  Sound Blaster on port p (in hexadecimal 220 for instance) with
  167.          IRQ i.
  168.  
  169.      /GSp    Gravis UltraSound on port p (hexadecimal)
  170.  
  171.   You don't need to provide p or i parameters (but leave the , ): the player
  172.   will look for those values in environment variables. If they don't exist,
  173.   it uses default values.
  174.  
  175.  
  176.  
  177.  V - Using Crystal Sound System │
  178. ────────────────────────────────┘
  179.  
  180.   Source was assembled by Turbo Assembler in ideal mode, and needs a 386.
  181.   Sound routines are gathered in CRYS26.ASM. To use them, you only need to
  182.   include the CRYS26.OBJ or the pascal TPU unit.
  183.  
  184.   Every function uses the pascal format to take parameters. They can
  185.   send back a 16 bits error code, but restore ES,DS,DI and SI. Other
  186.   registers may be altered.
  187.  
  188.   To play music, you need to call in order FLOADMOD or MLOADMOD to load
  189.   the module in memory, then SETMOD to tell which sound device you wish
  190.   to use and frequency, and finally STARTMOD to start playing the music.
  191.   You will then need to call MAKEMOD 50 times a second. To stop the music,
  192.   call STOPMOD. You can continue the music by calling STARTMOD again.
  193.   If you want to change the module, you will need to call UNLOADMOD, then
  194.   FLOADMOD or MLOADMOD and SETMOD again. There's also a function called
  195.   DETECTSND which looks for environment variables to determine the sound
  196.   device to use.
  197.  
  198.   Here's a detailed description of those functions.
  199.  
  200.   FLOADMOD
  201.  
  202.      Function: Load a MOD in memory from a file.
  203.  
  204.      Input:    A far pointer on the file name, finished by a nul character.
  205.  
  206.      Output:   An error code different from 0 if an error has occured.
  207.  
  208.      Remark:   This function takes itself the memory needed for the module.
  209.            Each sample use 764 bytes more than in the file. Each sample
  210.            can't be bigger than 64Ko and there must be less than 64
  211.            pattern.
  212.  
  213.  
  214.   MLOADMOD
  215.  
  216.      Function: Load a mod already in memory
  217.  
  218.      Input:    A far pointer on the module in memory
  219.  
  220.      Output:   An error code different from 0 if an error has occured.
  221.  
  222.      Remark:   This function exactly do the same thing that FLOADMOD,
  223.            except that it doesn't load the module from a file.
  224.            Notice that the module will be twice in memory, and that
  225.            you can dispose of the memory previously used in memory
  226.            by the module.
  227.  
  228.  
  229.   OLOADMOD
  230.  
  231.      Function: Load a MOD in memory from a overlay.
  232.  
  233.      Input:    The starting position of the module in your program file
  234.            on 32 bits.
  235.  
  236.      Output:   An error code different from 0 if an error has occured.
  237.  
  238.      Remark:   This function acts like FLOADMOD and has the same
  239.            restriction. It uses only the position of the module and
  240.            search itself the name of the program.
  241.  
  242.  
  243.   UNLOADMOD
  244.  
  245.      Function: Free the memory used by the module.
  246.  
  247.      Input:    Nothing
  248.  
  249.      Output:   Nothing
  250.  
  251.      Remark:   This function should be called at the end of the program or
  252.            before loading another module.
  253.  
  254.  
  255.   SETMOD
  256.  
  257.      Function: Define sound device and frequency
  258.  
  259.      Input:    In pascal order, you must give frequency in hundreds of Hertz
  260.            on 16 bits, sound device number on 8 bits, port on 16 bits and
  261.            IRQ on 8 bits.
  262.  
  263.      Output:   An error code different from 0 if an error has occured.
  264.  
  265.      Remark:   Number for sound devices are:
  266.          0 = no sound
  267.          1 = internal speaker
  268.          2 = DAC
  269.          3 = Sound Blaster
  270.          4 = Gravis Ultrasound
  271.            For the DAC, the port isn't an address, but the number of
  272.            the port the DAC is on. (1 to 4)
  273.            If you give 0 as the frequency, Crystal Player uses a
  274.            default value of 18.6 kHz.
  275.            Every card doesn't use all parameters. On GUS, modules are
  276.            played at 44 kHz. The IRQ is only needed for Sound Blaster
  277.            card.
  278.            Sound Blaster always use DMA 1 and IRQ less than 7.
  279.            This is this function that load samples in GUS memory.  
  280.  
  281.  
  282.   STARTMOD
  283.  
  284.      Function: Start the music
  285.  
  286.      Input:    Nothing
  287.  
  288.      Output:   Nothing
  289.  
  290.      Remark:   This functions disable all interrupts, except timer and
  291.            keyboard. But since the timer is used by every sound device
  292.            except Sound Blaster, you would better not use it. Try not
  293.            to call any function which masks interrupts as it would
  294.            decrease music quality.
  295.  
  296.  
  297.   MAKEMOD
  298.  
  299.      Function: Calculate 1/50 second of music
  300.  
  301.      Input:    Nothing
  302.  
  303.      Output:   Nothing
  304.  
  305.      Remark:   You MUST call this function in the main loop of your program.
  306.            Before filling the buffer, this function tests if it isn't
  307.            already full, so you can (and you should) call it more than
  308.            fifty times a second. If you can't call it for more than
  309.            1/50 second, call MAKEMOD several times before. Buffer size
  310.            is 2 Kb.
  311.  
  312.  
  313.   STOPMOD
  314.  
  315.      Function: Stop music
  316.  
  317.      Input:    Nothing
  318.  
  319.      Output:   Nothing
  320.  
  321.      Remark:   This function allow you to definitively stop the music or
  322.            only pause it and continue it later by calling STARTMOD again.
  323.            It restore the interrupts in their initial state. There may be
  324.            some problems with Sound Blaster cards.
  325.  
  326.  
  327.   DETECTSND
  328.  
  329.      Function: Detect installed sound device by looking for environment
  330.            variables.
  331.  
  332.      Input:    In order,four far pointer on a byte for the sound
  333.            device number, a word for the port, a byte for IRQ
  334.            and a byte for DMA.
  335.  
  336.      Output:   Nothing
  337.  
  338.      Remark:   If you give different values from 0, this routine won't change
  339.            them. So you can detect the configuration of a particular
  340.            sound card. If you give 5 as the sound device number, the
  341.            routine will take the card with the greater number. If it
  342.            doesn't find any sound device, it will output 1 (PC
  343.            speaker).  (put SET DAC=p (p=1 to 4) in your
  344.            autoexec.bat if you use a DAC)
  345.  
  346.  
  347.   CHANGEVOL
  348.  
  349.      Function: Set master volume.
  350.  
  351.      Input:    A byte for the volume (0 to 255).
  352.  
  353.      Output:   Nothing
  354.  
  355.      Remark:   Just change the volume for all voices but it's not
  356.            instantaneous, there is a delay of about 250ms. It depends
  357.            mainly on the mixing frequency.
  358.  
  359.  
  360.  
  361.  VI - Frequently Asked Questions │
  362. ─────────────────────────────────┘
  363.  
  364.   How can I use variables from the mod playing routines, to display the
  365.   current pattern for instance?
  366.  
  367.   > In order to keep Crystal Player easy to understand, I've only
  368.   documented the mod playing functions, and the Turbo Pascal unit only
  369.   contains those functions. But there are other public symbols and I use
  370.   them in the mod player. You can look into CRYS26.ASM for the symbols,
  371.   and in STINTER.ASM to see how to use them.
  372.  
  373.  
  374.   Why the sound isn't as good as other MOD players?
  375.  
  376.   > First, to keep Crystal Player fast, I mix sample from the different
  377.   channels on 8 bits whereas the majority of other players use 16 bits.
  378.   Moreover, I don't use every sound card at its best. I don't use
  379.   stereo on Sound Blaster Pro for instance. (but it may change)
  380.   Finally, the mixing default value is 18.6 kHz. More would be alter the
  381.   sound on the internal speaker. With a Sound Blaster, you can raise it
  382.   up to 22 kHz to gain more quality.
  383.  
  384.  
  385.   Why can't I test my program in the Turbo Pascal environment?
  386.  
  387.   > To play music on PC, I need to intercept hardware interrupts and do
  388.   some other tricky things that many program won't accept.
  389.  
  390.  
  391.   Why is the player so slow with EMM386 or QEMM386?
  392.  
  393.   > Extended memory managers put the system in virtual 86 mode, the system
  394.   isn't in real mode anymore, and interrupts last much longer. Since the
  395.   player uses many of them, those managers slow it.
  396.  
  397.  
  398.   I've tried to add some code to the Turbo Pascal unit, but nothing works
  399.   anymore. Why?
  400.  
  401.   > Every routines playing the module are in the same segment and it has
  402.   to got a special organization. In particular, the code must start
  403.   at address 0 of the segment. If you add code, it won't work, but you
  404.   can add declarations.
  405.  
  406.  
  407.   How can I know that a function went right?
  408.  
  409.   > Functions send back 0 and the carry is clear if everything went
  410.   right.  Else, they send back an error code (look in CRYSTAL.INC).
  411.  
  412.   Why does the function FLOADMOD or MLOADMOD return an error code
  413.   with the right file name ?
  414.   
  415.   > Probably because the function can't find enough memory to load
  416.   the samples.  Normaly a program takes all the available memory
  417.   when the DOS load it.  To correct this, use the SMALL memory model
  418.   in a C program, use the $M option in a pascal program or give back
  419.   all the unused memory with the DOS function 4Ah in a asm program.
  420.  
  421.  
  422.   How can I use a overlay module ?
  423.  
  424.   > First,you have to compile and link your program with passing a
  425.   dummy value to OLOADMOD. You can compress your program now and then
  426.   you take note of your program's length. You replace the dummy value by
  427.   the program's length and you compile, link and possibly compress your
  428.   program again.The program must have the same length than before. Now,
  429.   you have just to add the module at the end of your program with
  430.   using, by example, "copy /b program+module".
  431.  
  432.  VII - History │
  433. ───────────────┘
  434.  
  435.   As I've already said it in the introduction, I've coded this program
  436.   like a snowball falling, getting bigger and bigger. Three years ago,
  437.   I started to write a program which only worked on the internal pc speaker,
  438.   then I added more and more features. Here's the list of improvements which
  439.   were made since version 1.3, the first one to have a documentation.
  440.  
  441.   Version 1.3
  442.   
  443.      Rewrite of the code (more modular)
  444.      Changeable mixing frequency
  445.      Speed up the PC speaker routines (+20%)
  446.      Correct portamento tone and vibrato
  447.      Correct picth of the notes
  448.      Correct use of tempo 
  449.      Best doc
  450.      
  451.   Version 1.5
  452.  
  453.      Use Sound Blaster
  454.      Use MOD with 31 samples
  455.      
  456.   Version 1.6
  457.   
  458.      Correct bugs from version 1.5 !!    
  459.      Correct arpeggio
  460.      
  461.   Version 1.7
  462.  
  463.      Common recorrect of effects
  464.      Add portamento+volume slide,vibrato+volume slide,extended
  465.       tempo,tremolo,play end part of sample,fine portamento,fine
  466.       volume slide and loop
  467.  
  468.   Version 1.8
  469.   
  470.      Add some animation during replay
  471.      The speaker sound a little better
  472.      
  473.   Version 1.9
  474.   
  475.      Add some small details
  476.      Code a pascal unit and some example in pascal and C
  477.      Add some options during replay (change pattern...) 
  478.      Speed up the routines (+4%) 
  479.  
  480.   Version 2.0
  481.      
  482.      Speed up all the routines (+20%)
  483.      Add a function to load MOD in memory
  484.      Correct effect E6
  485.      Add the following effects: pattern delay,cut note,note
  486.        delay,rettrig sample
  487.  
  488.  
  489.   Version 2.1
  490.  
  491.      Recorrect portamento tone
  492.      Add the no sound option
  493.      Correct a bug with pattern jump
  494.      Partially correct bug on pause with Sound Blaster
  495.      Correct effect 9
  496.      
  497.   Version 2.2
  498.   
  499.     Use GUS
  500.     Correct another bug with Sound Blaster
  501.     Add function to detect installed sound card
  502.     
  503.   Version 2.3
  504.   
  505.     Load and play 8 voices MOD
  506.     Use 8 octave of Scream Tracker 3
  507.  
  508.   Version 2.4
  509.  
  510.      Use the byte from fine tune.
  511.      Fixed some bugs.
  512.      Examples in Turbo Pascal and C were rewritten.
  513.      Complete rewrite of documentation.
  514.  
  515.   Version 2.5
  516.  
  517.      Sound better with GUS
  518.      Add a master volume
  519.      Load and play 6 voices MOD
  520.      Use overlay
  521.  
  522.   And in the future...
  523.  
  524.      Support for new sound cards. (I need informations on every sound cards,
  525.        including but not limited to GUS MAX, SB PRO, SB 16, SB AWE,
  526.        PAS etc.. and a mean to make tests)
  527.      Total rewrite of code.
  528.      Support for new module formats. (Informations wanted too!)
  529.      Support for the last effects not used.
  530.      Sound mixing on 16 bits.
  531.  
  532.  
  533.  VIII - Thanks │
  534. ───────────────┘
  535.  
  536.   I want to thank these persons who have played and continue to play
  537.   a part in this program:
  538.  
  539.     William Petiot for GUS tests and adjustements.
  540.     Stéphane Gigandet for numerous SoundBlaster tests and moral support.
  541.     Tchi Southivong for numerous tests with Gravis UltraSound.
  542.     Stéphane Scherrer for informations on Sound Blaster.
  543.     Vincent Negrier for SoundBlaster tests.
  544.     Francis Gastellu for the name of the player.
  545.     Mark J.Cox for showing me that mods could be played on PC.
  546.     Bisounours / Nuage for the translation of this file.
  547.     VLA for informations on DMA.
  548.     CASCADA for GUSPLAY.
  549.  
  550.  
  551.  
  552.  IX - Contact informations  │
  553. ────────────────────────────┘
  554.  
  555.   If you want to include my routines in a commercial program, if you have
  556.   found bugs, if you want some particular improvements, if you need more
  557.   informations or have any remark, you can contact me by using the
  558.   following ways:
  559.  
  560.   Send Mail to:
  561.  
  562.   M. Sébastien Granjoux
  563.      17 rue de Paris
  564.        92190 Meudon
  565.           France
  566.  
  567.   You can also leave me a message on one of this French BBS (near
  568.   Paris):
  569.  
  570.      Dune BBS             +33-1-47-02-25-97  24.0 Bps
  571.      Deadline BBS         +33-1-46-48-67-63  14.4 Bps
  572.               +33-1-46-44-57-96  28.8 Bps
  573.      Eden BBS             +33-1-34-15-39-67  28.8 Bps
  574.               +33-1-34-13-95-28  14.4 Bps
  575.  
  576.   Or by email. (I'm absolutely not sure that it works!)
  577.  
  578.      sebastien.granjoux_barnabo@sparkhq.fdn.org
  579.  
  580.   Don't hesitate to contact me, I will always pleased to answer you, and
  581.   it will give me the feeling that all this work wasn't worth nothing.
  582.  
  583.  
  584.  X - Distribution Sites     │
  585. ────────────────────────────┘
  586.  
  587.  Crystal Player latest version will always be availlable at these BBSes,
  588.  free for download:
  589.  
  590.  - France:
  591.  
  592.    Dune BBS             +33-1-47-02-25-97  24.0 Bps
  593.    Deadline BBS         +33-1-46-48-67-63  14.4 Bps
  594.             +33-1-46-44-57-96  28.8 Bps
  595.    Eden BBS             +33-1-34-15-39-67  28.8 Bps
  596.             +33-1-34-13-95-28  14.4 Bps
  597.  
  598.  More sites wanted!!! If you are a sysop and want to distribute
  599.  Crystal Player, call one of those boards.
  600.  
  601.  
  602.  
  603.                      Sébastien Granjoux,   01/11/95
  604.  
  605.