home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sound Sensations!
/
sound_sensations.iso
/
soundb
/
tpsbk100
/
tpsbk.doc
< prev
Wrap
Text File
|
1991-07-29
|
54KB
|
1,485 lines
Turbo Pascal SoundBlaster Toolkit Version 1.00
TPSBK(tm)
User's Manual
Copyright(C) 1991 by
Trevor Robinson
All Rights Reserved
Trevor Robinson
5201 Teakwood Trace
Midland, TX. 79707
Written using Turbo Pascal v6.0
TPSBK v1.00 License i
L I C E N S E
______________________________________________________________________
CAREFULLY READ THE FOLLOWING TERMS AND CONDITIONS. IF YOU DO NOT
AGREE WITH THEM, YOU SHOULD PROMPTLY DELETE THE ENTIRE TOOLKIT.
USING THIS SOFTWARE INDICATES YOUR ACCEPTANCE OF THE AGREEMENT.
The Turbo Pascal SoundBlaster ToolKit (TPSBK) is not Public Domain and
it is not free. It is Copyright(c) 1991 by Trevor Robinson. All
rights are reserved.
Brand and product names mentioned are trademarks or registered trade-
marks of their respective holders.
Non-registered users of this program are granted a limited three-week
license to TPSBK to evaluate the programs suitability for their
requirements. Any usage of TPSBK beyond evaluation time period
requires registration of each copy of the program used. Use of non-
registered copies of TPSBK beyond the original evaluation period is
prohibited.
TPSBK may NOT be modified in any respect, for any reason, including
but not limited to, de-compiling, disassembling, or reverse
engineering of the program. The registration screen and all other
proprietary program output must never be altered, removed, bypassed or
modified by any means.
You are free to distribute the PUBLICLY AVAILABLE shareware version of
TPSBK to others subject to the above restrictions and also the
following:
A. No fee is charged for its use.
B. No re-numeration may be accepted for TPSBK. This does not
apply to computer access charges the system operators (Sysops)
of or organizations owning bulletin board systems, online
services, etc... may charge subscribers.
C. TPSBK must be copied in unaltered form, complete with files
containing license information, the FULL documentation and all
accompanying files. The archive distributed by me must not be
altered in ANY respect.
D. All shareware houses/distribution firms must make explicitly
clear that the diskette purchase containing any shareware
program has NOT registered the shareware with me.
System Operators may make TPSBK available for download only if the
above conditions are met. The archive (TPSBK100.ZIP) distributed by
me or an equivalent archive may be made available only in complete
form. Refer to section FILE LISTING to verify complete package
contents. If the contents appear altered or not complete, you may
obtain the latest release of TPSBK directly from me by sending a
formatted diskette labeled with the word "TPSBK". Please include $5
for handling.
TPSBK v1.00 License ii
Commercial distributors of "Public Domain", "Shareware", and/or User
Supported software may distribute TPSBK subject to the above
conditions only after obtaining WRITTEN permission from me. This
condition statement supersedes all previous agreements.
Please refer to the section entitled registration/ordering section for
additional information on registration.
______________________________________________________________________
The above license statement does not apply to the REGISTERED version
of TPSBK. The registered software is protected under United States
Copyright. It must be treated just like a book with certain exceptions
as follows:
A. I authorize the making of archival copies of the registered software
for the sole purpose of backing-up your software and protecting your
investment from possible loss.
B. The medium on which the registered software is recorded is
transferred to the customer, but not the title to the software.
C. The customer may resell or distribute unmodified copies of the
registered software provided the customer has purchased from me one
copy of the registered software for each one sold or distributed.
The provisions of this software license shall also be applicable to
third parties receiving copies of the registered software from the
customer.
D. You may transfer this software and license to another party if the
other party agrees to accept the terms and conditions of this
license, and you either transfer or destroy all copies in your
possession whether in printed or machine- readable form. This
includes all portions of the software contained or merged into
other programs.
E. By saying, "just like a book", I mean that the registered software
may be used by any number of people and may be freely moved from one
computer location to another so long as there is ABSOLUTELY NO
POSSIBILITY of it being used at one location while being used at
another. Just like a book that cannot be read by two different
people in two different locations at the same time.
F. You may include this software in your applications and distribute
them at your discretion. You may not distribute any portion(s) of
software that are not integrated into your application.
G. You may NOT include this software in programs that are toolkits!
This license is effective until terminated. You may terminate it at
any time by destroying the software together with all copies, modifi-
cations and merged portions in any form. The license also terminates
if you fail to comply with the terms and conditions of the agreement.
TPSBK v1.00 License iii
O R D E R I N G I N F O R M A T I O N
______________________________________________________________________
Once a registered user of TPSBK, you are free to utilize the program
as often as you wish. Other than having a clear conscience, there are
many advantages to registered. You will receive in the mail a
registered version of TPSBK with the registration screen and delay
removed, a printed copy of the documentation, and you will also be
notified in the mail when significant enhancements have been made to
the program. Once registered, all upgrades are available for a $5
upgrade fee plus the original TPSBK diskette (see below).
For $15 dollars plus an additional $5 for shipping/handling, I will
send you the latest shareware and registered versions of TPSBK on disk
along with the printed documentation.
If unsure, you can receive the latest shareware version of TPSBK for
evaluation by sending a formatted diskette plus $5 for handling.
Please use the following form or print the included file "MAILER" when
placing an order.
Non-U.S. residents : I can only accept U.S. currency. Also add $5 to
cover overseas shipping/handling.
U P G R A D I N G T O L A T E S T T P S B K
______________________________________________________________________
Users who have registered (and received a diskette) may upgrade to the
latest version of TPSBK by sending in their TPSBK ORIGINAL DISK, along
with $5 (service and handling). Please use the following order form
when upgrading. If there has been an address change, please indicate
so on the order form.
The original disk must be returned and contain the registered version
of TPSBK. The disk will be reformatted and the current Master copied
onto it. Any disk in poor condition will be replaced by me. If the
serial number label is missing or the diskette does not contain the
registered version of TPSBK, the update will be refused and the
diskette returned unchanged.
TPSBK v1.00 Ordering iv
O R D E R F O R M
______________________________________________________________________
Please Remit To: Trevor Robinson
5201 Teakwood Trace
Midland, TX. 79707
Qty. Description Each Total
____ TPSBK Upgrade to new version $5.00 ________
(When available)
(You must return your original diskette
containing your copy of the registered
version of TPSBK)
____ TPSBK Evaluation Copy $5.00 ________
(You supply diskette, no registration)
____ TPSBK Registration with diskette $20.00 ________
(Registration including diskette with the
latest shareware and registered program
versions along with printed manual)
Subtotal ________
(Foreign orders add $5 shipping & handling) Shipping ________
(TX residents please add 7.75% sales tax) Tax ________
TOTAL $________
Name: ________________________________________________________
Company: ________________________________________________________
Address: ________________________________________________________
________________________________________________________
________________________________________________________
Check one: [] 5 1/4 in. disks [] 3 1/2 in. disks
Check one: [] Turbo Pascal 5.5 [] Turbo Pascal 6.0
All checks must be drawn on U.S. Funds in U.S. Dollars. Sorry, no
C.O.D. orders will be accepted.
TPSBK v1.00 Warranty v
W A R R A N T Y
______________________________________________________________________
TPSBK is provided AS IS without any warranty, expressed or implied.
This includes without limitation the fitfulness to a particular
purpose or application, that software operation will be uninterrupted
or error free, and any warranties of merchantability.
While I have tried to be as through as possible while debugging TPSBK,
I shall not be liable for any damages, whether direct, indirect,
special, or consequential arising from a failure of this program or
accompanying files to operate in a manner desired by the user. I
shall not be liable for any damage to data or property which may have
caused directly or indirectly by use of this program.
In no event will I be liable to you for any damages, including any
lost profits, lost savings or other incidental or consequential
damages arising out of your use or inability to use the program, or
for any claim by any other party.
______________________________________________________________________
If you have a problem with TPSBK please feel free to write and
describe the situation. Registered users, please include the serial
number found on your diskette.
To those people who have registered (with diskette), the physical
diskette is warranted against defects in materials and workmanship for
a period of 60 days from date of shipment by me. Any returned disks
found damaged or bad will be replaced at no charge.
TPSBK v1.00 Table Of Contents vii
T A B L E O F C O N T E N T S
______________________________________________________________________
License
Single User License ....................................... i
Giving out Copies ......................................... i
System Operators (Sysops) Info ............................ i
Software Distributors - Read this ......................... ii
Registered Version License Agreement ...................... ii
Ordering Information
Registration .............................................. iii
Upgrading to latest TPSBK .............................. iii
Registration (diskette sent out) ....................... iii
Getting a Trial Copy ................................... iii
Invoice Order Form ........................................ iv
Warranty ..................................................... v
Introduction ................................................. 1
System Information ........................................... 2
File Listing ................................................. 3
TPSBK SoundBlaster Driver .................................... 4
TPSBK SoundBlaster BASIC Players ............................ 12
TPSBK SoundBlaster PianoMan Players ......................... 16
TPSBK SoundBlaster MultiPart Player ......................... 17
TPSBK SoundBlaster CMF Player ............................... 18
TPSBK Demo Files ............................................ 21
TPSBK Music Conversion Programs ............................. 22
Appendix A: Programmers Programming Tips .................... A
Appendix B: Common Questions and Answers .................... B
Appendix C: Revision History ................................ C
Appendix D: Future Enhancements ............................. D
TPSBK v1.00 Introduction 1
I N T R O D U C T I O N
______________________________________________________________________
The Turbo Pascal SoundBlaster Toolkit (TPSBK), is, as far as I know,
the only SoundBlaster toolkit for Turbo Pascal. It contains many
routines to access the SoundBlaster. Most don't need any kind of
special driver. Included in this version are routines to play Creat-
ive Music Files, great music files that don't waste a lot of disk
space. There are routines to play music files containing the data
for the BASIC PLAY verb. They aren't the best sounding files but
there are many of them available and even simple music can sound good
on the SoundBlaster. Routines for playing PianoMan music files are
also included. If you haven't seen PianoMan, check your local BBSes.
It is a great shareware music composer by Neil Rubenking. There are
many of these files around too. One of the best things about this
toolkit is that it can play all of the mentioned files in the back-
ground... Requiring no attention from you. It can also play multiple
part PianoMan files, such as ENTRTAN*.MUS. These files are included
in this archive and the PianoMan archive. It plays notes from each
file individually on different channels, producing quality music.
Still, the most powerful tool is the ability to play single notes.
You can use single notes to play any file format. They can be used
to make music composers. You can also load custom instruments.
Unfortunately, because the is the first version, and the SoundBlaster
is very difficult to program, the full capabilities of the Sound-
Blaster aren't available. Mainly playing of voice files. I must
write a new driver to be able to play files from the disk. There
just isn't enough memory to play most voice files. Hopefully all of
the features listed in the Future Enhancements Section, (Appendix D),
will be available by version 2 or 3. But the amount of work I'm able
to do depends on the response from you, the user.
TPSBK v1.00 System Information 2
S Y S T E M R E Q U I R E M E N T S
______________________________________________________________________
TPSBK requires an IBM PC/XT/AT or close compatible running MS-DOS 2.0
or higher. A hard drive is recommended although it is not required.
A Creative Lab's SoundBlaster card is also required needless to say.
I N S T A L L A T I O N
______________________________________________________________________
If you are installing on a hard disk, copy the archive (TPSBK100.ZIP)
to your Turbo Pascal directory.
COPY TPSBK100.ZIP C:\TP6
You must have PKUNZIP either in your Turbo Pascal directory or in a
directory in you PATH variable. Type:
PKUNZIP TPSBK100
If you have a self-extracting archive (TPSBK100.EXE), after copying
the file to the proper directory, just type:
TPSBK100
If you are installing on a floppy follow the same steps after copying
the file to your work disk.
Now your ready. To get an understanding of the toolkit, read on and
experiment with the demonstration files.
TPSBK v1.00 File Listing 3
F I L E L I S T I N G
______________________________________________________________________
The following briefly lists those files included with the shareware
version of TPSBK:
MAILER.TXT Prints out a registration form on your printer that
can be folded and mailed directly.
SBDRIVE.TPU Main program that contains all basic SoundBlaster
instrument and note playing commands.
SBBASIC.TPU Unit to play files containing data similar to that
used by the BASIC PLAY verb.
SBBKBAS.TPU Same as SBBASIC but capable of playing in background.
SBBKMUZ.TPU Unit to play PianoMan 4 files in background.
SBOPIANO.TPU Unit to play PianoMan files earlier than 4 in fore-
ground.
SBNPIANO.TPU Unit to play PianoMan 4 files in foreground.
SBOMULTI.TPU Unit to play up to 9 PianoMan files at the same time
to produce up to 9-part harmonies. Earlier than 4.
SBCMF.TPU Unit to play Creative Music Files in background.
SBDEMO.PAS Program to demonstrate all functions except back-
ground playing.
MUSICDOS.PAS Program to demonstrate background playing.
SBCMFDEM.PAS Program to demonstrate playing of CMF files.
MUS2MUZ.EXE Converts old PianoMan files to PianoMan 4 files.
MUZ2MUS.EXE Converts BASIC PLAY file to old PianoMan files.
SBDEMO.EXE Compiled TPSBK demonstration.
MUSICDOS.EXE Compiled Musical DOS (SBBKMUZ demonstration).
SBCMFDEM.EXE Compiled CMF player.
SOLFE.MUZ BASIC music file: Solfeggietto
CMINOR.MUS Old PianoMan music file: C Minor
DIXIE.MUZ New PianoMan music file: Dixie
ENTRTAN*.MUS Old PianoMan multipart files: The Entertainer
PAKLBEL*.MUS Old PianoMan multipart files: PAKLBEL
BADMAN.CMF Awesome Creative Music File
TPSBK v1.00 TPSBK SoundBlaster Driver 4
S O U N D B L A S T E R D R I V E R
______________________________________________________________________
INTERFACE SECTION FOR SBDRIVE.TPU :
{Turbo Pascal SoundBlaster Driver by Trevor Robinson
Copyright (c) 1991, Trevor Robinson
Unit SBDrive;
Interface
Uses
CRT;
Type
InstType = Array [0..15] Of Byte;
Const
SBDVersion = $0100;
Var
SBIOAddr : Word;
Function FindIOAddr : Word;
{ Searches ports $220 - $260 for SoundBlaster card. Returns 0 if not
installed. This routine sets SBIOAddr at startup time.
NOTE: To be compatible with AdLib cards, these FM music routines use
ports $388 and $389. If FindIOAddr returns 0, an AdLib card may still
be installed.
}
Function StatusRegister : Byte;
{ Returns the FM status register:
┌──────────────────────────────────────────────────────────────────┐
│ D7 D6 D5 D4 D3 D2 D1 D0 │
├────────┬───────────────┬─────────────────────────────────────────┤
│ IRQ │ FLAG │ │
│ │ T1 │ T2 │ │
└────────┴───────┴───────┴─────────────────────────────────────────┘
}
Procedure InitCard;
{ This must be called to initialize the FM synthesizer chips. }
Procedure SetTimer1(Count : Byte);
{ Timer1 is an 8 bit presettable counter. It has a resolution of 80usec.
Count is the preset value to be loaded into the counter. If an overflow
occurs, the Timer1 flag in the status register is set, and the preset
value is reloaded into the counter. In addition to normal timer func-
tions, Timer1 is also used for control of composite speech synthesis. }
Procedure SetTimer2(Count : Byte);
{ Timer2 is similar to Timer1 except that its resolution is 320usec. }
TPSBK v1.00 TPSBK SoundBlaster Driver 5
Procedure TimerControl(Control : Byte);
{ This procedure is used to start, stop and control flags of the timers.
┌──────────────────────────────────────────────────────────────────┐
│ D7 D6 D5 D4 D3 D2 D1 D0 │
├────────┬───────────────┬───────────────────────┬─────────────────┤
│ IRQ │ MASK │ │ START/STOP │
│ RST │ T1 │ T2 │ │ T1 │ T2 │
└────────┴───────┴───────┴───────────────────────┴───────┴─────────┘
D0 (Start/Stop Timer1)
When this bit is 1, the preset value is loaded into Timer1 and
counting starts. When this bit is 0, Timer1 does not operate.
D1 (Start/Stop Timer2)
Performs the same function as D0 for Timer2.
D5 (Mask Timer2)
When this bit is 1, the flag for Timer2 in the status register is
masked (always 0).
D6 (Mask Timer1)
Bit mask flag for Timer1.
D7 (IRQ-RESET)
When set to 1, the IRQ and Timer flags in the status register are
reset to 0. This bit then resets itself to 0. }
Procedure CSMMode_KbdSplit(MKS : Byte);
{ This procedure causes the synthesizer to operate in music mode or speech
synthesis mode and determines the keyboard split for keyboard scaling of
rate.
┌──────────────────────────────────────────────────────────────────┐
│ D7 D6 D5 D4 D3 D2 D1 D0 │
├────────┬───────┬─────────────────────────────────────────────────┤
│ CSM │ SEL │ │
└────────┴───────┴─────────────────────────────────────────────────┘
D6 (NOTE SELECT)
This bit controls the split point of the keyboard. When 0, the key-
board split is the second bit from the most significant bit of the
F-Number. The MSB of the F-Number is used when 1.
NOTE SELECT = 0
┌────────────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┐
│ OCTAVE │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │
├────────────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤
│ BLOCK DATA │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │
├────────────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤
│ F-NUMBER 9 │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │ 1 │
├────────────┼───┬───┼───┬───┼───┬───┼───┬───┼───┬───┼───┬───┼───┬───┼───┬───┤
│ F-NUMBER 8 │ 0 │ 1 │ 0 │ 1 │ 0 │ 1 │ 0 │ 1 │ 0 │ 1 │ 0 │ 1 │ 0 │ 1 │ 0 │ 1 │
├────────────┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
│ SPLIT NUM │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │10 │11 │12 │13 │14 │15 │
└────────────┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
TPSBK v1.00 TPSBK SoundBlaster Driver 6
NOTE SELECT = 1
┌────────────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┐
│ OCTAVE │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │
├────────────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤
│ BLOCK DATA │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │
├────────────┼───┬───┼───┬───┼───┬───┼───┬───┼───┬───┼───┬───┼───┬───┼───┬───┤
│ F-NUMBER 9 │ 0 │ 1 │ 0 │ 1 │ 0 │ 1 │ 0 │ 1 │ 0 │ 1 │ 0 │ 1 │ 0 │ 1 │ 0 │ 1 │
├────────────┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
│ SPLIT NUM │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │10 │11 │12 │13 │14 │15 │
└────────────┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
D7 (CSM)
The composite sine wave speech synthesis mode is selected when 1. All
channels must be off when this mode is selected. }
Procedure AM_VIB_EG_KSR_Multiple(InstNum, Modulator, Carrier : Byte);
{ This procedure controls several parameters affecting the timbre of the
output signal.
┌──────────────────────────────────────────────────────────────────┐
│ D7 D6 D5 D4 D3 D2 D1 D0 │
├────────┬───────┬───────┬───────┬─────────────────────────────────┤
│ AM │ VIB │ EG │ KSR │ MULTIPLE │
└────────┴───────┴───────┴───────┴─────────────────────────────────┘
D0-D3 (MULTIPLE)
The basic FM equation with the multiplication factor included is:
F(t) = A sin (Mc Wc t + I sin (Mm Wm t))
where A is the output amplitude
I is the modulation index (amplitude of Modulator)
Wc is the carrier frequency
Wm is the modulator frequency
Mc is the multiplication factor for Carrier cell
Mm is the multiplication factor for Modulator cell
The relationship between MULTIPLE and multiplication factor is:
┌──────────┬────────────────┐ ┌──────────┬────────────────┐
│ MULTIPLE │ MULTIPLICATION │ │ MULTIPLE │ MULTIPLICATION │
│ │ FACTOR │ │ │ FACTOR │
├──────────┼────────────────┤ ├──────────┼────────────────┤
│ 0 │ 0.5 │ │ 8 │ 8 │
│ 1 │ 1 │ │ 9 │ 9 │
│ 2 │ 2 │ │ A │ 10 │
│ 3 │ 3 │ │ B │ 10 │
│ 4 │ 4 │ │ C │ 12 │
│ 5 │ 5 │ │ D │ 12 │
│ 6 │ 6 │ │ E │ 15 │
│ 7 │ 7 │ │ F │ 15 │
└──────────┴────────────────┘ └──────────┴────────────────┘
TPSBK v1.00 TPSBK SoundBlaster Driver 7
D4 (KEY SCALING RATE)
When this bit is set to 1, the envelope length is gradually shortened
as higher notes on the keyboard are played.
D5 (ENVELOPE TYPE)
A diminishing sound is selected when this bit is 0 and a continuous
sound when it is 1.
D6 (VIBRATO)
Setting this bit to 1 cause a vibrato effect to be applied to the
operator cell.
D7 (AMPLITUDE MODULATION)
Setting this bit to 1 causes tremolo to be applied to operator cell. }
Procedure KSL_TotalLevel(InstNum, Modulator, Carrier : Byte);
{ This procedure controls the attenuation of the operator cells' output
signal.
┌──────────────────────────────────────────────────────────────────┐
│ D7 D6 D5 D4 D3 D2 D1 D0 │
├────────────────┬─────────────────────────────────────────────────┤
│ KSL │ TOTAL LEVEL │
└────────────────┴─────────────────────────────────────────────────┘
D0-D5 (TOTAL LEVEL)
The TOTAL LEVEL attenuates the operator's output. Varying the output
level of an operator functioning as a carrier results in a change in
the overall level of the sound contributed to the voice by that operator.
This is how the volume changes. Attenuating the output from a modulator
will change the frequency spectrum produces by the carrier. TOTAL LEVEL
has a range of 0 to 63. Maximum attenuation is 47.25 dB. Degree of
attenuation is given be the following formula.
Attenuation = TOTAL LEVEL * 0.75 dB
D6-D7 (KEYBOARD SCALING LEVEL)
The KSL produces a gradual decrease in note output level towards higher
pitch notes. The degree of attenuation is controlled as follows:
┌────┬────┬───────────────────────┐
│ D7 │ D6 │ Degree of Attenuation │
├────┼────┼───────────────────────┤
│ 0 │ 0 │ 0 │
│ 1 │ 0 │ 1.5dB/OCT │
│ 0 │ 1 │ 3dB/OCT │
│ 1 │ 1 │ 6dB/OCT │
└────┴────┴───────────────────────┘
}
TPSBK v1.00 TPSBK SoundBlaster Driver 8
Procedure Attack_Decay(InstNum, Modulator, Carrier : Byte);
{ The ATTACK RATE is the rising time for the sound. The DECAY RATE is the
diminishing time after the attack. These rates range from 0 to 15.
┌──────────────────────────────────────────────────────────────────┐
│ D7 D6 D5 D4 D3 D2 D1 D0 │
├────────────────────────────────┬─────────────────────────────────┤
│ ATTACK RATE │ DECAY RATE │
│ 2^3 2^2 2^1 2^0 │ 2^3 2^2 2^1 2^0 │
└────────────────────────────────┴─────────────────────────────────┘
}
Procedure Sustain_Release(InstNum, Modulator, Carrier : Byte);
{ For continuing sounds, the SUSTAIN LEVEL gives the point of change where
the attenuated sound in the decay mode changes to a sound having a con-
stant level. For diminishing sounds, the sustain level gives the point
where the decay mode changes to the release mode.
For continuing sounds, the RELEASE RATE defines the rate at which the
sound disappears after the notes is turned off. For diminishing sounds,
release rate indicates the attenuation after the sustain level is reached.
┌──────────────────────────────────────────────────────────────────┐
│ D7 D6 D5 D4 D3 D2 D1 D0 │
├────────────────────────────────┬─────────────────────────────────┤
│ SUSTAIN LEVEL │ RELEASE RATE │
│ 24dB 12dB 6dB 3dB │ 2^3 2^2 2^1 2^0 │
└────────────────────────────────┴─────────────────────────────────┘
}
Procedure Block_FNum(InstNum, Modulator, Carrier : Byte);
{ This procedure determines the octave and frequency of the output signal.
┌──────────────────────────────────────────────────────────────────┐
│ D7 D6 D5 D4 D3 D2 D1 D0 │
├──────────────────────────────────────────────────────────────────┤
│ F-NUMBER (L) │
├────────────────┬───────┬───────────────────────┬─────────────────┤
│ │ KEYON │ BLOCK │ F-NUMBER (H) │
└────────────────┴───────┴───────────────────────┴─────────────────┘
D0-D7 (F-NUMBER L) & D0-D1 (F-NUMBER H)
The F-Number is a 10 bit number that determines the frequency of the
output signal.
D2-D4 (BLOCK)
These 3 buts determine the octave of the output signal.
D5 (KEYON)
When this be is 1, the channels is ON and voiced. When 0, the channel
is OFF.
The relationship among F-NUMBER, BLOCK and output frequency is as follows:
FREQUENCY = 50000 * F-NUMBER * 2^BLOCK-20
TPSBK v1.00 TPSBK SoundBlaster Driver 9
FREQUENCY FOR BLOCK 4
┌──────┬───────────┬──────────┬────────┬────────────────────────────────┐
│ │ │ │ FNUM H │ F-NUMBER L │
│ NOTE │ FREQUENCY │ F-NUMBER ├────────┼────────────────────────────────┤
│ │ │ │ D1 D0 │ D7 D6 D5 D4 D3 D2 D1 D0 │
├──────┼───────────┼──────────┼────────┼────────────────────────────────┤
│ C# │ 277.2 │ 363 │ 0 1 │ 0 1 1 0 1 0 1 1 │
│ D │ 293.7 │ 385 │ 0 1 │ 1 0 0 0 0 0 0 1 │
│ D# │ 311.1 │ 408 │ 0 1 │ 1 0 0 1 1 0 0 0 │
│ E │ 329.6 │ 432 │ 0 1 │ 1 0 1 1 0 0 0 0 │
│ F │ 349.2 │ 458 │ 0 1 │ 1 1 0 0 1 0 1 0 │
│ F# │ 370.0 │ 485 │ 0 1 │ 1 1 1 0 0 1 0 1 │
│ G │ 392.0 │ 514 │ 1 0 │ 0 0 0 0 0 0 1 0 │
│ G# │ 415.3 │ 544 │ 1 0 │ 0 0 1 0 0 0 0 0 │
│ A │ 440.0 │ 577 │ 1 0 │ 0 1 0 0 0 0 0 1 │
│ A# │ 466.2 │ 611 │ 1 0 │ 0 1 1 0 0 0 1 1 │
│ B │ 493.9 │ 647 │ 1 0 │ 1 0 0 0 0 1 1 1 │
│ C │ 523.3 │ 686 │ 1 0 │ 1 0 1 0 1 1 1 0 │
└──────┴───────────┴──────────┴────────┴────────────────────────────────┘
}
Procedure AMVIBDepth_Rhythm(RegData : Byte);
{ This allows for control of amplitude modulation and vibrato depth, selec-
tion of rhythm mode, and ON/OFF control of various rhythm instruments.
┌──────────────────────────────────────────────────────────────────┐
│ D7 D6 D5 D4 D3 D2 D1 D0 │
├────────────────┬───────┬───────┬───────┬───────┬───────┬─────────┤
│ DEPTH │ RHY- │ BASS │ SNARE │ TOM │ TOP │ HI │
│ AM │ VIB │ THM │ DRUM │ DRUM │ TOM │ CYM │ HAT │
└────────┴───────┴───────┴───────┴───────┴───────┴───────┴─────────┘
D0-D5 (RHYTHM)
The synthesizer is set to rhythm sound mode when D5 is 1. D0-D4 allow
for ON/OFF control of the various rhythm instruments. The last 3 FM
channels must be off. Slots 13-18 correspond to the rhythm sound shown
below. Data such as rate must be input as a value appropriate to each
rhythm sound.
┌───────────────────────┬───────────────┐
│ PERCUSSION INSTRUMENT │ OPERATOR CELL │
├───────────────────────┼───────────────┤
│ Bass Drum │ 13,16 │
│ Hi Hat │ 14 │
│ Tom Tom │ 15 │
│ Snare Drum │ 17 │
│ Top Cymbal │ 18 │
└───────────────────────┴───────────────┘
D6 (VIB DEPTH)
The vibrato depth is 14 cent when 1, 7 cent when 0.
D7 (AM DEPTH)
The tremolo depth is 4.8dB when 1, 1dB when 0.
}
TPSBK v1.00 TPSBK SoundBlaster Driver 10
Procedure WaveSelect(InstNum, Modulator, Carrier : Byte);
{ When Wave Select is on, the output sine wave is distorted as shown below.
┌──────────────────────────────────────────────────────────────────┐
│ D7 D6 D5 D4 D3 D2 D1 D0 │
├────────────────────────────────────────────────┬─────────────────┤
│ │ WAVE SEL │
└────────────────────────────────────────────────┴─────────────────┘
┌────┬────┬──────────────┐
│ D1 │ D0 │ Waveform │
├────┼────┼──────────────┤
│ │ │ ┌──┐ │
│ │ │ ┌┘ └┐ │
│ 0 │ 0 │ └────┼────┐ │
│ │ │ └┐ ┌┘ │
│ │ │ └──┘ │
│ │ │ ┌──┐ │
│ 0 │ 1 │ ┌┘ └┐ │
│ │ │ └────┴───── │
│ │ │ ┌──┐ ┌──┐ │
│ 1 │ 0 │ ┌┘ └┐┌┘ └┐ │
│ │ │ └────┴┴────┘ │
│ │ │ ┌─┐ ┌─┐ │
│ 1 │ 1 │ ┌┘ │ ┌┘ │ │
│ │ │ └──┴──┴──┴─ │
└────┴────┴──────────────┘
}
Procedure FeedBack_Connect(InstNum, RegData : Byte);
{ This procedure determines the modulation factor for self-feedback and
the type of FM modulation.
┌──────────────────────────────────────────────────────────────────┐
│ D7 D6 D5 D4 D3 D2 D1 D0 │
├────────────────────────────────┬───────────────────────┬─────────┤
│ │ FEEDBACK │ CON │
└────────────────────────────────┴───────────────────────┴─────────┘
D0 (CONNECTION)
Connection controls the manner in which the two operator cells are
connected. The FM modulation mode is selected when this bit is 0.
The two operator cells are connected in parallel for sine wave output
in the composite mode when this bit is 1.
D1-D3 (FEEDBACK)
Gives the modulation factor for feedback FM modulation of the first
operator cell.
┌────────────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┐
│ FEEDBACK │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │
├────────────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤
│ MODULATION │ │ │ │ │ │ │ │ │
│ FACTOR │ 0 │ II/16 │ II/8 │ II/4 │ II/2 │ II │ 2II │ 4II │
└────────────┴───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────┘
}
TPSBK v1.00 TPSBK SoundBlaster Driver 11
{ High-Level Procedures }
Procedure LoadInstrument(Inst : Byte; InstData : InstType);
{ This procedure loads an instrument of InstType into the FM synthesizer.
The instrument data starts at offset $24 of an SBI file.
}
Procedure NoteOn(Inst, Oct, Note : Byte);
{ The procedure plays a note (1-12) in an octave (0-7) on channel (1-9).
Note 1 is C#.
}
Procedure NoteOff(Inst, Oct, Note : Byte);
{ The procedure stops a note (1-12) in an octave (0-7) on channel (1-9).
(In this version, octave and note are ignored.)
}
Implementation
End.
TPSBK v1.00 TPSBK Basic Players 12
B A S I C P L A Y E R S
______________________________________________________________________
INTERFACE SECTION FOR SBBKBAS.TPU :
{Turbo Pascal SoundBlaster Basic Music Player by Trevor Robinson
Copyright (c) 1991, Trevor Robinson}
Unit SBBKBAS;
Interface
Uses DOS, CRT, SBDrive;
Type Song = Procedure;
SongAction = (EndRepeatSong,RepeatSong,ResumeSong,StopSong,SuspendSong);
Var
BasicAborted,
BasicCheckAbort : Boolean;
Function BasicBackInit: boolean;
{ This returns true if the background buffer has been
allocated. This function must be called before any other. }
Procedure BasicShutdownBack;
{ This procedure deallocates memory used by the background
buffer. BackgroundInit must be called to play music again. }
Procedure BasicPlay (TuneString:String);
{ The BasicPlay procedure uses a string very similar to that used with the
PLAY verb in BASIC. If the background buffer has not been installed,
BasicPlay will ignore the command to play music in the background (MB). }
Function PlayBasicFile(Filename : String) : Boolean;
{ The PlayBasicFile function takes the name of a text file containing
lines of BASIC PLAY data. It returns False if the file could not be
found or opened. }
Function BasicPlayingInBack: Boolean;
{ BasicPlayingInBack return True if music is playing in the background,
False otherwise. }
Procedure BasicPlayingMode(Action: SongAction);
{ BasicPlayingMode accepts one of these verbs:
EndRepeatSong Stop when finished
RepeatSong Repeat when finished
ResumeSong Continue music
StopSong Stop music in buffer immediately
SuspendSong Pause music }
TPSBK v1.00 TPSBK Basic Players 13
Procedure BasicPlayANote(Oct,Note: Byte; Duration,Pause: Integer);
{ BasicPlayANote puts a note into the background music buffer and starts
playing. Oct is an octave (0-7). Note is a note (1-13). Duration is
the length of the note in milliseconds (1-32767). Pause is the wait
after the note in milliseconds (1-32767). Its is used for staccato.
NOTE VALUES:
1) C# 2) D 3) D# 4) E 5) F 6) F# 7) G
8) G# 9) A 10) A# 11) B 12) C 13) Rest }
Implementation
End.
INTERFACE SECTION FOR SBBASIC.TPU :
{Turbo Pascal SoundBlaster Basic Music Player by Trevor Robinson
Copyright (c) 1991, Trevor Robinson
Unit SBBasic;
Interface
Uses CRT, SBDrive;
Var
BasicAborted,
BasicCheckAbort : Boolean;
Procedure BasicPlay (TuneString:String);
{ The BasicPlay procedure uses a string very similar to that used with the
PLAY verb in BASIC. }
Function PlayBasicFile(Filename : String) : Boolean;
{ The PlayBasicFile function takes the name of a text file containing
lines of BASIC PLAY data. It returns False if the file could not be
found or opened. }
Implementation
End.
TPSBK v1.00 TPSBK Basic Players 14
If BasicCheckAbort is True, the unit will check for Escape, Control-
Break, and Control-C keys. BasicPlay will abort and set BasicAbort to
True. If music is playing in the background, you must trap these keys
and call PlayingMode(StopSong).
The string characters are interpreted as follows:
A .. G The musical notes A thru G. A note may be followed
by an accidental ('#' or '+' for sharp and '-' for
flat.) Additionally, a note (With optional sharp or
flat) may also be followed by a number denoting the
note length (1 for a whole note thru 64 for a 64th
note.) The note, with optional accidental and
length, may also be followed by one or more dots
("."), each of which extends the note by one half
of its existing value. For example, two dots produce
a length of 9/4 the original value, and three dots
a length of 27/8 the original value.
Ln Specifies the default length of the notes following
("n" must be 1 for a whole note thru 64 for a 64th
note.) The initial default value is 4 (quarter note.)
Mz Specifies the fraction of the note length that the
note is actually sounding. "z" is one of the letters
"S", "N", or "L", which have these meanings:
MS Music staccato (3/4 of note length)
MN Music normal (7/8 of note length)
ML Music legato (all of note length)
If SBBKBAS is being used, "z" can also be "F" or "B".
MF Music foreground (normal note length)
MB Music background (normal note length)
On Specifies the octave in which the notes following
are to be played (0 thru 7). The initial default
octave is 3, which is the octave which begins at
middle C.
Pn Specifies that no sound is to be made for an
interval. "n" (optional) is the note length (1
for a whole note thru 64 for a 64th note.) If "n"
is omitted, the current default note length is used.
One or more dots may follow, each of which extends
the rest by one half of its existing value.
TPSBK v1.00 TPSBK PianoMan Players 15
Tn Specifies the tempo in beats per minute (32 thru
255.) The initial default value is 120.
> Increases notes one octave.
< Decreases notes one octave.
NOTE: You must use either SBBASIC or SBBKMUZ, NOT BOTH! They have the
same procedure and variable names and will get confused. SBBASIC is
only included for programs that don't need background playing and
don't want the extra size.
TPSBK v1.00 TPSBK PianoMan Players 16
P I A N O M A N P L A Y E R S
______________________________________________________________________
INTERFACE SECTION FOR SBOPIANO.TPU :
{Turbo Pascal SoundBlaster PianoMan Player by Trevor Robinson
Copyright (c) 1991, Trevor Robinson}
Unit SBOPiano;
Interface
Uses CRT,SBDrive;
Var
OldPianoCheckAbort : Boolean;
Function PlayOldPiano(Filename : String) : Boolean;
Implementation
End.
The function and variable names are the same in SBNPiano except the
every "Old" is replace with a "New". (PlayOldPiano is PlayNewPiano).
If OldPianoCheckAbort is True, the unit aborts when a key is pressed.
TPSBK v1.00 TPSBK MultiPart Player 17
M U L T I P A R T P L A Y E R
______________________________________________________________________
INTERFACE SECTION FOR SBOMULTI.TPU :
{Turbo Pascal SoundBlaster Multi-Part PianoMan Player by Trevor Robinson
Copyright (c) 1991, Trevor Robinson}
Unit SBOMulti;
Interface
Uses CRT,SBDrive;
Var
OldMultiCheckAbort : Boolean;
Procedure OldAddFile(Filename : String);
{ Adds a file name to the Multiple Play List. }
Procedure OldClearList;
{ Clears the Multiple Play List }
Function PlayOldMulti : Boolean;
{ Plays files contained in the Multiple Play List. Return true if
successful. }
Implementation
End.
If OldMultiCheckAbort is True, the unit aborts when a key is pressed.
TPSBK v1.00 TPSBK CMF Player 18
C M F P L A Y E R
______________________________________________________________________
INTERFACE SECTION FOR SBCMF.TPU :
{Turbo Pascal SoundBlaster CMF Player by Trevor Robinson
Copyright (c) 1991, Trevor Robinson}
Unit SBCMF;
Interface
Uses CRT, DOS;
Const
FileDataSize = 64000;
Type
DataType = Array [1..FileDataSize] Of Byte;
FileDataType = Record
Id : Array[0..3] Of Char;
Version : Integer;
Inst_Blk : Integer;
Music_Blk : Integer;
Ticks_Per_Beat : Integer;
Clock_Ticks : Integer;
Music_Title : Integer;
Composer_Name : Integer;
Music_Remark : Integer;
Channel_Used : Array[0..15] Of Char;
Inst_Num : Integer;
Basic_Tempo : Integer;
MusicData : DataType;
End;
FileDataP = ^FileDataType;
Var
DriverInt : Byte;
Function FindDriverInt : Byte;
{ The function FindDriverInt searches the possible interrupts the CMF
driver could be located at and returns its interrupt number. It
returns 0 if the driver is not loaded. It is called during unit
initialization.
}
Function GetDriverVersion : Word;
{ The function GetDriverVersion returns the version of the CMF driver
currently in use. The high and low order bytes contain the major
and minor version number, respectively.
}
TPSBK v1.00 TPSBK CMF Player 19
Procedure SetMusicStatusByte(Var StatusByte : Byte);
{ SetMusicStatusByte provides the driver with the address of the music
status byte. The driver updates the byte under the following
conditions:
1. Reset it to 0 during initialization.
2. Set it to FF hex when music output starts.
3. Set it to 0 when the driver comes to the end of the music block.
4. When it encounters a Control Event, the driver updates it with
the value of the Control Data.
5. Does not change it when the music is paused and resumed.
}
Procedure LoadInstruments(Insts, SegInsts, OfsInsts : Word);
{ The procedure LoadInstruments loads the number of instruments speci-
fied by Insts from the Instrument Block located at SegInsts:OfsInsts.
}
Procedure SetMusicSpeed(Speed : Word);
{ SetMusicSpeed informs the driver of the clock speed to use when it
starts music output. Speed is the clock frequency in hertz. The
default is 96Hz.
}
Procedure TransposeMusic(Semitone : Integer);
{ TransposeMusic allows transposition of the music. Semitone contains
the number of semitones to transpose. A positive value transposes the
music to a higher key, a negative value transposes to a lower key.
}
Function PlayMusic(SegMusic, OfsMusic : Word) : Word;
{ PlayMusic plays the music block located at SegMusic:OfsMusic in the
background. The first byte of the music block must be a delta time of
events which is usually zero. The music status byte is set to FF hex.
The driver programs the system timer using the clock rate set by
SetMusicSpeed. The music status byte it set to 0 when finished. It
returns 1 if another song is currently active.
}
Function StopMusic : Word;
{ StopMusic stops the music and resets the music status byte to 0. It
returns 1 if no music was active.
}
Function ResetDriver : Word;
{ ResetDriver turns off the FM chips and resets the instrument table to
the default. It returns a 1 if music was active.
}
Function PauseMusic : Word;
{ PauseMusic pauses the active music. It returns 1 if no music was active.
}
TPSBK v1.00 TPSBK CMF Player 20
Function ResumeMusic : Word;
{ ResumeMusic resumes the previously paused music. Returns 1 if no music
was paused.
}
Function PlayCMFFile(Fname : String) : Word;
{ PlayCMFFile plays a CMF file using the above commands. It plays
until a key is pressed or the music is finished. If a key pressed,
it is not captured.
PlayCMFFile Return Codes :
0 - No Error
1 - FM Driver Not Installed
2 - Error Opening File
3 - Error Allocating Memory
4 - Error Resetting Driver
5 - Error Reading File
6 - Error Playing Music
7 - Error Stopping Music
8 - Error Closing File
}
Implementation
End.
NOTE: Requires SBFMDRV.COM!!!
TPSBK v1.00 TPSBK Demo Files 21
D E M O F I L E S
______________________________________________________________________
SBDEMO.PAS contains examples of all TPSBK except PianoMan and CMF
background playing. It demonstrates fore/background basic playing,
playing of old and new PianoMan files in the foreground, and playing
of old and new Multiple Part PianoMan files.
MUSICDOS.PAS demonstrates playing of PianoMan music files in the
background. It loads a file of your choice then exits to DOS, still
playing your music file! With a good song, it can take much of the
boredom of DOS away.
SBCMFDEM.PAS plays a Creative Music File (CMF) specified on the
command-line. (Requires SBFMDRV.COM)
Demo Music Files:
SOLFE.MUZ BASIC music file: Solfeggietto
CMINOR.MUS Old PianoMan music file: C Minor
DIXIE.MUZ New PianoMan music file: Dixie
ENTRTAN*.MUS Old PianoMan multipart files: The Entertainer
PAKLBEL*.MUS Old PianoMan multipart files: PAKLBEL
BADMAN.CMF Awesome Creative Music File
TPSBK v1.00 Music Conversion Programs 22
M U S I C C O N V E R S I O N P R O G R A M S
______________________________________________________________________
BAS2MUS-
Converts files containing basic PLAY verb data to PianoMan files in
the format:
FiledNote = Record
Octave, Note, Staccato : Byte;
Duration : Integer;
End;
NoteFile = File Of FiledNote;
MUS2MUZ-
Converts old PianoMan data files to new, smaller PianoMan 4.0 files
in the format:
FiledNote = Record
Octave, NoteStaccato : Byte;
Duration : Integer;
End;
NoteFile = File Of FiledNote;
The 4 high order bits of NoteStaccato contain the note, the 4 low
order bits contain the Staccato.
MUZ2MUS-
Converts new PianoMan 4.0 data files to old PianoMan files.
TPSBK v1.00 Programmers Programming Tips A
P R O G R A M M E R S P R O G R A M M I N G T I P S
______________________________________________________________________
If you have any tips or suggestions to make TPSBK easier to use for
others, please share them.
TPSBK v1.00 Common Questions and Answers B
C O M M O N Q U E S T I O N S A N D A N S W E R S
______________________________________________________________________
I haven't been asked any questions, yet......
TPSBK v1.00 Revision History C
R E V I S I O N H I S T O R Y
______________________________________________________________________
Version 1.00 - 7/23/91
Completed!!!
TPSBK v1.00 Future Enhancements D
F U T U R E E N H A N C E M E N T S
______________________________________________________________________
- Playing and Recording of VOC bigger than 64K
- Double Disk Buffering Playing and Recording of VOC files
- FM Music using Rhythm Mode
- Text-to-Speech
- AdLib ROL files
- Anything else I can think of...