home *** CD-ROM | disk | FTP | other *** search
- #include <BSDSoundLib.h>
-
- Handle snd;
- Boolean done = false;
- CursHandle left, center, right;
- short refNum, oldResFile;
- StandardFileReply file;
-
- void main (void);
- Boolean IsKeyPressed (unsigned short keycode);
- Boolean OpenSndFile (StandardFileReply *reply, short *refNum);
-
- Boolean IsKeyPressed (unsigned short keycode) {
- unsigned char km[16];
-
- GetKeys((unsigned long*)km);
- return ((km[keycode >> 3] >> (keycode & 7)) & 1);
- }
-
- Boolean OpenSndFile (StandardFileReply *reply, short *refNum) {
- SFTypeList typeList;
-
- typeList[0] = 'sfil';
- StandardGetFile(nil, 1, typeList, reply);
- if (reply->sfGood) {
- (*refNum) = FSpOpenResFile(&reply->sfFile, fsRdPerm);
- return(true);
- }
- return(false);
- }
-
- void main (void) {
- Str255 s;
- short freeChan = 0;
- Point mouse;
-
- MaxApplZone();
-
- InitGraf(&qd.thePort);
- InitDialogs(nil);
- InitFonts();
- InitWindows();
-
- FlushEvents(everyEvent, 0);
-
- HLockHi((Handle)(left = GetCursor(128)));
- HLockHi((Handle)(center = GetCursor(129)));
- HLockHi((Handle)(right = GetCursor(130)));
-
- InitSoundUtils(kMaxSndChans); //Initialize sound channels
-
- NumToString(numChannels, s);
- ParamText(s, nil, nil ,nil);
- Alert(128, nil);
- ParamText(nil, nil, nil, nil);
-
- oldResFile = CurResFile();
- if (!OpenSndFile(&file, &refNum)) ExitToShell();
-
- snd = GetIndResource('snd ', 1);
- HLockHi(snd);
- DetachResource(snd);
-
- CloseResFile(refNum);
- UseResFile(oldResFile);
-
- while (!done) {
-
- GetMouse(&mouse);
- if (mouse.h < 213) SetCursor((*left));
- else if (mouse.h > 426) SetCursor((*right));
- else SetCursor((*center));
-
- if (Button()) {
- freeChan = FindFreeChannel();
- if (freeChan != -1) {
-
- if (mouse.h < 213) SetChanVol(freeChan, kMaxLeft);
- else if (mouse.h > 426) SetChanVol(freeChan, kMaxRight);
- else SetChanVol(freeChan, kBalanced);
-
- PlaySoundChan(freeChan, snd); // play sound on a free channel
- if (Button()) Delay(15, nil);
- }
- }
-
- if ((IsKeyPressed(12) && IsKeyPressed(55)) ||
- (IsKeyPressed(53))) done = true;
- }
-
- DisposeSoundUtils(); // dispose sound channels
-
- HUnlock(snd);
- DisposeHandle(snd);
-
- HUnlock((Handle)left);
- ReleaseResource((Handle)left);
- DisposeHandle((Handle)left);
- HUnlock((Handle)center);
- DisposeHandle((Handle)center);
- ReleaseResource((Handle)center);
- HUnlock((Handle)right);
- DisposeHandle((Handle)right);
- ReleaseResource((Handle)right);
-
- InitCursor();
-
- FlushEvents(everyEvent, 0);
- }