home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-06-20 | 31.6 KB | 1,334 lines |
- 18-Jun-88 14:44:25-MDT,33609;000000000000
- Return-Path: <u-lchoqu%sunset@cs.utah.edu>
- Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 14:43:40 MDT
- Received: by cs.utah.edu (5.54/utah-2.0-cs)
- id AA22654; Sat, 18 Jun 88 14:43:38 MDT
- Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
- id AA24788; Sat, 18 Jun 88 14:43:33 MDT
- Date: Sat, 18 Jun 88 14:43:33 MDT
- From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
- Message-Id: <8806182043.AA24788@sunset.utah.edu>
- To: rthum@simtel20.arpa
- Subject: SoundDemo.c.shar
-
- #! /bin/sh
- #
- # This is a shell archive. Save this into a file, edit it
- # and delete all lines above this comment. Then give this
- # file to sh by executing the command "sh file". The files
- # will be extracted into the current directory owned by
- # you with default permissions.
- #
- # The files contained herein are:
- #
- # 1 SoundDemo.a
- # 8 SoundDemo.c
- # 7 SoundDemo.r
- # 2 Makefile
- # 1 Notes.r
- # 5 ErrDialog.c
- # 7 ErrDialog.r
- #
- echo 'Extracting SoundDemo.a'
- if test -f SoundDemo.a; then echo 'shar: will not overwrite SoundDemo.a'; else
- sed 's/^X//' << '________This_Is_The_END________' > SoundDemo.a
- X*
- X* Sound Demonstration Program
- X* written for the Boston MacWorld Expo
- X* using the Macintosh Programmer's Workshop
- X*
- X* (c) 1986 Fred A. Huxham
- X*
- X*------------------------------------------
- X* This is some assembly language glue
- X* to setup and restore register A5 around
- X* the call to our Vertical Retrace Task
- X*------------------------------------------
- X*
- X INCLUDE 'SysEqu.a'
- X
- X IMPORT mySoundVBL
- X
- XVBLGlue PROC EXPORT
- X MOVEM.L A4-A5/D4-D7,-(SP) ;Save our Registers
- X MOVE.L CurrentA5,A5 ;Restoring A5
- X JSR mySoundVBL ;Jump to our VBL Task
- X MOVEM.L (SP)+,A4-A5/D4-D7 ;Restore our Registers
- X RTS ;and return
- X ENDPROC
- X
- X END
- ________This_Is_The_END________
- if test `wc -l < SoundDemo.a` -ne 26; then
- echo 'shar: SoundDemo.a was damaged during transit'
- echo ' (should have been 26 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'Extracting SoundDemo.c'
- if test -f SoundDemo.c; then echo 'shar: will not overwrite SoundDemo.c'; else
- sed 's/^X//' << '________This_Is_The_END________' > SoundDemo.c
- X/*
- X* Sound Demonstration Program
- X* written for the Boston MacWorld Expo
- X* using the Macintosh Programmer's Workshop
- X*
- X* (c) 1986 Fred A. Huxham
- X*
- X*--------------------------------------
- X* This is the Main code
- X*--------------------------------------
- X*
- X*/
- X
- X
- X/* Macintosh Include Files */
- X#include <types.h>
- X#include <resources.h>
- X#include <quickdraw.h>
- X#include <fonts.h>
- X#include <events.h>
- X#include <windows.h>
- X#include <controls.h>
- X#include <dialogs.h>
- X#include <segload.h>
- X#include <files.h>
- X#include <retrace.h>
- X
- X/* Constant Values */
- X#define TRUE 1
- X#define FALSE 0
- X#define NIL 0
- X#define MiddleC 25
- X#define BuffSize 63
- X
- X/*------------------------------------------------------------------*/
- X/* Our own definitions of the SquareWave Sound Data Structures */
- X/*------------------------------------------------------------------*/
- X#define swMode (-1)
- X
- Xtypedef struct Tone {
- X short count;
- X short amplitude;
- X short duration;
- X} Tone;
- X
- Xtypedef Tone Tones[BuffSize];
- X
- Xtypedef struct SWSynthRec {
- X short mode;
- X Tones triplets;
- X} SWSynthRec, *SWSynthPtr;
- X
- X/* Global Variables */
- Xshort Sound, theNote, **theNotes;
- XVBLTask SoundTask;
- XIOParam *SndParamPtr;
- XSWSynthPtr SqWvPtr;
- X
- X/* External Functions */
- Xvoid VBLGlue();
- X
- X/*==================================================================*/
- X/* Our restart procedure for InitDialogs */
- X/*==================================================================*/
- Xvoid reStartProc()
- X{
- X ExitToShell();
- X}
- X
- X
- X/*==================================================================*/
- X/* Our Vertical Blanking Interrupt routine */
- X/*==================================================================*/
- Xvoid mySoundVBL()
- X{
- X SoundTask.vblCount = 1; /* Reset our task counter */
- X
- X if(Sound) {
- X if(SndParamPtr->ioActCount >= 370) SndParamPtr->ioActCount = 0;
- X }
- X}
- X
- X
- X/*==================================================================*/
- X/* This routine sets up the Square Wave Synthesizer buffer */
- X/*==================================================================*/
- Xvoid SetUpSqWv()
- X{
- X short i;
- X
- X (*SqWvPtr).mode = swMode;
- X for(i = 0; i < BuffSize - 1; i++) {
- X (*SqWvPtr).triplets[i].count = 2994;
- X (*SqWvPtr).triplets[i].amplitude = 200;
- X (*SqWvPtr).triplets[i].duration = 1;
- X }
- X (*SqWvPtr).triplets[BuffSize - 1].count = 0;
- X (*SqWvPtr).triplets[BuffSize - 1].amplitude = 0;
- X (*SqWvPtr).triplets[BuffSize - 1].duration = 0;
- X
- X SndParamPtr->ioBuffer = (Ptr)SqWvPtr;
- X SndParamPtr->ioReqCount = (sizeof(SWSynthRec));
- X}
- X
- X
- X/*==================================================================*/
- X/* This routine starts the sound */
- X/*==================================================================*/
- Xvoid StartOurSound()
- X{
- X short result;
- X
- X result = PBWrite(SndParamPtr, TRUE);
- X if(result) OSError("PBWrite", result, "");
- X Sound = TRUE;
- X}
- X
- X
- X/*==================================================================*/
- X/* This routine stops the sound */
- X/*==================================================================*/
- Xvoid StopOurSound()
- X{
- X short result;
- X
- X result = PBKillIO(SndParamPtr, TRUE);
- X if(result) OSError("PBKillIO", result, "");
- X Sound = FALSE;
- X}
- X
- X
- X/*==================================================================*/
- X/* This routine changes the note to play */
- X/*==================================================================*/
- XChangeNote(whichNote)
- X short whichNote;
- X{
- X short newCount, i;
- X
- X newCount = (*theNotes)[whichNote - 1];
- X
- X (*SqWvPtr).mode = swMode;
- X for(i = 0; i < BuffSize - 1; i++) {
- X (*SqWvPtr).triplets[i].count = newCount;
- X (*SqWvPtr).triplets[i].amplitude = 200;
- X (*SqWvPtr).triplets[i].duration = 1;
- X }
- X (*SqWvPtr).triplets[BuffSize - 1].count = 0;
- X (*SqWvPtr).triplets[BuffSize - 1].amplitude = 0;
- X (*SqWvPtr).triplets[BuffSize - 1].duration = 0;
- X}
- X
- X
- X/*==================================================================*/
- X/* DoModeless takes a dialog item and a modeless dialog pointer */
- X/* as arguments, and responds to the user's actions appropriately */
- X/*==================================================================*/
- Xvoid DoModeless(whichItem,whichDialog)
- Xshort whichItem;
- XDialogPtr whichDialog;
- X{
- X short itemType;
- X ControlHandle item;
- X Rect box;
- X
- X if(whichItem >= 1 && whichItem <= 60) {
- X GetDItem(whichDialog, theNote, &itemType, &item, &box);
- X SetCtlValue(item, FALSE);
- X GetDItem(whichDialog, whichItem, &itemType, &item, &box);
- X SetCtlValue(item, TRUE);
- X theNote = whichItem;
- X ChangeNote(whichItem);
- X }
- X}
- X
- X
- X/*==================================================================*/
- X/* DoWindowStuff takes care of mouse-downs in the drag and goAway */
- X/* regions of the modeless dialog */
- X/*==================================================================*/
- Xvoid DoWindowStuff(theEvent,whichWindow,windowcode)
- XEventRecord *theEvent;
- XWindowPtr whichWindow;
- Xshort windowcode;
- X{
- X short result;
- X Rect screenRect;
- X
- X SetRect(&screenRect,10,30,502,332);
- X switch(windowcode) {
- X case inDrag:
- X DragWindow(whichWindow,&theEvent->where,&screenRect);
- X break;
- X case inGoAway:
- X if(TrackGoAway(whichWindow,&theEvent->where)) {
- X result = VRemove(&SoundTask);
- X if(result) OSError("VRemove", result, "");
- X StopOurSound();
- X ExitToShell();
- X }
- X break;
- X }
- X}
- X
- X
- X/*==================================================================*/
- X/* Here's our main event loop */
- X/*==================================================================*/
- Xmain()
- X{
- X extern struct qd qd;
- X
- X EventRecord theEvent;
- X DialogPtr modeless,whichDialog;
- X short whichItem,windowcode, itemType, i, result;
- X WindowPtr whichWindow;
- X Rect box;
- X ControlHandle item;
- X
- X /* The Standard Initializations */
- X InitGraf(&qd.thePort);
- X InitFonts();
- X FlushEvents(everyEvent, 0);
- X InitWindows();
- X InitDialogs(reStartProc);
- X InitCursor();
- X
- X /* Initialize our global variables */
- X Sound = FALSE;
- X theNote = MiddleC;
- X
- X /* Allocate our Pointers */
- X SqWvPtr = (SWSynthPtr)NewPtr(sizeof(SWSynthRec));
- X SndParamPtr = (IOParam *)NewPtr(sizeof(IOParam));
- X
- X /* Load the Notes resource */
- X theNotes = (short **)GetResource('Note', 8888);
- X if(ResError()) OSError("GetResource", ResError(), "in main()");
- X DetachResource(theNotes);
- X if(ResError()) OSError("DetachResource", ResError(), "in main()");
- X
- X
- X /* Set up the fields of the VBLTask */
- X SoundTask.qType = 1; /* 1 = vType */
- X SoundTask.vblAddr = VBLGlue;
- X SoundTask.vblCount = 1;
- X SoundTask.vblPhase = 0;
- X
- X /* Set up the Sound Parameter block */
- X SndParamPtr->ioCompletion = NIL;
- X SndParamPtr->ioRefNum = (-4);
- X
- X /* Fill in our SquareWave Pointer */
- X SetUpSqWv();
- X
- X /* put up the modeless dialog with middle C checked */
- X modeless = GetNewDialog(1000,NIL,(WindowPtr)-1);
- X GetDItem(modeless, theNote, &itemType, &item, &box);
- X SetCtlValue(item, TRUE);
- X ShowWindow(modeless);
- X
- X /* Install the VBLTask and then start the sound */
- X result = VInstall(&SoundTask);
- X if(result) OSError("VInstall", result, "");
- X StartOurSound();
- X
- X /* And here's the loop */
- X while (TRUE) {
- X if(GetNextEvent(everyEvent,&theEvent)) {
- X if(IsDialogEvent(&theEvent)) {
- X if(DialogSelect(&theEvent,&whichDialog,&whichItem)) {
- X DoModeless(whichItem,whichDialog);
- X }
- X }
- X switch (theEvent.what) {
- X case mouseDown:
- X windowcode = FindWindow(&theEvent.where,&whichWindow);
- X DoWindowStuff(&theEvent,whichWindow,windowcode);
- X break;
- X }
- X }
- X }
- X}
- ________This_Is_The_END________
- if test `wc -l < SoundDemo.c` -ne 283; then
- echo 'shar: SoundDemo.c was damaged during transit'
- echo ' (should have been 283 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'Extracting SoundDemo.r'
- if test -f SoundDemo.r; then echo 'shar: will not overwrite SoundDemo.r'; else
- sed 's/^X//' << '________This_Is_The_END________' > SoundDemo.r
- X/*
- X* Sound Demonstration Program
- X* written for the Boston MacWorld Expo
- X* using the Macintosh Programmer's Workshop
- X*
- X* (c) 1986 Fred A. Huxham
- X*
- X*--------------------------------------
- X* This is the Rez Code
- X*--------------------------------------
- X*
- X*/
- X
- X
- Xresource 'DLOG' (1000) {
- X {40, 10, 330, 376},
- X documentProc,
- X invisible,
- X goAway,
- X 0x0,
- X 1000,
- X "SquareWave SoundDemo"
- X};
- X
- Xresource 'DITL' (1000) {
- X { /* array DITLarray: 65 elements */
- X /* [1] */
- X {8, 8, 24, 40},
- X CheckBox {
- X enabled,
- X "C"
- X };
- X /* [2] */
- X {24, 8, 40, 48},
- X CheckBox {
- X enabled,
- X "C#"
- X };
- X /* [3] */
- X {40, 8, 56, 48},
- X CheckBox {
- X enabled,
- X "D"
- X };
- X /* [4] */
- X {56, 8, 72, 56},
- X CheckBox {
- X enabled,
- X "D#"
- X };
- X /* [5] */
- X {72, 8, 88, 40},
- X CheckBox {
- X enabled,
- X "E"
- X };
- X /* [6] */
- X {88, 8, 104, 40},
- X CheckBox {
- X enabled,
- X "F"
- X };
- X /* [7] */
- X {104, 8, 120, 56},
- X CheckBox {
- X enabled,
- X "F#"
- X };
- X /* [8] */
- X {120, 8, 136, 48},
- X CheckBox {
- X enabled,
- X "G"
- X };
- X /* [9] */
- X {136, 8, 152, 48},
- X CheckBox {
- X enabled,
- X "G#"
- X };
- X /* [10] */
- X {152, 8, 168, 40},
- X CheckBox {
- X enabled,
- X "A"
- X };
- X /* [11] */
- X {168, 8, 184, 48},
- X CheckBox {
- X enabled,
- X "A#"
- X };
- X /* [12] */
- X {184, 8, 200, 48},
- X CheckBox {
- X enabled,
- X "B"
- X };
- X /* [13] */
- X {8, 80, 24, 112},
- X CheckBox {
- X enabled,
- X "C"
- X };
- X /* [14] */
- X {24, 80, 40, 120},
- X CheckBox {
- X enabled,
- X "C#"
- X };
- X /* [15] */
- X {40, 80, 56, 120},
- X CheckBox {
- X enabled,
- X "D"
- X };
- X /* [16] */
- X {56, 80, 72, 128},
- X CheckBox {
- X enabled,
- X "D#"
- X };
- X /* [17] */
- X {72, 80, 88, 112},
- X CheckBox {
- X enabled,
- X "E"
- X };
- X /* [18] */
- X {88, 80, 104, 112},
- X CheckBox {
- X enabled,
- X "F"
- X };
- X /* [19] */
- X {104, 80, 120, 128},
- X CheckBox {
- X enabled,
- X "F#"
- X };
- X /* [20] */
- X {120, 80, 136, 120},
- X CheckBox {
- X enabled,
- X "G"
- X };
- X /* [21] */
- X {136, 80, 152, 120},
- X CheckBox {
- X enabled,
- X "G#"
- X };
- X /* [22] */
- X {152, 80, 168, 112},
- X CheckBox {
- X enabled,
- X "A"
- X };
- X /* [23] */
- X {168, 80, 184, 120},
- X CheckBox {
- X enabled,
- X "A#"
- X };
- X /* [24] */
- X {184, 80, 200, 120},
- X CheckBox {
- X enabled,
- X "B"
- X };
- X /* [25] */
- X {8, 152, 24, 184},
- X CheckBox {
- X enabled,
- X "C"
- X };
- X /* [26] */
- X {24, 152, 40, 192},
- X CheckBox {
- X enabled,
- X "C#"
- X };
- X /* [27] */
- X {40, 152, 56, 192},
- X CheckBox {
- X enabled,
- X "D"
- X };
- X /* [28] */
- X {56, 152, 72, 200},
- X CheckBox {
- X enabled,
- X "D#"
- X };
- X /* [29] */
- X {72, 152, 88, 184},
- X CheckBox {
- X enabled,
- X "E"
- X };
- X /* [30] */
- X {88, 152, 104, 184},
- X CheckBox {
- X enabled,
- X "F"
- X };
- X /* [31] */
- X {104, 152, 120, 200},
- X CheckBox {
- X enabled,
- X "F#"
- X };
- X /* [32] */
- X {120, 152, 136, 192},
- X CheckBox {
- X enabled,
- X "G"
- X };
- X /* [33] */
- X {136, 152, 152, 192},
- X CheckBox {
- X enabled,
- X "G#"
- X };
- X /* [34] */
- X {152, 152, 168, 184},
- X CheckBox {
- X enabled,
- X "A"
- X };
- X /* [35] */
- X {168, 152, 184, 192},
- X CheckBox {
- X enabled,
- X "A#"
- X };
- X /* [36] */
- X {184, 152, 200, 192},
- X CheckBox {
- X enabled,
- X "B"
- X };
- X /* [37] */
- X {8, 224, 24, 256},
- X CheckBox {
- X enabled,
- X "C"
- X };
- X /* [38] */
- X {24, 224, 40, 264},
- X CheckBox {
- X enabled,
- X "C#"
- X };
- X /* [39] */
- X {40, 224, 56, 264},
- X CheckBox {
- X enabled,
- X "D"
- X };
- X /* [40] */
- X {56, 224, 72, 272},
- X CheckBox {
- X enabled,
- X "D#"
- X };
- X /* [41] */
- X {72, 224, 88, 256},
- X CheckBox {
- X enabled,
- X "E"
- X };
- X /* [42] */
- X {88, 224, 104, 256},
- X CheckBox {
- X enabled,
- X "F"
- X };
- X /* [43] */
- X {104, 224, 120, 272},
- X CheckBox {
- X enabled,
- X "F#"
- X };
- X /* [44] */
- X {120, 224, 136, 264},
- X CheckBox {
- X enabled,
- X "G"
- X };
- X /* [45] */
- X {136, 224, 152, 264},
- X CheckBox {
- X enabled,
- X "G#"
- X };
- X /* [46] */
- X {152, 224, 168, 256},
- X CheckBox {
- X enabled,
- X "A"
- X };
- X /* [47] */
- X {168, 224, 184, 264},
- X CheckBox {
- X enabled,
- X "A#"
- X };
- X /* [48] */
- X {184, 224, 200, 264},
- X CheckBox {
- X enabled,
- X "B"
- X };
- X /* [49] */
- X {8, 296, 24, 328},
- X CheckBox {
- X enabled,
- X "C"
- X };
- X /* [50] */
- X {24, 296, 40, 336},
- X CheckBox {
- X enabled,
- X "C#"
- X };
- X /* [51] */
- X {40, 296, 56, 336},
- X CheckBox {
- X enabled,
- X "D"
- X };
- X /* [52] */
- X {56, 296, 72, 344},
- X CheckBox {
- X enabled,
- X "D#"
- X };
- X /* [53] */
- X {72, 296, 88, 328},
- X CheckBox {
- X enabled,
- X "E"
- X };
- X /* [54] */
- X {88, 296, 104, 328},
- X CheckBox {
- X enabled,
- X "F"
- X };
- X /* [55] */
- X {104, 296, 120, 344},
- X CheckBox {
- X enabled,
- X "F#"
- X };
- X /* [56] */
- X {120, 296, 136, 336},
- X CheckBox {
- X enabled,
- X "G"
- X };
- X /* [57] */
- X {136, 296, 152, 336},
- X CheckBox {
- X enabled,
- X "G#"
- X };
- X /* [58] */
- X {152, 296, 168, 328},
- X CheckBox {
- X enabled,
- X "A"
- X };
- X /* [59] */
- X {168, 296, 184, 336},
- X CheckBox {
- X enabled,
- X "A#"
- X };
- X /* [60] */
- X {184, 296, 200, 336},
- X CheckBox {
- X enabled,
- X "B"
- X };
- X /* [61] */
- X {208, 152, 237, 216},
- X StaticText {
- X enabled,
- X "Middle\nC"
- X };
- X /* [62] */
- X {208, 80, 256, 144},
- X StaticText {
- X enabled,
- X "One \nOctave\nBelow"
- X };
- X /* [63] */
- X {208, 8, 256, 72},
- X StaticText {
- X enabled,
- X "Two\nOctaves\nBelow"
- X };
- X /* [64] */
- X {208, 224, 256, 288},
- X StaticText {
- X enabled,
- X "One \nOctave\nAbove"
- X };
- X /* [65] */
- X {208, 296, 256, 360},
- X StaticText {
- X enabled,
- X "Two\nOctaves\nAbove"
- X }
- X }
- X};
- X
- Xresource 'ICN#' (128, "SoundIcon", purgeable, preload) {
- X { /* array: 2 elements */
- X /* [1] */
- X $"0000 1F00 0000 FF00 0007 F900 003F C100"
- X $"01FE 0100 01F0 0100 0100 0100 0100 0100"
- X $"0100 0100 0100 0100 0100 0100 FFFF FFFF"
- X $"0100 0100 0100 3D00 0100 7F00 0100 7F00"
- X $"FFFF FFFF 7F00 7F00 7F00 3C00 7F00 0000"
- X $"7F00 0000 FFFF FFFF 0000 0000 0000 0000"
- X $"0000 0000 0000 0000 FFFF FFFF 0000 0000"
- X $"0000 0000 0000 0000 0000 0000 0000 0000";
- X /* [2] */
- X $"FFFF FFFF FE7F 4B7B A400 C007 C660 0801"
- X $"C272 0601 C8D2 4E09 936B 6D29 A01B 2209"
- X $"A068 7E01 DFAF 3E51 80A0 2C01 C05B 8421"
- X $"C088 BE55 C106 5605 D193 E285 CA05 0107"
- X $"8739 0127 8381 0117 CCA1 0017 D801 BDD7"
- X $"C615 81A7 C147 6067 CCAB 32E7 D410 1C47"
- X $"C020 0C47 C4F1 0283 E685 608B E18B 1587"
- X $"E1BB 6027 F304 BB17 FC03 C1DB FFFF FFFF"
- X }
- X};
- X
- Xresource 'BNDL' (128, "SoundDemo") {
- X 'Snd1',
- X 0,
- X { /* array TypeArray: 2 elements */
- X /* [1] */
- X 'ICN#',
- X { /* array IDArray: 1 elements */
- X /* [1] */
- X 0,
- X 128
- X };
- X /* [2] */
- X 'FREF',
- X { /* array IDArray: 1 elements */
- X /* [1] */
- X 0,
- X 128
- X }
- X }
- X};
- X
- Xresource 'FREF' (128, "FREF 1") {
- X 'APPL',
- X 0,
- X ""
- X};
- X
- Xdata 'Snd1' (0) {
- X $"6522 536F 756E 6444 656D 6F22 0D41 2053" /* e"SoundDemo".A S */
- X $"6F75 6E64 2064 656D 6F6E 7374 7261 7469" /* ound demonstrati */
- X $"6F6E 2070 726F 6772 616D 0D77 7269 7474" /* on program.writt */
- X $"656E 2066 6F72 2074 6865 2042 6F73 746F" /* en for the Bosto */
- X $"6E20 4D61 6357 6F72 6C64 2045 7870 6F2E" /* n MacWorld Expo. */
- X $"2020 A931 3938 3620 4672 6564 2041 2E20" /* .1986 Fred A. */
- X $"4875 7868 616D" /* Huxham */
- X};
- X
- ________This_Is_The_END________
- if test `wc -l < SoundDemo.r` -ne 479; then
- echo 'shar: SoundDemo.r was damaged during transit'
- echo ' (should have been 479 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'Extracting Makefile'
- if test -f Makefile; then echo 'shar: will not overwrite Makefile'; else
- sed 's/^X//' << '________This_Is_The_END________' > Makefile
- X#
- X# Sound Demonstration Program
- X# written for the Boston MacWorld Expo
- X# using the Macintosh Programmer's Workshop
- X#
- X# (c) 1986 Fred A. Huxham
- X#
- X#--------------------------------------
- X# This is the Makefile
- X#--------------------------------------
- X#
- X# Options for the C compiler and Assembler
- XCOptions =
- XAOptions = -case on
- X
- X#------------------------------------------------------------
- X
- XSoundDemo.rsrc [dependency symbol] SoundDemo.r ErrDialog.r Notes.r
- X Rez -o SoundDemo.rsrc -t RSRC -c 'MPS ' [line continuation symbol]
- X {RIncludes}Types.r [line continuation symbol]
- X SoundDemo.r [line continuation symbol]
- X Notes.r [line continuation symbol]
- X ErrDialog.r
- X
- X#------------------------------------------------------------
- X
- XSoundDemo [dependency symbol] SoundDemo.a.o SoundDemo.c.o ErrDialog.c.o SoundDemo.rsrc
- X Duplicate -r -y SoundDemo.rsrc SoundDemo
- X Link -ot "APPL" -oc "Snd1" -o SoundDemo [line continuation symbol]
- X SoundDemo.a.o [line continuation symbol]
- X SoundDemo.c.o [line continuation symbol]
- X ErrDialog.c.o [line continuation symbol]
- X {CLibraries}CInterface.o [line continuation symbol]
- X {CLibraries}CRuntime.o [line continuation symbol]
- X {CLibraries}StdCLib.o
- X SetFile -a B SoundDemo
- X
- X#------------------------------------------------------------
- ________This_Is_The_END________
- if test `wc -l < Makefile` -ne 38; then
- echo 'shar: Makefile was damaged during transit'
- echo ' (should have been 38 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'Extracting Notes.r'
- if test -f Notes.r; then echo 'shar: will not overwrite Notes.r'; else
- sed 's/^X//' << '________This_Is_The_END________' > Notes.r
- X/*
- X* Sound Demonstration Program
- X* written for the Boston MacWorld Expo
- X* using the Macintosh Programmer's Workshop
- X*
- X* (c) 1986 Fred A. Huxham
- X*
- X*--------------------------------------
- X* This is Rez file that defines the
- X* square wave notes resource type
- X*--------------------------------------
- X*
- X*/
- X
- X
- Xtype 'Note' {
- X array NoteArray {
- X unsigned integer;
- X };
- X};
- X
- Xresource 'Note' (8888, "SqWvNotes", appheap, preload) {
- X {
- X 11977;
- X 11305;
- X 10670;
- X 10071;
- X 9506;
- X 8972;
- X 8469;
- X 7994;
- X 7545;
- X 7121;
- X 6722;
- X 6344;
- X 5988;
- X 5652;
- X 5335;
- X 5036;
- X 4753;
- X 4486;
- X 4234;
- X 3997;
- X 3772;
- X 3561;
- X 3361;
- X 3172;
- X 2994;
- X 2826;
- X 2668;
- X 2518;
- X 2377;
- X 2243;
- X 2117;
- X 1998;
- X 1886;
- X 1780;
- X 1680;
- X 1586;
- X 1497;
- X 1413;
- X 1334;
- X 1259;
- X 1188;
- X 1122;
- X 1059;
- X 999;
- X 943;
- X 890;
- X 840;
- X 793;
- X 749;
- X 707;
- X 667;
- X 629;
- X 594;
- X 561;
- X 529;
- X 500;
- X 472;
- X 445;
- X 420;
- X 397
- X }
- X};
- ________This_Is_The_END________
- if test `wc -l < Notes.r` -ne 85; then
- echo 'shar: Notes.r was damaged during transit'
- echo ' (should have been 85 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'Extracting ErrDialog.c'
- if test -f ErrDialog.c; then echo 'shar: will not overwrite ErrDialog.c'; else
- sed 's/^X//' << '________This_Is_The_END________' > ErrDialog.c
- X/***************************************************************************/
- X/* */
- X/* ErrDialog.c */
- X/* */
- X/* Contains code for ErrDialog, OSError & ErrMessage */
- X/* For use when debugging application code */
- X/* */
- X/* 10/2/85 DJ Burnard */
- X/* */
- X/* 10/27/85 - DJB Put error strings into STR# resource */
- X/* 11/30/85 - DJB Changed to an Alert! */
- X/* 05/03/86 - DJB Ported to MPW */
- X/* */
- X/***************************************************************************/
- X
- X/* include MPW C header files */
- X#include <types.h>
- X#include <strings.h>
- X#include <memory.h>
- X#include <quickdraw.h>
- X#include <windows.h>
- X#include <events.h>
- X#include <dialogs.h>
- X#include <resources.h>
- X
- X/* #include <corrections.h> */
- X/* #include <mystring.h> */
- X
- X#define TRUE 1
- X#define FALSE 0
- X#define NIL 0
- X
- X/* constant for error dialog kept in the resource fork*/
- X#define errDialogID 9999
- X#define errStringID 9999
- X#define myLastErr -120
- X#define noErr 0
- X
- X
- X
- XStr255 *Num2String(theNum, theStr)
- X long theNum;
- X Str255 *theStr;
- X /* This is a minor variation on the Binary-Decimal Conversion
- X Package of the same name. Here we have made the procedure
- X into a function returning a pointer to the string. */
- X{
- X NumToString(theNum, theStr);
- X return theStr;
- X}
- X
- Xlong String2Num(theStr)
- X Str255 *theStr;
- X /* This is a minor variation on the Binary-Decimal Conversion
- X Package of the same name. Here we have made the procedure
- X into a function returning the long number. */
- X{
- X long theNum;
- X
- X StringToNum(theStr, &theNum);
- X return theNum;
- X}
- X
- X
- X/*
- X * ErrMessage: djb 10/27/85
- X *
- X * Retrieve a message describing Mac OS Errors
- X * Expects the following parameters:
- X *
- X * theOSErr - an OSErr - error code returned by OS routine
- X *
- X * Message returned is in C format
- X */
- X
- Xchar *ErrMessage(theOSErr, mesg)
- X OSErr theOSErr;
- X char *mesg;
- X{
- X Str255 strtmp;
- X
- X if(theOSErr == noErr) {
- X strcpy(mesg, "noErr: False Alarm");
- X } else if(theOSErr > noErr) {
- X /* positive error code */
- X strcpy(mesg, Num2String(theOSErr, &strtmp));
- X strcat(mesg, " = Illegal Error Code > 0");
- X } else if((theOSErr < noErr) && (theOSErr > myLastErr)) {
- X /* get error message from STR# resource */
- X GetIndString(mesg, errStringID, -theOSErr);
- X } else {
- X /* an error code below the last one in STR# resource */
- X strcpy(mesg, Num2String(theOSErr, &strtmp));
- X strcat(mesg, ": Error not included in STR# resource");
- X }
- X return (mesg);
- X}
- X
- X
- X/*
- X * OSError: djb 10/02/85
- X *
- X * display an error message for system errors.
- X * Expects the following parameters:
- X *
- X * procName - C string (usually contains name of
- X * routine where error occurred)
- X * errNum - error code returned by system (OSErr)
- X * msg - C string (arbitrary error message)
- X */
- X
- XOSError(procName, errNum, msg)
- X char *procName, *msg;
- X OSErr errNum;
- X{
- X Str255 errMsg, trapMsg;
- X
- X /* paste together trap message */
- X strcpy(&trapMsg, procName);
- X strcat(&trapMsg, " reports an error");
- X
- X ErrDialog(&trapMsg, ErrMessage(errNum, &errMsg), msg);
- X}
- X
- X
- X/*
- X * ErrDialog: djb 10/02/85
- X *
- X * Alert programmer to an error situation
- X * Expects the following parameters:
- X *
- X * str1, str2, str3 - C strings (arbitrary error messages
- X * to the programmer)
- X */
- X
- XErrDialog(str1, str2, str3)
- X char *str1;
- X char *str2;
- X char *str3;
- X{
- X char *err = "Programmer Error:";
- X
- X ParamText(err, str1, str2, str3);
- X StopAlert(errDialogID, NIL);
- X}
- ________This_Is_The_END________
- if test `wc -l < ErrDialog.c` -ne 145; then
- echo 'shar: ErrDialog.c was damaged during transit'
- echo ' (should have been 145 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'Extracting ErrDialog.r'
- if test -f ErrDialog.r; then echo 'shar: will not overwrite ErrDialog.r'; else
- sed 's/^X//' << '________This_Is_The_END________' > ErrDialog.r
- X/***************************************************************************/
- X/* */
- X/* ErrDialog.r */
- X/* */
- X/* Contains resource definitions for */
- X/* ErrDialog, OSError & ErrMessage */
- X/* For use when debugging application code */
- X/* */
- X/* */
- X/***************************************************************************/
- X
- Xresource 'ALRT' (9999) {
- X {69, 99, 300, 410},
- X 9999,
- X ok,
- X visible,
- X 1,
- X ok,
- X visible,
- X 1,
- X ok,
- X visible,
- X 1,
- X ok,
- X visible,
- X 1
- X};
- X
- Xresource 'DITL' (9999) {
- X { /* array ditlarray: 5 elements */
- X {200, 120, 224, 176},
- X button {
- X enabled,
- X "OK"
- X };
- X {24, 64, 40, 288},
- X statictext {
- X disabled,
- X "^0"
- X };
- X {72, 16, 104, 288},
- X statictext {
- X disabled,
- X "^1"
- X };
- X {112, 16, 144, 288},
- X statictext {
- X disabled,
- X "^2"
- X };
- X {152, 16, 184, 288},
- X statictext {
- X disabled,
- X "^3"
- X }
- X }
- X};
- X
- Xresource 'STR#' (9999) {
- X { /* array stringarray: 120 elements */
- X "-1 = queue element not found during deletion";
- X "-2 = invalid queue element";
- X "-3 = core routine number out of range";
- X "-4 = unimplemented core routine";
- X "-5 = undocumented error code";
- X "-6 = undocumented error code";
- X "-7 = undocumented error code";
- X "-8 = undocumented error code";
- X "-9 = undocumented error code";
- X "-10 = undocumented error code";
- X "-11 = undocumented error code";
- X "-12 = undocumented error code";
- X "-13 = undocumented error code";
- X "-14 = undocumented error code";
- X "-15 = undocumented error code";
- X "-16 = undocumented error code";
- X "-17 = driver can't respond to Control call";
- X "-18 = driver can't respond to Status call";
- X "-19 = driver can't respond to Read call";
- X "-20 = driver can't respond to Write call";
- X "-21 = refNum doesn't match unit table";
- X "-22 = refNum specifies NIL handle in unit table";
- X "-23 = driver ccan't respond to Open call";
- X "-24 = driver ccan't respond to Close call";
- X "-25 = tried to remove an open driver";
- X "-26 = DrvrInstall couldn't find driver";
- X "-27 = I/O call aborted by KillIO";
- X "-28 = can't rd/wr/ctl/sts - drvr not open";
- X "-29 = undocumented error code";
- X "-30 = undocumented error code";
- X "-31 = undocumented error code";
- X "-32 = undocumented error code";
- X "-33 = file directory full ";
- X "-34 = all allocation blocks on the disk are full";
- X "-35 = no such volume or directory";
- X "-36 = disk I/O error";
- X "-37 = bad file or volume/directory name (empty?)";
- X "-38 = file not found";
- X "-39 = logical EOF reached during read operation";
- X "-40 = attempt to position mark before start of file";
- X "-41 = system heap is full";
- X "-42 = too many files open (12 max)";
- X "-43 = file not found";
- X "-44 = disk is write protected (hardware)";
- X "-45 = file is locked (File System flag)";
- X "-46 = volume is locked (File System flag)";
- X "-47 = file is busy (File System flag)";
- X "-48 = a file with this name already exists";
- X "-49 = file already open with write permission";
- X "-50 = error in user parameter list (bad volume)";
- X "-51 = refNum specifies nonexistent access path";
- X "-52 = undocumented error code";
- X "-53 = volume not on-line";
- X "-54 = R/W permission doesn't allow writing";
- X "-55 = drive/volume already on-line";
- X "-56 = no such drive number/ not in queue";
- X "-57 = not a Mac disk/ bad directory format";
- X "-58 = external file system error";
- X "-59 = problem during _Rename";
- X "-60 = bad master dir block - reinitialize";
- X "-61 = R/W or open permission doesn't allow writing";
- X "-62 = undocumented error code";
- X "-63 = undocumented error code";
- X "-64 = drive not installed";
- X "-65 = R/W requested for an off-line drive";
- X "-66 = couldn't find 5 nibbles in 200 tries";
- X "-67 = couldn't find valid address mark";
- X "-68 = verify compare during _Read failed";
- X "-69 = bad address mark checksum";
- X "-70 = bad address mark slip nibbles";
- X "-71 = couldn't find a data mark header";
- X "-72 = bad data mark checksum";
- X "-73 = bad data mark slip nibbles";
- X "-74 = write underrun occurred";
- X "-75 = step handshake failed";
- X "-76 = track 0 detect doesn't change";
- X "-77 = unable to initialize IWM";
- X "-78 = tried to read 2nd side of 1-side drive";
- X "-79 = unable to correctlt adjust disk speed";
- X "-80 = track number wrong on address mark";
- X "-81 = sector number never found on track";
- X "-82 = undocumented error code";
- X "-83 = undocumented error code";
- X "-84 = first low-level disk error";
- X "-85 = unable to read same clock value twice";
- X "-86 = time written didn't verify";
- X "-87 = parameter RAM didn't read-verify";
- X "-88 = InitUtil found parameter RAM uninitialized";
- X "-89 = SCC receiver error (framing, parity, ...)";
- X "-90 = break received (SCC)";
- X "-91 = undocumented error code";
- X "-92 = undocumented error code";
- X "-93 = undocumented error code";
- X "-94 = undocumented error code";
- X "-95 = undocumented error code";
- X "-96 = undocumented error code";
- X "-97 = undocumented error code";
- X "-98 = undocumented error code";
- X "-99 = undocumented error code";
- X "-100 = no scrap exists";
- X "-101 = undocumented error code";
- X "-102 = no object of that type in scrap";
- X "-103 = undocumented error code";
- X "-104 = undocumented error code";
- X "-105 = undocumented error code";
- X "-106 = undocumented error code";
- X "-107 = undocumented error code";
- X "-108 = not enough memory in heap zone";
- X "-109 = Master Pointer is NIL";
- X "-110 = specified address is odd or out of range";
- X "-111 = attempt to operate on a free block";
- X "-112 = trying to purge a locked or non-purgeable block";
- X "-113 = address in zone check failed";
- X "-114 = pointer ckeck failed";
- X "-115 = block ckeck failed";
- X "-116 = size check failed";
- X "-117 = undocumented error code";
- X "-118 = undocumented error code";
- X "-119 = undocumented error code";
- X "-120 = undocumented error code"
- X }
- X};
- ________This_Is_The_END________
- if test `wc -l < ErrDialog.r` -ne 182; then
- echo 'shar: ErrDialog.r was damaged during transit'
- echo ' (should have been 182 bytes)'
- fi
- fi ; : end of overwriting check
- exit 0
-