home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / mmstereo / mmstereo.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  6.7 KB  |  177 lines

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