home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Periodicals / develop / develop Issue 11 / develop 11 code / MultiBuffer / MultiBuffer Source / MainApp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-15  |  4.9 KB  |  186 lines  |  [TEXT/MPS ]

  1.  
  2. #ifndef __MAININCLUDES__
  3. #define __MAININCLUDES__
  4. #endif
  5.  
  6.  
  7. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. // resources IDs
  9.  
  10. // Menus. The menu IDs  have an "m" prefix and item numbers have an "i" prefix.
  11.  
  12. #define    rMenuBar                1000    // application's menu bar
  13.  
  14. #define    mApple                    128        // Apple menu
  15. #define    iAbout                    1
  16.  
  17. #define    mFile                    129        // File menu
  18. #define    iPlay                    1
  19. #define iPlayBackwards            2
  20. #define    iRecord                    3
  21. #define iSynthisize                4
  22. #define    iKill                    5
  23. #define    iQuit                    7
  24.  
  25. #define    mEdit                    130        // Edit menu
  26. #define    iUndo                    1
  27. #define    iCut                    3
  28. #define    iCopy                    4
  29. #define    iPaste                    5
  30. #define    iClear                    6
  31.  
  32.  
  33. // window resources
  34.  
  35. #define rMainWindow                1000        // main window
  36.  
  37. #define rAmpButton                1000        // main window buttons
  38. #define rPitchButton            1001
  39.  
  40.  
  41. // dialog resources
  42.  
  43. #define    rAboutAlert                1000        // about alert
  44. #define    rUserAlert                1001        // user error alert
  45.  
  46.  
  47. // error strings resource
  48. #define    rErrStrings                1000        // error string list
  49.  
  50. #define    eSystemTooOld            1            // indicies into error STR# resource
  51. #define    eNoMenuBar                2
  52. #define    eNoMemory                3
  53. #define    eNoWindow                4
  54. #define eNoSndInDevice            5
  55. #define eRecording                6
  56. #define eGettingChan            7
  57. #define eSndOutMgr                8
  58. #define eSndInMgr                9
  59. #define eResourceErr            10
  60. #define eFileErr                11
  61. #define eUnexpected                12
  62.  
  63. // other strings
  64. #define rAmpString                1000        // text drawn below the amplitude control
  65. #define rPitchString            1001        // text drawn below the pitch control
  66.  
  67.  
  68. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  69. // application constants
  70.  
  71. #define kOldestSystemAllowed    0x0602    // System 6.0.2 version number
  72.  
  73. #define kBackSleep        MAXLONG            // sleeping amount while in background
  74. #define kForeSleep        60                // sleep amount while in foreground
  75.  
  76. #define kFatalError        true            // error was fatal for AlertUser
  77.  
  78. #define kMiddleC        60                // meaningless baseFrequency
  79.  
  80. #define kMinSize        (160 * 1024)    // minimal partition for SIZE resource
  81. #define kPrefSize        (300 * 1024)    // preferred partition for SIZE resource
  82.  
  83. #define kMinHeap        (80 * 1024)        // minimal heap size I want to run in
  84. #define kMinSpace        (40 * 1024)        // minimal heap size left for toolbox
  85.  
  86. #define kDIPosition        *(Point *)0x00500070 // the topLeft for the Disk Init dialog
  87.  
  88. #define kAppCreator        'CAMl'            // creator type of this application
  89.  
  90. #define kFileType        'APPL'            // file type of this application
  91.  
  92. #define kControlTextOffset    24            // text is drawn this far below the controls
  93.  
  94. #define    kPitchDefault    440                // default pitch setting (A)
  95. #define kAmpDefault        64                // default amplitude
  96.  
  97. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  98. // typedefs
  99.  
  100. // typedefs cannot be used by Rez
  101. #ifndef forRez
  102.  
  103. struct MainWindow {
  104.     WindowRecord    window;
  105.     StringHandle    ampString;
  106.     StringHandle    pitchString;
  107. };
  108. typedef struct MainWindow MainWindow;
  109. typedef struct MainWindow *MainWindowPtr;
  110.  
  111.  
  112. struct WaveCycle {
  113.     unsigned short    length;
  114.     Ptr                wavePtr;
  115. };
  116. typedef struct WaveCycle WaveCycle;
  117. typedef struct WaveCycle *WaveCyclePtr;
  118.  
  119. #endif
  120.  
  121. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  122. // handy macros
  123.  
  124. // C macros cannot be used by Rez
  125. #ifndef forRez
  126.  
  127. // this is much better than the toolbox calls
  128. #define HiWrd(aLong)    (((aLong) >> 16) & 0xFFFF)
  129. #define LoWrd(aLong)    ((aLong) & 0xFFFF)
  130.  
  131. // This will insert debugging code in the application to check conditions
  132. #if _DEBUG
  133. #define Assert(cond, s)            if (cond) DebugStr (s)
  134. #else
  135. #define Assert(cond, s)            ((void)    0)
  136. #endif
  137.  
  138. // This will display a message in the debugger
  139. #if _VERBOSE
  140. #define DebugMessage(s)            DebugStr (s)
  141. #else
  142. #define DebugMessage(s)            ((void)    0)
  143. #endif
  144.  
  145.  
  146. #endif
  147.  
  148.  
  149. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  150. // prototypes for file outside of the main source file
  151.  
  152. // C function prototypes cannot be used by Rez
  153. #ifndef forRez
  154.  
  155. // From the source file AIFFGoodies.c
  156. OSErr        OpenAIFFFile (short *fRefNum);
  157. long        GetAIFFHeaderInfo (short frefNum, SoundHeaderPtr theHeader);
  158. OSErr        RecordAIFFFile (OSType creator);
  159.  
  160.  
  161. // From the source file DoubleBuffers.c
  162. OSErr        InitDoubleBuffer(void);
  163. void        CloseDoubleBuffer(void);
  164.  
  165. OSErr        PlayFile(Boolean foreward, Ptr *privateData);
  166. void         PlayWave (long durration, WaveCyclePtr theWave, Ptr *privateData);
  167.  
  168.  
  169. OSErr        DoubleBuffer (SndChannelPtr chan, unsigned long fileRefNum, ProcPtr readproc, ProcPtr processproc,
  170.                         SoundHeaderPtr generalHeader, unsigned long playSize, long dataOffset, Ptr *privateData);
  171.                         
  172. void         FreeDBPrivateMem (void *freeSpace);
  173.                         
  174. void         KillDoubleBuffer (void);
  175. OSErr        ReadProc (void  *private, short bufNum, Boolean asynch);
  176. void        ProcessingProc (void);
  177. OSErr        BackReadProc (void *private, short bufNum, Boolean asynch);
  178. void        BackProcessingProc (void);
  179. pascal void DBService(SndChannelPtr chan, SndCommand* acmd);
  180.  
  181. // From the source file Oscilator.c
  182. WaveCyclePtr NewWaveForm (unsigned char amplitude, unsigned short frequency);
  183.  
  184. #endif
  185.  
  186.