home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Computer Club Elmshorn Atari PD
/
CCE_PD.iso
/
pc
/
0900
/
CCE_0940.ZIP
/
CCE_0940.PD
/
WAXPLAY
/
WAX_D2D.DOC
< prev
next >
Wrap
Text File
|
1994-10-25
|
18KB
|
692 lines
Wax Direct To Disk Player
This software was started in June/July 1993 just when I bought
my Falcon 030.
I started it with Gen at the time, and continued it alone.
It was working perfectly all right as TOS, so when Gen & I did
our Fabulous Macros Release 3
...
(just like an object-oriented language but in assembler, we only
code in assembler on the Falcon 030 because some other people
force us to code in C/Shell/Fortran on other shitty machines
(hey ! ya know the one starting with P and ending with C))
...
I decided to convert it into GEM environment (with multi-tos
possibilities) and finally I added lots a features (concerning
compression/decompression) so it has become what it is !
This program is written in what I call "Good assembler" it means
no supervisor rout, only Trap calls. The only possible
incompatibility with the future Falcon 040 is the Timer-A
interrupt routine which uses the hard addresses of the DMA sound
port. (Start/End replay Address)
I did it because using the xbios trap in interruption did bring
me some bombs sometimes, very strange by the way ...
With this fabulous software, you can play any sample which is
16 bits (mono or stereo) at any conventional frequency. Even
with external sync if you can connect one on your DSP port !
You can improve your comfort of listening in three ways :
- first : getting the fabulous selectrix which permits you to
play several samples or Play-List continuously.
- second : making some .WAX files (an example is provided
below) which should be put in the same directory as the track
and which permit to define the frequency, header length, and
format of your track (they will be loaded if they exist).
- third : making some .LT files (an example is provided below)
which permits you to prepare a list of the tracks that you want
to hear (just like a disk-jockey) even if they are on different
partitions.
Enjoy the quality.
WAX, Jully 18th 1994.
Explanations about the .WAX files :
You can store some small files with your tracks (same
directory) which give the infos about the file type. Useful if
they were recorded with D2D Edit (header included) or Falc D2D
(no frequency info).
Those files will allow you to play multiple files (if you have
selectrix) provided you put the good infos in them and that you
turn off the 'Loop' option.
Warning : they must not exceed 256 bytes : only the first 256
bytes will be loaded. (they will not, unless you put some very
big comments (like me))
Here is an implementation example :
dir f:\tracks\
SUSSUDIO.TRK 16458400 bytes. (16 bit track)
SUSSUDIO.WAX 213 bytes. (text file)
The .Wax files have this kind of format (edit them with any text editor) :
; put a dot : '.' after the end of each parameter.
head=16. ; can be anything if form=dvsw.
; Put 16 for a 16-bit winrec DVSM unpacked file.
; Put the good value for a D2D Edit file (I Don't know which one, I don't use it)
freq=49. ; can be 8,10,12,16,20,25,33,49.
form=16bs. ; can be 16bs (16 bit stereo) or 16bm (16 bit mono)
; or dvsw (dvswax)
; or in future : dvsm (winrec table, not yet implemented)
; automatic mono/stereo detect for dvsw.
Explanations about the .LT files :
You can create some small files (List of Tracks) which, once
loaded, allow you to play tracks which are on different
partitions, in the order that you want. (not a type classified
one like selectrix)
Here is an implementation example (don't put any tab or comment):
cat f:\tracks\list.lt
e:\wonder.trk
f:\samples\maximum.dvw
About using the Wax Player as a program :
You shall declare it as an application for all .TRK, .DVW and
.LT files.
About using the Wax Player in accessory :
You can rename the program WAX2PLAY.PRG to WAX2PLAY.ACC and
listen to tracks while working under mono-task environment.
Every ACC-CLOSE event will stop the music (so no bug when
changing resolution). If you want to stop the currently playing
track, then call the accessory again and press 'Cancel' on
file-selector.
You can also send him orders using the GEM messages (message
number is 224) and tell him : play=g:\samples\track.trk to play
a file or stop to stop playing. How easy ...
Some bombs appear when assembling under Devpac while playing a
track, I still wonder why (I mean : is it my fault ?)
Explanations about the menus :
Files :
Load :
choose your track(s) to be played. If you have selectrix then
you can play several tracks continuously. Don't forget to
disable the Loop option in this case.
If your track does not play then it means that another program
uses the Sound Semaphore, so stop it before !
If you had selected several tracks and you had stopped one,
you will not have the file selector(except if it was the last
one) and the next file will be played.
Get info on file :
Allows you to have information (pack method, frequency, time
of replay) on a .DVW file or, if a .LT file is selected, the
time of replay for all files (*.DVW) will be displayed.
Loop :
replays when you reach the end of the track. If a list of
tracks is selected : uncheck it !
Stop :
lets you stop the replay without exiting and liberates the
sound Semaphore.
Frequency :
You can choose your frequency 8 ... 49.
It will be set immediately if a sample is playing, or only at
loading initialization if none is played.
External or Internal will allow you to choose the
synchronization mode.
Method :
Method 1 : natural 16 bit stereo sound (natural for a Falcon
of course)
Methods 2 to 5 : strange methods to double (*2) (understand
guess values that does not exist) or even (*4) with linear,
second degree or Newton methods, not interesting for the result
itself (especially if you forget to double the frequency replay)
but for mathematical and sound studies (frequency and spectral
studies.)
Method 6 : allows you to play a mono sample (left=right) very
interesting compared to stereo 16 bit : 50 % of room for no
difference on tracks which do not use fabulous stereo effects.
Method 7 to 8 : same principle as methods 2 to 5 but in mono.
Method 9 : the most interesting, allows you to replay a track
which has been compressed with the DVSW (understand dvs wax)
packer (50 % for same quality in 16 bits)
Conversion :
Left/Right => Left + Right :
You take a stereo file and you create two mono files
containing the left and right sounds (useful to convert in mono
a file which has a much better channel than the other)
Left/Right => Mono :
Converts your track in mono (50% room) just doing (Channel L+ Channel R)/2.
Mono => Left/Right :
Just the opposite : puts the a mono channel on left & right
(you lose 100 % of room). This can be useful if your favorite
sample editor processes only stereo sounds. (Winrec for instance)
DVSM => Track :
Just to be compatible and let you depack your samples made
under Winrec and possibly re-pack them with the Wax player which
is more practical for multiple sample & multiple format replay.
You will not gain any quality if you repack it under Wax-D2D
because your sounds values, once unpacked, will be discreet (use
DVSM.TAB or better : DVSW1.TAB to pack again)
Choose compression table :
You will load the table that will be used for compression (see
next menus) your table must have $8000 as first value(0) , $0000
for value 128 and $7FFF for value 255. Its length must be of
256*2 bytes.
Some pre-calculated tables are given :
- DVSM.TAB : the table used by Winrec.
- DVSW1.TAB : same as DVSM but with never twice the same value
(it's no use having the same value twice, unless it's quicker to
pack/unpack (it's the case for Winrec))
- DVSW2.TAB : a table calculated to keep a theoretical
constant distortion rate (see menu below called Calculate
distortion) of 4.5%
- DVSW3.TAB : a table calculated for a 3.6 % but strangely
depending on the tracks does sometimes better, and sometimes
worse than the previous one.
- in fact DVSW2 = DVSW3 please, do analyze sample before.
Stereo track => Dvsw :
Mono track => Dvsw :
Dvsw => original Track :
You can now pack/depack your favorite tracks using the Wax
packer.
The table is saved in the compressed file and used for replay,
assuming full compatibility if you were to create your custom
compression table (optimizing your own criteria).
For your information :
It will take you an average 4.5 secs to get 128*1024 bytes
compressed.
The file format is the following :
1*1.L='DVSW' : header
1*1.B=1 : packed.
(always =1 : packed, otherwise I leaves the track with no header)
1*1.B=8 : packed in 8-bit table format (future 7, 6 ? bit pack).
1*1.B : 0=stereo, 1=mono.
1*1.B : frequency, 0=don't know, 1=49 KHz ... 11=8 KHz.
(the values are the same as Hardware Inits, look at your Compendium)
16-8=8*1.B=0 : for future extensions.
Total : 16*1.B : file infos.
256*1.W : the table used for packing.
2*1.W if stereo, 1*1.W otherwise. (starting channel(s) value(s))
This was for inits, then follows :
x*2.B : if stereo, or x*1.B : if mono.
the 8 bits values corresponding to the reference in the table.
.... until the end of the file.
Some example of a stereo replay routine :
; d6=left channel. (you must initialize them)
; d7=right channel. (by loading the first values)
lea start_of_8bits_values,a0
lea unpack,a1 ; buffer for DMA replay
lea table+128*2,a6
cool: move.b (a0)+,d1 ; depack is easy and in cache !!
ext.w d1
add.w (a6,d1*2),d6 ; d6 is ready
move.w d6,(a1)+
move.b (a0)+,d1 ; remove these 4 lines for mono replay.
ext.w d1
add.w (a6,d1*2),d7 ; d7 too , they can be stored or else ...
move.w d7,(a1)+
dbf d0,cool
Special : (available only for 6888x owners)
Analyze stereo track :
Lets you have an idea about the deltas (average, variance max
and min) which is very useful when you want to create your own
compression table which will be optimum for your own specific
sample.
Calculate distortion :
Just imagine that you have an original track (.TRK) (recorded
with Falc_D2D) that you compress it with different methods DVSM,
DVSW1(table 1) & DVSW2(table 2) and that you decompress them to
compare them with the original to calculate the difference
(because of course your ears can't hear anything). It is what
this program will do. You must create some .WAX files if you've
got some original DVSM files to set the header to 16 (otherwise
you'll get some amazing results)
The calculation is very simple :
you read a 16 bits value in the first sample : V1, you read
another in the second file : V2, you calculate (V1-V2)/V1 you do
it many times (128*1024/2) and you print the average result
multiplied by 1000.
You'll get what I call a "Distortion Rate".
Just for your general knowledge (and for my pride) :
DVSM : 8-9 %
DVSW (optimum) : 3-4 %
That is all for the use of the Wax Direct to Disk Player.
Have Fun.
Additional information :
How to create a constant distortion rate compression table :
Just imagine you have a value V (a delta of course) to
compress, you search in your compression table and you find that
the inferior value for your delta is Vi and that the superior
value is Vs. The biggest error in percentage would be if you had
to encode (Vi+Vs)/2. Let's assume that it's the case. Then you
set your relative-error (distortion rate) to T.
You'll get the following two equations :
T=(Vs-V)/V
T=(V-Vi)/V
Eliminating V, you get the following :
Vs=Vi*(1+T)/(1-T)=Vi*alpha
If you start at the 1 value then the second is given by the
formula: 1*alpha then 1*alpha^2...
If you assume that the maximum delta that can appear is 32767
(which is very close to reality), then you have a relation
between the number of bits for your table (8 bits <=> 256
values) and the distortion rate. You can even think about a 7
bit pack/unpack. (68030 or DSP only, if you have real time willings)
32767=1*((1+T)/(1-T))^(2^(n-1)-1)=alpha^127 for n=8.
8 bit table gives 4.12 % distortion
7bit : 8.36 %
6 bit : 17.15 %
5 bit : 35 %
4 bit : 70 %.
Creating your table this way (floating calculus), you will see
that some consecutive values are the same (at the beginning in
fact), you can do a test and so optimize again your table this
way :
value=1
repeat 2^(n-1)-1 times
store value;
next=int(value*alpha)
if next=value then next=value+1
value=next
loop
There are two ways :
- First : you calculate your tables making T smaller and
smaller each time, until you reach 32767 for last value. Then
you calculate your final table with the T that you found.
- Second : you don't touch T and then you'll get a greater
dynamic (your maximum delta will not be 32767 but bigger) but
it's less interesting and the Wax Player won't accept your table
because the last value is not 32767.
Your final table must be symmetrical in the way that 0 is in
the middle of the table (128th value), $7FFF is the last one
(255th) and -32768 the first value(offset 0), all your values
must be classified in the growing order and though two
consecutive values should not be equal, you can do it anyway.
You can do like me : you calculate the positive values
(algorithm is given) you then inverse (-) them for the negative
range, the final result should look like this :
-32768 -32767 ........... -4 -3 -2 -1 0 1 2 3 4 ...... 32767 : values
0 1 128 255 : index
Another approach : statistical compression table :
You can build your compression table in a second way. You scan
your sample and store the deltas, then you calculate the average
delta, and the variance. (this corresponds to the menu : Analyze
stereo track)
And then, assuming it's a Gaussian repartition you make your
values so that they are centered exponentially around the
average delta. Taking average +/- variance should bring you 66 %
of values, +/- 2*variance : 95 % , etc ...
I have tried, and it seems that the repartition is not quite
Gaussian.
You must not forget the values -1, 0 and 1 in your table,
otherwise it may happen that a follow-trajectory and a static
error appears.
Another way, that would lead to another format (why not?) would
be to analyze, let's say 128K of sample and to build a specific
table well adapted to it, and then to analyze another 128K and
to build a second table ... and so on (very little room lost
because 512 << 128*1024).
Even better, you could think about having deferent
bit-pack-codes in the same file (8 bit pack ... then 7 bit then
9 bit ... etc ... with headers giving you the pack size.
Always remember those basic rules to record a sound
(whichever) :
When you are talking about recording sounds, there are four
parameters that must be taken into account :
- the sampling frequency.
- the time of recording.
- the signal/noise rate.
- the maximum signal amplitude.
Sampling frequency :
you should theoretically take at least twice the maximum
harmonic frequency of your signal. In fact an average 10 times
is more realistic for your ears. For simple human voice on the
contrary, 8 KHz is far enough (humans hardly go over 1 KHz).
Please notice (and try it if you don't believe me) that your
ears don't make the difference between 33 KHz and 49 KHz for
99,9 % of tracks, whereas it is nearly twice the room in terms
of bytes.. Think about it ...
Time of recording :
depending only on you and on your hard disk ! Just know that
the room taken will be : freq*2*2 bytes*seconds_of_record for 16
bit stereo tracks.
The signal/noise rate :
Not depending on you, it comes directly from the source of
the sound. If it is a DDD laser disk : 96 DB, if it is a ADD or
AAD then 70 DB, finally if the source is a cassette then it goes
from 48 DB (Dolby A) to 68 DB (Dolby C).
Know for yourself that a sound recorded in 8 bit has a
signal/noise rate of 20*log(2^8)=48 DB and in 16 bit mode : 96
DB.
Direct deduction : IT IS TOTALLY USELESS (ROOM WASTING) TO
RECORD IN 16-BIT MODE A SOUND COMING FROM A DOLBY-A CASSETTE.
The maximum signal amplitude :
Depending on you totally, so you have to put you Falcon's
input gain at its maximum and then to regulate your source
output level so that your sound reaches just the limits of
saturation. The principle is to use your falcon input
attenuation at its minimum level so that your source amplifies
the least, because additional source distortion is directly
depending on the output level. (Whatever the analogic source)
Beware of one single thing : it may sometimes be more
intelligent to have some seconds of saturation in a 3 minute
long track but an improved global signal/noise, than to have no
saturation at all but a low average sound level. Don't forget
that you sometimes don't hear any saturation at all even if
there is one, and that anyway, the Wax D2D Player has no bug
when packing those sorts of tracks.
Global conclusion :
The Wax compression is better (no cheat) it has the advantage
of having no problem with saturation (not like Winrec, hum) but
it cannot be done in real time because lots a comparisons in .L
are needed. On the other hand, once packed it is strictly the
same principle and decompression algorithm (in assembler though)
as Winrec (I copied his very clever idea). Real time compression
could be done with 68040 or DSP but it does not interest me for
the time being. Finally, as my files are not made of blocks, no
easy copy/paste or seek can be done, but so easy to program !
ə