home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / SOUND.ZIP / snd.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-11-21  |  4.8 KB  |  194 lines

  1. // snd.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "snd.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "sndDoc.h"
  9. #include "sndView.h"
  10.  
  11. // added for the Sound 
  12. #include "soundin.h"
  13. #include "soundout.h"
  14.  
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20.  
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CSndApp
  23.  
  24. BEGIN_MESSAGE_MAP(CSndApp, CWinApp)
  25.     //{{AFX_MSG_MAP(CSndApp)
  26.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  27.     ON_COMMAND(IDR_SOUND_OUT_START, OnSoundOutStart)
  28.     ON_COMMAND(IDR_SOUND_IN_STOP, OnSoundInStop)
  29.     ON_COMMAND(IDR_SOUND_IN_START, OnSoundInStart)
  30.     ON_COMMAND(IDR_SOUND_OUT_STOP, OnSoundOutStop)
  31.         // NOTE - the ClassWizard will add and remove mapping macros here.
  32.         //    DO NOT EDIT what you see in these blocks of generated code!
  33.     //}}AFX_MSG_MAP
  34.     // Standard file based document commands
  35.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  36.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  37.     // Standard print setup command
  38.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  39. END_MESSAGE_MAP()
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CSndApp construction
  43.  
  44. CSndApp::CSndApp()
  45. {
  46.     // TODO: add construction code here,
  47.     // Place all significant initialization in InitInstance
  48. }
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. // The one and only CSndApp object
  52.  
  53. CSndApp theApp;
  54. // added for the Sound 
  55. CSoundIn SoundIn;
  56. CSoundOut SoundOut;
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CSndApp initialization
  59.  
  60. BOOL CSndApp::InitInstance()
  61. {
  62.     AfxEnableControlContainer();
  63.  
  64.     // Standard initialization
  65.     // If you are not using these features and wish to reduce the size
  66.     //  of your final executable, you should remove from the following
  67.     //  the specific initialization routines you do not need.
  68.  
  69. #ifdef _AFXDLL
  70.     Enable3dControls();            // Call this when using MFC in a shared DLL
  71. #else
  72.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  73. #endif
  74.  
  75.     // Change the registry key under which our settings are stored.
  76.     // You should modify this string to be something appropriate
  77.     // such as the name of your company or organization.
  78.     SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  79.  
  80.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  81.  
  82.     // Register the application's document templates.  Document templates
  83.     //  serve as the connection between documents, frame windows and views.
  84.  
  85.     CSingleDocTemplate* pDocTemplate;
  86.     pDocTemplate = new CSingleDocTemplate(
  87.         IDR_MAINFRAME,
  88.         RUNTIME_CLASS(CSndDoc),
  89.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  90.         RUNTIME_CLASS(CSndView));
  91.     AddDocTemplate(pDocTemplate);
  92.  
  93.     // Parse command line for standard shell commands, DDE, file open
  94.     CCommandLineInfo cmdInfo;
  95.     ParseCommandLine(cmdInfo);
  96.  
  97.     // Dispatch commands specified on the command line
  98.     if (!ProcessShellCommand(cmdInfo))
  99.         return FALSE;
  100.  
  101.     // The one and only window has been initialized, so show and update it.
  102.     m_pMainWnd->ShowWindow(SW_SHOW);
  103.     m_pMainWnd->UpdateWindow();
  104.  
  105.     // added for sound
  106.     SoundOut.OpenOutput();
  107.  
  108.     return TRUE;
  109. }
  110.  
  111. /////////////////////////////////////////////////////////////////////////////
  112. // CAboutDlg dialog used for App About
  113.  
  114. class CAboutDlg : public CDialog
  115. {
  116. public:
  117.     CAboutDlg();
  118.  
  119. // Dialog Data
  120.     //{{AFX_DATA(CAboutDlg)
  121.     enum { IDD = IDD_ABOUTBOX };
  122.     //}}AFX_DATA
  123.  
  124.     // ClassWizard generated virtual function overrides
  125.     //{{AFX_VIRTUAL(CAboutDlg)
  126.     protected:
  127.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  128.     //}}AFX_VIRTUAL
  129.  
  130. // Implementation
  131. protected:
  132.     //{{AFX_MSG(CAboutDlg)
  133.         // No message handlers
  134.     //}}AFX_MSG
  135.     DECLARE_MESSAGE_MAP()
  136. };
  137.  
  138. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  139. {
  140.     //{{AFX_DATA_INIT(CAboutDlg)
  141.     //}}AFX_DATA_INIT
  142. }
  143.  
  144. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  145. {
  146.     CDialog::DoDataExchange(pDX);
  147.     //{{AFX_DATA_MAP(CAboutDlg)
  148.     //}}AFX_DATA_MAP
  149. }
  150.  
  151. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  152.     //{{AFX_MSG_MAP(CAboutDlg)
  153.         // No message handlers
  154.     //}}AFX_MSG_MAP
  155. END_MESSAGE_MAP()
  156.  
  157. // App command to run the dialog
  158. void CSndApp::OnAppAbout()
  159. {
  160.     CAboutDlg aboutDlg;
  161.     aboutDlg.DoModal();
  162. }
  163.  
  164. /////////////////////////////////////////////////////////////////////////////
  165. // CSndApp commands
  166.  
  167. int CSndApp::ExitInstance() 
  168. {
  169.         
  170.     SoundIn.CloseMic();
  171.     SoundOut.CloseOutput();
  172.     return CWinApp::ExitInstance();
  173. }
  174.  
  175.  
  176. void CSndApp::OnSoundInStart() 
  177. {
  178.     SoundIn.OpenMic();
  179. }
  180. void CSndApp::OnSoundInStop() 
  181. {
  182.     SoundIn.CloseMic();
  183. }
  184.  
  185. void CSndApp::OnSoundOutStart() 
  186. {
  187.     SoundOut.OpenOutput();
  188. }
  189. void CSndApp::OnSoundOutStop() 
  190. {
  191.     SoundOut.CloseOutput();
  192. }
  193.  
  194.