home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 September (IDG) / Sep99.iso / Shareware World / Info / For Developers / PlayerPRO 5.2 Dev.Kit Mac / MADH Library 5.2 / MADLibrary Source / PPPlug.h < prev    next >
Encoding:
Text File  |  1999-05-15  |  9.8 KB  |  267 lines  |  [TEXT/CWIE]

  1. /********************                        ***********************/
  2. //
  3. //    Player PRO 5.0 - DRIVER SOURCE CODE -
  4. //
  5. //    Library Version 5.0
  6. //
  7. //    To use with MAD Library for Mac: Symantec, CodeWarrior and MPW
  8. //
  9. //    Antoine ROSSET
  10. //    16 Tranchees
  11. //    1206 GENEVA
  12. //    SWITZERLAND
  13. //
  14. //    COPYRIGHT ANTOINE ROSSET 1996, 1997, 1998
  15. //
  16. //    Thank you for your interest in PlayerPRO !
  17. //
  18. //    FAX:                (+41 22) 346 11 97
  19. //    PHONE:             (+41 79) 203 74 62
  20. //    Internet:     RossetAntoine@bluewin.ch
  21. //
  22. /********************                        ***********************/
  23.  
  24. #ifndef __PPPLUGH__
  25. #define __PPPLUGH__
  26.  
  27. #ifndef __RDRIVERH__
  28. #include "RDriver.h"
  29. #endif
  30.  
  31. #if defined(powerc) || defined (__powerc)
  32. #pragma options align=mac68k
  33. #else
  34. #if !defined(THINK_C)
  35. #pragma options align=mac68k
  36. #endif
  37. #endif
  38.  
  39. /******************************************************************/
  40. //    *****************    FILTERS FOR SAMPLES/SOUNDS    ***************/
  41. //
  42. //    Your main function have to be in this form:
  43. //    OSErr main(     sData                    *theData,                    // Sample informations, see MAD.h
  44. //                    long                    SelectionStart,                // SelectionStart 
  45. //                    long                    SelectionEnd,                // SelectionEnd, your filter SHOULD apply his effect only on the selection
  46. //                    PPInfoPlug                *thePPInfoPlug                // Some functions of PlayerPRO that you can use in your plugs
  47. //                    short                    stereoMode)                    // StereoMode, see 'Silence.c' example
  48. //
  49. //    *****************                        ***********************/
  50. //
  51. //    If you want to reallocate theData or theData->data:
  52. //    
  53. //    if( theData->data != 0L) DisposPtr( theData->data);        // VERY IMPORTANT to free memory
  54. //    theData->data = NewPtr( newsize);                        // Use NewPtr ONLY to allocate memory!
  55. //    
  56. //    theData->size = newsize;                                // In bytes !! Even for 16 bits !
  57. //    
  58. //    Don't forget to UPDATE the theData->size !!!!!!!!!!!!
  59. //
  60. //    *****************                        ***********************/
  61. //
  62. //    About Resources:
  63. //
  64. //    Your Plug should have: Creator: 'SNPL', Type: 'PLug'
  65. //
  66. //    Your Plug have to have these resources:
  67. //
  68. //    - One resource CODE 1000 with 68k Code  ** You should NOT use the 68881 coprocessor **
  69. //    - One resource PPCC 1000 with PPC Code  (OPTIONAL: if PlayerPRO PPC version cannot find it, it will use the CODE 1000 68k resource)
  70. //    - One STR# resource :
  71. //
  72. //        1 string: Menu Name (see Instrument window in PlayerPRO)
  73. //
  74. /********************                        ***********************/
  75.  
  76. typedef struct
  77. {
  78.     void        *RPlaySoundUPP;            //    OSErr            RPlaySound( Ptr whichSound, long SoundSize, long whichTrack, long Period, long Amplitude, long loopStart, long loopLength)
  79.     void        *UpdateALLWindowUPP;    //    void            UpdateALLWindow( void)
  80.     void        *MyDlgFilterUPP;        //    pascal Boolean    MyDlgFilter( DialogPtr theDlg, EventRecord *theEvt, short *itemHit)
  81.     OSType        fileType;
  82.     
  83. } PPInfoPlug;
  84.  
  85. typedef OSErr            (*RPlaySoundUPP)        ( Ptr, long, long, long, long, long, long, unsigned long, Boolean);
  86. typedef void            (*UpdateALLWindowUPP)    ( void);
  87. typedef pascal Boolean    (*MyDlgFilterUPP)        ( DialogPtr, EventRecord*, short*);
  88.  
  89.  
  90. #if defined(powerc) || defined(__powerc)
  91.  
  92. #include "mixedmode.h"
  93.  
  94.         /****** POWERPC calls *********/
  95.  
  96. #define         RPlaySoundCallMode (    kCStackBased|\
  97.                 RESULT_SIZE( SIZE_CODE( sizeof(OSErr) ))|\
  98.                 STACK_ROUTINE_PARAMETER( 1, SIZE_CODE( sizeof( Ptr)))|\
  99.                 STACK_ROUTINE_PARAMETER( 2, SIZE_CODE( sizeof( long)))|\
  100.                 STACK_ROUTINE_PARAMETER( 3, SIZE_CODE( sizeof( long)))|\
  101.                 STACK_ROUTINE_PARAMETER( 4, SIZE_CODE( sizeof( long)))|\
  102.                 STACK_ROUTINE_PARAMETER( 5, SIZE_CODE( sizeof( long)))|\
  103.                 STACK_ROUTINE_PARAMETER( 6, SIZE_CODE( sizeof( long)))|\
  104.                  STACK_ROUTINE_PARAMETER( 7, SIZE_CODE( sizeof( long)))|\
  105.                  STACK_ROUTINE_PARAMETER( 8, SIZE_CODE( sizeof( unsigned long)))|\
  106.                  STACK_ROUTINE_PARAMETER( 9, SIZE_CODE( sizeof( Boolean))))
  107.                  
  108. #define CallRPlaySoundUPP( v1, v2, v3, v4, v5, v6, v7, v8, v9)        \
  109.         CallUniversalProc( thePPInfoPlug->RPlaySoundUPP, RPlaySoundCallMode, v1, v2, v3, v4, v5, v6, v7, v8, v9)
  110.  
  111. /**/
  112.  
  113. #define UpdateALLWindowCallMode (    kCStackBased)
  114.  
  115. #define CallUpdateALLWindowUPP()        \
  116.         CallUniversalProc( thePPInfoPlug->UpdateALLWindowUPP, UpdateALLWindowCallMode)
  117.  
  118. /**/
  119.  
  120. #else    /******** 68K calls ***********/
  121.  
  122. #define CallRPlaySoundUPP( v1, v2, v3, v4, v5, v6, v7, v8, v9)        \
  123.         (* (RPlaySoundUPP) (thePPInfoPlug->RPlaySoundUPP))( v1, v2, v3, v4, v5, v6, v7, v8, v9)
  124.  
  125. /**/
  126.  
  127. #define CallUpdateALLWindowUPP()        \
  128.         (* (UpdateALLWindowUPP) (thePPInfoPlug->UpdateALLWindowUPP))
  129.  
  130. /**/
  131. #endif
  132.  
  133. /********************                        ***********************/
  134. //
  135. //
  136. // RPlaySoundUPP    : See Developper Toolkit documentation. Play a SoundPtr at a specific Period by using PlayerPRO Driver.
  137. // UpdateALLWindow    : Check all PlayerPRO windows and update them if need it.
  138. // MyDlgFilterUPP    : to use with a ModalDialog function: allow movable dialog, PlayerPRO windows updating, Item 1 Frame, Copy/Paste support, Key support
  139. //
  140. //
  141. /********************                        ***********************/
  142.  
  143.  
  144. /******************************************************************/
  145. //******************* DIGITAL EDITOR PLUGS  ***********************/
  146. //
  147. //    Your main function have to be in this form:
  148. //    OSErr main(     Pcmd                    *Pcmd,                        // Digital Selection
  149. //                    PPInfoPlug                *thePPInfoPlug)                // Some functions of PlayerPRO that you can use in your plugs
  150. //
  151. //
  152. //    *****************                        ***********************/
  153. //
  154. //    If you want to reallocate Pcmd:
  155. //    
  156. //    if( Pcmd != 0L) DisposPtr( (Ptr) Pcmd);                            // VERY IMPORTANT
  157. //    Pcmd = NewPtrClear( sizeof( Pcmd) + noCell * sizeof( Cmd));        // Use NewPtr ONLY to allocate memory!
  158. //
  159. //    myPcmd->structSize     = sizeof( Pcmd) + noCell * sizeof( Cmd);
  160. //    
  161. //    Don't forget to UPDATE the myPcmd->structSize !!!!!!!!!!!!
  162. //
  163. //    *****************                        ***********************/
  164. //
  165. //    About Resources:
  166. //
  167. //    Your Plug should have: Creator: 'SNPL', Type: 'PPDG'
  168. //
  169. //    Your Plug have to have these resources:
  170. //
  171. //    - One resource CODE 1000 with 68k Code  ** You should NOT use the 68881 coprocessor **
  172. //    - One resource PPCC 1000 with PPC Code  (OPTIONAL: if PlayerPRO in PPC cannot find it, it will use the CODE 1000 resource)
  173. //    - One STR# resource :
  174. //
  175. //        1 string: Menu Name (see Button in Digital Editor window in PlayerPRO)
  176. //
  177. /********************                        ***********************/
  178.  
  179. typedef struct
  180. {
  181.     short            tracks;                    // number of tracks in myCmd[]
  182.     short            length;                    // number of rows in myCmd[]
  183.     short            trackStart;                // track ID of first track in myCmd[]
  184.     short            posStart;                // row ID of first row in myCmd[]
  185.     long            structSize;                // struct size in bytes - see Definition
  186.     Cmd                myCmd[];
  187. } Pcmd;
  188.  
  189. /******************************************************************/
  190. //******************* INSTRUMENTS IMPORT/EXPORT PLUGS  ************/
  191. //
  192. //    Your main function have to be in this form:
  193. //    OSErr main(     OSType                    order,                        // Order to execute
  194. //                    InstrData                *InsHeader,                    // Ptr on instrument header
  195. //                    sData                    **sample,                    // Ptr on samples data
  196. //                    short                    *sampleID,                    // If you need to replace/add only a sample, not replace the entire instrument (by example for 'AIFF' sound)
  197. //                                                                        // If sampleID == -1 : add sample else replace selected sample.
  198. //                    FSSpec                    *AlienFile,                    // IN/OUT file
  199. //                    PPInfoPlug                *thePPInfoPlug)                // Some functions of PlayerPRO that you can use in your plugs
  200. //
  201. //
  202. //    *****************                        ***********************/
  203. //    Actual plug have to support these orders:
  204. //
  205. //    order: 'TEST':    check the AlienFile to see if your Plug really supports it.
  206. //    order: 'IMPT':    convert the AlienFile into a PlayerPRO instrument. You have to allocate/dispose your sData*. NOT InsHeader!
  207. //    order: 'EXPT':    Convert current instrument&samples into a file.
  208. //    order: 'PLAY':    Play the sound file at base note via PlayerPRO driver in SYNC.
  209. //    *****************                        ***********************/
  210. //
  211. //    About Resources:
  212. //
  213. //    Your Plug should have: Creator: 'SNPL', Type: 'PPIN'
  214. //
  215. //    Your Plug have to have these resources:
  216. //
  217. //    - One resource CODE 1000 with 68k Code  ** You should NOT use the 68881 coprocessor **
  218. //    - One resource PPCC 1000 with PPC Code  (OPTIONAL: if PlayerPRO in PPC cannot find it, it will use the CODE 1000 resource)
  219. //    - One STR# resource :
  220. //
  221. //
  222. //        1 string: which kind of files your plug support (OSType value !!! 4 char) By example: 'WAVE', 'snd ', 'AIFF', etc...
  223. //        2 string: what does your Plug: EXPL : only Export files, IMPL : only Import Files, EXIM : import AND export.
  224. //        3 string: string that will be used in Import and Export menu of PlayerPRO
  225. //        4 string: Copyright string of this plug.
  226. //        5 string: Is it a sample or an instrument format? 'INST' or 'SAMP'
  227. //
  228. /********************                        ***********************/
  229.  
  230. OSErr    PPINImportFile( OSType    kindFile, short ins, short *samp, FSSpec    *AlienFile);
  231. OSErr    PPINTestFile( OSType    kindFile, FSSpec    *AlienFile);
  232. OSErr    PPINExportFile( OSType    kindFile, short ins, short samp, FSSpec    *AlienFile);
  233. OSType    PressPPINMenu( Rect    *PopUpRect, OSType curType, short, Str255);
  234. OSErr    PPINAvailablePlug( OSType    kindFile, OSType *plugType); // plugType == 'INST' or 'SAMP'
  235. OSErr    PPINGetPlugByID( OSType *type, short id, short samp);
  236.  
  237.  
  238. // SndUtils.c Definition :
  239.  
  240. Ptr ConvertWAV(FSSpec *fileSpec, long *loopStart, long *loopEnd, short    *sampleSize, unsigned long *rate, Boolean *stereo);
  241. OSErr ConvertDataToWAVE( FSSpec file, FSSpec *newfile, PPInfoPlug *thePPInfoPlug);
  242. void pStrcpy(register unsigned char *s1, register unsigned char *s2);
  243. Ptr     MyExp1to6( Ptr sound, unsigned long numSampleFrames);
  244. Ptr     MyExp1to3( Ptr sound, unsigned long numSampleFrames);
  245. void     ConvertInstrumentIn( register    Byte    *tempPtr,    register long sSize);
  246. OSErr inAddSoundToMAD(    Ptr                theSound,
  247.                         long            lS,
  248.                         long            lE,
  249.                         short            sS,
  250.                         short            bFreq,
  251.                         unsigned long    rate,
  252.                         Boolean            stereo,
  253.                         Str255            name,
  254.                         InstrData        *InsHeader,                    // Ptr on instrument header
  255.                         sData            **sample,                    // Ptr on samples data
  256.                         short            *sampleID);
  257. sData    * inMADCreateSample();
  258.  
  259.  
  260. #if defined(powerc) || defined (__powerc)
  261. #pragma options align=reset
  262. #else
  263. #if !defined(THINK_C)
  264. #pragma options align=reset
  265. #endif
  266. #endif
  267. #endif