Wax Direct To Disk Player Professional Edition 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, November 13th 1994. Explanations about the .WAX files : You can store some small files with your tracks (same directory, same name but .WAX as extension) 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=dvsm. ; Put 16 for a 16-bit winrec DVSM unpacked file renamed as .TRK ; 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 dvsm (I can read Winrec samples but he cannot read mine : 2 bombs) ; automatic mono/stereo detect for dvs. ster=YES. ; can be YES. or NO. tells that this file should be replayed using a ; pseudo-stereo method if it is mono. (not for .DVS) dlay=25. ; see above : it is the delay in milliseconds that should be applied to slide ; the left and right channels. 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.dvs About using the Wax Player as a program : You shall declare it as an application for all .TRK, .DVS and .LT files. About using the Wax Player in accessory : You can rename the program WD2D_PRO.APP to WD2D_PRO.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. Some bombs appear when assembling under Devpac while playing a track, I still wonder why (I mean : is it my fault ?) You can also send him orders using the GEM messages (message number is 224) and send him three sorts of ASCII messages (look at the source CALL_WAX.S): - tell him to play a file : "play=g:\samples\track.trk" - tell him to stop playing : "stop" - tell him to convert a file : like this "conv=1,file1.trk,file2.trk," ; st‚r‚o -> mono "conv=2,file1.trk,file2.trk,file3.trk," ; st‚r‚o -> R & L "conv=3,file1.trk,file2.trk," ; mono -> st‚r‚o "conv=4,table.tab," ; choose compression table "conv=5,file1.trk,file2.dvs," ; TRK st‚r‚o -> DVS "conv=6,file1.trk,file2.dvs," ; TRK mono -> DVS "conv=7,file1.dvs,file2.trk," ; DVS -> TRK 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 (title, author, pack method, frequency, time of replay) on a .DVS file or, if a .LT file is selected, the time of replay for all files (*.DVS) 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) Method 2 : 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 3 : the most interesting, allows you to replay a track which has been compressed under DVS format : 50 % for same quality in 16 bits. (better though if packed with Wax D2D Player than Winrec 1.371 : longer time but finer compression table) Replay mono files in pseudo-stereo : if this menu is checked (or if ster=YES. in you .WAX file) then mono tracks will be replayed sliding the left and right channels of some milli-seconds (0 to 99). The value is set by the next option (see below) Not yet supported for .DVS files. Adjust pseudo-stereo delay : this is the value for pseudo-stereo effects in milliseconds, it can range from -99 to 99 including 0 : mono replay. The difference between a value of -45 and a value of +45 will be which channel will be 'in advance' : left or right ? You can try values during the replay, and it's very interesting to do it to see how the sounds starts by getting a sort of 'volume in space' to reach an echo effect for large values. You will also notice that it is TOTALLY DIFFERENT whether you are using headphones or amplificated speakers which are seperated by 5 meters (logical when you get to think about it) ... You can make some very impressive effects if the value is adapted to the layout of your room ... Conversion : Left/Right => Mono : Converts your track in mono (50% room) just doing (Channel L+ Channel R)/2. 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) 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) 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 => DVS : Mono track => DVS : DVS => original Track : You can now pack/depack your favorite tracks using the Wax packer, to stop conversion : press the left and right shift simultaneously. 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). The frequency saved in the file header is the one selected in the menu Frequency. 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 recorded by Winrec : 8-9 % DVSM converted by the Wax D2D Pro (optimum) : 3-4 % That is all for the use of the Wax Direct to Disk Player, Have Fun ! The DVS file format header: 6 bytes DVSM\0\0 length: 1 word distance of the sound data from the start of the file. freq: 1 word 0-7 : allowed CODEC frequencies (0: 8kHz ... 7: 49kHz) pack: 1 byte 0=not packed,2=DVS pack,4=voice pack mode: 1 byte 0=st‚r‚o 8bit, 1=st‚r‚o 16bit, 2=mono 8bit, 3=mono 16bit block_length: 1 long block length : for mono files 8*7*6*5*4*2+2 16 bytes followed by optional cookies (can be read or skipped) cookie_identify: 1 long cookie_length: 1 word should be 6 + length of the following data cookie_data: x bytes list of the so far recognized cookies : cookie Lenght of the data Usage ------------------------------------------------------------------------------------------------------------------------- 'LPKC' 1 word length of pack code in bits (8 -> 1) 'TITL' 26 bytes Title of the song 'AUTH' 26 bytes Author of the song 'CLCK' 1 word 0: intern clock, 1: extern CD, 2: extern DAT 'PEAK' 4 byte one word for the left and right channel containing the highest sample value 'DSPE' x bytes DSP program (soundeffect !!) in binary format 'PARA' x bytes x parameters for the sound effect. NOT before the 'DSPE' block! 'PACK' 512 or 16 bytes Deltapack table for the distance values. Used instead of the standard table. 'INFO' x bytes info text (e.g. full title) Not use in WinRec (by now) 'KARA' x Bytes karaoke text (see below) The maximal header length (all blocks together) is limited to 65535 Bytes. Every programm should parse the blocks, and decide to use them or not. karaoke text format --------------------------- long cookie='KARA' int len int textlen followed by the text ('textlen' bytes) in standard ASCII format. After this the extension included a measure table, with a long word (4 byte) for every word in the text. The long word contains the time distance to the next word in 1/sampling frequency 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 istortion 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 !