Checksum: 31370 Path: utzoo!utgpu!tomwest From: tomwest@gpu.utcs.utoronto.ca (Tom West) Date: Thu, 6-Jul-89 17:00:26 EDT Message-ID: <1989Jul6.170026.15228@gpu.utcs.utoronto.ca> Organization: University of Toronto Computing Services Newsgroups: comp.sys.mac.programmer Subject: Playing Sound Files & Help Request This program plays a sound file such as is produced by MacRecorder or used by Sound Master. I have included some documentation at the beginning. It is really very basic, but it does the job. My question is how would this be converted to use the Sound Manager? I have looked at the new-improved doc for it and I still can't figure it out. If anyone has a simple change to the last few lines to make change it to use the Sound Manager, please post. (I got a number of requests to post my results...) ---------------Cut Here--------------------------------- /* PlaySound This is a mind-numbingly simple program to play a sound file selected by SF file. Sound files of this type are used by Sound Master and are produced by MacRecorder. The format of a sound file is very simple. It just contains the sound data as it would be used by the free form synthesizer in the sound manager. The sound buffer for the FF synth looks like: int mode; The synth to use (free form = 1) Fixed count; The sampling speed (always 22k in this program) char waveBytes[]; The wave data The program just reads in the wave data and sticks in the appropriate beginning data. This program is based on Ron Butcher's article "Sounding off in MS QuickBasic" found in May '89 MacTutor (a superlative tech journal for the Macintosh). The only other point of interest is that Sound Files have type FSSD. */ main() { Point where; SFTypeList typeList; SFReply reply; OSErr err; short soundFile; long fileLength; char *soundBuffer , *newSoundBuffer; int i; InitGraf(&thePort); InitFonts(); InitWindows(); TEInit(); InitDialogs(0); where.v = 50; /* Place the SF Dialog somewhere */ where.h = 50; typeList[0] = (OSType) 'FSSD'; /* Display only Sound files */ /* in the SF window */ SFGetFile(where , "" , (ProcPtr) 0 , 1 , typeList , (ProcPtr) 0 , &reply); if (!reply.good) ExitToShell(); err = FSOpen(reply.fName , reply.vRefNum , &soundFile); if (err) ExitToShell(); err = GetEOF(soundFile , &fileLength); if (err) ExitToShell(); soundBuffer = NewPtr(fileLength + 6); if (!soundBuffer) ExitToShell(); err = SetFPos(soundFile , 1 , 0); if (err) ExitToShell(); newSoundBuffer = (char *)((long) (soundBuffer) + 6); err = FSRead(soundFile , &fileLength , newSoundBuffer); if (err) ExitToShell(); err = FSClose(soundFile); if (err) ExitToShell(); soundBuffer[0] = 0; /* int ffmode = 0 */ soundBuffer[1] = 0; soundBuffer[2] = 0; /* Fixed count = 1.0 */ soundBuffer[3] = 1; soundBuffer[4] = 0; soundBuffer[5] = 0; StartSound(soundBuffer , fileLength + 6 , (ProcPtr) -1); } Tom West tomwest@gpu.utcs.utoronto.ca tomwest@gpu.utcs.toronto.edu tomwest@utorgpu.bitnet west@turing.utoronto.ca west@turing.toronto.edu west@hsa.on.ca -- Tom West BITNET: tomwest@utorgpu.bitnet, tomwest@gpu.utcs.utoronto Internet: tomwest@gpu.utcs.utoronto.ca UUCP: tomwest@utgpu