Copyright © 2001-2008 MultiMedia Soft 
Return to Table of contents  
 
Spectrum object 
 
The Spectrum object, accessible through the control's Spectrum property, is internally implemented as a COM interface called ISpectrum and contains information needed to render the embedded Spectrum visual feedback
 
It can be used at Run-time in order to create the embedded Spectrum and to change its graphic settings. For details about using Visual Feedbacks refer to the How to use the embedded Visual Feedbacks section 
 
The Spectrum object is implemented through the following methods and properties: 
Methods 
 
  • Create 
  • Show 
  • SetHwnd 
  • GetTable 
  • SetBackPictureFromFile 
  • SetBackPictureFromHandle 
  •  
    Properties 
     
  • BandsWidth 
  • HasPeaks 
  • ColorBands 
  • ColorPeaks 
  • ColorBackground 
  • ZoomPerc 
  •  
    The following code snippets show how to create and change this object in your code. These examples assume that you have placed a control named MyPlayer on a form or dialog and that you want to change a couple of graphic settings (Bands and Background colors). 
  • Microsoft Visual C++ (4.0, 5.0 and 6.0) 
  • Microsoft Visual Basic (5.0 and 6.0) 
  • Microsoft Visual Basic.NET 
  • Microsoft Visual C#.NET 
  • Microsoft Visual J#.NET 
  •  
     
    Microsoft Visual C++ (4.0, 5.0 and 6.0) 
     
    Properties and methods of the control are accessible through the control wrapper class CAmp3dj contained inside the amp3dj.cpp and amp3dj.h files: these wrapper files are automatically generated when you insert the control inside your project so, in order to access the wrapper functions, you will have to insert the following line of code somewhere in your code. 
     
    #include "amp3dj.h" 
     
    The Spectrum object is defined by the control wrapper class CSpectrum contained inside the spectrum.cpp and spectrum.h files: also these wrapper files are automatically generated when you insert the control inside your project so, in order to access this object, you will have to insert the following line of code somewhere in your code. 
     
    #include "spectrum.h" 
     
    Here follows the code needed to perform the requested operation of initialising the Spectrum object and changing some of its properties. 
     
    // declare a Spectrum object 
    CSpectrum spectrum; 
     
    // init the object with the control's Spectrum reference 
    spectrum = MyPlayer.GetSpectrum (); 
     
    // create the Spectrum for player 0 over an existing control 
    spectrum.Create (0, (OLE_HANDLE) GetDlgItem (IDC_PICTURE)->GetSafeHwnd ()); 
     
    // again for player 0, set the Spectrum bands color to blue and background color to white 
    spectrum.SetColorBands (0, RGB (0, 0, 255)); 
    spectrum.SetColorBackground (0, RGB (255, 255, 255)); 
     
    As you can see the access to the Spectrum properties ColorBands and ColorBackground are wrapped by the SetColorBands and SetColorBackground functions declared inside the wrapper class CSpectrum. 
     
    Microsoft Visual Basic (5.0 and 6.0) 
     
    Here follows the code needed to perform the requested operations 
     
    ' create the Spectrum on player 0 over an existing control 
    MyPlayer.Spectrum.Create 0, Picture1.hWnd 
     
    ' set the blue color for Spectrum bands of player 0 
    MyPlayer.Spectrum.ColorBands(0) = RGB(0, 0, 255) 
     
    ' set the white color for Spectrum background of player 0 
    MyPlayer.Spectrum.ColorBackground(0) = RGB(255, 255, 255) 
     
    Microsoft Visual Basic.NET 
     
    Here follows the code needed to perform the requested operations 
     
    ' create the Spectrum on player 0 over an existing control 
    MyPlayer.Spectrum.Create(0, PictureBox1.Handle.ToInt32()) 
     
    ' set the blue color for Spectrum bands of player 0 
    MyPlayer.Spectrum.ColorBands(0) = Convert.ToUInt32(RGB(0, 0, 255)) 
     
    ' set the white color for Spectrum background of player 0 
    MyPlayer.Spectrum.ColorBackground(0) = Convert.ToUInt32(RGB(255, 255, 255)) 
     
     
    Microsoft Visual C#.NET 
     
    Here follows the code needed to perform the requested operations 
     
    // create the Spectrum on player 0 over an existing control 
    MyPlayer.Spectrum.Create(0, pictureBox1.Handle.ToInt32()); 
     
    // set the blue color for Spectrum bands of player 0 
    MyPlayer.Spectrum.set_ColorBands (0, Convert.ToUInt32 (ColorTranslator.ToWin32 (Color.Blue))); 
     
    // set the white color for Spectrum background of player 0 
    MyPlayer.Spectrum.set_ColorBackground(0, Convert.ToUInt32 (ColorTranslator.ToWin32 (Color.White))); 
     
    Microsoft Visual J#.NET 
     
    Here follows the code needed to perform the requested operations 
     
    // create the Spectrum on player 0 over an existing control 
    MyPlayer.get_Spectrum ().Create ((short) 0, (int) pictureBox1.get_Handle().ToInt32()); 
     
    // set the blue color for Spectrum bands of player 0 
    System.UInt32 colorBlue = (System.UInt32) ColorTranslator.ToWin32 (Color.get_Blue ()); 
    MyPlayer.get_Spectrum ().set_ColorBands ((short) 0, colorBlue); 
     
    // set the white color for Spectrum background of player 0 
    System.UInt32 colorWhite = (System.UInt32) ColorTranslator.ToWin32 (Color.get_White ()); 
    MyPlayer.get_Spectrum ().set_ColorBackground((short) 0, colorWhite); 
     
    As you can see, in J#.NET the access to the control properties is made through the use of wrapper functions (automatically generated when you insert the control inside your project) with the "get_" and "set_" prefixes. Intellisense will help you finding the right wrapper function. 
     
     
     
     
     
     
     
     
     
     
     
    Copyright © 2001-2008 MultiMedia Soft 
    Return to Table of contents