home *** CD-ROM | disk | FTP | other *** search
/ Sound Sensations! / sound_sensations.iso / soundb / sndhack / fpaste.c < prev    next >
C/C++ Source or Header  |  1991-07-30  |  25KB  |  783 lines

  1. #include <windows.h>
  2. #include <string.h>
  3. #include "app.h"
  4.  
  5. /*
  6.  * Module: fpaste.c
  7.  *
  8.  * Contains: Function paste specific functions. Menu
  9.  * commands are handled here, and Function paste dialog box
  10.  * callback functions should be located here.
  11.  *
  12.  */
  13.  
  14.  
  15. /*********************************************************************/
  16. /* Local Function Prototypes                                         */
  17. /*********************************************************************/
  18.  
  19. /*********************************************************************/
  20. /* Local data and structures                                         */
  21. /*********************************************************************/
  22.  
  23. extern SndDef SndState;
  24.  
  25. static BOOL b;
  26. static int rc;
  27. static char rcmsg[80];
  28. static char str[255];
  29.  
  30. /*********************************************************************/
  31. /* Global functions                                                  */
  32. /*********************************************************************/
  33.  
  34. /*-------------------------------------------------------------------*/
  35. /* Function paste command processor                                  */
  36. /*-------------------------------------------------------------------*/
  37.  
  38. void PasteMenuCommand(hWnd, id)
  39. HWND hWnd;
  40. int id;
  41. {
  42.   switch (id) {
  43.     case IDM_CLOSESOUND:
  44.       EditPutString("CloseSound();\r");
  45.       break;
  46.  
  47.     case IDM_COUNTVOICENOTES:
  48.       GoDialogBox(hInst, "DlgCountVoiceNotes", hWnd, DlgCountVoiceNotes);
  49.       break;
  50.  
  51.     case IDM_GETTHRESHOLDEVENT:
  52.       EditPutString("GetThresholdEvent();\r");
  53.       break;
  54.  
  55.     case IDM_GETTHRESHOLDSTATUS:
  56.       EditPutString("GetThresholdStatus();\r");
  57.       break;
  58.  
  59.     case IDM_OPENSOUND:
  60.       EditPutString("OpenSound();\r");
  61.       break;
  62.  
  63.     case IDM_SETSOUNDNOISE:
  64.       GoDialogBox(hInst, "DlgSetSoundNoise", hWnd, DlgSetSoundNoise);
  65.       break;
  66.  
  67.     case IDM_SETVOICEACCENT:
  68.       GoDialogBox(hInst, "DlgSetVoiceAccent", hWnd, DlgSetVoiceAccent);
  69.       break;
  70.  
  71.     case IDM_SETVOICEENVELOPE:
  72.       GoDialogBox(hInst, "DlgSetVoiceEnvelope", hWnd, DlgSetVoiceEnvelope);
  73.       break;
  74.  
  75.     case IDM_SETVOICENOTE:
  76.       GoDialogBox(hInst, "DlgSetVoiceNote", hWnd, DlgSetVoiceNote);
  77.       break;
  78.  
  79.     case IDM_SETVOICEQUEUESIZE:
  80.       GoDialogBox(hInst, "DlgSetVoiceQueueSize", hWnd, DlgSetVoiceQueueSize);
  81.       break;
  82.  
  83.     case IDM_SETVOICESOUND:
  84.       GoDialogBox(hInst, "DlgSetVoiceSound", hWnd, DlgSetVoiceSound);
  85.       break;
  86.  
  87.     case IDM_SETVOICETHRESHOLD:
  88.       GoDialogBox(hInst, "DlgSetVoiceThreshold", hWnd, DlgSetVoiceThreshold);
  89.       break;
  90.  
  91.     case IDM_STARTSOUND:
  92.       EditPutString("StartSound();\r");
  93.       break;
  94.  
  95.     case IDM_STOPSOUND:
  96.       EditPutString("StopSound();\r");
  97.       break;
  98.  
  99.     case IDM_SYNCALLVOICES:
  100.       EditPutString("SyncAllVoices();\r");
  101.       break;
  102.  
  103.     case IDM_WAITSOUNDSTATE:
  104.       GoDialogBox(hInst, "DlgWaitSoundState", hWnd, DlgWaitSoundState);
  105.       break;
  106.  
  107.     default:
  108.       break;
  109.   }
  110. }
  111.  
  112.  
  113. /*-------------------------------------------------------------------*/
  114. /* CountVoiceNotes dialog box callback function                      */
  115. /*-------------------------------------------------------------------*/
  116.  
  117. BOOL FAR PASCAL DlgCountVoiceNotes(hDlg, message, wParam, lParam)
  118. HWND hDlg;
  119. unsigned message;
  120. WORD wParam;
  121. LONG lParam;
  122. {
  123.   static char fname[] = "CountVoiceNotes";
  124.  
  125.   switch (message) {
  126.     case WM_COMMAND:
  127.       switch (wParam) {
  128.  
  129.         case IDD_OK:
  130.           SndState.voice = GetDlgItemInt(hDlg, IDD_COUNTVOICENOTES_VOICE, &b, FALSE);
  131.           if (!b) {
  132.             SetFocus(GetDlgItem(hDlg, IDD_COUNTVOICENOTES_VOICE));
  133.             MessageBeep(0);
  134.             return(FALSE);
  135.           }
  136.  
  137.           wsprintf(str,"%s(%d);\r",
  138.             (LPSTR)fname,
  139.             SndState.voice);
  140.           EditPutString(str);
  141.  
  142.         case IDD_CANCEL:
  143.           EndDialog(hDlg, NULL);
  144.           return(TRUE);
  145.  
  146.         case IDD_HELP:
  147.           WinHelp(hDlg,HelpFileName,HELP_KEY,(DWORD)(LPSTR)fname);
  148.           return(TRUE);
  149.  
  150.         default:
  151.           break;
  152.       }
  153.       return(FALSE);
  154.  
  155.     case WM_INITDIALOG:
  156.       SetDlgItemInt(hDlg, IDD_COUNTVOICENOTES_VOICE, SndState.voice, TRUE);
  157.       break;
  158.  
  159.     default:
  160.       return(FALSE);
  161.   }
  162.   return(TRUE);
  163. }
  164.  
  165.  
  166. /*-------------------------------------------------------------------*/
  167. /* SetSoundNoise dialog box callback function                        */
  168. /*-------------------------------------------------------------------*/
  169.  
  170. BOOL FAR PASCAL DlgSetSoundNoise(hDlg, message, wParam, lParam)
  171. HWND hDlg;
  172. unsigned message;
  173. WORD wParam;
  174. LONG lParam;
  175. {
  176.   static char fname[] = "SetSoundNoise";
  177.   static char sourcestr[15];
  178.  
  179.   switch (message) {
  180.     case WM_COMMAND:
  181.       switch (wParam) {
  182.  
  183.         case IDD_OK:
  184.           GetDlgItemText(hDlg, IDD_SETSOUNDNOISE_SOURCE, sourcestr, sizeof(sourcestr)-1);
  185.           if (strcmp(sourcestr,"S_PERIOD512") == 0)
  186.             SndState.source = S_PERIOD512;
  187.           else if (strcmp(sourcestr,"S_PERIOD1024") == 0)
  188.             SndState.source = S_PERIOD1024;
  189.           else if (strcmp(sourcestr,"S_PERIOD2048") == 0)
  190.             SndState.source = S_PERIOD2048;
  191.           else if (strcmp(sourcestr,"S_PERIODVOICE") == 0)
  192.             SndState.source = S_PERIODVOICE;
  193.           else if (strcmp(sourcestr,"S_WHITE512") == 0)
  194.             SndState.source = S_WHITE512;
  195.           else if (strcmp(sourcestr,"S_WHITE1024") == 0)
  196.             SndState.source = S_WHITE1024;
  197.           else if (strcmp(sourcestr,"S_WHITE2048") == 0)
  198.             SndState.source = S_WHITE2048;
  199.           else if (strcmp(sourcestr,"S_WHITEVOICE") == 0)
  200.             SndState.source = S_WHITEVOICE;
  201.           else {
  202.             SetFocus(GetDlgItem(hDlg, IDD_SETSOUNDNOISE_SOURCE));
  203.             MessageBeep(0);
  204.             return(FALSE);
  205.           }
  206.           SndState.duration = GetDlgItemInt(hDlg, IDD_SETSOUNDNOISE_DURATION, &b, FALSE);
  207.           if (!b) {
  208.             SetFocus(GetDlgItem(hDlg, IDD_SETSOUNDNOISE_DURATION));
  209.             MessageBeep(0);
  210.             return(FALSE);
  211.           }
  212.  
  213.           wsprintf(str,"%s(%s, %d);\r",
  214.             (LPSTR)fname,
  215.             (LPSTR)sourcestr,
  216.             SndState.duration);
  217.           EditPutString(str);
  218.  
  219.         case IDD_CANCEL:
  220.           EndDialog(hDlg, NULL);
  221.           return(TRUE);
  222.  
  223.         case IDD_HELP:
  224.           WinHelp(hDlg,HelpFileName,HELP_KEY,(DWORD)(LPSTR)fname);
  225.           return(TRUE);
  226.  
  227.         default:
  228.           break;
  229.       }
  230.       return(FALSE);
  231.  
  232.     case WM_INITDIALOG:
  233.       SendDlgItemMessage(hDlg,IDD_SETSOUNDNOISE_SOURCE,CB_ADDSTRING,0,(DWORD)((LPSTR)"S_PERIOD512"));
  234.       SendDlgItemMessage(hDlg,IDD_SETSOUNDNOISE_SOURCE,CB_ADDSTRING,0,(DWORD)((LPSTR)"S_PERIOD1024"));
  235.       SendDlgItemMessage(hDlg,IDD_SETSOUNDNOISE_SOURCE,CB_ADDSTRING,0,(DWORD)((LPSTR)"S_PERIOD2048"));
  236.       SendDlgItemMessage(hDlg,IDD_SETSOUNDNOISE_SOURCE,CB_ADDSTRING,0,(DWORD)((LPSTR)"S_PERIODVOICE"));
  237.       SendDlgItemMessage(hDlg,IDD_SETSOUNDNOISE_SOURCE,CB_ADDSTRING,0,(DWORD)((LPSTR)"S_WHITE512"));
  238.       SendDlgItemMessage(hDlg,IDD_SETSOUNDNOISE_SOURCE,CB_ADDSTRING,0,(DWORD)((LPSTR)"S_WHITE1024"));
  239.       SendDlgItemMessage(hDlg,IDD_SETSOUNDNOISE_SOURCE,CB_ADDSTRING,0,(DWORD)((LPSTR)"S_WHITE2048"));
  240.       SendDlgItemMessage(hDlg,IDD_SETSOUNDNOISE_SOURCE,CB_ADDSTRING,0,(DWORD)((LPSTR)"S_WHITEVOICE"));
  241.       if (SndState.source == S_PERIOD512)
  242.         SendDlgItemMessage(hDlg,IDD_SETSOUNDNOISE_SOURCE,CB_SELECTSTRING,0,(DWORD)((LPSTR)"S_PERIOD512"));
  243.       else if (SndState.source == S_PERIOD1024)
  244.         SendDlgItemMessage(hDlg,IDD_SETSOUNDNOISE_SOURCE,CB_SELECTSTRING,0,(DWORD)((LPSTR)"S_PERIOD1024"));
  245.       else if (SndState.source == S_PERIOD2048)
  246.         SendDlgItemMessage(hDlg,IDD_SETSOUNDNOISE_SOURCE,CB_SELECTSTRING,0,(DWORD)((LPSTR)"S_PERIOD2048"));
  247.       else if (SndState.source == S_PERIODVOICE)
  248.         SendDlgItemMessage(hDlg,IDD_SETSOUNDNOISE_SOURCE,CB_SELECTSTRING,0,(DWORD)((LPSTR)"S_PERIODVOICE"));
  249.       else if (SndState.source == S_WHITE512)
  250.         SendDlgItemMessage(hDlg,IDD_SETSOUNDNOISE_SOURCE,CB_SELECTSTRING,0,(DWORD)((LPSTR)"S_WHITE512"));
  251.       else if (SndState.source == S_WHITE1024)
  252.         SendDlgItemMessage(hDlg,IDD_SETSOUNDNOISE_SOURCE,CB_SELECTSTRING,0,(DWORD)((LPSTR)"S_WHITE1024"));
  253.       else if (SndState.source == S_WHITE2048)
  254.         SendDlgItemMessage(hDlg,IDD_SETSOUNDNOISE_SOURCE,CB_SELECTSTRING,0,(DWORD)((LPSTR)"S_WHITE2048"));
  255.       else {
  256.         SendDlgItemMessage(hDlg,IDD_SETSOUNDNOISE_SOURCE,CB_SELECTSTRING,0,(DWORD)((LPSTR)"S_WHITEVOICE"));
  257.         SndState.source = S_WHITEVOICE;
  258.       }
  259.       SetDlgItemInt(hDlg, IDD_SETSOUNDNOISE_DURATION, SndState.duration, TRUE);
  260.       break;
  261.  
  262.     default:
  263.       return(FALSE);
  264.   }
  265.   return(TRUE);
  266. }
  267.  
  268.  
  269.  
  270. /*-------------------------------------------------------------------*/
  271. /* SetVoiceAccent dialog box callback function                       */
  272. /*-------------------------------------------------------------------*/
  273.  
  274. BOOL FAR PASCAL DlgSetVoiceAccent(hDlg, message, wParam, lParam)
  275. HWND hDlg;
  276. unsigned message;
  277. WORD wParam;
  278. LONG lParam;
  279. {
  280.   static char fname[] = "SetVoiceAccent";
  281.   static char modestr[11];
  282.  
  283.   switch (message) {
  284.     case WM_COMMAND:
  285.       switch (wParam) {
  286.  
  287.         case IDD_OK:
  288.           SndState.voice = GetDlgItemInt(hDlg, IDD_SETVOICEACCENT_VOICE, &b, FALSE);
  289.           if (!b) {
  290.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICEACCENT_VOICE));
  291.             MessageBeep(0);
  292.             return(FALSE);
  293.           }
  294.           SndState.tempo = GetDlgItemInt(hDlg, IDD_SETVOICEACCENT_TEMPO, &b, FALSE);
  295.           if (!b) {
  296.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICEACCENT_TEMPO));
  297.             MessageBeep(0);
  298.             return(FALSE);
  299.           }
  300.           SndState.volume = GetDlgItemInt(hDlg, IDD_SETVOICEACCENT_VOLUME, &b, FALSE);
  301.           if (!b) {
  302.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICEACCENT_VOLUME));
  303.             MessageBeep(0);
  304.             return(FALSE);
  305.           }
  306.           GetDlgItemText(hDlg, IDD_SETVOICEACCENT_MODE, modestr, sizeof(modestr)-1);
  307.           if (strcmp(modestr,"S_LEGATO") == 0)
  308.             SndState.mode = S_LEGATO;
  309.           else if (strcmp(modestr,"S_NORMAL") == 0)
  310.             SndState.mode = S_NORMAL;
  311.           else if (strcmp(modestr,"S_STACCATO") == 0)
  312.             SndState.mode = S_STACCATO;
  313.           else {
  314.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICEACCENT_MODE));
  315.             MessageBeep(0);
  316.             return(FALSE);
  317.           }
  318.           SndState.pitch = GetDlgItemInt(hDlg, IDD_SETVOICEACCENT_PITCH, &b, FALSE);
  319.           if (!b) {
  320.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICEACCENT_PITCH));
  321.             MessageBeep(0);
  322.             return(FALSE);
  323.           }
  324.  
  325.           wsprintf(str,"%s(%d, %d, %d, %s, %d);\r",
  326.             (LPSTR)fname,
  327.             SndState.voice,
  328.             SndState.tempo,
  329.             SndState.volume,
  330.             (LPSTR)modestr,
  331.             SndState.pitch);
  332.           EditPutString(str);
  333.  
  334.         case IDD_CANCEL:
  335.           EndDialog(hDlg, NULL);
  336.           return(TRUE);
  337.  
  338.         case IDD_HELP:
  339.           WinHelp(hDlg,HelpFileName,HELP_KEY,(DWORD)(LPSTR)fname);
  340.           return(TRUE);
  341.  
  342.         default:
  343.           break;
  344.       }
  345.       return(FALSE);
  346.  
  347.     case WM_INITDIALOG:
  348.       SetDlgItemInt(hDlg, IDD_SETVOICEACCENT_VOICE, SndState.voice, TRUE);
  349.       SetDlgItemInt(hDlg, IDD_SETVOICEACCENT_TEMPO, SndState.tempo, TRUE);
  350.       SetDlgItemInt(hDlg, IDD_SETVOICEACCENT_VOLUME, SndState.volume, TRUE);
  351.       SendDlgItemMessage(hDlg,IDD_SETVOICEACCENT_MODE,CB_ADDSTRING,0,(DWORD)((LPSTR)"S_LEGATO"));
  352.       SendDlgItemMessage(hDlg,IDD_SETVOICEACCENT_MODE,CB_ADDSTRING,0,(DWORD)((LPSTR)"S_NORMAL"));
  353.       SendDlgItemMessage(hDlg,IDD_SETVOICEACCENT_MODE,CB_ADDSTRING,0,(DWORD)((LPSTR)"S_STACCATO"));
  354.       if (SndState.mode == S_LEGATO)
  355.         SendDlgItemMessage(hDlg,IDD_SETVOICEACCENT_MODE,CB_SELECTSTRING,0,(DWORD)((LPSTR)"S_LEGATO"));
  356.       else if (SndState.mode == S_STACCATO)
  357.         SendDlgItemMessage(hDlg,IDD_SETVOICEACCENT_MODE,CB_SELECTSTRING,0,(DWORD)((LPSTR)"S_STACCATO"));
  358.       else {
  359.         SendDlgItemMessage(hDlg,IDD_SETVOICEACCENT_MODE,CB_SELECTSTRING,0,(DWORD)((LPSTR)"S_NORMAL"));
  360.         SndState.mode = S_NORMAL;
  361.       }
  362.       SetDlgItemInt(hDlg, IDD_SETVOICEACCENT_PITCH, SndState.pitch, TRUE);
  363.       break;
  364.  
  365.     default:
  366.       return(FALSE);
  367.   }
  368.   return(TRUE);
  369. }
  370.  
  371.  
  372. /*-------------------------------------------------------------------*/
  373. /* SetVoiceEnvelope dialog box callback function                     */
  374. /*-------------------------------------------------------------------*/
  375.  
  376. BOOL FAR PASCAL DlgSetVoiceEnvelope(hDlg, message, wParam, lParam)
  377. HWND hDlg;
  378. unsigned message;
  379. WORD wParam;
  380. LONG lParam;
  381. {
  382.   static char fname[] = "SetVoiceEnvelope";
  383.  
  384.   switch (message) {
  385.     case WM_COMMAND:
  386.       switch (wParam) {
  387.  
  388.         case IDD_OK:
  389.           SndState.voice = GetDlgItemInt(hDlg, IDD_SETVOICEENVELOPE_VOICE, &b, FALSE);
  390.           if (!b) {
  391.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICEENVELOPE_VOICE));
  392.             MessageBeep(0);
  393.             return(FALSE);
  394.           }
  395.           SndState.shape = GetDlgItemInt(hDlg, IDD_SETVOICEENVELOPE_SHAPE, &b, FALSE);
  396.           if (!b) {
  397.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICEENVELOPE_SHAPE));
  398.             MessageBeep(0);
  399.             return(FALSE);
  400.           }
  401.           SndState.repeat = GetDlgItemInt(hDlg, IDD_SETVOICEENVELOPE_REPEAT, &b, FALSE);
  402.           if (!b) {
  403.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICEENVELOPE_REPEAT));
  404.             MessageBeep(0);
  405.             return(FALSE);
  406.           }
  407.  
  408.           wsprintf(str,"%s(%d, %d, %d);\r",
  409.             (LPSTR)fname,
  410.             SndState.voice,
  411.             SndState.shape,
  412.             SndState.repeat);
  413.           EditPutString(str);
  414.  
  415.         case IDD_CANCEL:
  416.           EndDialog(hDlg, NULL);
  417.           return(TRUE);
  418.  
  419.         case IDD_HELP:
  420.           WinHelp(hDlg,HelpFileName,HELP_KEY,(DWORD)(LPSTR)fname);
  421.           return(TRUE);
  422.  
  423.         default:
  424.           break;
  425.       }
  426.       return(FALSE);
  427.  
  428.     case WM_INITDIALOG:
  429.       SetDlgItemInt(hDlg, IDD_SETVOICEENVELOPE_VOICE, SndState.voice, TRUE);
  430.       SetDlgItemInt(hDlg, IDD_SETVOICEENVELOPE_SHAPE, SndState.shape, TRUE);
  431.       SetDlgItemInt(hDlg, IDD_SETVOICEENVELOPE_REPEAT, SndState.repeat, TRUE);
  432.       break;
  433.  
  434.     default:
  435.       return(FALSE);
  436.   }
  437.   return(TRUE);
  438. }
  439.  
  440. /*-------------------------------------------------------------------*/
  441. /* SetVoiceNote dialog box callback function                         */
  442. /*-------------------------------------------------------------------*/
  443.  
  444. BOOL FAR PASCAL DlgSetVoiceNote(hDlg, message, wParam, lParam)
  445. HWND hDlg;
  446. unsigned message;
  447. WORD wParam;
  448. LONG lParam;
  449. {
  450.   static char fname[] = "SetVoiceNote";
  451.   static char notestr[5];
  452.  
  453.   switch (message) {
  454.     case WM_COMMAND:
  455.       switch (wParam) {
  456.  
  457.         case IDD_OK:
  458.           SndState.voice = GetDlgItemInt(hDlg, IDD_SETVOICENOTE_VOICE, &b, FALSE);
  459.           if (!b) {
  460.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICENOTE_VOICE));
  461.             MessageBeep(0);
  462.             return(FALSE);
  463.           }
  464.           GetDlgItemText(hDlg, IDD_SETVOICENOTE_VALUE, notestr, sizeof(notestr)-1);
  465.           b = PlayNoteConvert(notestr,&SndState.value);
  466.           if (!b) {
  467.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICENOTE_VALUE));
  468.             MessageBeep(0);
  469.             return(FALSE);
  470.           }
  471.           SndState.length = GetDlgItemInt(hDlg, IDD_SETVOICENOTE_LENGTH, &b, FALSE);
  472.           if (!b) {
  473.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICENOTE_LENGTH));
  474.             MessageBeep(0);
  475.             return(FALSE);
  476.           }
  477.           SndState.cdots = GetDlgItemInt(hDlg, IDD_SETVOICENOTE_CDOTS, &b, FALSE);
  478.           if (!b) {
  479.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICENOTE_CDOTS));
  480.             MessageBeep(0);
  481.             return(FALSE);
  482.           }
  483.  
  484.           wsprintf(str,"%s(%d, %d, %d, %d);\r",
  485.             (LPSTR)fname,
  486.             SndState.voice,
  487.             SndState.value,
  488.             SndState.length,
  489.             SndState.cdots);
  490.           EditPutString(str);
  491.  
  492.         case IDD_CANCEL:
  493.           EndDialog(hDlg, NULL);
  494.           return(TRUE);
  495.  
  496.         case IDD_HELP:
  497.           WinHelp(hDlg,HelpFileName,HELP_KEY,(DWORD)(LPSTR)fname);
  498.           return(TRUE);
  499.  
  500.         default:
  501.           break;
  502.       }
  503.       return(FALSE);
  504.  
  505.     case WM_INITDIALOG:
  506.       SetDlgItemInt(hDlg, IDD_SETVOICENOTE_VOICE, SndState.voice, TRUE);
  507.       SetDlgItemInt(hDlg, IDD_SETVOICENOTE_VALUE, SndState.value, TRUE);
  508.       SetDlgItemInt(hDlg, IDD_SETVOICENOTE_LENGTH, SndState.length, TRUE);
  509.       SetDlgItemInt(hDlg, IDD_SETVOICENOTE_CDOTS, SndState.cdots, TRUE);
  510.       break;
  511.  
  512.     default:
  513.       return(FALSE);
  514.   }
  515.   return(TRUE);
  516. }
  517.  
  518. /*-------------------------------------------------------------------*/
  519. /* SetVoiceQueueSize dialog box callback function                    */
  520. /*-------------------------------------------------------------------*/
  521.  
  522. BOOL FAR PASCAL DlgSetVoiceQueueSize(hDlg, message, wParam, lParam)
  523. HWND hDlg;
  524. unsigned message;
  525. WORD wParam;
  526. LONG lParam;
  527. {
  528.   static char fname[] = "SetVoiceQueueSize";
  529.  
  530.   switch (message) {
  531.     case WM_COMMAND:
  532.       switch (wParam) {
  533.  
  534.         case IDD_OK:
  535.           SndState.voice = GetDlgItemInt(hDlg, IDD_SETVOICEQUEUESIZE_VOICE, &b, FALSE);
  536.           if (!b) {
  537.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICEQUEUESIZE_VOICE));
  538.             MessageBeep(0);
  539.             return(FALSE);
  540.           }
  541.           SndState.qsize= GetDlgItemInt(hDlg, IDD_SETVOICEQUEUESIZE_QSIZE, &b, FALSE);
  542.           if (!b) {
  543.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICEQUEUESIZE_QSIZE));
  544.             MessageBeep(0);
  545.             return(FALSE);
  546.           }
  547.  
  548.           wsprintf(str,"%s(%d, %d);\r",
  549.             (LPSTR)fname,
  550.             SndState.voice,
  551.             SndState.qsize);
  552.           EditPutString(str);
  553.  
  554.         case IDD_CANCEL:
  555.           EndDialog(hDlg, NULL);
  556.           return(TRUE);
  557.  
  558.         case IDD_HELP:
  559.           WinHelp(hDlg,HelpFileName,HELP_KEY,(DWORD)(LPSTR)fname);
  560.           return(TRUE);
  561.  
  562.         default:
  563.           break;
  564.       }
  565.       return(FALSE);
  566.  
  567.     case WM_INITDIALOG:
  568.       SetDlgItemInt(hDlg, IDD_SETVOICEQUEUESIZE_VOICE, SndState.voice, TRUE);
  569.       SetDlgItemInt(hDlg, IDD_SETVOICEQUEUESIZE_QSIZE, SndState.qsize, TRUE);
  570.       break;
  571.  
  572.     default:
  573.       return(FALSE);
  574.   }
  575.   return(TRUE);
  576. }
  577.  
  578.  
  579. /*-------------------------------------------------------------------*/
  580. /* SetVoiceSound dialog box callback function                        */
  581. /*-------------------------------------------------------------------*/
  582.  
  583. BOOL FAR PASCAL DlgSetVoiceSound(hDlg, message, wParam, lParam)
  584. HWND hDlg;
  585. unsigned message;
  586. WORD wParam;
  587. LONG lParam;
  588. {
  589.   static char fname[] = "SetVoiceSound";
  590.  
  591.   switch (message) {
  592.     case WM_COMMAND:
  593.       switch (wParam) {
  594.  
  595.         case IDD_OK:
  596.           SndState.voice = GetDlgItemInt(hDlg, IDD_SETVOICESOUND_VOICE, &b, FALSE);
  597.           if (!b) {
  598.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICESOUND_VOICE));
  599.             MessageBeep(0);
  600.             return(FALSE);
  601.           }
  602.           SndState.frequency = GetDlgItemInt(hDlg, IDD_SETVOICESOUND_FREQUENCY, &b, FALSE);
  603.           if (!b) {
  604.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICESOUND_FREQUENCY));
  605.             MessageBeep(0);
  606.             return(FALSE);
  607.           }
  608.           SndState.fraction = GetDlgItemInt(hDlg, IDD_SETVOICESOUND_FRACTION, &b, FALSE);
  609.           if (!b) {
  610.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICESOUND_FRACTION));
  611.             MessageBeep(0);
  612.             return(FALSE);
  613.           }
  614.           SndState.duration = GetDlgItemInt(hDlg, IDD_SETVOICESOUND_DURATION, &b, FALSE);
  615.           if (!b) {
  616.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICESOUND_DURATION));
  617.             MessageBeep(0);
  618.             return(FALSE);
  619.           }
  620.  
  621.           SndState.lfreq = ((LONG)SndState.frequency << 16) + SndState.fraction;
  622.           wsprintf(str,"%s(%d, 0x%lx, %d);\r",
  623.             (LPSTR)fname,
  624.             SndState.voice,
  625.             SndState.lfreq,
  626.             SndState.duration);
  627.           EditPutString(str);
  628.  
  629.         case IDD_CANCEL:
  630.           EndDialog(hDlg, NULL);
  631.           return(TRUE);
  632.  
  633.         case IDD_HELP:
  634.           WinHelp(hDlg,HelpFileName,HELP_KEY,(DWORD)(LPSTR)fname);
  635.           return(TRUE);
  636.  
  637.         default:
  638.           break;
  639.       }
  640.       return(FALSE);
  641.  
  642.     case WM_INITDIALOG:
  643.       SetDlgItemInt(hDlg, IDD_SETVOICESOUND_VOICE, SndState.voice, TRUE);
  644.       SetDlgItemInt(hDlg, IDD_SETVOICESOUND_FREQUENCY, SndState.frequency, TRUE);
  645.       SetDlgItemInt(hDlg, IDD_SETVOICESOUND_FRACTION, SndState.fraction, TRUE);
  646.       SetDlgItemInt(hDlg, IDD_SETVOICESOUND_DURATION, SndState.duration, TRUE);
  647.       break;
  648.  
  649.     default:
  650.       return(FALSE);
  651.   }
  652.   return(TRUE);
  653. }
  654.  
  655. /*-------------------------------------------------------------------*/
  656. /* SetVoiceThreshold dialog box callback function                    */
  657. /*-------------------------------------------------------------------*/
  658.  
  659. BOOL FAR PASCAL DlgSetVoiceThreshold(hDlg, message, wParam, lParam)
  660. HWND hDlg;
  661. unsigned message;
  662. WORD wParam;
  663. LONG lParam;
  664. {
  665.   static char fname[] = "SetVoiceThreshold";
  666.  
  667.   switch (message) {
  668.     case WM_COMMAND:
  669.       switch (wParam) {
  670.  
  671.         case IDD_OK:
  672.           SndState.voice = GetDlgItemInt(hDlg, IDD_SETVOICETHRESHOLD_VOICE, &b, FALSE);
  673.           if (!b) {
  674.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICETHRESHOLD_VOICE));
  675.             MessageBeep(0);
  676.             return(FALSE);
  677.           }
  678.           SndState.tcount = GetDlgItemInt(hDlg, IDD_SETVOICETHRESHOLD_TCOUNT, &b, FALSE);
  679.           if (!b) {
  680.             SetFocus(GetDlgItem(hDlg, IDD_SETVOICETHRESHOLD_TCOUNT));
  681.             MessageBeep(0);
  682.             return(FALSE);
  683.           }
  684.  
  685.           wsprintf(str,"%s(%d, %d);\r",
  686.             (LPSTR)fname,
  687.             SndState.voice,
  688.             SndState.tcount);
  689.           EditPutString(str);
  690.  
  691.         case IDD_CANCEL:
  692.           EndDialog(hDlg, NULL);
  693.           return(TRUE);
  694.  
  695.         case IDD_HELP:
  696.           WinHelp(hDlg,HelpFileName,HELP_KEY,(DWORD)(LPSTR)fname);
  697.           return(TRUE);
  698.  
  699.         default:
  700.           break;
  701.       }
  702.       return(FALSE);
  703.  
  704.     case WM_INITDIALOG:
  705.       SetDlgItemInt(hDlg, IDD_SETVOICETHRESHOLD_VOICE, SndState.voice, TRUE);
  706.       SetDlgItemInt(hDlg, IDD_SETVOICETHRESHOLD_TCOUNT, SndState.tcount, TRUE);
  707.       break;
  708.  
  709.     default:
  710.       return(FALSE);
  711.   }
  712.   return(TRUE);
  713. }
  714.  
  715. /*-------------------------------------------------------------------*/
  716. /* WaitSoundState dialog box callback function                       */
  717. /*-------------------------------------------------------------------*/
  718.  
  719. BOOL FAR PASCAL DlgWaitSoundState(hDlg, message, wParam, lParam)
  720. HWND hDlg;
  721. unsigned message;
  722. WORD wParam;
  723. LONG lParam;
  724. {
  725.   static char fname[] = "WaitSoundState";
  726.   static char waitstr[15];
  727.  
  728.   switch (message) {
  729.     case WM_COMMAND:
  730.       switch (wParam) {
  731.  
  732.         case IDD_OK:
  733.           GetDlgItemText(hDlg, IDD_WAITSOUNDSTATE_STATE, waitstr, sizeof(waitstr)-1);
  734.           if (strcmp(waitstr,"S_ALLTHRESHOLD") == 0)
  735.             SndState.waitstate = S_ALLTHRESHOLD;
  736.           else if (strcmp(waitstr,"S_QUEUEEMPTY") == 0)
  737.             SndState.waitstate = S_QUEUEEMPTY;
  738.           else if (strcmp(waitstr,"S_THRESHOLD") == 0)
  739.             SndState.waitstate = S_THRESHOLD;
  740.           else {
  741.             SetFocus(GetDlgItem(hDlg, IDD_WAITSOUNDSTATE_STATE));
  742.             MessageBeep(0);
  743.             return(FALSE);
  744.           }
  745.  
  746.           wsprintf(str,"%s(%s);\r",
  747.             (LPSTR)fname,
  748.             (LPSTR)waitstr);
  749.           EditPutString(str);
  750.  
  751.         case IDD_CANCEL:
  752.           EndDialog(hDlg, NULL);
  753.           return(TRUE);
  754.  
  755.         case IDD_HELP:
  756.           WinHelp(hDlg,HelpFileName,HELP_KEY,(DWORD)(LPSTR)fname);
  757.           return(TRUE);
  758.  
  759.         default:
  760.           break;
  761.       }
  762.       return(FALSE);
  763.  
  764.     case WM_INITDIALOG:
  765.       SendDlgItemMessage(hDlg,IDD_WAITSOUNDSTATE_STATE,CB_ADDSTRING,0,(DWORD)((LPSTR)"S_ALLTHRESHOLD"));
  766.       SendDlgItemMessage(hDlg,IDD_WAITSOUNDSTATE_STATE,CB_ADDSTRING,0,(DWORD)((LPSTR)"S_QUEUEEMPTY"));
  767.       SendDlgItemMessage(hDlg,IDD_WAITSOUNDSTATE_STATE,CB_ADDSTRING,0,(DWORD)((LPSTR)"S_THRESHOLD"));
  768.       if (SndState.waitstate == S_ALLTHRESHOLD)
  769.         SendDlgItemMessage(hDlg,IDD_WAITSOUNDSTATE_STATE,CB_SELECTSTRING,0,(DWORD)((LPSTR)"S_ALLTHRESHOLD"));
  770.       else if (SndState.waitstate == S_THRESHOLD)
  771.         SendDlgItemMessage(hDlg,IDD_WAITSOUNDSTATE_STATE,CB_SELECTSTRING,0,(DWORD)((LPSTR)"S_THRESHOLD"));
  772.       else {
  773.         SendDlgItemMessage(hDlg,IDD_WAITSOUNDSTATE_STATE,CB_SELECTSTRING,0,(DWORD)((LPSTR)"S_QUEUEEMPTY"));
  774.         SndState.waitstate = S_QUEUEEMPTY;
  775.       }
  776.       break;
  777.  
  778.     default:
  779.       return(FALSE);
  780.   }
  781.   return(TRUE);
  782. }
  783.