VDJPedia



 Plugins_SDKv8_Example6

Last edit by djcel, Atomix Productions on Mon 25 Jul 16 @ 1:44 pm

Back to Plugin SDK8

Audio Plugin (BUFFER DSP) using SDK v8



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.

For this example, you need to include the following files from the SDK v8 in your project: vdjPlugin8.h (basic common base-class for all plugins) and vdjDsp8.h (base classes for all Dsp 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

#include "vdjDsp8.h"

class CMyPlugin8 : public IVdjPluginBufferDsp8
{
public:
HRESULT VDJ_API OnLoad();
HRESULT VDJ_API OnGetPluginInfo(TVdjPluginInfo8 *infos);
ULONG VDJ_API Release();
HRESULT VDJ_API OnStart();
HRESULT VDJ_API OnStop();
short * VDJ_API OnGetSongBuffer(int pos, int nb);

private:
int Bpm;
int StartPos;
};

#endif


MyPlugin8.cpp:
#include "MyPlugin8.h"

//-----------------------------------------------------------------------------
HRESULT VDJ_API CMyPlugin8::OnLoad()
{
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; // you could also use VDJFLAG_PROCESSAFTERSTOP if you want to process sound when the deck is stopped
infos->Bitmap = NULL;

return S_OK;
}
//---------------------------------------------------------------------------
ULONG VDJ_API CMyPlugin8::Release()
{
delete this;
return 0;
}
//---------------------------------------------------------------------------
HRESULT VDJ_API CMyPlugin8::OnStart()
{
// ADD YOUR CODE HERE WHEN THE AUDIO PLUGIN IS STARTED

Bpm = SongBpm?SongBpm:(SampleRate/2); // by default 120bpm
StartPos = int(SongPosBeats * Bpm);

return S_OK;
}
//---------------------------------------------------------------------------
HRESULT VDJ_API CMyPlugin8::OnStop()
{
// ADD YOUR CODE HERE WHEN THE AUDIO PLUGIN IS STOPPED

StartPos = 0;

return S_OK;
}
//---------------------------------------------------------------------------
short * VDJ_API OnGetSongBuffer(int pos, int nb)
{
// ADD YOUR AUDIO TREATMENT CODE HERE USING THE AUDIO BUFFER *buffer OF 2*nb SHORT SAMPLES (STEREO SIGNAL)
HRESULT hr;

short *buffer;
hr = GetSongBuffer(pos, nb, (short **) &buffer);


return buffer;
}


Main.cpp:
// This is the standard DLL loader for COM object.

#include "MyPlugin8.h"

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

return NO_ERROR;
}





Back to Plugin SDK8