home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Audio 4.94 - Over 11,000 Files
/
audio-11000.iso
/
msdos
/
sndbords
/
proaudio
/
mvdoc
/
pcm.doc
< prev
next >
Wrap
Text File
|
1993-03-09
|
24KB
|
743 lines
PCM - TSR Providing PCM Access - version 3.9
Syntax
pcm # display command syntax and TSR status
pcm -h # to display more information
pcm -s # to display status on the ISR/TSR
pcm -i # to install PCM routines as a TSR
pcm -u # to unload the TSR
pcm -l [command] # to load the ISR, run command, then unload
pcm -bXXX # XXX= board address
Options
q - toggle quiet mode (-l sets quiet)
h - display additional information
s - display install status
i - install as TSR
u - uninstall TSR
l program.exe
- load ISR, run "program.exe", unload and exit
- returns as "errorlevel" the result of "program.exe"
bXXX - XXX= port address of board (default: find it)
What is PCM.COM?
pcm.com is a program that can operate as either a TSR (Terminate, Stay
Resident), or as a set of installable ISR's (Interrupt Service Routines).
As a TSR, it provides interrupt service routines for other programs in
order to access PCM (sound) routines for the Media Vision Spectrum/CDPC
interface boards.
The program includes code to access both the PAS and the on-board SB.
The program checks the environment at load-time for a "BLASTER=..."
statement, and configures itself accordingly.
As an ISR, it provides these same services, but instead of terminating
and staying resident, it loads and runs another program that expects
these services to be available, and then uninstalls these routines
before terminating.
Programs that expect pcm.com services include "tpcm.exe",
"srs16.exe", "play.exe", and other sound programs from
Media Vision.
These programs, and others, do not include the PCM access
routines in their own body of code. This makes each of the
programs smaller, and allows changes/improvements to the
PCM code more easily implemented among the various programs.
In short, pcm.com is a flexible program that provides PCM services
via interrupt 94h to other programs requiring such, either as a TSR
or as a front-end loader, and can also add extra sound-playing
capabilities to your computer by using extended memory, the timer,
and your keyboard.
Operation
Use the "pcm.com" program in order to provide access to PCM functions
via interrupt 94h.
There are two ways to utilize these functions: resident at all times,
or loaded before program execution.
When run as:
C:> pcm -i
The program will install into interrupts not already
hooked, and go resident if installation took place.
Some versions of the pcm.com program provide "background"
play capability when loaded using the "loadpcm.exe"
program; this requires that pcm.com be installed as
as a TSR.
Other programs, such as "tpcm.exe", will load pcm.com
if it is not already loaded, and so do not required
that be installed as a TSR.
To unload the program, use:
C:> pcm -u
When run as:
C:> pcm -l "program -options arguments"
The program will install into all its interrupts,
regardless of previous installation, run "program"
with its options and arguments, then remove itself
from the interrupts and exit.
Note: the quotation marks are not required.
C:> pcm -l "command.com"
This will install the routines and run the command
shell, thus making the routines available, but
after typing "exit" to the command shell, pcm.com
unloads the ISR's and exits.
Programs must be in the current directory in order
to be found and loaded, or their location must be
explicitly specified:
pcm -l c:\usr\bin\tp.exe -v *.wav
pcm -l ..\test\test.exe *.wav
If you find that you are using frequently programs that
require pcm.com, you can load it as a TSR. If you find
that you only need it for one program, you can use it as
a front-end loader, manually or in a .bat file.
Errorlevel Return Values
The program returns to DOS an errorlevel using the following logic:
if the "-l" option was used to run another program, the
errorlevel is that returned by the other program
if the "-i" option is specified, the returned values are:
0 successfully installed
1 not installed, detected pcm.com resident code
if the "-u" option is specified, the returned values are:
0 successfully uninstalled
#-1 not uninstalled, number of routines found
# not uninstalled, no routines found resident
Here, "#" is the number of routines normally installed.
For the "fun" version, this # is 5.
For the standard "pcm.com", this # is 1.
Note: the standard "pcm.com" returns either
0 (successfully uninstalled) or
1 (already resident)
if the "-s" option is specified, the returned values are:
0 not installed
1 number of installed vectors
These returned errorlevels can be used in .bat files:
pcm -s
if errorlevel 1 echo PCM.COM is installed
pcm -i
if errorlevel 1 echo PCM.COM failed installation
pcm -u
if errorlevel 1 echo PCM.COM could not unload
Auxiliary Programs
Use "loadpcm.exe" to load sounds into extended memory for background play.
Some versions of pcm.com may intercept other interrupts in
order to provide additional services, such as background play.
Most likely to be hooked are the keyboard, timer, console i/o;
with these versions, the TSR can be programmed to provide timed,
random, or initiated asynchronous sound output when loaded
with an extended-memory service provider, such as "himem.sys",
using the int 2F interface.
With this version of the program, you can use "loadpcm.exe"
to load sound files into extended memory, and the TSR will
then play these files using the keyboard, the timer, or
intercept CONTROL-G, at any time.
You will know if your version does by the following:
If after installing pcm.com using "pcm -i" you see only:
94h- Digital Audio Installed.
then the version provides only PCM access routines.
If after installing pcm.com using "pcm -i" you see:
94h- Digital Audio Installed.
09h- Keyboard Installed.
10h- Video Services Installed.
29h- Fast Putchar() Installed.
08h- Hardware Timer Installed.
then the version provides these extra "fun" features.
See "pcmfun.doc".
Use "setdma.exe" to fix an area of memory for DMA transfers.
This program searches the Memory Arena for the end, then
subtracts 16K from the top and allocates it as system
memory, thereby ensuring that the DMA buffer does not
cross a 64K segment boundary.
This program could search the UMB's, effectively providing a
DMA buffer that is completely out of conventional memory.
The program adds the string "DMABUF=SEGADDR PARASIZE" to the
master environment, which can be used in a .bat file by the
"loadpcm.exe" program:
loadpcm %dmabuf% 64
This causes loadpcm to inform the pcm.com TSR to use memory
at SEGADDR:0000 with a size in bytes of PARASIZE * 16 split
into 64 divisions.
Use the "freedma.exe" program to release this memory.
Note: the program uses "undocumented" DOS information to
perform this memory allocation.
See "sfdma.doc" for more information on these programs.
"proas.exe" will locate and initialize Media Vision hardware.
This program will allow you to use your sound board without
the need for "mvsound.sys" being resident.
pcm.com can read the DMA/IRQ channels from the hardware,
allowing programs using the int94 interface to function
without mvsound.sys (requires MV101 Rev D).
Programming using PCM.COM
Although programming by linking to the static libraries provided in
the Media Vision SDK is easy enough, using this TSR provides
additional functionality:
during load, the Hardware State Table is initialized.
provide access to global DMA buffer for any program
perform all initialization automatically (Function 8004)
perform custom initialization automatically (Function 8011)
internal User Functions to track your DMA buffer counters
background sound play/record using extended memory
improvements to PCM routines incorporated through PCM.COM
automatic 16- to 8-bit conversion on low-end hardware
Some changes in these PCM routines over their ancestors in the SDK:
Access to SB
Use a "set blaster=..." statement before loading
"pcm.com" to have it configure itself to access
the on-board SB.
C:> set blaster=a220 d1 i5 t3
aXXX XXX= base port for SB (220h)
dX X= dma channel
iX X= irq channel
tX X= CT product number (not used)
The program "tpcm.exe", written for the PAS, was
able to access the SB with only one program change:
"or" in the "sb request" bit into the function call.
Access to the PAS and SB can be simultaneous and
is independent.
DMA Buffer Divisions
No longer must the number of divisions be a
a multiple of two, and instead can be any number.
DMA Buffer Size
No longer must it be a multiple of 1024 bytes.
If the dma buffer size as passed in DMABuffer()
(function #3) is >= 100h, then it is assumed to
be the actual size and not the size in Kbytes.
It is the responsibility of the calling program
to ensure that the Buffer Size is an integral
multiple of the Number of Divisions; failure
can be as minor as "bumps" in the sound output
to destroying the memory control block arena.
IRQ/DMA Channel Changes
With the latest Media Vision hardware, it is
possible to program the board to use specific
DMA/IRQ channels.
The pcm.com program retrieves this information
from mvsound.sys, but also uses the information
from the board, and, in case of conflict, uses
those values programmed into the hardware.
Running without, or in conflict with, MVSOUND.SYS
pcm.com can read the hardware at load time, which
allows programs to function without mvsound.sys
being loaded ("pasinit.exe" will wake up and
initialize the board, and "mixinit.exe" will
program the mixer).
Also, "proas.exe" can change the DMA/IRQ
channels on the board, and pcm.com will detect
a conflict with mvsound.sys and use the values
programmed into the hardware.
Note: changing channels should not be done with
pcm.com loaded; the detection is made at "pcm -i"
time. If you do change the hardware, then, use
function 0 - InitMVSound - to cause the DMA/IRQ
channel info to be updated.
Note: with the PAS Original, the DMA/IRQ info
is not available from the hardware, so this
capability is not available.
Hardware Configuration Information
pcm.com provides a function to retrieve a bitfield
describing the known hardware configuration.
Playing 16-bit data on 8-bit Hardware
pcm.com will convert the 16-bit data to 8-bit
if it detects that the hardware does not have
a 16-bit DAC onboard.
It accomplishes this when the following logic
is used in the int 94h interface:
call PCMInfo() - notify 16-bit coming up
call DMABuffer()- calculate stuff
call PausePCM() - set state to Paused
call PlayPCM() - prepare to Play, but still paused
load the DMA Buffer from the app
call ResumePCM()- converts 1st division data
thereafter, every IRQ the next division is
converted
Pause/Play/Record/Resume Operation
Previously, calling PausePCM() then PCMPlay()
resulted in sound output. So, in order to
"setup" and then use "pause" and "resume",
you had to "Play" then "Pause", but then a
little bit of data played.
Now, the operation of the "PausePCM()" function
is like that of the "pause" button on a tape deck.
Press Pause.
Press Play (or Record)
nothing happens
Press Resume
begin play/record
This was desired, but required when run-time
16- to 8-bit conversion was required.
========================================================================
NOTE: There are two programs, pcmfun.com and pcmmin.com, that share
the same code. Occasionally, one or the other is distributed
as "pcm.com".
The intention is to maintain both "serious" and "fun"
sides to this set of routines, but leaving you the user
the option of deciding whether or not you want, or can,
use the "fun" stuff.
If you prefer to not use the fun stuff, and thus not
allocate the memory, but you do like the programs that
depend on the int 94h services, then rename "pcmmin.com"
to "pcm.com", and leave it in the same directory as the
other programs (tpcm.exe, srs.exe). These programs will
load "pcm.com" if it is not already installed.
Of course, I would prefer if the TSR were to dynamically
install those functions desired by the user via a command-
line option, but, alas, there has been too little time!
Know, though, that I know that this is a worthy goal.
I apologize in advance for any confusion that may arise.
========================================================================
Programming for Interrupt 94h
Use of the interrupt 94h interface is similar to that for "fm.com",
which was based on the "sound.com" program.
This could be considered unfortunate, as the "si"
register is used to pass the function number, and
this register must be preserved across function calls,
when programming in C.
The functions 0 - B are duplicate the similarly named
functions from the SDK. Function C is new. Functions
8000 - 8011 are functions that might simplify some
programming for sound output. Functions 8012 - 8016 are
included only in versions of pcm.com that provide the
background play ability (the "fun" stuff).
Additionally, the SI register also holds the requested "board address",
as well as a "card" bit:
SI Register Definition
;; STPP PPPP PPff ffff
;; S= Special Function if set
;; T= 0= PAS, 1= ThunderBoard (Sound Blaster)
;; PP PPPP PPcc= port address (388, 38C, 384: low 2 bits clear)
;; ff ffff= function number
Interrupt 94h Functions
Entry
si = special/card/port/function
es:bx = points to data buffer specific to function
Exit
ax = return integer or boolean value
dx:ax = return long value or far address
si = 0 if recognized function
Description of Function
SI ES:BX points to Buffer Containing...
Returned in AX (int) or DX:AX (void far *)
0 InitMVSound() - initialize the Hardware State Table
N/A
char far * NULL if failed, else Hardware State Table address
1 InitPCM() - initialize PCM State Tables
N/A
int 0 if failed, else Library Version Number
2 PCMInfo() - set samplerate and mono/stereo
struct pcminfo {long samplerate; int stereoflag};
int 0 if okay, -1 if Samplerate Out of Range
3 DMABuffer() - set DMA buffer address, size and partitions
struct dmabuf {char far * dmabuf, int bufkbsize, partitions;};
char far * NULL if failed, else succeeded
4 UserFunc() - set up callback routine for DMA interrupts
void far (*userfunction)();
void far * NULL if failed, else succeeded
5 PCMPlay() - play
N/A
int 0 if successful, else failed
6 PCMRecord() - record
N/A
int 0 if successful, else failed
7 PausePCM() - pause playback or record
N/A
N/A
8 ResumePCM() - resume paused playback or record
N/A
N/A
9 StopPCM() - stop playback or record
N/A
N/A
A RemovePCM() - remove PCM hook to IRQ, clear internal DMA vars
N/A
N/A
B FindDMABuffer() - find area from memory within 64K block
struct fdmabuf {char huge *dmabuf; int bufkbsize};
char far *dmabuf NULL if failed, else Valid DMA address
C GetHWVersionBits() - return a bitfield describing configuration
N/A
int bitfield (see HWVersionBits below)
8000 Retrieve Current DMA Address
N/A
char far *dmabuf NULL if none, else Current DMA address
8001 Retrieve Current DMA Size and Divisions
N/A
AX= Current DMA Size, DX= Current DMA Divisions
8002 - 8003 NOT IMPLEMENTED
8004 Make Ready For Play Mono at 11025Hz using B000:0 as 32K/2 DMA Buffer
N/A
N/A
8005 - 8010 NOT IMPLEMENTED
8011 Make Ready For Play using User Specified Parameters
struct pcmstate *{}; All Parms for PCMInfo, DMABuffer, UserFunc
struct pcmstate *{}; See Below for structure definition
---- The following functions are included only with the extra "fun"
---- background play stuff.
8012 Load Sound for Background Play
struct extstate *{}; All Parms for sound and access to XMS
N/A
8013 Return Bitfield Describing Background Sound Slot Usage
N/A
ax= bitfield of sounds used, dx= max sound slots (8)
8014 Fill Structure for Specified Sound Slot
struct extstate *{}; desired sound number in field member
struct extstate *{}; structure filled with internal info
8015 Set/Get/Unset Internal DMA Buffer
struct dmabuf *{}; if dmaoff != -1, set internal to contents
struct dmabuf *{}; if dmaoff == -1, set contents to internal
8016 Simulate LeftShift-RightShift-# Keystroke
ax= 1 through 8 desired slot #
N/A
8017 Control Background Processing Logic
al= 1 Control-G Intercept
ah= 0 Off, 1 On
al= 2 Double-Shift Key Intercept
ah= 0 Off, 1 On
al= 4 Random Sound
ah= 0 Off, 1 On
cx= minimum delay in ticks (if turning on)
dx= maximum delay in ticks
al= 8 No Activity
ah= 0 Off, 1 On
cx= delay in ticks (if turning on)
al= F Timer Control
ah= timer # (0-3)
dx:cx= delay in ticks, b15=0 reload, b15= 1 oneshot
Parameter Definitions
The "pcminfo" structure holds the Sample Rate and Mono/Stereo Flag.
The Sample Rate can vary from 100 to 88200 Hz Mono output, or 200 to
44100 Hz for Stereo.
struct pcminfo /* Passed to PCMInfo() */
{
long samplerate; /* 100 - 88200 (100 - 44100 for stereo) */
int stereoflag; /* 0 = mono, 1 = stereo */
};
The "dmabuf" structure contains the address of memory to be used as
the DMA Load/Unload Buffer, the Size of this Buffer in KB, and the
Number of Partitions it is to be split into. This buffer must not wrap
around a 64KB block (the address should never get to ????:FFFF+ 1).
struct dmabuf /* Passed to DMABuffer() */
{
char far *dmabuf; /* address of DMA buffer */
int bufkbsize; /* size of DMA buffer in KB */
int partitions; /* number of partitions */
};
The "fdmabuf" structure contains a "huge" pointer to an area of memory
that is at least twice as large as the associated "kbsize" parameter,
which specifies the desired size of memory in KB.
struct fdmabuf /* Passed to FindDMABuffer() */
{
char huge *dmabuf; /* address of memory allocated */
int bufkbsize; /* size of memory in KB */
};
The "userfunc" parameter is the address of a routine that is to be
called every time the PCM hardware has completed the output/input
of a partition of the DMA buffer. Typically this routine decrements
a "flag" (see pcmstate.stat, below) which is monitored in the main
program, allowing it to read/write data during PCM playback/record.
void (far *userfunc)(); /* address of callback routine
The "pcmstate" structure is used to completely initialize the DMA and PCM
state with user-supplied parameters, and includes space for the return
values as well as a default DMA interrupt function that decrements the
int pointed to by pcmstate.stat, and one that reads/writes files in the
background using the pcmstate.fh file handle. Set pcmdir to 0 for play,
set to 1 for record; the internal user function decrements the stat flag
during play, and increments during record.
struct pcmstate
{
char far *f00r; /* hardware state table returned from InitMVSound */
int f01r; /* library code version returned from InitPCM */
long f02c1; /* samplerate passed to PCMInfo */
int f02c2; /* mono/stero flag passed to PCMInfo */
int f02r; /* -1 returned by PCMInfo if error, else (?) */
void (far *f04c)(); /* address of interrupt function or index to internals */
void far *f04r; /* 0 returned by UserFunc if error, else (?) */
char huge *f11c1; /* not used at present FindDMABuffer */
int f11c2; /* not used at present FindDMABuffer */
void far *f11r; /* not used at present FindDMABuffer */
char far *f03c1; /* DMA buffer passed to DMABuffer */
int f03c2; /* size of DMA buffer in kilobytes passed to DMABuffer */
int f03c3; /* number of partitions of DMA buffer passed to DMABuffer */
char far *f03r; /* 0 returned by DMABuffer if error, else (?) */
int f10r; /* returned by RemovePCM */
int f05r; /* returned by PCMPlay */
int f07r; /* returned by PausePCM */
int far *stat; /* "volatile int" address decremented each DMA pass */
int fh ; /* file handle for input/output file (not implemented) */
int sbsize; /* calculated size of each partition in bytes */
int f02c3; /* compression flag */
int f02c4; /* data size (8 or 16, specifying bit-size of sample)
int pcmdir; /* 0= play, 1= record */
int unknown[16]; /* for expansion */
};
struct extstate
{
uint snum; /* sound slot number */
uint xmsh; /* XMS handle */
ulong xmso; /* XMS offset for data */
ulong xmss; /* XMS memory size */
ulong rate; /* samplerate of sound */
uint chan; /* number of sound channels */
uint comp; /* code for compression */
uint dsiz; /* bitsize of sample data */
char name; /* name of sound file */
};
HWVersionBits Definition
bMVA508 = 0000000000000001b ; MVA508(1) or National(0) mixer
bMVPS2 = 0000000000000010b ; PS2 bus stuff
bMVSLAVE = 0000000000000100b ; CDPC Slave device is present
bMVSCSI = 0000000000001000b ; SCSI interface
bMVENHSCSI = 0000000000010000b ; Enhanced SCSI interface
bMVSONY = 0000000000100000b ; Sony 535 interface
bMVDAC16 = 0000000001000000b ; 16 bit DAC
bMVSBEMUL = 0000000010000000b ; SB h/w emulation
bMVMPUEMUL = 0000000100000000b ; MPU h/w emulation
bMVOPL3 = 0000001000000000b ; OPL3(1) or 3812(0)
bMV101 = 0000010000000000b ; MV101 ASIC
bMV101_REV = 0111100000000000b ; MV101 Revision
Note: this document and its associated programs are subject to change
at any time and is being distributed for informational purposes only.
Copyright (c) 1992. Media Vision, Inc. All Rights Reserved.
Programmer: Bart Crane
************************************************************************
pcm.com - main TSR/ISR
ctrlgon.com - turn on CTRL-G intercept (plays sound #1)
ctrlgoff.com - turn off CTRL-G interception
keyx.com - play a key # (syntax: keyx 14)
noacton.com - turn on no-activity detection (plays sounds 25-32)
noactoff.com - turn off no-activity detection
rndon.com - turn on random sounds (plays sounds 33-64)
rndoff.com - turn off random sounds
sskeyoff.com - turn off left-right-shift key detection
sskeyon.com - turn on left-right-shift key detection
tmr1set.com - set timer 1 time
tmr1on.com - turn on timer 1
tmr1off.com - turn off timer 1
tmr2set.com - set timer 1 time
tmr2on.com - turn on timer 1
tmr2off.com - turn off timer 1
tmr3set.com - set timer 1 time
tmr3on.com - turn on timer 1
tmr3off.com - turn off timer 1
tmr4set.com - set timer 1 time
tmr4on.com - turn on timer 1
tmr4off.com - turn off timer 1
tmr5set.com - set timer 1 time
tmr5on.com - turn on timer 1
tmr5off.com - turn off timer 1
tmr6set.com - set timer 1 time
tmr6on.com - turn on timer 1
tmr6off.com - turn off timer 1
tmr7set.com - set timer 1 time
tmr7on.com - turn on timer 1
tmr7off.com - turn off timer 1
tmr8set.com - set timer 1 time
tmr8on.com - turn on timer 1
tmr8off.com - turn off timer 1