home *** CD-ROM | disk | FTP | other *** search
/ NEXT Generation 27 / NEXT27.iso / pc / demos / emperor / dx3.exe / SDK / SAMPLES / DSSHOW / SHELL.H < prev    next >
C/C++ Source or Header  |  1996-08-28  |  12KB  |  298 lines

  1. /*==========================================================================
  2.  *
  3.  *  Copyright (C) 1995-1996 Microsoft Corporation. All Rights Reserved.
  4.  *
  5.  *  File:       shell.h
  6.  *  Content:    DirectSound shell header
  7.  *
  8.  ***************************************************************************/
  9. #ifndef __SHELL_INCLUDED__
  10. #define __SHELL_INCLUDED__
  11. // If this is defined, then an extra text string under the filename will show
  12. // if the file is stopped or playing.
  13. #define SHOWSTATUS
  14.  
  15. #define MAXCONTROLS             8
  16.  
  17. // For setting the ranges on the freq, vol, etc.
  18. // dwFreq*FREQMUL+FREQADD = # to show on screen.
  19.  
  20. #define FREQFACTOR              (5)                   
  21. #define FREQADD                 (0)
  22. #define FREQPAGE                (100)
  23. #define PANPAGE                 (5)
  24.  
  25. #define MINFREQ_TB              0
  26. #define MAXFREQ_TB              100000
  27. #define MINPAN_TB               0
  28. #define MIDPAN_TB               400
  29. #define MAXPAN_TB               800
  30. #define SHIFTPAN_TB             (-400)
  31. #define MULTPAN_TB              (10L)
  32. #define MINPAN_VAL              (-400)
  33. #define MIDPAN_VAL              0
  34. #define MAXPAN_VAL              400
  35. #define MINVOL_TB               0
  36. #define MAXVOL_TB               400
  37. #define SHIFTVOL_TB             (-400)
  38. #define MULTVOL_TB              (10L)
  39. #define MINVOL_VAL              -400
  40. #define MAXVOL_VAL              0
  41.  
  42.  
  43. // Id code deltas
  44. #define idFreqTB                1
  45. #define idPanTB                 2
  46. #define idVolLTB                3
  47. #define idVolRTB                4
  48. #define idVolMTB                5
  49. #define idLoopedBN              6
  50. #define idPlayBN                7
  51. #define idRemoveBN              8
  52.  
  53.  
  54. // UI stuff.
  55.  
  56.  
  57. #define DX_WIN_BORDER           30
  58. #define DY_WIN_BORDER           30
  59. #define DX_MINWINDOW            640
  60. #define DY_MINWINDOW            450                         // Was 560 Must tweek to keep above the taskbar <= 450
  61.  
  62. #define DX_CONTROLSPACING       150
  63. #define DY_CONTROLSPACING       0
  64.  
  65. #define DX_LINEEDGE             (DX_CONTROLSPACING - 20)
  66. #define DY_LINEEDGE             (1)
  67.  
  68.                                                             
  69. #define COX_STARTCONTROL        (20)                        // Defines the left edge of the first file window
  70. #define COY_STARTCONTROL        (10)                        // Defines the upper edge of the first file window
  71.  
  72. #define DX_TEXTSPACING          5                           
  73. #define DY_TEXTSPACING          10                          
  74.  
  75. #define DX_LOOPEDSPACING        0                           //Relative horizontal offset of top four areas
  76. #define DY_LOOPEDSPACING        -6                          //Space offset around lines 
  77.  
  78. #define DX_STATUSSPACING        0
  79.  
  80. #ifdef SHOWSTATUS
  81. #define DY_STATUSSPACING        8                           
  82. #else
  83. #define DY_STATUSSPACING        0                           
  84. #endif
  85.  
  86.  
  87. #define DX_FREQSPACING          0
  88. #define DY_FREQSPACING          10
  89.  
  90. #define DY_PANSPACING           10
  91. #define DY_VOLSPACING           10
  92.  
  93. //Establish the Widths of various windows:
  94. #define DX_FILENAME_TXT         120 //Filename window
  95. #define DX_STATUS_TXT           120 //Status window
  96. #define DX_FREQ_TXT             120 //Frequency window
  97. #define DX_PAN_TXT              100 //Pan window
  98. #define DX_VOL_TXT              100 //Volume window
  99. #define DX_LOOPED_TXT           100 //Checkbox + 'Looped' window
  100.  
  101. //Establish slider sizes:
  102. #define DX_FREQ_TB              130 //Frequency slider width
  103. #define DY_FREQ_TB              40  //Frequency slider height
  104. #define DX_PAN_TB       130 //Pan slider width
  105. #define DY_PAN_TB               40  //Pan slider height
  106. #define DX_VOL_TB               40  //Master volume slider width
  107. #define DY_VOL_TB               100 //Master volume slider height
  108. #define DX_VOLSPACING_TB        5   //Distance between master volume and its label
  109.  
  110. #define DX_VOLUMECHAR           15
  111. #define DY_VOLSPACINGY          -5  //Distance between channel mixers and L & R labels 
  112.  
  113. #define DX_BUTTONSPACING        61  //Width of the Play and Remove buttons
  114. #define DY_BUTTONSPACING        10
  115. #define DY_BEFOREFIRSTBUTTON    18  //Distance above and below Volume->buttons line
  116. #define DY_BETWEENBUTTONS       5   //Vertical space between buttons
  117.  
  118. #define DX_FRAMEEDGE            10  //Distance between leftmost control and the window edge
  119. #define DY_FRAMEEDGE            10  //Distance between outermost contol and the window edge
  120. #define DX_FRAMEEDGEINNER       4   //Distance between file windows
  121.  
  122.  
  123. // To check for stopping of sounds, a timer is set...use this for the rate.
  124. #define TIMERPERIOD     500 // In milliseconds
  125.  
  126. // In Options/Output Type, there are strings to pick the format...Here are the number of them.
  127. #define C_DROPDOWNPCMFORMATS    16
  128.  
  129. typedef struct _fileinfo
  130.     {
  131.     BYTE                *pbData;        // Pointer to actual data of file.
  132.     UINT                cbSize;         // Size of data.
  133.     WAVEFORMATEX    *pwfx;          // Pointer to waveformatex structure.
  134.  
  135.     DWORD               dwFreq;         // Frequency.
  136.     DWORD               dwPan;          // Panning info.
  137.     DWORD               dwVol;          // Total volume.
  138.     BOOL                fLooped;        // Looped?
  139.  
  140.     BOOL                fPlaying;       // Is this one playing?
  141.     BOOL                fLost;          // Is this one lost?
  142.     BOOL                fHardware;      // Is this a hardware buffer?
  143.     BOOL                fSticky;        // Is this a sticky buffer?
  144.  
  145.     int         cox;            // Coordinates of where the structure is
  146.     int         coy;            // printed.
  147.  
  148.     // HWND's needed.
  149.     HWND                hWndFileName_TXT;   // Filename text string.
  150.     HWND                hWndFreq_TB;        // Trackbar handle.
  151.     HWND                hWndFreq_TXT;       // Text string for freq.
  152.     HWND                hWndPan_TB;         // Trackbar handle.
  153.     HWND                hWndPan_TXT;        // Text string for pan.
  154.     HWND                hWndVol_TXT;        // Text string for volume.
  155.     HWND                hWndVolL_TB;        // Trackbar for volume left.
  156.     HWND                hWndVolR_TB;        // Trackbar for volume right.
  157.     HWND                hWndVolM_TB;        // Main volume.
  158.     HWND                hWndLooped_BN;      // Looped
  159.     HWND                hWndPlay_BN;        // Play
  160.     HWND                hWndRemove_BN;      // Remove.
  161.     
  162.     HWND                hWndFileName_EDGE;  // The line under filename.
  163.     HWND                hWndLooped_EDGE;    // The line under looped.
  164.     HWND                hWndFreq_EDGE;      // The line under freq.
  165.     HWND                hWndPan_EDGE;       // The line under pan.
  166.     HWND                hWndVol_EDGE;       // The line under volume.
  167.     HWND                hWndWhole_EDGE;     // The whole surrounding edge.
  168.     HWND                hWndVolL_TXT;       // For the L
  169.     HWND                hWndVolR_TXT;       // For the R
  170.  
  171.     #ifdef SHOWSTATUS
  172.     HWND                hWndStatus_TXT;     // For status.
  173.     HWND                hWndStatus_EDGE;
  174.     HWND                hWndPlayPosition_TXT;
  175.     HWND                hWndPlayPosition_EDGE;
  176.     HWND                hWndWritePosition_TXT;
  177.     HWND                hWndWritePosition_EDGE;
  178.     #endif
  179.  
  180.     LPDIRECTSOUNDBUFFER pDSB;               // Pointer to direct sound buffer.
  181.  
  182.     int                 nFileName;          // Index to filename, not including dir.
  183.     char                szFileName[MAX_PATH];
  184.     struct _fileinfo    *pNext;             // Pointer to next file.
  185.  
  186.     } FILEINFO;
  187.  
  188.  
  189. char            szAppName[]     = "Direct Sound Demo";
  190. char            szMessage[]     = "Direct Sound Demo";
  191.  
  192. char gszCDStartPath[MAX_PATH];          // The path to start the Open dialog in
  193.  
  194. // Registry Key and Value names that allow us to retrive a path something like
  195. // "C:\DXSDK\SDK\MEDIA", but matching the current install.
  196. const TCHAR gszRegKeyDirect3D[] = TEXT("Software\\Microsoft\\Direct3D");
  197. const TCHAR gszRegValueD3DPath[] = TEXT("D3D Path");
  198.  
  199. HANDLE          hInst;
  200. HWND            hWndMain        = NULL;
  201. DWORD           dwTimer         = 0;        // Timer handle.
  202. GUID                    guID;
  203. BOOL                    fEnumDrivers = FALSE;
  204.  
  205. /*  This is the main head of the linked list, but its only used for the
  206.     pNext which will point to the first FILEINFO structure, or NULL if there
  207.     are no files loaded  */
  208. FILEINFO        FileInfoFirst;              // Start of linked list.
  209.  
  210. char            szFreq[]        = "Freq";
  211. char            szPan[]         = "Pan";
  212. char            szVolume[]      = "Volume";
  213. char            szLooped[]      = "Looped";
  214. char            szPlay[]        = "Play";
  215. char            szStop[]        = "Stop";
  216. char            szRemove[]      = "Close";
  217.  
  218. #ifdef SHOWSTATUS
  219. char            szFmtPlayPosition[] = "Play %d";
  220. char            szFmtWritePosition[]    = "Write %d";
  221. char            szPlaying[]     = "Playing";
  222. char            szStopped[]     = "Stopped";
  223. char            szSticky[]      = "Sticky";
  224. char                    szLost[]        = "Lost";
  225. char            szHW[]          = "HW-";
  226. char                    szSW[]                  = "SW-";
  227. #endif
  228.  
  229.  
  230. char *rgszTypes[C_DROPDOWNPCMFORMATS] = 
  231.     {                                       // Index
  232.     "8.000 kHz, 8-Bit, Mono",               // 0
  233.     "8.000 kHz, 8-Bit, Stereo",             // 1
  234.     "8.000 kHz, 16-Bit, Mono",              // 2
  235.     "8.000 kHz, 16-Bit, Stereo",            // 3
  236.     "11.025 kHz, 8-Bit, Mono",              // 4
  237.     "11.025 kHz, 8-Bit, Stereo",            // 5
  238.     "11.025 kHz, 16-Bit, Mono",             // 6
  239.     "11.025 kHz, 16-Bit, Stereo",           // 7
  240.     "22.050 kHz, 8-Bit, Mono",              // 8
  241.     "22.050 kHz, 8-Bit, Stereo",            // 9
  242.     "22.050 kHz, 16-Bit, Mono",             // 10
  243.     "22,050 kHz, 16-Bit, Stereo",           // 11
  244.     "44.100 kHz, 8-Bit, Mono",              // 12
  245.     "44.100 kHz, 8-Bit, Stereo",            // 13
  246.     "44.100 kHz, 16-Bit, Mono",             // 14
  247.     "44.100 kHz, 16-Bit, Stereo"            // 15
  248.     };                                      
  249.  
  250. BOOL                    rgfcoxAvail[MAXCONTROLS];
  251.  
  252. LPDIRECTSOUND           gpds            = NULL;
  253.  
  254.  
  255. long FAR PASCAL WndProc(HWND, unsigned, WPARAM, LPARAM);
  256. long FAR PASCAL DLGHelpAbout(HWND, UINT, WPARAM, LPARAM);
  257. long FAR PASCAL DLGOutputBufferType(HWND, UINT, WPARAM, LPARAM);
  258. long FAR PASCAL DLGCheckLatency(HWND, UINT, WPARAM, LPARAM);
  259. UINT CALLBACK FileOpenCustomTemplateDlgProc(HWND, UINT, WPARAM, LPARAM);
  260.  
  261. BOOL ClassInit(HANDLE);
  262. void PD_FileOpen(HWND);
  263. BOOL OpenFileDialog(HWND, LPSTR, int *, LPBOOL);
  264. BOOL IsValidWave(LPSTR);
  265. void GetMediaStartPath(void);
  266.  
  267. int CreateControl(HWND, FILEINFO *, DWORD, DWORD, DWORD);
  268. void GetNextControlCoords(FILEINFO *, int *, int *);
  269. int AddToList(FILEINFO *, FILEINFO *);
  270. int FreeAllList(HWND, FILEINFO *);
  271. int RemoveFromList(FILEINFO *, FILEINFO *);
  272. int GetNumControls(FILEINFO *);
  273. int StartDSound(HWND, FILEINFO *);
  274. int StopDSound(HWND, FILEINFO *);
  275. int StopAllDSounds(HWND, FILEINFO *);
  276.  
  277. BOOL UIMainWindowVSBHandler(HWND, WPARAM, LPARAM); 
  278. BOOL UIMainWindowHSBHandler(HWND, WPARAM, LPARAM); 
  279. BOOL UIMainWindowCMDHandler(HWND, WPARAM, LPARAM); 
  280. BOOL UIMainWindowTimerHandler(HWND, WPARAM, LPARAM); 
  281. void SetAllText(FILEINFO *);
  282. void UpdateLRVolume(FILEINFO *);
  283.  
  284. void AppDestroy(HWND);
  285. BOOL AppInit(HWND);
  286. BOOL ParseCommandLine(PSTR);
  287. BOOL BatchOpenFiles(PSTR *,int,BOOL,BOOL);
  288.  
  289. int NewDirectSoundBuffer(FILEINFO *);
  290. int ReleaseDirectSoundBuffer(FILEINFO *);
  291. int ChangeOutputPan(FILEINFO *);
  292. int ChangeOutputFreq(FILEINFO *);
  293. int ChangeOutputVol(FILEINFO *);
  294.  
  295. int FormatToIndex(HWND, FILEINFO *);
  296. int IndexToFormat(HWND, FILEINFO *, int);
  297. #endif
  298.