Eplay: The Atari STe audio sample player
*********** Eplay ***********
Version 2.0 07/22/90
Public Domain
The STe audio sample player
(via the STe DMA soundchip)
By: AAron nAAs
AAron@sun.soe.clarkson.edu
*****************************
To use Eplay effectively you should understand at least "a little" about how the STe DMA sound chip works. The info given to it stays in it until it is intentionally changed. Among the information the chip can be given, are the playback RATE (6.25/12.5/25/50 kHz.), Mono/Stereo MODE and the location of the SAMPLE. And of course how to PLAY the sample, Once/Loop/Stop. Master Volume, Left/Right Channel Volume, Treble, Bass and Mix are also settable. So if you play a sample with certain parameters, then play another sample without specifying new parameters, the old settings will still be used ("remembered").
The sample memory is a collection of contiguous Words (two bytes) where each byte is a Signed number (from -128 to 127) which represents the speaker displacement, where 0 is "neutral." If the chip is in stereo mode, the upper byte of each word is played through the left speaker, and the lower byte through the right speaker. So, to play a sample only through one speaker, the sample must be loaded into every other byte.
**********
There are many ways a sample can be stored, one way (a very popular format for ST audio samples), is that each byte is an UNSIGNED number. Eplay can translate these bytes to Signed numbers while loading, so that they playback correctly.
Another problem arises when you try to play a sound that wasn't sampled in one of the four playback rates the chip supports. There is more to the sample conversion than just skipping or stuffing bytes to adjust the playback rate (It wouldn't sound right). I will be working on a progam that recalculates samples from one sample rate to another sample rate. So, until then, if you want to play a sound that was sampled at the popular 10kHz or 15kHz rates, you have to live with chosing a sample playback rate that is "close" to the rate you want.
**********
ALSO remember that each time you run a program, it is most likely that all free memory is cleared. So if you start a sample looping, it will continue playing correctly until you run another program (where the sample will be blanked, and it will end up playing whatever is put there), unless you protect the sample when you load it. Of course if you protect a sample you loose some free memory (more precisely the amount just about equals the size of the sample plus the size of the player, even though its only the sample you wanted to protect).
**********
Usage:
**********
(Rename eplay.tos to eplay.ttp if you want to pass parameters from the desktop)
Examples (all examples are to be considered independant of each other,
and note that the input is not case sensative, and the order
of the parameters does not matter):
1) eplay sample1.spl
(will play sample1.spl at 12kHz, in mono
mode, once, which are defaults)
2) eplay -lu sample1.spl -r0 -ms -pl
(will play sample1.spl at 6.25kHz, in stereo
mode, looping continuously. It will continue
playing the memory where the sample is/was,
and if something happens to the memory where
the sample is/was, it ends up playing whatever
happens to end up in that location. This won't
hurt anything, it will just end up sounding
really wierd.
The 'u' after the "-l" causes the sample to be
translating from Unsigned bytes.)
eplay -ps
(Stops the sample playing)
3) eplay -lu sample1.spl -r3 -ms -pl -k
(will do what the above did, but the "-k"
informs the computer to "Keep" the memory
so it is not corrupted in the future.
Sample1.spl will continue to play again, and
again, and again, ...)
eplay -ps
(Stops the sample playing)
eplay -pl
or (Starts it looping again)
eplay -po
(Plays it one more time)
4) eplay -lu sample1.spl -r3 -mm -pl -k
eplay -r2
(slows loaded sample to 24.5 kHz)
eplay -ms
(switches play Mode to Stereo, which since it
is playing two bytes at a time, effectively
doubles the playback rate)
eplay -po
or (Lets the sample play to completion then stops)
eplay -ps
(Stops the sample immediately)
5) eplay -lru sample1.spl -r0 -pl -k
(Loads sample1.spl into only the Right speaker,
translating Unsigned, and plays at 6.25 kHz.,
and "Keeps" it's memory. We note the locations
that eplay loaded the sample into, and refer
to them as 0xStart and 0xEnd in the next line.
The program saw "-lr", and assumed stereo Mode)
eplay -llu sample2.spl -s 0xStart 0xEnd
(Loads sample2.spl into only the Left speaker,
translating Unsigned, and loads as much as it
can into the memory protected by the above line.
Note the memory has already been protected, so
there is no need to protect it again.)
(Result: sample1.spl playing from right speaker,
sample2.spl playing from left speaker, over,
and over, and over ... at 6.25 kHz.)
eplay -ps
(Stops the sample playing)
(Try something like this!!)
6) eplay -lru sample1.spl -r1 -k -pl
(Noting 0xStart and 0xEnd again, now add 0x1000
to 0xStart and call it 0xStart2 and put our
values into the next line.)
eplay -llu sample1.spl -s 0xStart2 0xEnd
(You should end up with the whole sample playing
in the right ear, and in the left ear, the same
sample lagging behind by 0x1000 bytes, and
missing the last 0x1000 bytes, pretty weird
sounding!)
eplay -ps
(Stops the sample playing)
**********
Final words:
Have fun, and remember that if you use the "-k" option, you don't get your free memory back!!!
And, you can play memory ANYWHERE in the computer with the "-s" option, but if you start loading samples into memory that you haven't protected, (Kept with "-k"), you could crash your computer or corrupt other programs!
But hey, just turn the computer off, and start playing again!
**********
Possession stuff:
As stated previously, I am releasing this into the public domain, though I reserve all rights to the executable and the sourcecode. Copying and distributing this package AS A WHOLE is not only permitted, but encouraged. If profit can be made using this package, or ANY part of it, an agreement must be made with me before any profit can be collected.
Address:
AAron nAAs
8 W. Elizabeth St.
Skaneateles, NY (USA)
13152
E-Mail:
AAron@sun.soe.clarkson.edu
**********