Crossfire Designs
Back to mainpage
Change language
Send a mail About this site
Source code
Image gallery

my emailadress   : stefan dot goehler at gmx dot de
my homepage      :

Readme file for soundlib.pas
Made on August 31th 1997
Last changes made on 7th of August 2001

some shortcuts and other things:
i.e. = in example
sb16 means sb16 and higher


  Copyright agreement, changes reserved
  All these statements apply, if not explicitely stated different, on ANY
  unit delivered with this package.

  You can use my units entired in your own programs. Ripping any code off
  or using parts (unimportant if modified or original) of this package
  somewhere else, e.g. in other packages, is not allowed without my


   If you wrote any code for the package yourself (meaning not modified
    code), you are allowed to use this special kind of code yourself and
    without my permission (just because it's your work, not mine)
   You can get a license for parts of this package or the whole package,
    the respective author(s) of such a part will get a donation from you

  This package is Freeware, as long as the product which uses it, is Freeware.

  You can use it freely in any kind of software which uses this and any of
  the other delivered units with these restrictions:

   You need to state the name of the package and also the names of the
    authors who did their hard work in this product on an often seen place
    of your product (intro/extro etc.).
   THE COMMERCIAL USE IS NOT FREE. You have to contact me if you use this
    package in any kind of commercial software, you need to get a license
    for it

  You are allowed to do modifications on my units. If they are useful, please
  let me know what you've done and give me the modifications.
  Modifications concerning the existence and/or modification of any
  copyright/author/name statements are generally not allowed.
  You are not allowed to publish modified units, you may only use them in
  your own productions (where these sources aren't published).
  Version publications are restricted to my person (Stefan Goehler).
  Additionally, you aren't allowed to charge any money for the units or any
  derivates of them, except you put them on some kind of
  shareware/freeware/sourcecode collection media.

  If not different stated, you aren't allowed use or spread any of the
  delivered units single, you have to spread the package with all files.
  Spreading units single is only allowed if I gave you my permission or
  the unit is yours and is not special licensed (see chapter 1).

  If you don't agree with these statements, please erase this sofware.
  If you don't understand a part, feel free to contact me.

A short description of the proggys you get with this unit:
SOUNDEMO.PAS : A short, simple example how to play a soundfile
               -give the file to play as parameter 1 (VOC or WAV)
SOUNDEM2.PAS : A more complex program to show how to use the features
               of the soundlib
               -give the file to play as parameter 1 (VOC or WAV)
SOUNDEM3.PAS : A simple recorder. It records to the file TEST.WAV with
               CD-Quality until you press a key. This program records from
               your CD-ROM drive. So start the playback of a cd first.
               That program is only runable on an SB16!

SOUNDEM4.PAS : This program was originally not for public release, so it's
               more difficult to understand it. This program records with
               8bit, 44100 Hz Stereo into the memory and shows the recorded
               realtime with a scope and a vumeter. The Number below shows
               how often the displayinterrupt has been called a second. It
               should be around 70 times. If this is not so, your PC isn't
               very fast. If the recorded volume is too high for a good
               record, the program shows "overload". Please note that you
               need the file too to compile soundem4.pas. This
               file is availible on my homepage. Also the file bk.obj is
               needed, which you should get with this unit. That's the
               backgroundpic of the scope.

SOUNDEM6.PAS : This is a frequency analyzer, which uses the Fast Fourier
               Transformation. The file _fft.pas is written by Bas van

MIXFILES.PAS : This is a small example how to mix files. This may help
               you in your own games. Just press buttons 1..4.

No warranty for the running under TP ver 6.0! At least soundemo.pas
works, but no warranty for the other files.

Hi there!

Here the overview about the functions provided by soundlib:

>> function  initblaster : byte;
   This is the first function you have to call. It initializes the sound-
   blaster and the variables for it's usage. It returns zero if there is
   a soundblaster beginning from version 2.0. If it returns nonzero, you
   are able to find the fitting error string in the sb_errorstr-constant.

>> initrecord(p : tmemp;buffersize,frequency : word;flags : word);
   This unit initializes recording from the soundblaster. The P-variable
   is the pointer where to write the data to (you have to get this pointer
   via getmem). BUFFERSIZE is the size of the doublebuffer. FREQUENCY is
   the samplerate to record. FLAGS includes, like also in other procedures,
   some information about the format to use.
   You are able to use the following constants:
   snd_nonsigned  ( Unsigned data values, all versions )
   snd_signed      ( Signed data values, >= SB16 )
   If you want to initialize a typical 16 bit recording, you just use
   this as parameter:

>> procedure initplay(datanum: byte;p : tmemp;buffersize,frequency : word;flags : word);
   This unit initializes playback from the soundblaster. DATANUM describes
   the datablock (i.e. samplingrate) in the variable PLAY. The P-variable
   is the pointer where to write the data to (you have to get this pointer
   via getmem). BUFFERSIZE is the size of the doublebuffer. FREQUENCY is
   the samplerate to record. For flags see the last lines in initrecord

!!! Attention:-Don't use buffersizes > 32 KB! This could hang the PC or
               could result that the playback scratches very bad.
              -Yes, this unit could be able to record and play at the same
               time on a SB16, but it can't till now. If that would be so,
               you were only able to do that with a different resolution.
               Creative doesn't documentate how to find out if the interrupt
               was called by playback or recording. If anyone knows how
               to find that out, please email me!!!

>> procedure exitplay;
   Stop playback if you have used initplay therefore.

>> procedure exitrecord;
   Stop recording if you have used initrecord therefore.

>> procedure pauserecord(pause : boolean);
   Pause (true) or continue (false) recording.

>> procedure pauseplay(pause : boolean);
   Pause (true) or continue (false) the actual playing file.

>> procedure startplay(datanum : byte);
   Start playback of a file which you have opened via opensound, openwav
   or openvoc.

>> procedure stopplay;
   Stop playback of the actual playing file.

>> procedure setplaypos(datanum : byte;pos : longint);
   Seek to a position in a file which you have opened via open****.
   You can only change the position if you actually play the file or
   if you have paused it.

>> function  setoutput(output : byte;left,right : boolean) : boolean;
   Set the channels where you want to hear the output:
   This function returns false if you haven't used this attributes or
   the blaster is not a sb16.

>> function  setinput(input,channel : byte;left,right : boolean) : boolean;
   This function is a little bit more complicated. INPUT stands for
   -MIDI (only sb16)
   CHANNEL is 1 for left and 2 for right. You can set the input
   i.e. on the left channel for left _and_ right. Also that for
   the right channel. Why this? If you record in mono, you must
   set the left channel to left and right - otherwise you record
   only from the left channel.

>> function  getinput(input,channel : byte;var left,right : boolean) : boolean;
   Like above, but you get back the inputsettings

>> function  setgain(out : boolean;left,right : byte) : boolean;
   With this function you can manipulate the amplification of the
   sb16 amplifier. The maximum value for LEFT and RIGHT is 3 (4x
   amplification). The minimum value is zero (1x amplification).
   Set OUT to true, if you want to change the amplification for
   the output otherwise set it to false to change the input

>> function  getgain(out : boolean;var left,right : byte) : boolean;
   Like above, but returns the values for left and right

>> function  setmemsize(size : word) : boolean;
   Set the buffersize of the doublebuffer. You can't use sizes
   higher than 16107 bytes.

>> procedure pauserecord(pause : boolean);
   Pause recording.

>> procedure pauseplay(pause : boolean);
   Pause playback.

>> procedure startplay;
   Start playback if you have used OPENSOUND, OPENWAV or OPENVOC.

>> procedure stopplay; {stop  playback if you used open****}
   Stop playback if you have used OPENSOUND, OPENWAV or OPENVOC.

>> function  getactpos : longint;
   Gives back the actual position of the file. This function is not accurate
   at the end (last 2 blocks) of the file, but very accurate while normal
   playback, because it gives not only the fileposition, but the _real_
   position (the playback position of the soundblaster is also calculated).

>> procedure setplaypos(pos : longint);{set fileposition of playback file - only if you used open****}
   Set a new position in the playback file. Use it only while the file is
   playing or paused!

>> function  setvolume(what,left,right : byte) : boolean;
   Set the volume of following parts:
    master  = master volume
    voice   = voice volume
    midi    = midi/FM volume
    cd      = CD volume
    linein  = line_in volume
    mike    = microphone volume
    speaker = PC Speaker volume
    treble  = treble intensity
    bass    = bass intensity
   The function returns false if the volume couldn't be setted (that's
   when the current soundblaster doesn't support this volumesetting)

>> function  getvolume(what : byte;var left,right : byte) : boolean;
   Like SETVOLUME, but you get back the volumes from the blaster.

>> function  openvoc(datanum : byte;filename : string;buffersize : word) : boolean;
   Open VOCfile. This function returns false if there was an error
   opening this file (file not found, format not supported)

>> function  openwav(datanum : byte;filename : string;buffersize : word) : boolean;
   Open WAVfile. This function returns false if there was an error
   opening this file (file not found, format not supported)

>> function  opensound(datanum : byte;s : string) : boolean;
   Open a VOC or a WAVfile. The program detects that at the fileending
   (.VOC or .WAV).

>> procedure closesound(datanum : byte);
   Close the file opened with OPENSOUND, OPENVOC or OPENWAV and stop

Why is there the variable DATANUM?? Well, you are able to open 20 files
at the same time. I think, that's a very good thing if you wanna program
multimedia-programs or something in this way. Here a very short and simple
program how to use that:

uses crt,soundlib;
  initblaster;                            {Init soundblaster}
  if opensound(0,paramstr(1)) then begin  {Open parameter 1 file as file 0}
    opensound(1,paramstr(2));             {Open parameter 2 file as file 1}
    startplay(0);                         {start playback of file 0}
    until (keypressed)or(play.stopped);   {Until key pressed or file reached its end}

    startplay(1);                         {start playback of file 1}
    until (keypressed)or(play.stopped);   {Until key pressed or file reached its end}
    if keypressed then readkey;
    closesound(0);                        {close file 0}
    closesound(1);                        {close file 1}

If you wanna test the functions with a lower version of the soundblaster,
set the variable blaster.version i.e. to sbpro after you called initblaster.
Please note that the sb16 emulates soundblasters lower than sbpro not
correctly at all - i.e. it doesn't play stereo in Sb Pro mode.

Try the soundlib with a dumped file from a audiocd and you will hear how
good the soundlib is - real CD-QUALITY*!!!

* on a sb16 - on other sb's you'll hear the maximum availible quality

Some additional information:
The mixer settings will be automaticly saved when you call initblaster
and will be restored when you exit the program. If you wanna make a mixer
utility that needs to let the new settings in the mixer, set the variable
autorestore to false!

If you want to play soundfiles with a memory-manager like EMM386, then
you should tell this manager to reserve some memory for the DMA-Buffer!
This is really needed!!! If you make some public software don't forget
to mention this in your readme!
How to make that with EMM386? Add to the line in the CONFIG.SYS where
EMM386 is called the parameter D=xx. XX stands for a number between 16
and 256. This is the size in KB. My unit uses up to 32 KB DMA-Buffer,
so you should the the size to at least 32 KB! If this doesn't help,
try to add a simple "RAM" to that line.

If you run this program under Windows 95 in compatible(16 bit) Harddisk
mode, it maybe won't run fully.

There's a variable called surround. If you set it to true, and you play in
stereo, you'll get surround sound. Maybe you think it sounds not very good.
That's a thing that you have to decide youyrself. Well, write me if you think,
that this advancement is not very good, or you know how to improve it. It's
also better to use surround only on amplifiers which support surround sound -
I tested this out - it sounds better with those amplifiers.

How to get now surround sound with your equipment? Well, I have found a
little manual in the readme of the Cubic Player how to manage that:

 This sounds pretty nice if you have a stereo non-wavetable soundcard.
 Just buy 1,2 or 3 additional speakers and connect them as showed below:

                + L -           - R +
               +-+ +-+         +-+ +-+
               +-+ +-+         +-+ +-+
                I   I           I   I
                I   I           I   I
           +----+   +-----+-----+   +-----+
           I    I         I         I     I
           I    I         I         I     I
           I    I         -         I     I
           I    I     M-Speaker     I     I
           I    I         +         I     I
           I    I         I         I     I
           I    +   - ----+---- -   +     I
           I  L-Speaker        R-Speaker  I
           I                              I
           I                              I
           +---+  +-------------+  +------+
               I  I             I  I
               +  -             -  +
             S1-Speaker      S2-Speaker

       Thanks to Michael Erdmann for this diagram.
       (we cannot be made liable for burning equipment, etc.)

I've tried it... it sounds pretty good!

To my person:
My name is Stefan Ghler
-I'm 21 years old
-I'm living in Germany near Rostock
-I'm 1.73 m tall
-My shoe size is 42 
-.... :->

Have fun with my unit! If there's anything that I don't know about it
(I mean bugs or additions from you), please email me.

Stefan Ghler


Send a mail About this site