home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / IOC / MMSTEREO / MMSTEREO.CPP < prev    next >
Text File  |  1995-05-01  |  6KB  |  150 lines

  1. /******************************************************************************/
  2. /* Mltmedia  SAMPLE PROGRAM - Version 1: Class Implementation                 */
  3. /*                                                                            */
  4. /* COPYRIGHT: Copyright (C) International Business Machines Corp., 1992,1993. */
  5. /*                                                                            */
  6. /* DISCLAIMER OF WARRANTIES:                                                  */
  7. /*   The following [enclosed] code is sample code created by IBM              */
  8. /*   Corporation.  This sample code is not part of any standard IBM product   */
  9. /*   and is provided to you solely for the purpose of assisting you in the    */
  10. /*   development of your applications.  The code is provided "AS IS",         */
  11. /*   without warranty of any kind.  IBM shall not be liable for any damages   */
  12. /*   arising out of your use of the sample code, even if they have been       */
  13. /*   advised of the possibility of such damages.                              */
  14. /******************************************************************************/
  15. #include "mmstereo.hpp"
  16.  
  17. //*************************************************************************
  18. // main  - Application entry point                                        *
  19. //*************************************************************************
  20. int main()                             //Main procedure with no parameters
  21. {
  22.   MainWindow  mainWindow(WINDOWID);     //Create our main window on the desktop
  23.  
  24.   IApplication::current().run();        //Get the current application and
  25.                                         // run it
  26.   return 0;
  27. } /* end main */
  28.  
  29.  
  30. /*------------------------------------------------------------------------------
  31. | MainWindow::MainWindow                                                       |
  32. |                                                                              |
  33. |                                                                              |
  34. ------------------------------------------------------------------------------*/
  35. MainWindow::MainWindow( unsigned long windowId)
  36.             //Call IFrameWindow constructor
  37.           : IFrameWindow("Multimedia MMSTEREO Sample",windowId,
  38.                  IFrameWindow::defaultStyle() | IFrameWindow::minimizedIcon),
  39.             clientCanvas(CLIENTCANVASID,this,this),
  40.             cdPlayer(0),
  41.             wavPlayer(0),
  42.             vidPlayer(0)
  43. {
  44.    //Create the audio cd device, but if we get an exception then
  45.    //we will still display the cd player, but it will be disabled
  46.    try
  47.    {
  48.       cdPlayer = new IMMAudioCD();
  49.    }
  50.    catch (...)
  51.    {
  52.         cdPlayer  = 0;
  53.         ampMixer1 = 0;
  54.    }
  55.    if (cdPlayer)
  56.    {
  57.       try
  58.       {
  59.          //Enable Digital transfer from the cd
  60. //         cdPlayer->enableConnector(IMMDevice::cdStream);
  61.          ampMixer1 = new IMMAmpMixer(cdPlayer->connectedDeviceId(IMMDevice::cdStream));
  62.          ampMixer1->enableMonitoring();
  63.          ampMixer1->setCloseOnDestroy(false);
  64.       }
  65.       catch (...)
  66.       {
  67.          ampMixer1 = 0;
  68.       }
  69.    } /* endif */
  70.    cd       = new CD   (cdPlayer , CD_ID   ,  &clientCanvas, this);
  71.    if (!cdPlayer)
  72.       ((IMultiCellCanvas*)cd)->disable();
  73.  
  74.    //Create the wave audio device, but if we get an exception then
  75.    //we will still display the wave player, but it will be disabled
  76.    try
  77.    {
  78.       wavPlayer = new IMMWaveAudio();
  79.       ampMixer2 = new IMMAmpMixer(wavPlayer->connectedDeviceId(IMMDevice::waveStream));
  80. //      ampMixer2->enableMonitoring();
  81.       ampMixer2->setCloseOnDestroy(false);
  82.    }
  83.    catch (...)
  84.    {
  85.       wavPlayer = 0;
  86.       ampMixer2 = 0;
  87.    }
  88.    wave     = new WAVE (wavPlayer, WAVE_ID ,  &clientCanvas, this);
  89.    if (!wavPlayer)
  90.       ((IMultiCellCanvas*)wave)->disable();
  91.  
  92.    //Create the video device, but if we get an exception then
  93.    //we will still display the video player, but it will be disabled
  94.    try
  95.    {
  96.       vidPlayer = new IMMDigitalVideo();
  97.       ampMixer3 = new IMMAmpMixer(vidPlayer->connectedDeviceId(IMMDevice::waveStream));
  98. //      ampMixer3->enableMonitoring();
  99.       ampMixer3->setCloseOnDestroy(false);
  100.    }
  101.    catch (...)
  102.    {
  103.       vidPlayer = 0;
  104.       ampMixer3 = 0;
  105.    }
  106.    video    = new VIDEO(vidPlayer, VIDEO_ID,  &clientCanvas, this);
  107.    if (!vidPlayer)
  108.       ((IMultiCellCanvas*)video)->disable();
  109.  
  110.    //Create the amplifier mixer panel, to control the sound for all of the
  111.    //device's amplifier mixers
  112.    amp      = new Amp  (ampMixer1,ampMixer2,ampMixer3, AMP_ID, &clientCanvas, this);
  113.  
  114.    clientCanvas.setBackgroundColor(IColor(IColor::black));
  115.    setBackgroundColor(IColor(IColor::paleGray));
  116.    IFont("Helv",8).setWindowFont(&clientCanvas);
  117.  
  118.    setClient(&clientCanvas);
  119.    clientCanvas.setDeckOrientation(ISetCanvas::vertical);
  120.    ISize size = clientCanvas.minimumSize();
  121.    moveSizeToClient(IRectangle(0, 0, size.width(), size.height()));
  122.  
  123.    show();
  124.    setFocus();
  125. }
  126.  
  127. MainWindow::~MainWindow()
  128. {
  129.    if (amp)
  130.       delete amp;
  131.    if (cd)
  132.       delete cd;
  133.    if (wave)
  134.       delete wave;
  135.    if (video)
  136.       delete video;
  137.    if (cdPlayer)
  138.       delete cdPlayer;
  139.    if (wavPlayer)
  140.       delete wavPlayer;
  141.    if (vidPlayer)
  142.       delete vidPlayer;
  143.    if (ampMixer1)
  144.       delete ampMixer1;
  145.    if (ampMixer2)
  146.       delete ampMixer2;
  147.    if (ampMixer3)
  148.       delete ampMixer3;
  149. }
  150.