Waveform object |
|
The Waveform object, accessible through the control's Waveform property, is internally implemented as a COM interface called IWaveform and contains information needed to render the embedded Waveform visual feedback or, in alternative, to generate the full sound's waveform bitmap before starting the sound's playback...
It can be used at Run-time in order to create the embedded Waveform and to change its graphic settings.
For details about using Visual Feedbacks refer to the How to use the embedded Visual Feedbacks section. For further details about generating a waveform bitmap of the loaded sound, before starting its playback, refer to the How to obtain the sound's waveform tutorial.
The Waveform object is implemented through the following methods and properties:
Methods
Properties
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 (Line and Background colors). Microsoft Visual C++ (4.0, 5.0 and 6.0) Microsoft Visual Basic (5.0 and 6.0)
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 Waveform object is defined by the control wrapper class CWaveform contained inside the waveform.cpp and waveform.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 "waveform.h"
Here follows the code needed to perform the requested operation of initialising the Waveform object and changing some of its properties.
// declare a Waveform object CWaveform waveform;
// init the object with the control's Waveform reference waveform = MyPlayer.GetWaveform ();
// create the Waveform for player 0 over an existing control waveform.Create (0, (OLE_HANDLE) GetDlgItem (IDC_PICTURE)->GetSafeHwnd ());
// again for player 0, set the Waveform line color to blue and background color to white waveform.SetColorLine (0, RGB (0, 0, 255)); waveform.SetColorBackground (0, RGB (255, 255, 255));
As you can see the access to the Waveform properties ColorLine and ColorBackground are wrapped by the SetColorLine and SetColorBackground functions declared inside the wrapper class CWaveform.
Microsoft Visual Basic (5.0 and 6.0)
Here follows the code needed to perform the requested operations
' create the Waveform on player 0 over an existing control MyPlayer.Waveform.Create 0, Picture1.hWnd
' set the blue color for Waveform line of player 0 MyPlayer.Waveform.ColorLine(0) = RGB(0, 0, 255)
' set the white color for Waveform background of player 0 MyPlayer.Waveform.ColorBackground(0) = RGB(255, 255, 255)
Here follows the code needed to perform the requested operations
' create the Waveform on player 0 over an existing control MyPlayer.Waveform.Create(0, PictureBox1.Handle.ToInt32())
' set the blue color for Waveform line of player 0 MyPlayer.Waveform.ColorLine(0) = Convert.ToUInt32(RGB(0, 0, 255))
' set the white color for Waveform background of player 0 MyPlayer.Waveform.ColorBackground(0) = Convert.ToUInt32(RGB(255, 255, 255))
Here follows the code needed to perform the requested operations
// create the Waveform on player 0 over an existing control MyPlayer.Waveform.Create(0, pictureBox1.Handle.ToInt32());
// set the blue color for Waveform line of player 0 MyPlayer.Waveform.set_ColorLine (0, Convert.ToUlong (ColorTranslator.ToWin32 (Color.Blue)));
// set the white color for Waveform background of player 0 MyPlayer.Waveform.set_ColorBackground(0, Convert.ToUlong (ColorTranslator.ToWin32 (Color.White)));
Here follows the code needed to perform the requested operations
// create the Waveform on player 0 over an existing control MyPlayer.get_Waveform ().Create ((short) 0, (int) pictureBox1.get_Handle().ToInt32());
// set the blue color for Waveform line of player 0 System.Ulong colorBlue = (System.UInt32) ColorTranslator.ToWin32 (Color.get_Blue ()); MyPlayer.get_Waveform ().set_ColorLine ((short) 0, colorBlue);
// set the white color for Waveform background of player 0 System.Ulong colorWhite = (System.UInt32) ColorTranslator.ToWin32 (Color.get_White ()); MyPlayer.get_Waveform ().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.
|