home *** CD-ROM | disk | FTP | other *** search
- #Options Z
-
- // SoundPlay Driver for Sounds Saved By SoundCap¬ and recorded using the
- // MacNifty¬ Audio Digitizer. SoundCap¬ and MacNifty¬ Audio Digitizer
- // are marketed by: Kette Group, Inc.
- // 13895 Industrial Blvd.
- // Minneapolis, MN 55441
- // (800)-328-0184
- //
- // (SoundCap is a Trademark of Fractal Software)
- // (MacNifty is a Trademark of Kette Group, Inc.)
- //
- // SoundPlay was developed by Tom Hedges and Mark Zimmer of
- // Fractal Software, San Jose, CA.
- //
- // This file was compiled with Consulair Mac C¬ Rev 2.0
- //
- // mod 9 30 85 tsh - sound play driver
-
- #include "macdefs.h"
- #include "macCdefs.h"
- #include "MAZlib.h"
- #include "OSio.h"
- #include "packages.h"
- #include "pbDefs.h"
-
-
- #asm
- include SysEquX.D
- #endasm
-
- extern long int huffman_readsize();
- extern int huffman_input();
- extern play_back_sound();
-
- // IO packet
- extern ioParam huffIo;
-
- // I/O buffer
- #define iocnt 0x2000
-
- short iobuff[0x1010];
-
-
- // interface to standard file package
- SFGetFile(where, prompt, fileFilter, numTypes, typeList, dlgHook, reply)
- long *where; // really address of a point
- struct PStr *prompt;
- int (*fileFilter)();
- short numTypes;
- SFTypeList *typeList;
- int (*dlgHook)();
- SFReply *reply;
- {
- #asm
- MOVE.L D0,A0
- MOVE.L (A0),-(SP) ; WHERE
- MOVE.L D1,-(SP) ; PROMPT
- MOVE.L D2,-(SP) ; FILTER PROC
- MOVE.W D3,-(SP) ; numTypes
- MOVE.L D4,-(SP) ; typeList
- MOVE.L D5,-(SP) ; dlgHook
- MOVE.L D6,-(SP) ; reply
- MOVE #2,-(SP) ; PARM
- DC.W $A9EA ; _Pack3
- #endasm
- };
-
- // mainline
- main()
- {
- long count, sampling;
- short compressed, errcode, refnum;
- Point loc;
- unsigned char *buffer;
- SFReply reply;
- SFTypeList typeList;
- char filename[64];
-
- // get the name of the file to play
- typeList.ftype[0] = 'FSSD';
- loc.v = 80;
- loc.h = 100;
- SFGetFile(&loc, 0, 0, 1, &typeList, 0, &reply);
- // get out if cancelled
- if (reply.good == 0)
- return;
- // open sound file and get size
- count = huffman_readsize(&reply.Namelength, reply.vRefNum);
- // return if error
- if (count < -1)
- return;
- // test for non-compressed sound
- if (count == -1)
- {
- // flag non-compressed cound
- compressed = 0;
- // get size of the file
- PBGetEOF(&huffIo, false);
- count = huffIo.ioMisc;
- }
- else compressed = 1; // compressed sound
- // allocate buffer
- buffer = (unsigned char *)NewPtr(count);
- if (buffer == null)
- {
- // not enough room: close channel
- huffman_close();
- // and exit
- return;
- }
- // read the sound data in
- if (compressed)
- {
- // readin and unpack compressed sound data
- errcode = huffman_input(buffer, &sampling, iobuff, iocnt);
- }
- else
- {
- // read in the uncompressed sound directly
- huffIo.ioBuffer = (char *)buffer;
- huffIo.ioReqCount = count; // 2 longwords
- huffIo.ioPosMode = 1; // absolute
- huffIo.ioPosOffset = 0; // from the beginning
- PBRead(&huffIo, false);
- errcode = huffIo.ioResult;
- // assume sampling rate is 1
- sampling = 1;
- }
- // close channel
- huffman_close();
- // play the sound if there was no error reading in
- if (errcode == 0)
- play_back_sound(buffer, count, sampling);
- }
-