(******CONV2SND.DOC******)
* *
* CONV2SND.PAS: 2.02 *
* *
* February 3, 1993 *
* Kenneth Udut *
* Revised 10/15/96 *
* J.L. Hayes *
* *
(******CONV2SND.DOC******)
CONV2SND.EXE, CONV2SND.PAS, CONV2SND.DOC, CONV2SND.HST HEREBY ARE
RELEASED INTO THE PUBLIC DOMAIN. UNLESS SPECIAL CIRCUMSTANCES WARRANT
OTHERWISE, EVERY SOFTWARE PRODUCT CREATED BY (_KENNETH UDUT_) WILL:
1. BE RELEASED INTO THE PUBLIC DOMAIN, FREELY COPYABLE AND CHANGEABLE.
2. INCLUDE THE SOURCE CODE.
AS THE AUTHOR OF (_CONV2SND_), I WOULDN'T MIND CREDIT FOR MY WORK.
HOWEVER, IT IS *NOT* A NECESSITY, SO DON'T WORRY ABOUT IT! :)
[Note: My modifications are also public domain. Ken wrote much of the
following, but I have changed a lot of it to match this version. - J.L.
Hayes]
Now enough of this screaming!
1. CONV2SND is a program with one thing in mind: To open the worlds
of digitized sounds created on other machines and by other methods
to anyone using a Tandy 1000 SL, TL, RL, RLX, 2500 RLX, RSX and
every other machine that uses:
SOUND.PDM
Ken wrote: "I wish that Tandy had created something a few years ago
that would have done this, as it might have kept the Tandy's with the
superb 8-bit DAC a little more in step with the SoundBlaster, the
Macintosh, the Amiga and the Atari ST, all of which are able to create
superb digitized sounds and have programs that allow you to share them
with one another.
"So, here it is."
2. To start the program, type:
CONV2SND <infile>
or:
CONV2SND <infile> <outfile>
The process will then take place (almost) automatically. Filenames can
include drive and path if you want. If you use the first form, the
output filename will be the same as the input filename, including drive
and path if present, but with an ".snd" extension attached. If you use
the second form, the output filename will be what you specified. If
the output filename does not have an extension, it defaults to ".snd".
There is no default for the input file, so you have to specify the
extension for it. If you want the output file not to have an
extension, end its name with a period.
As of version 2.00, CONV2SND can read and understand .wav headers. The
.wav will be detected by the header, not by the filename. CONV2SND
will check that the .wav is an 8-bit mono file and display some advice
if it isn't (see below). If the .wav is 8-bit mono, CONV2SND will read
the sampling rate from the header and check to see if it is within 5%
of one of the three rates supported by SOUND.PDM. If so, the sampling
rate will be taken from the .wav header, and you won't be asked about
that. If not, you will be told to resample the file. There is a
program available to do this, discussed below. If the .wav header is
invalid, you will be given the option of continuing as if the file were
not a .wav. I don't know how useful that will be.
You will be asked a couple of questions.
A) Asks about the sampling rate (speed of playback). You won't be
asked this question if CONV2SND is able to determine the sampling
rate from the .wav header.
These are the options (Ken's notes):
5500 is a slow sampling rate, often used for speech purposes or some
games. [5500 seems to be rare nowadays. - JLH]
11000 is the the most common sampling rate. It is #2 on the
selection list and the one you will want to try first. The
only reason it is so popular is that it is of sufficient
quality for music and such. 5500 really isn't. WAV files are
usually sampled at 11000 samples per second.
22000 is most often used with the Macintosh Sound files. It is of a
higher quality, but it does take up more disk space, which is
why it is the 2nd most popular sampling rate to record at.
[This rate is becoming more common. - JLH]
If you screw up and select the wrong one, that's okay! Just redo the
procedure and select a different rate next time!
[It should be mentioned that 44000, or 44kHz, is an increasingly
common rate. This is the rate that audio CD's are sampled at. The
Tandy sound chip is perfectly capable of going that fast, but
SOUND.PDM does not support that speed. I have written a .wav player
for the Tandy chip that will play .wav's at 44kHz - see Snd2wav.doc.
Included here with CONV2SND is a utility called Ppwav that can cut
the sampling rate of these .wav's down to 22kHz so that CONV2SND can
convert them. See below. - JLH]
B) Asks for the "name" of the sound.
This isn't the file name. This is the name that appears when you
are in SOUND.PDM, right next to "Name: ", in the right hand box. If
you don't specify a name, none will be used. This is a change from
version 1.98, which required you to enter a name. It is a good idea
to specify a name anyway, in case the name of the file gets changed
at some point in the future.
You can read the name of the sound by typing DEBUG filename.snd and
then "d". You will see the name of the sound file in the right hand
side of the screen. (NOTE: "q" gets you out of DEBUG)
C) Asks whether you want to convert to the new DeskMate .snd file
format. The old format is native to the 1988 version of SOUND.PDM;
the new format is native to the 1989 version. Any version of
SOUND.PDM can read the old format, so it is a good idea to convert
to that one unless you have a reason not to. In other words, you
probably want to say "no" to this question.
Programs using Frank Durda's PSSJ Digital Sound Toolkit (not from
Tandy) do not understand the old format, so you need to convert to
the new format for them.
D) Asks for your name. "No real reason yet, but I'm thinking of one!"
writes Ken. Version 1.98 required you to enter your name; this
version will call you "CONV2SND user" if you don't enter a name.
A new file with your sound will be created. This is the DeskMate SOUND
version of the other digitized file.
3. You will need to do the following after the file is created:
* Go into SOUND.PDM, and load the new .SND file (F2, Open)
* Play the file and see if the conversion was done right. If the file
sounds like Alvin the Chipmunk, the sampling rate you gave was too
low; go back and run CONV2SND again with a higher rate. If it sounds
like Lurch on "The Addams Family," the rate is too high, and you need
to try a lower one. (That is, unless the file *is* a recording of
Lurch! :-) If the file sounds like nothing at all, just static, it
may not be an 8-bit mono PCM file. You will have to use a program
called Sox to convert it to one before CONV2SND can use it; see
below.
If the input file was a .wav, you should not have this problem. If
the .wav is of a type that can't be converted (most can), CONV2SND
will tell you why and halt without creating an output file.
* If the sampling rate seems right, carefully remove any noise at the
beginning of the file, using a very small increment (use "sample").
Beginning noise, if present, represents the header of the original
sound file; it is not actual sound. There are a few types of sound
files that don't have a header ("raw" files made by Sox are one - see
below), but most do. The noise will be a short click or pop.
Again, if the input file was a .wav, the .wav header will be deleted
automatically, and this problem will not arise.
* Hit F2 and Save the file.
Example: ROCKY.WAV is converted into ROCKY.SND
After listening to the file to check the conversion and getting
rid of the little beginning noise, hit F2, and Save. Exit
SOUND.PDM if you don't want to do more with the file at that time.
Here are some problems you may have, and what to do about them:
* If the file sounds like nothing at all, just static, it may not be an
8-bit unsigned mono PCM file. That means the sound data in the file
is not the right type for SOUND.PDM, and it will have to be converted
to 8-bit unsigned mono PCM before CONV2SND can use it. There is a
program called Sox that can tell you what kind of file it is and do
the conversion. As of this writing (8/15/1996), Sox is available by
ftp from:
oak.oakland.edu
Get file:
/pub/simtelnet/msdos/sound/sox7dos.zip
and read the documentation that comes with Sox. You will need to
tell Sox to make its output file a RIFF WAVE file, size "byte," "1
channel" and select a sampling rate of 5500, 11000, or 22000. Use
the "verbose" option with the "stat" effect to find out what the
sampling rate of the original file is; if it's close to one of those
three, leave it alone. CONV2SND will accept sampling rates within 5%
of 5500, 11000, or 22000. It is best not to resample if you don't
have to since it introduces noise. Warning: Sox is a little
confusing to use at first.
As an alternative to Sox, this distribution includes a utility called
Ppwav that operates only on .wav files. Ppwav can convert wav's with
more than one channel to mono and larger sample sizes to 8-bit. It
can also cut the sampling rate of a file in half. Sox does all that
Ppwav does and more, but Ppwav is much faster and easier to use. If
you have a .wav that can't be converted because of one of the
problems that Ppwav can solve, CONV2SND will refuse to convert the
file and tell you to use Ppwav. See the separate documentation file
on Ppwav. Note that there are rare types of .wav's that neither Sox
nor Ppwav can convert.
* If you've tried all 3 sampling rates, 5500, 11000, and 22000, and
none of them seems to be right, you will have to resample the sound
to change the sampling rate to one of those three. SOUND.PDM can
only use one of those 3 rates. Sox (see above) can be used to do
this. Changing the sampling rate will introduce noise, unfortun-
ately; change to a sampling rate that is an integer multiple of the
original to minimize the noise.
Other sampling rates that I have seen are 8000, 15000, and 44000.
Sun .au files are usually sampled at 8000 (note that Sun .au is not
PCM but mu-law - Sox can convert these to .wav). If the input file
is a .wav, CONV2SND will refuse to convert the file if the header
indicates that the sampling rate is not one of the three that
SOUND.PDM supports.
* If CONV2SND tells you the disk where the output file goes is full,
you will need to specify another drive for the output file, one with
more space on it. If you have a single-floppy system, you can
specify drive B:, and DOS will prompt you to swap disks when needed.
It will be awkward to do it this way, but it will work.
* If SOUND.PDM tells you the .snd file won't fit in memory, there is
unfortunately not much you can do. If your system can take
additional DOS memory, you can install additional memory if you
haven't already. This is a very cheap upgrade and highly
recommended; check your owner's manual to find out how. I'm
referring to systems with less than 640k of DOS memory; I doubt that
SOUND.PDM will use expanded or extended.
That's it! Ken's phone (908) 241-6246 is open for your use up 'till about
11pm or so. He is Kenneth Udut, 170 East Clay Avenue, Roselle Park, NJ USA
07204-2050.
Note: Ken hasn't worked
with this program in a while
and doesn't seem to be on the
Internet any more.
-JL Hayes, Oct 15, 1996
I'm still here, Jeff. :P
-K Udut, March 23, 2015
I am responsible for versions 2.00 and above,
including much of the above text. My phone is (207) 866-7903. I'm
tvdog@agate.net on the Internet. Snailmail: Jeffrey L. Hayes, 130 Forest
Ave., Lot 1, Orono, Maine 04473.
"Thanks for reading and hope you NOT ONLY enjoy using it, but also play
around with the source code and work with it!
"I want to see a world where source code is freely distributable, where
there isn't all that "data-hiding" and all that. I would hate to see a
society where the 'elite programmers' only knew the secrets of 'real'
programming, while the peons were kept down low...
"I prefer openness and honesty, personally :)
"Talk to you soon!
"--Ken
"February 3, 1993"
FIDONET: Kenneth Udut @ 1:107/900
INTERNET: kudut@ritz.mordor.com
America Online: K Udut
PC-Link: K Udut
CompuServe: INTERNET> kudut@ritz.mordor.com
BITNET: kudut%ritz.mordor.com@yalevm.bitnet
Home Address:
Kenneth Udut
170 East Clay Avenue
Roselle Park, New Jersey 07204-2050
Phone Numbers:
(908) 241-6246
(908) 241-8528 -- FAX number
Can be found on:
The Juice Bar BBS, located in Roselle Park, New Jersey, USA
(908) 298-0764. I'm user #11, and a VERY VERY active poster!
I also run a list on BITNET.
Y-RIGHTS@SJUVM.BITNET - discussion on the rights of kids and teens.
"Leave me a message somewhere or give me a phone call! I'll set a pot of
tea out for you and we'll chat :)" - Ken
Also check out the Tandy sound package! Play mono or stereo 8- or 16-bit
.wav's of arbitrary size at up to 65535 Hz, record .wav's of arbitrary
length at up to 62kHz, convert raw 8-bit sound files to .wav, convert 16-
bit or stereo .wav's to mono 8-bit, convert .snd instrument files to Amiga
.mod samples (including looped samples!), use your Tandy DAC with programs
that support a generic DAC, and play your Tandy like a piano with the 3-
voice chip (chords too!). All source code included, and the best, most
complete programming information on the Tandy sound that you will find
anywhere! All free! How do I get this marvellous package, you ask? Just
ftp it from:
ftp.agate.net:/users/01935/tandy1000/sound/tspak17.zip
- JLH
-----------[technical stuff]------------
Many (but not all) types of sound files are basically identical to DeskMate
.snd. That is, the actual sound data is encoded in exactly the same way.
The difference lies in the "header."
The header of a file is a small series of bytes, usually 44 in the case of
DeskMate .snd files. The purpose of a header?
A header tells the program how big the file is, as most programs that read
digitized sound files need to be specially told how many bits of sound they
need to load up. It also might tell you the "name" or description of the
sound file. The sampling rate (how fast the sound was recorded and should
be played back) is also usually included.
Christopher Taveres was the first to try to decode the .snd header.
Chris's effort appeared as part of his SOUNDOFF.C program in _PCM_, the
Tandy magazine. Here's what he came up with:
======================================================================
/* Sound Off!
/* Written by Christopher Taveres
/* Copyright (c) January 1992
/* Falsoft, Inc.
/* PCM
/** Definintion for the header block for Deskmate .snd files **/
struct dmheader { /* Structure of the header block */
int marker; /* Marker bytes - should be 00 1a */
char note_count; /* Number of notes in instrument file */
char inst_num; /* Instrument number */
char inst_name[10]; /* Instrument name */
int sample_rate; /* Sampling rate */
char filler[16]; /* I don't know what this does */
unsigned long sample_size; /* Number of samples in file */
char filler2[8]; /* More unknown space */
======================================================================
Ken noticed that the marker bytes could be 1A 01 instead of 1A 00. The
number of samples confused him, however. After fiddling around with
SOUND.PDM for a while, I filled in most of the blanks as follows:
TANDY DESKMATE .SND FORMAT NOTES (old .snd file format)
-------------------------------------------------------
Tandy .snd files are created by Sound.pdm, a program that came with the
proprietary DeskMate environment. They are used by Music.pdm to create
music modules (.sng files). DeskMate Sound and Music require the Tandy
sound chip.
Tandy used two incompatible .snd file formats. The first format, described
here, was used by the 1988 and 1989 versions of DeskMate Sound and Music -
the version bundled with the 1000SL and 1000TL. The second format,
described below, was used by the 1990 versions of these programs - the
version bundled with the 2500-series. The 1990 version of Sound.pdm can
read but not write the old file format and can be used to convert to the
new format; the 1988 version of Sound.pdm does not understand the new
format.
There are two types of DeskMate .snd files, "sound" files and "instrument"
files. Both contain 8-bit unsigned PCM samples.
Sound files are garden-variety sample files with a fixed-length header
giving the name of the sound, the recording frequency, and the length of
the sound. Sound files may be recorded at 5500Hz, 11kHz or 22kHz.
Instrument files contain samples as well as frequency and looping
information used by Music.pdm to represent an instrument. Instrument files
provide for attack, sustain, and decay (I'm not sure whether the decay
section is ever actually played) with several samples having different
implied frequencies and being used by Music.pdm to represent the instrument
in different pitch ranges. Up to 16 different notes (with 16 different
samples) can be contained in one instrument file. Instrument files are
always recorded at 11kHz.
Frank Durda notes that if the sound was recorded on a Tandy 1000SL or
1000TL, the actual sampling rate will be slightly different from the rate
specified in the file. The adjustment required does not appear to be a
simple function, though. The old format does not describe the recording
hardware anyway.
Both sound files and instrument files may be compressed in one of two ways,
"music" compression or "speech" compression, or they may be uncompressed.
Music compression uses a combination of run length encoding and non-
adaptive differential PCM. Speech compression adds a silence suppression
step before the run length encoding. Both compression types are lossy,
speech compression more so. The Tandy Digital Sound Toolkit, now in the
public domain in binary form, can be used for decompression. Frank Durda's
PSSJ Digital Sound Toolkit also contains decompression code. It is
available in both source and binary forms but is restricted to
noncommercial use. Sound.pdm can also be used to decompress an .snd file.
There are some programs for playing .snd files at my ftp/WWW site:
ftp://ftp.agate.net/users/01935/tandy1000/sound/
http://www.agate.net/~tvdog/sound.html
Basic stuff for beginners :-):
A sound can be represented mathematically as a waveform that is a
function of time; for example, y = sin(t) would represent a pure tone.
The sound wave is continuous, however, and computers deal with discrete
data. Hence, to represent a sound in a computer, the waveform is
"sampled" at regular intervals and its level recorded. The more
frequently the wave is sampled, and the finer the measurement of its
level, the closer the approximation to the original wave, and the better
the quality of the recorded sound. The chip that samples the sound wave
is called an "analog-to-digital converter," or ADC. When the recorded
sound is to be played back, another chip takes the samples and changes
them back into an approximation of the sound wave. That chip is called
a "digital-to-analog converter," or DAC. In the Tandy, the same chip,
called "PSSJ," performs both functions.
There are different ways of representing the level of the sound wave
when sampling. The simplest way is to record the sound level as an
integer, usually in 8 or 16 bits. This is called "pulse code
modulation," or PCM. In unsigned PCM, zero is the lowest possible level
of the sound wave, and the samples range from 0 to 255 (8 bits) or from
0 to 65535 (16 bits). In signed PCM, zero is the middle level of the
wave, and the samples range from -128 to 127 (8 bits) or -32768 to 32767
(16 bits). The Tandy chip uses 8-bit unsigned PCM samples. It is also
possible to record the level of the sound wave as a real number, or
rather an approximate real number. A-law and mu-law encoding are
examples of that. Once the samples have been recorded, they can be
compressed by various methods. "Run length encoding," "differential
pulse code modulation," and "adaptive differential pulse code
modulation" are a few compression methods. Some compression methods are
"lossy," meaning that when you decompress the compressed file, you don't
get back *quite* the original sound. It is frequently possible to get
more compression if you can tolerate some loss in the sound quality.
Many of the numbers below are given in hexadecimal, or base-16 notation.
Hexadecimal is a common way to express numbers when programming at the
machine level. In base-16, letters A through F are used to represent
"digits" 10 through 15. Also: "word" is a 16-bit unsigned integer, and
"dword" is a 32-bit unsigned integer.
"American Standard Pitch" refers to the sound frequencies assigned to
the various musical notes by the American Standards Association. Sound
frequencies are based on A above middle C being 440 cycles per second.
This A is called A4. An octave below that is A3, an octave above, A5.
The frequency doubles with each octave increase in pitch. Sound.pdm
does not display standard notes to you, though. Standard octaves begin
at C, so you would have A#2, B2, C3. Sound.pdm starts its octaves at A.
The sampling rate has nothing to do with the pitch frequency, except
that the rate must be at least twice as high as the highest frequency
you want to record.
The old DeskMate .snd file header consists of 16 bytes of fixed header
information followed by one or more 28-byte note records. The sample
information, which may be compressed, follows the header.
DeskMate .snd File Format - Fixed Header
----------------------------------------
offset size what
------ ---- ----
0 byte 1Ah (<control>-Z, prevents DOS TYPE from trying to
put the file on the screen).
1 byte Compression code: 0 = no compression; 1 = music
compression; 2 = speech compression.
2 byte Number of notes in the instrument file. 1 if sound
file. There can be a maximum of 16 notes in an
instrument file. Note: when an instrument file is
created, it automatically has one unset note placed
in it.
3 byte Instrument number. 0 if sound file; 0FFh if instrument
file with no number set. Valid instrument numbers in
an instrument file are 1 to 32. Use this field to
distinguish a sound file from an instrument file.
4 10 bytes Sound or instrument name. The name is null-terminated,
so the name may be at most 9 characters long.
0Eh word Sampling rate in samples per second. Note that although
a sampling rate other than 5500, 11000 and 22000 can be
entered here, Sound.pdm will not actually play at other
rates.
10h variable Note records begin, 28 bytes each. Number of records
given in byte 2 above.
DeskMate .snd File Format - Note Record
---------------------------------------
0 byte Pitch of the note: 1 = A1 in American Standard Pitch;
2 = A#1; etc. A1 is lowest note allowed; highest note
allowed is B6 (3Fh). Sound files have 0FFh here; so do
instrument files with no note set.
Note that Sound.pdm does not designate notes in the
standard manner to the user. Although A1 and B6 in
Sound.pdm are the same as A1 and B6 in standard pitch,
Sound.pdm starts octaves at A rather than at C (as is
standard). Thus, middle C, C4 in standard pitch, is C3
in Sound.pdm.
1 byte Sound files, and instrument files with no pitch set,
have 0 here. If the pitch is set, this byte is 0FFh.
2 2 bytes Range of the note, first byte is lower limit, second
is higher limit. Byte encoding as for offset 0 (i.e.,
01h to 3Fh). Sound files have FF FF here; so do
instrument files with no range set.
4 dword Offset in the file where samples for this note begin
(zero-relative), after compression if that was done.
8 dword If compressed, the length of the compressed data in the
file for this note. Uncompressed files have 0 here.
0Ch dword Set to zero.
10h dword Number of samples in the note, after decompression if
necessary.
14h dword Number of sample at start of sustain region for the
note, relative to the first (zeroth) sample of the note.
For sound files, or if sustain is not set, this field is
0.
18h dword Number of sample at end of sustain region for the note,
relative to the first (zeroth) sample of the note. For
sound files, or if sustain is not set, this field is 0.
NEW TANDY .SND FILE FORMAT
--------------------------
These files are created by the 1990 version of DeskMate Sound.pdm, bundled
with the Tandy 2500-series computers.
This information was provided by John Ball (john.ball@two-t.com), author of
Playsnd, and by the PSSJ Digital Sound Toolkit of Frank Durda IV.
Like the old format, the new format header consists of a fixed part
followed by one or more sample descriptors. The fixed part is 114 bytes;
the sample descriptors are 46 bytes each. Samples are still 8-bit unsigned
PCM, possibly compressed.
Fixed header:
offset size what
------ ---- ----
0 44 bytes Name or description of the sound. According
to John Ball, this is null-terminated ASCII.
According to Frank Durda, this is ASCII
terminated with carriage return, line feed,
and <control>-Z (1Ah).
2Ch byte <Control>-Z (1Ah). As with the old format,
this prevents the file from being typed to the
screen with the DOS TYPE command.
2Dh byte Format code: 80h.
2Eh word Number of sounds in the file, 1 for sound
files. Instrument files may have more than 1
sound (note).
30h byte Instrument number of an instrument file.
Sound files have 0 here.
31h 17 bytes Reserved, set to 0.
42h word Compression code (0 = no compression, 1 =
music compression, 2 = speech compression).
44h 20 bytes Compression information; refer to the PSSJ
Digital Sound Toolkit. This information does
not seem to be needed to decompress if
compression types 1 or 2 were used.
58h word Sampling rate in Hz.
5Ah word Reserved, set to 0.
5Ch word Hardware bias value, refers to the recording
hardware used. Refer to the PSSJ Digital
Sound Toolkit. If writing the file, you can
set this to 0.
5Eh 20 bytes Reserved, set to 0.
72h variable Sample descriptors begin.
Sample descriptors (number given by word at 2Eh above):
offset size what
------ ---- ----
0 dword Link to next sample descriptor (offset in file
of next sample descriptor record). 0 if last.
4 word Sound options, refer to the PSSJ Digital Sound
Toolkit. 1 = player should close the file
after playback. If writing the file, you can
set this to 0.
6 byte Pitch of note (01h-3Fh), 01 = A1 in American
Standard Pitch; 0FFh if not set.
7 byte Unknown (compare old .snd format; value is 00
or FF, but seemingly unrelated to pitch
setting). Only used by Sound.pdm, according
to Mr. Durda.
8 2 bytes Range of note. First byte is lower limit,
second is higher limit. Values as for byte
at offset 6 above; FF FFh if not set.
0Ah dword Offset in file of start of sound data for
this sample.
0Eh dword Length of sample sound data in bytes, after
compression if that was done.
12h dword Uncompressed length of sound data (number of
samples).
16h dword Start of sustain region.
1Ah dword End of sustain region.
1Eh 16 bytes Reserved, set to 0.
//// end of conv2snd.doc ////
[responsivevoice_button voice="US English Male"]