VDJPedia



 Plugins_SDKv8_Example

Back to Plugin SDK8

Basic Plugin using SDK v8 (with default Interface)



Here is an example to start developping a plugin "MyPlugin8". We use the class "CMyPlugin8" to define our object but you can use what you want. The file "Main.cpp" is the caller of your object "CMyPlugin8" and is the entry point to communicate with VirtualDJ.
We also use the VDJINTERFACE_DEFAULT in this example to easy draw sliders/buttons/... in the plugin.

For this example, you need to include the following file from the SDK v8 in your project: vdjPlugin8.h (basic common base-class for all plugins)
You can use other compiler but please find one example of Visual C++ project for this project on a PC. It will generate a .dll file
For the case of this example, please copy all the files in the same folder.

MyPlugin8.h:
#ifndef MYPLUGIN8_H
#define MYPLUGIN8_H

// we include stdio.h only to use the sprintf() function
// we define _CRT_SECURE_NO_WARNINGS for the warnings of the sprintf() function
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#include "vdjPlugin8.h"

class CMyPlugin8 : public IVdjPlugin8
{
public:
HRESULT VDJ_API OnLoad();
HRESULT VDJ_API OnGetPluginInfo(TVdjPluginInfo8 *infos);
ULONG VDJ_API Release();
HRESULT VDJ_API OnGetUserInterface(TVdjPluginInterface8 *pluginInterface);
HRESULT VDJ_API OnParameter(int id);
HRESULT VDJ_API OnGetParameterString(int id, char *outParam, int outParamSize);

private:
int m_Reset;
float m_Dry;
float m_Wet;

bool isMasterFX(); // an example of additional function for the use of GetInfo()

protected:
typedef enum _ID_Interface
{
ID_BUTTON_1,
ID_SLIDER_1
} ID_Interface;
};

#endif


MyPlugin8.cpp:
#include "MyPlugin8.h"


//-----------------------------------------------------------------------------
HRESULT VDJ_API CMyPlugin8::OnLoad()
{
// ADD YOUR CODE HERE WHEN THE PLUGIN IS CALLED
m_Reset = 0;
m_Dry = 0.0f;
m_Wet = 0.0f;

bool bMasterFX = isMasterFX();


DeclareParameterButton(&m_Reset,ID_BUTTON_1,"Reset","R");
DeclareParameterSlider(&m_Wet,ID_SLIDER_1,"Dry/Wet","D/W",1.0f);

OnParameter(ID_SLIDER_1);

return S_OK;
}
//-----------------------------------------------------------------------------
HRESULT VDJ_API CMyPlugin8::OnGetPluginInfo(TVdjPluginInfo8 *infos)
{
infos->PluginName = "MyPlugin8";
infos->Author = "Atomix Productions";
infos->Description = "My first VirtualDJ 8 plugin";
infos->Version = "1.0";
infos->Flags = 0x00;
infos->Bitmap = NULL;

return S_OK;
}
//---------------------------------------------------------------------------
ULONG VDJ_API CMyPlugin8::Release()
{
// ADD YOUR CODE HERE WHEN THE PLUGIN IS RELEASED

delete this;
return 0;
}
//---------------------------------------------------------------------------
HRESULT VDJ_API CMyPlugin8::OnGetUserInterface(TVdjPluginInterface8 *pluginInterface)
{
pluginInterface->Type = VDJINTERFACE_DEFAULT;

return S_OK;
}
//---------------------------------------------------------------------------
HRESULT VDJ_API CMyPlugin8::OnParameter(int id)
{
switch(id)
{
case ID_BUTTON_1:
if(m_Reset == 1)
{
m_Wet = 0.5f;
//HRESULT hr;
//hr = SendCommand("effect_slider 1 50%");
}
break;

case ID_SLIDER_1:
m_Dry = 1 - m_Wet;
break;
}

return S_OK;
}
//---------------------------------------------------------------------------
HRESULT VDJ_API CMyPlugin8::OnGetParameterString(int id, char *outParam, int outParamSize)
{
switch(id)
{
case ID_SLIDER_1:
sprintf(outParam,"+%.0f%%", m_Wet*100);
break;
}

return S_OK;
}

//-------------------------------------------------------------------------------------------------------------------------------------
// BELOW, ADDITIONAL FUNCTIONS ONLY TO EXPLAIN SOME FEATURES (CAN BE REMOVED)
//-------------------------------------------------------------------------------------------------------------------------------------
bool CMyPlugin8::isMasterFX()
{
double qRes;
HRESULT hr = S_FALSE;

hr = GetInfo("get_deck 'master' ? true : false", &qRes);

if(qRes==1.0f) return true;
else return false;
}


Main.cpp:
#include "MyPlugin8.h"

// This is the standard DLL loader for COM object.

HRESULT VDJ_API DllGetClassObject(const GUID &rclsid,const GUID &riid,void** ppObject)
{
if (memcmp(&rclsid,&CLSID_VdjPlugin8,sizeof(GUID))==0 && memcmp(&riid,&IID_IVdjPluginBasic8,sizeof(GUID))==0)
{
*ppObject=new CMyPlugin8();
}
else
{
return CLASS_E_CLASSNOTAVAILABLE;
}

return NO_ERROR;
}





Back to Plugin SDK8