InitDJSystem method |
|
Remarks
Initializes the control: the call to this method (or in alternative to the IniDJSystemEx method) is always mandatory when the control is instanced inside the container form and must be performed before calling any other method that will use any player related functionality, possibly from the initialization routine of the container form or dialog: calling this method inside the constructor function of the container form will not work and could cause unpredictable results.
In case the component should be instanced in conjunction with the recorder component and/or the editor component, this method should be called before calling the initialization methods of the other components (InitRecordingSystem for the recorder component and InitEditor for the editor component).
The purpose of this initialization method is to allocate the desired number of players (*), to synchronize the control with the container form, to set the output device (sound card) for the first 4 allocated players (players exceeding the fourth one will automatically output their sound flow into the system default sound card) and, eventually, setting the DirectX buffer length in order to reduce the latency time.
Use the value returned by the GetOutputDevicesCount method in order to know how many output devices are currently installed on the system and the GetOutputDeviceDesc method in order to retrieve the friendly name of every output device.
The output device for a certain player can be changed at a later time using the StreamOutputDeviceSet method.
For further details about "multi-player" management, take a look to the How to deal with multi-player features section.
For further details about output devices management, take a look to the How to work with multiple output devices and speakers section.
Syntax
[Visual Basic] control.InitDJSystem ( nTotalPlayers as short, hWndParent as OLE_HANDLE, nOutput0 as Integer, nOutput1 as Integer, nOutput2 as Integer, nOutput3 as Integer ) as Integer |
[C++] short control.InitDJSystem ( short nTotalPlayers, OLE_HANDLE hWndParent, short nOutput0, short nOutput1, short nOutput2, short nOutput3 ); |
Parameter |
Description |
|
|
nTotalPlayers |
Number of players (*) that must be allocated by the control. |
hWndParent |
Handle of the container (parent) window: for Visual Basic is represented by the hWnd property of the container form, while for Visual C++ is represented by the call to the container dialog box GetSafeHwnd member function: the return value of this call represents a HWND so it must be cast to OLE_HANDLE to avoid compiler errors |
nOutput0 |
Number representing the zero-based index of the output device (sound card) that will be used for playback by player 0 (pass 0 for using the system default output device). If the parameter is set to -1, the specific player can be used also in absence of a sound card, for example for performing a waveform analysis. Check the How to use the control in your projects section for details about obtaining output devices. If the multimedia engine shouldn't find any enabled or valid output device, the container application would be notified through the WarnNoOutputDevice event. |
nOutput1 |
Number representing the zero-based index of the output device (sound card) that will be used for playback by player 1 (use 0 for system default output device). If the parameter is set to -1, the specific player can be used also in absence of a sound card, for example for performing a waveform analysis. |
nOutput2 |
Number representing the zero-based index of the output device (sound card) that will be used for playback by player 2 (use 0 for system default output device). If the parameter is set to -1, the specific player can be used also in absence of a sound card, for example for performing a waveform analysis. |
nOutput3 |
Number representing the zero-based index of the output device (sound card) that will be used for playback by player 3 (use 0 for system default output device). If the parameter is set to -1, the specific player can be used also in absence of a sound card, for example for performing a waveform analysis. |
Examples of use of the nOutputX parameters
As mentioned inside the tutorials, you can obtain the number of sound cards installed inside the system by invoking the GetOutputDevicesCount method and storing its return value into a numeric variable named, for example, nCount.
Example 1: nCount value is 1
Suppose that you must allocate two players (0 and 1); you have only one sound card that, for exclusion, will be the default one, so you can set the following values:
nTotalPlayers = 2 (*)
hWndParent = your form or dialog box HWND
nOutput0 = 0 (use default sound card)
nOutput1 = 0 (use default sound card)
nOutput2 = 0 (value ignored)
nOutput3 = 0 (value ignored)
Example 2: nCount value is 3
Call the GetOutputDeviceDesc method nCount times (once for every sound card) using a zero-based index in order to obtain every sound card friendly name (suppose you obtain A, B and C).
Now suppose that you must allocate four players (0, 1, 2 and 3) that will redirect their output in the following way:
- player 0 and player 1 must output to the system default sound card A.
- player 2 must output to sound card C.
- player 3 must output to sound card B.
You will have to call the InitDJSystem method with the following parameters:
nTotalPlayers = 4 (*)
hWndParent = your form or dialog box HWND
nOutput0 = 0
nOutput1 = 0
nOutput2 = 2
nOutput3 = 1
Return value
Value |
Meaning |
|
|
0 |
An error occurred, check the LastError property value in order to get the error code |
Value > 0 |
The method completed successfully and this value represents the number of allocated players. In order to know if all of the instanced players have been set to operate with a valid output device, you should check the value of the LastError property: if it should have value 2 (WARNING_INVALID_DEVICE), this would mean that one or more of the nOutputX parameters where set to an invalid output device: in this case a reset of the multimedia engine (ResetEngine method) and of the control (ResetControl method) would be needed in order to set correct output devices. |
(*) A "player" can be compared to a physical "deck" on a DJ console, the place where you put the vinyl/CD to be played; the developer can create a console with many virtual decks that can play simultaneously many different songs on one or more sound cards, each deck having its own volume/tempo/pitch settings. The availability of a certain number of players (decks) will enable the container application to mix several songs on different output channels, giving for example the ability to play advertising spots while songs are being played/mixed on different output channels: this is very useful for multi-channel radio stations automation software.