Ok, folks, don't laugh too hard.  Here is my very first attempt at 
GEM programming for the ST.  The program was done in assembly using 
DevPackST 2 from HiSoft.  A real nice package.  I NEED to update to 
DevPackST 3 RSN. 8^}

There has been a lot of interest in GEMSOUND, a very nice package 
that allows you to add sounds to AES events on the STes and TTs.  The 
problem has been that there were few samples available and they were 
in a wierd format, SoundWizard.  OUTRIDER (Terry) and I have been 
working on hacks via GEnie to convert various sound formats to 
something GEMSOUND will recognize.  What this consists of is adding 
a 12 byte header to the sound file and converting unsigned samples to 
signed samples.  That is what this program does.

What it does NOT do is resample the sample.  GEMSOUND is expecting 
to see a sample at 12.5KHz.  No matter what the sampling rate the 
sample was made at, GEMSOUND plays it back at 12.5 KHz.  So, you 
need 12.5KHz samples to start with.  If, like me, you have Replay 4 
you can make sound samples at 12.5 KHz and just convert them using 
TO_GSND.  Another very good option is to use the Shareware package 
SoundLab to resample samples you might already have.  Of course 
SoundLab will create samples at the 12.5KHz if you have a sampling 
cart.

To use TO_GSND just double click on it.  You will get an alert box 
asking if the input sample is a .SPL (unsigned, from Replay) or a 
.SAM (signed from somewhere - I don't know where - ask Terry).  Click 
on the appropriate box and then you will get a file selector looking 
for an input file of the appropriate type.  This box also tells the 
program whether or not conversion to signed samples is needed.

You will then (assuming everything went well) get another file 
selector looking for an output PATH.  Just get the path where you 
want it and click on OK.  The program will write a GEMSOUND 
compatible file to that path.  The file will have the same name as 
the input file but its extension will be .SMP.  It should be 12 bytes 
longer than the original file.

Hope y'all like it.  No more hex math.

This program is PUBLIC DOMAIN!  I make no claims against it.  I also 
take no responsibility for its actions.  It works on my 4 meg MSTe 
with tos 2.05.

For you programmers out there I am enclosing the source code.  As I 
mentioned this is my first try at ST programming and I would 
appreciate comments, positive and negative, as well as suggestions.  
I sure would like to know what I did right and what I did wrong and 
where I was somewhat stupid.  Thanks

I modified the GEM Macros and the AES lib file from DevPackST 2 to 
take advantage of the title feature in Charles F. Johnson's Shareware 
product, Little Green Selector.

If you wish to do the same, here are my changes.

In GEMMACRO.S modify the fsel_input macro as follows:

fsel_input	macro	path,filename,title1,title2
	move.l	\1,addr_in
	move.l	\2,addr_in+4
	IFNC	'\3',''
	move.l	\3,addr_in+8
	ENDC
	IFNC	'\4',''
	move.l	\4,addr_in+12
	ENDC
	aes	90
	endm


In AESLIB.S find the line

	dc.b	0,2,2	90

and change it to:

	dc.b	0,2,4	90

In the BSS section of AESLIB.S change addr_in as to the following

addr_in		ds.l	4



Mike Allen	(MIKE-ALLEN on GEnie)
Las Cruces, NM
11/21/92

**********************************************************************

Version 1.01

Corrected a problem that would lock up the ST if you tried to load a 
sound file larger than available memory - not probable if one is 
making samples for GEMSOUND, but shouldn't have happened anyway.  I 
found it trying to load a 3.5 meg sample.

Mike Allen
11/21/92

**********************************************************************

Version 1.02

Added the option to remain in the program in anticipation of Terry's 
request.

Mike Allen
11/22/92

**********************************************************************

Version 1.03

Changed the sequence in which things were done so that the path 
doesn't reset to the original default but remains at the last selection.  
This done at Terry's request and a good idea it was.

Mike Allen
11/22/92

**********************************************************************

Version 1.04

This is, I hope, the final version.  Maintains separate input and 
output paths.

Mike Allen
11/23/92

**********************************************************************

Version 1.05

Never done!  At Terry's suggestion (whom else?) removed the "More" 
alert box since the program can be exited from the input file type 
selector.  Also added the option to delete the input file.

Added support for AES call 91 (fsel_exinput).  This call added in TOS 
1.4 allows for prompts in the file selector box.  (CFJs Little Green 
Selector had that capability for years.)

Fixed a bug correcting the stack after freeing memory.

Mike Allen
12/10/92

**********************************************************************

Version 2.00 (aka TO_GSNDV)

Ok, so I couldn't leave well enough alone.  TO_GSNDV is functionally 
the same as TO_GSND version 1.05.  What I did was add sampled sound 
voice prompts to the various alert boxes and file selectors.  These 
samples are low quality (6.25 KHz) to save file/memory space.

To run TO_GSNDV just copy TO_GSNDV.PRG and the VOICE folder to the 
same directory.  Then just run TO_GSNDV.

If your machine is incapable of using dma sounds, TO_GSNDV will just 
act like TO_GSND.  If, however, dma sound is available, you will get 
a title voice with the title alert box.  You will then get an alert 
box (with voice) asking if you want to use the voice prompts.  If you 
select no, TO_GSNDV acts just like TO_GSND.  If you select yes, you 
will hear me prompting you for each alert box and file selector.

TO_GSNDV is smart enough to find out if you are using GEMSOUND.  If 
you are, it will turn GEMSOUND off while the voice prompts are 
active.  If you elect not to use the voice prompts or exit the 
program TO_GSNDV will turn GEMSOUND back on.

I learned a lot about the cookie jar and dma sounds writing this 
program.  In the UTILS folder you will find a couple of routines I 
wrote that I figure might be useful in the future.  One looks for a 
given cookie in the cookie jar and reads it.  If there is no cookie 
jar or the cookie doesn't exist it tells you that too.  The other 
routine plays dma sounds.

I hope you have as much fun using this program as I did writing it.  
TO_GSNDV, like TO_GSND, is public domain.  Although I have tested 
this program as much as possible, use of the program is at the user's 
risk.  I take no responsibility for any mis-happenings that may occur 
due to the use (or misuse) of this program.

Sure would like to find out if this program runs on a Falcon030 
(hint-hint).  I suspect it won't run under MultiTOS since I haven't 
opened a window for it.

Mike Allen
2/6/93

**********************************************************************

Version 2.01 (aka TO_GSNDV)

Found a minor bug.  If GEMSOUND wasn't installed you couldn't turn 
off the voice prompts.  I forgot to test without GEMSOUND - shame on 
me.

Mike Allen
2/9/93
