Applications Graphics & Sound Sound & Music Sourcecode & Information Soundblaster sourcecode Assembler  

1371play 0.0 ESS 1371/3 .wav player for DOS

download download home home  
important code information
jeff leyda
minimum requirements:
1371play 0.0 ESS 1371/3 .wav player for DOS description

Simple Ensoniq 1371/1373 and soundblaster PCI 64 .wav player for DOS. No drivers required, full source code (x86 asm) provided.

Ensoniq 1371/1373 .wav file player for DOS

jeff leyda

ver 0.0: October 04 2003


No drivers required.

Usage: player <wavfile.wav>

To stop playback, press any key.


This player was based off my original Intel ICHx AC97 player.
Even though the hardware is different, many of the same principles apply.
You should be able to locate that player in the same spot you downloaded this.


Major issues:

1) Doesn't properly examine the .wav file header to find the start of the
data chunks, and it also assumes that there is only 1 data chunk in the file.

Having multiple chunks in a wav file is just plain stupid anyway.

2) Only supports 16bit samples, stereo format .wav files.
Multiple sample rates (48, 44.1, 22.05 and 11.025kHz are supported.)

Minor issues:

1) The last portion of the .wav data is padded with 0's so that the .wav file
is always in multiples of 64k in size. All this really means is that the
.wav file might play slightly more silence at the end of a song than the
true length of the file. A better solution would be to change the number
of samples to play for the final buffer.

2) To be safe, the codec initialization routines unmute EVERYTHING (main out,
DAC out, video out, CD out, headphone out, kitchen sink out, you name it.)
I do this because different sound cards (or if your 1371/codec are mounted
on the motherboard) are different beasts. Yours might be wired differently
than mine, or you might even have your speakers plugged into the headphone
jack instead of the line out jack. There is nothing more frustrating than
debugging a program only to find out the stupid output is muted or the
volume is so low that you can't hear it. The idea is for you to take this
code and incorporate it into your project, so comment out stuff until it
breaks and then you'll know the minimum required to play sounds on your

3) The playback speeds may not be 100% accurate. The 1371/3 is a wholly
undocumented piece of voodoo when it comes to setting the frequency rates.
The playback rates utilized here were obtained completely through trial and
error, leaning heavily toward error. There seems to be 2 sections where the
playback rate is adjusted, but neither of them made much sense. You'll find
these adjustments in 1371wav.asm

4) Currently plays garbage when run under windows 9x. I suppose this could
be listed under major issues, but really, it is a DOS wav player and there
are plenty of them for windows, so who cares?


Good reading materials:

1) Ensoniq 1371 spec. (ES1371.PDF)

2) linux source code: /drivers/sound/es1371.c
(although I personally found this more confusing than the docs)

3) various .wav file format specs available everywhere on the web.


Playing a .wav file using the 1371/3 in a nutshell:

1) locate the 1371 device in PCI space. The 1373 and the 5880 from Create
labs are supposedly register compatible. This is untested.

2) Get the IO base address from PCI register 10h

3) Open .wav file, read the .wav header and get playback sample rate.

4) Configure the codec and the 1371. Both the codec and 1371 need to know
what sample rate to play back from.
(actually, the codec on my card had a fixed frequency of 48kHz, but other
codecs DO care about what playback rate is needed.)

5) Allocate 1 buffer, 128k in size for storing .wav file data.
This buffer is divided into two 64k buffers.

6) Read the .wav file, skipping past the file header, and load 128k of data
into the two 64k buffers.

7) Point the DAC1 page frame address to the 128k buffer we've allocated.

8) Start the DMA engine playing the sound.

9) Now you have 2 options:

A) Poll the playback Index Register to see which buffer we're playing.
It tells us how many samples we've played. Since we know how many
samples are in each of the 64k buffers, it's easy to determine when
the playback engine has started playing the 2nd buffer.
Once the player switches to the 2nd buffer, refresh buffer 1 with new
data. Alternate filling buffers until the last data is loaded.
(we use this option since we're single task in DOS and it's easier!)

B) Have the playback engine fire an interrupt at the completion of a
buffer, alerting your ISR routine to refresh the buffers with new data.
You'd want to do that if you have lots of other things happening like
a multithreaded O/S would. The concept is straightforward, but
implementing it is beyond the scope of this program.
There is an example (not written by me) in the Intel ICHx version of
this player that might be convertable to the 1371.

10) Repeat refreshing whichever buffer is not being played until the .wav
file data is finished. The playback engine is in loop mode, so it'll
happily continue playing the same 128k of memory. It's up to us to keep
it filled with new data.

11) repeat speps 9-10 until .wav file finished.

12) stop DMA engine, close file, exit program.

More details provided in the heavily commented source code.


About the source:

It's free, do with it what you will. I don't particularly care.
Feel free to contact me with questions and improvements. I'm a nice guy and
I don't expect a flood of email about this to bog me down, so I'll give you
as much support as you need.

It's compiled with microsoft assembler 6.11, linked with microsoft linker.
To compile it, just type "nmaker", provided MASM is in your path.

I've tried to use a non-MASM specific style, so it should also compile under
TASM or similar compilers with very few modifications.

When messing with this program, you will probably want to also download the
diagnostic utility I wrote called 1371dump. It dumps out the contents of
all the registers inside the part, PCI, IO, SRC and codec. You can use
the dump program to verify your register changes have taken place, or use it
to dump out the config after you let windows change some things (works under
win 9x only) should be available where you downloaded this.

file list:
1371WAV.ASM 1371 configuration and .wav playing routines
CMDLINE.ASM simple command line parse code to find the .wav filename
CODEC.ASM codec configuration and setup code.
CODEC.INC constants and equates for codecs. Most codecs are compatible.
CONSTANT.INC equates that never change
EQUATES.INC equates of things that could change. (not much here really)
ESS1371.INC 1371 specific register definitions
FILE.ASM routines for opening, closing, reading files
MACROS.INC macros for writeln and writelncr
MAKEFILE compile control
MEMALLOC.ASM dos memory allocation routines
PCI.ASM pci reader/writers
PLAYER.ASM main executable/startup
PLAYER.EXE the end result.
README.TXT right here baby!
UTILS.ASM non-platform specific tools

File List:

Similar code
Ensoniq 1371/3 SB64 register dump utility (DOS) 0.0 (Popularity: ) : Ensoniq 1371/3 and Creative soundblaster PCI 64 internal register dump utility for DOS. Displays PCI, IO space, Sample Rate Converter, and Codec registers to the screen for diagnostic purposes. Works best in pure DOS, but can also operate in a ...
User reviews

Write a review:
1 2 3 4 5 6 7 8 9 10
1=poor 10=excellent
Write review*
Your name*
  (Comments are moderated, and will not appear on this site until the editor has approved them)
Rate me
supported os
downloads 227
size in Kb 26
popularity   3885/7916390
user rating 6/10

New Code
Popular Code