VDJPedia



 Plugins_SDKv5

SDK v5

vdjPlugin.h wrote :
//////////////////////////////////////////////////////////////////////////
//
// VirtualDJ / Cue / VirtualVinyl
// Plugin SDK for Windows / MAC OS
// (c)Atomix Productions 2006-2007
// File Version: 1.1
//
//////////////////////////////////////////////////////////////////////////
//
// This file defines the basic functions that are used in all plugins.
// It defines the functions and variables needed to:
// - load and unload a plugin
// - give the infos about the plugin (name, picture, etc)
// - get the parameters automatically saved and restored between loads
// - interact with VirtualDJ (ask queries or send commands)
// - implement a custom interface
//
// Other functions specific to particular types of plugin can be found
// in their respective header file
//
//////////////////////////////////////////////////////////////////////////


#ifndef VdjPluginH
#define VdjPluginH

//////////////////////////////////////////////////////////////////////////
// Platform specific defines for compatibility Mac/Windows
#ifdef VDJ_NOEXPORT
#elif (defined(WIN32) || defined(_WIN32) || defined(__WIN32_))
#define WIN32_LEAN_AND_MEAN //For preventing linking errors with DllGetClassObject
#include <windows.h>
#define VDJ_WIN
#define VDJ_EXPORT __declspec( dllexport )
#define VDJ_API __stdcall
#define VDJ_BITMAP HBITMAP
#define VDJ_HINSTANCE HINSTANCE
#define VDJ_WINDOW HWND
#elif (defined(__APPLE__) || defined(MACOSX) || defined(__MACOSX__))
#include <CoreFoundation/CoreFoundation.h>
#include <MacTypes.h>
#define VDJ_MAC
#define VDJ_EXPORT __attribute__ ((visibility ("default")))
#define VDJ_API
#define VDJ_BITMAP char *
#define VDJ_HINSTANCE CFBundleRef
#define VDJ_WINDOW void* // VDJ_Window expected to be a NSWindow
typedef SInt32 HRESULT;
typedef UInt32 ULONG;
typedef unsigned int DWORD;
#define S_OK ((HRESULT)0x00000000L)
#define S_FALSE ((HRESULT)0x00000001L)
#define E_NOTIMPL ((HRESULT)0x80004001L)
#define E_FAIL ((HRESULT)0x80004005L)
#define CLASS_E_CLASSNOTAVAILABLE -1
#define NO_ERROR 0
#ifndef GUID_DEFINED
#define GUID_DEFINED
typedef struct _GUID {
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[ 8 ];
} GUID;
#endif
#endif


//////////////////////////////////////////////////////////////////////////
// Standard structures and defines

struct TVdjPluginInfo
{
char *PluginName;
char *Author;
char *Description;
VDJ_BITMAP Bitmap;
DWORD Flag;
};

#define VDJPARAM_BUTTON 0
#define VDJPARAM_SLIDER 1
#define VDJPARAM_SWITCH 2
#define VDJPARAM_STRING 3
#define VDJPARAM_CUSTOM 4
#define VDJPARAM_RADIO 5

//////////////////////////////////////////////////////////////////////////
// Base class

class IVdjPlugin
{
public:
// Initialization
virtual HRESULT VDJ_API OnLoad() {return 0;}
virtual HRESULT VDJ_API OnGetPluginInfo(TVdjPluginInfo *infos) {return E_NOTIMPL;}
virtual ULONG VDJ_API Release() {delete this;return 0;}
virtual ~IVdjPlugin() {}

// callback functions to communicate with VirtualDJ
HRESULT (VDJ_API *SendCommand)(char *command,int deck); // send a command to VirtualDJ
HRESULT (VDJ_API *GetInfo)(char *query,void *result); // get infos from VirtualDJ

// parameters stuff
// call DeclareParameter() for all your variables during OnLoad()
// if type=VDJPARAM_CUSTOM or VDJPARAM_STRING, defaultvalue must be set to sizeof(*parameter)
HRESULT (VDJ_API *DeclareParameter)(void *parameter,int type,int id,char *name,int defaultvalue);
// OnParameter will be called each time a parameter is changed from within VirtualDJ
virtual HRESULT VDJ_API OnParameter(int id) {return 0;}

// Custom user-interface
// Create a Window using CreateWindow() or CreateDialog(), and send back the HWND.
// If you return E_NOTIMPL, the default interface will be used.
virtual HRESULT VDJ_API OnGetUserInterface(VDJ_WINDOW *hWnd) {return E_NOTIMPL;}

VDJ_HINSTANCE hInstance;
int Width,Height;
};

//////////////////////////////////////////////////////////////////////////
// GUID definitions

#ifndef VDJCLASSGUID_DEFINED
#define VDJCLASSGUID_DEFINED
static const GUID CLSID_VdjPlugin5 = { 0x2e1480fe, 0x4ff4, 0x4539, { 0x90, 0xb3, 0x64, 0x5f, 0x5d, 0x86, 0xf9, 0x3b } };
#else
extern static const GUID CLSID_VdjPlugin5;
#endif

//////////////////////////////////////////////////////////////////////////
// DLL export function

#ifndef NODLLEXPORT
#ifdef __cplusplus
extern "C" {
#endif
VDJ_EXPORT HRESULT VDJ_API DllGetClassObject(const GUID &rclsid,const GUID &riid,void** ppObject);
#ifdef __cplusplus
}
#endif
#endif

//////////////////////////////////////////////////////////////////////////

#endif


vdjDsp.h wrote :
//////////////////////////////////////////////////////////////////////////
//
// VirtualDJ / Cue / VirtualVinyl
// Plugin SDK for Windows / MAC OS
// (c)Atomix Productions 2006-2007
// File Version: 1.0
//
//////////////////////////////////////////////////////////////////////////
//
// This file defines the sound effect plugins.
// In addition to all the elements supported from the base IVdjPlugin class,
// it defines additional DSP-specific functions and variables:
//
//////////////////////////////////////////////////////////////////////////


#ifndef VdjDspH
#define VdjDspH

#include "vdjPlugin.h"

//////////////////////////////////////////////////////////////////////////
// DSP plugin class

class IVdjPluginDsp : public IVdjPlugin
{
public:
// called when the plugin is started or stopped
virtual HRESULT VDJ_API OnStart(int pos,int deck) {return 0;}
virtual HRESULT VDJ_API OnStop() {return 0;}

// This function will be called each time VirtualDJ needs your plugin
// to be applied on a new sound buffer
// NOTE: samples are stereo, so you need to process up to buffer[2*nb]
virtual HRESULT VDJ_API OnProcessSamples(short *buffer,int nb,int pos)=0;
// This function let you take specific action once a particular point has been reached
virtual HRESULT VDJ_API OnPosition(int actualpos) {return 0;}

// If your plugin needs to access an other sound buffer than the one at the
// position provided, you can get it with this function
HRESULT VDJ_API *GetSongSamples)(int pos,int nb,short **buffer);
// Call this function if you need to stop your plugin automatically
HRESULT VDJ_API *Stop)();
// Call this function if you want to change the current reading position displayed
HRESULT VDJ_API *ChangePosition)(int newpos);

// Some useful variables
int SongBpm; // number of samples between two consecutive beats
int SongPhase; // number of samples between the start of the song and the first beat
};

//////////////////////////////////////////////////////////////////////////
// flags used in OnGetPluginInfo()
#define VDJPLUGINFLAG_INPLACE 0x00 // normal behavior
#define VDJPLUGINFLAG_NOTINPLACE 0x01 // set if you don't need buffer to contain song's data on input (if you call GetSongSamples)

#define VDJPLUGINFLAG_CACHE 0x00 // if set, OnProcessSamples will be called as linearly as possible (default behavior)
#define VDJPLUGINFLAG_NOCACHE 0x02 // if set, OnProcessSamples might be called in every direction, and with nb as low as 1
#define VDJPLUGINFLAG_FIXED512 0x04 // if set, OnPorcessSamples will received only 512 samples buffers

#define VDJPLUGINFLAG_PROCESSSONG 0x00 // apply the plugin on the song (default behavior)
#define VDJPLUGINFLAG_PROCESSSCRATCH 0x08 // apply the plugin on the deck output (useful for scratch plugins)
#define VDJPLUGINFLAG_PROCESSMASTER 0x10 // apply the plugin on the master output

//------------------------------------------------------------------------------
// Sound processing
//------------------------------------------------------------------------------
#define SAMPLING_RATE 44100
#define LEFTCHAN(v) ((short)(v&0xFFFF))
#define RIGHTCHAN(v) ((short)(v>>16))
#define MAKECHAN(l,r) ((r<<16)+(l&0xFFFF))
#define LIMITER(x) {if(x<-32768) x=-32768; else if(x>32767) x=32767;}

//////////////////////////////////////////////////////////////////////////
// GUID definitions

#ifndef VDJDSPGUID_DEFINED
#define VDJDSPGUID_DEFINED
static const GUID IID_IVdjPluginDsp = { 0x41dbff5, 0x55d4, 0x47ee, { 0x9d, 0x32, 0xd3, 0xc8, 0xa2, 0x0, 0x61, 0xff } };
#else
extern static const GUID IID_IVdjPluginDsp;
#endif

//////////////////////////////////////////////////////////////////////////

#endif


vdjVideo.h wrote :
//////////////////////////////////////////////////////////////////////////
//
// VirtualDJ / Cue / VirtualVinyl
// Plugin SDK for Windows only
// (c)Atomix Productions 2006-2007
// File Version: 1.0
//
//////////////////////////////////////////////////////////////////////////
//
// This file defines the video plugins (both Fx and Transition).
// In addition to all the elements supported from the base IVdjPlugin class,
// it defines additional video-specific functions and variables:
//
//////////////////////////////////////////////////////////////////////////


#ifndef VdjVideoH
#define VdjVideoH

#include "VdjPlugin.h"

//////////////////////////////////////////////////////////////////////////
// DirectX data types

struct IDirect3DDevice9;
struct IDirect3DTexture9;
struct TVertex
{
struct {float x,y,z;} position;
DWORD color;
FLOAT tu,tv;
};

//////////////////////////////////////////////////////////////////////////
// VideoFx plugin class

class IVdjPluginVideoFx : public IVdjPlugin
{
public:
// called when DirectX is initialized and closed
// if you need to allocate private surfaces or textures,
// this is the place to do it
virtual HRESULT __stdcall OnDXInit() {return 0;}
virtual HRESULT __stdcall OnDXClose() {return 0;}

// called on start and stop of the plugin
virtual HRESULT __stdcall OnStart() {return 0;}
virtual HRESULT __stdcall OnStop() {return 0;}

// use this function to render the D3D surface on the device, using any modification you want
// return S_OK if you actually draw the texture on the device, or S_FALSE to let VirtualDJ do it
virtual HRESULT __stdcall OnDraw(IDirect3DTexture9 *texture,TVertex *vertices)=0;

// variables you can use (once DX has been initialized)
IDirect3DDevice9 *D3DDevice;
int ImageWidth,ImageHeight;
};

//////////////////////////////////////////////////////////////////////////
// VideoTransition plugin class

class IVdjPluginVideoTransition : public IVdjPlugin
{
public:
// called when DirectX is initialized and closed
// if you need to allocate private surfaces or textures,
// this is the place to do it
virtual HRESULT __stdcall OnDXInit() {return 0;}
virtual HRESULT __stdcall OnDXClose() {return 0;}

// use this function to compose both surfaces on the device.
// calling the RenderSurface[x] function will render the image on the actual render target,
// using the vertices[x] given.
virtual HRESULT __stdcall Compose(int crossfader,HRESULT(__stdcall *RenderSurface[2])(),TVertex *vertices[2])=0;

// OnStart() and OnStop() are called if the user activate the auto-transition.
// once activated, OnCrossfaderTimer() will be called every frame to let you change
// the value of the video crossfader before rendering.
// return S_FALSE will stop the auto-transition (OnStop() will not be called).
// return E_NOTIMPL will use the default auto-transition.
// NOTE: if crossfader is set to 0 or 4096, the Compose() function will not be called.
virtual HRESULT __stdcall OnStart(int chan) {return 0;}
virtual HRESULT __stdcall OnStop() {return 0;}
virtual HRESULT __stdcall OnCrossfaderTimer(int *crossfader) {return E_NOTIMPL;}

// variables you can use (once DX has been initialized)
IDirect3DDevice9 *D3DDevice;
int ImageWidth,ImageHeight;
};

//////////////////////////////////////////////////////////////////////////
// flags used in OnGetPluginInfo()
#define VDJPLUGINFLAG_VIDEOINPLACE 0x20 // tell VirtualDJ not to send textures in OnDraw() but instead use directly the backbuffer

//////////////////////////////////////////////////////////////////////////
// GUID definitions

#ifndef VDJVIDEOGUID_DEFINED
#define VDJVIDEOGUID_DEFINED
static const GUID IID_IVdjPluginVideoFx = { 0x9ad1e934, 0x31ce, 0x4be8, { 0xb3, 0xee, 0x1e, 0x1f, 0x1c, 0x94, 0x55, 0x10 } };
static const GUID IID_IVdjPluginVideoTransition = { 0x119f6f6a, 0x1a37, 0x4fe5, { 0x96, 0x53, 0x31, 0x20, 0x3a, 0xc9, 0x4e, 0x28 } };
#else
extern static const GUID IID_IVdjPluginVideoFx;
extern static const GUID IID_IVdjPluginVideoTransition;
#endif

//////////////////////////////////////////////////////////////////////////

#endif


vdjDevice.h wrote :
//////////////////////////////////////////////////////////////////////////
//
// VirtualDJ / Cue
// Plugin SDK
// (c)Atomix Productions 2006
//
//////////////////////////////////////////////////////////////////////////
//
// This file defines the external-device custom mapper plugins.
// In addition to all the elements supported from the base IVdjPlugin class,
// it defines additional device-specific functions and variables:
//
//////////////////////////////////////////////////////////////////////////


#ifndef VdjDeviceH
#define VdjDeviceH

#include "VdjPlugin.h"

struct TVdjDeckInfo;

//////////////////////////////////////////////////////////////////////////
// VdjDevice plugin class

class IVdjPluginDevice : public IVdjPlugin
{
public:
// You must implement this function and return the device type for which this
// plugin has been written.
virtual HRESULT __stdcall GetDeviceType(int *type)=0;

// called when device is initialized
virtual HRESULT __stdcall OnReset() {return 0;}

// This function is called each time a button is pressed or depressed
// (return E_NOTIMPL if you want VirtualDJ to use the default mapper)
virtual HRESULT __stdcall OnButton(int chan,int button,int down) {return 0;}
// This function is called each time a knob or slider is moved.
// absvalue is the absolute position of the slider between 0 and 4096 included.
// relvalue is the relative movement of this slider, on the same scale.
virtual HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue) {return 0;}
// This function is called on devices that are compatible with low-latency scratch.
// return S_OK and VirtualDJ will apply a low-latency scratch automatically.
// return S_FALSE and OnSlider() will be called the regular way.
virtual HRESULT __stdcall OnScratch(int chan,int *value) {return 0;}

// This function is called once every 100ms, letting you update the LEDs on the device
virtual HRESULT __stdcall OnTimer() {return 0;} // 100 ms
// Call these functions to update the LEDs and display on the device.
HRESULT (__stdcall *SetLed)(int chan,int n,int value);
HRESULT (__stdcall *SetDigit)(int chan,int n,int value);
HRESULT (__stdcall *SetText)(int chan,int n,char *value);
// This structure gives you direct access to common information useful for LED status.
// You can call GetInfo() if you need other less common datas.
TVdjDeckInfo *DeckInfo[2];
// Leds and Digits sends are buffered. If you need to flush the buffer, use this:
HRESULT (__stdcall *CommitSends)();

// An alternative to SendCommand, that lets you specify up and down status (for compat. with previous SDK)
HRESULT (__stdcall *SendAction)(char *action,char *chan,char *param,int down);

// extension function and variable for specific-device needs
void *DeviceSpecificVar;
HRESULT (__stdcall *DeviceSpecificCall)(int cmd,int param1,void *param2);
};

//////////////////////////////////////////////////////////////////////////
// Structures declarations

struct TVdjDeckInfo
{
int StructSize; // =72 in current version. Might be expanded in the future
int Position; // position in number of samples since begining
int Length; // total number of samples in song (1 sample = 1/44100 second)
int Status;
int Playing;
int Bpm;
int Pitch;
int PitchReset;
int PitchMin,PitchMax;
int Loop;
int LoopLength;
int CuePos,CuePos2,CuePos3;
int BeatLed;
int BeatLocked;
int AutoMix;
int MixNow;
int Selected;
int BassKill,MediumKill,HighKill;
};

//////////////////////////////////////////////////////////////////////////
// Common defines

#define PLUGINDEVICE_XP10 1
#define PLUGINDEVICE_DJCONSOLE 2
#define PLUGINDEVICE_DMC1 3
#define PLUGINDEVICE_DVINYL 4
#define PLUGINDEVICE_DAC3 5
#define PLUGINDEVICE_BCD2000 6
#define PLUGINDEVICE_ICDX 7
#define PLUGINDEVICE_DMC2 8
#define PLUGINDEVICE_TOTALCONTROL 9
#define PLUGINDEVICE_ICUE 10
#define PLUGINDEVICE_XPONENT 11
#define PLUGINDEVICE_DNHC4500 12
#define PLUGINDEVICE_VC100 13

//////////////////////////////////////////////////////////////////////////
// GUID definitions

#ifndef VDJDEVICEGUID_DEFINED
#define VDJDEVICEGUID_DEFINED
static const GUID IID_IVdjPluginDevice = { 0xc17ed55e, 0x76b2, 0x4fb7, { 0x99, 0x34, 0xbb, 0xb1, 0xaf, 0xcd, 0x8c, 0x7b } };
#else
extern static const GUID IID_IVdjPluginDevice;
#endif

//////////////////////////////////////////////////////////////////////////

#endif


vdjTimecode.h wrote :
//////////////////////////////////////////////////////////////////////////
//
// VirtualDJ / Cue / VirtualVinyl
// Plugin SDK for Windows / MAC OS
// (c)Atomix Productions 2007
// File Version: 1.0
//
//////////////////////////////////////////////////////////////////////////
//
// This file defines the timecode custom engine plugins.
// In addition to all the elements supported from the base IVdjPlugin class,
// it defines additional timecode-specific functions and variables:
//
//////////////////////////////////////////////////////////////////////////


#ifndef VdjTimecodeH
#define VdjTimecodeH

#include "VdjPlugin.h"

struct TVdjPluginTimecodeConfig;

//////////////////////////////////////////////////////////////////////////
// VdjTimecodeSignal plugin class
// This class let you define your own timecode signal management, in order
// to be compatible with other records than the default VDJ's ones

class IVdjPluginTimecodeSignal : public IVdjPlugin
{
public:
// called when timecode is activated on that deck
virtual HRESULT __stdcall Init() {return 0;}

// Implement your timecode analysis algorithm in this function.
// buffer is a signed 32bits interleaved stereo buffer of nb stereo incoming samples
// the gain, optional RIAA filter and stereo inversion are already applied on the incoming datas
virtual HRESULT __stdcall Decode(int *buffer,int nb)=0;

// Here are the variables that your Decode function should set:
int LastSyncCode; // value of the last timecode read-out (in 1/44100s)
int DeltaPosSinceSync; // movement registered on the disc since the last valid timecode
int UnsyncedLength; // time elapsed since the last valid timecode was found
int SilenceLength; // time elapsed since the last audible signal was picked
int Direction; // direction of the disc (-1 or +1)

// LastSyncCode and UnsyncedLength are values that should be filled in by TimecodeSignal plugins. They are used by TimecodeEngine plugins.
// When you write TimecodeSignal plugins, fill LastSyncCode with the latest valid timecode you could read,
// and UnsyncedLength with the number of samples you read but couldn't match to a valid timecode since that.


// GetQuality should return the signal quality, from 0 to 256, or -1 for silent
virtual HRESULT __stdcall GetQuality(int *quality) {return 0;}
// GetCustomDisplay is called from the timecode config page in advanced mode when the user select the
// alternate display. Bits is a Width*Height DWORD buffer to receive the 32bit image
virtual HRESULT __stdcall GetCustomDisplay(DWORD *Bits,int Width,int Height) {return 0;}
// AutoConfig is called if the user click on the auto button on the config page
// The buffer is one second of signed 32bit interleaved stereo buffers (nb=44100)
virtual HRESULT __stdcall AutoConfig(int *buffer,int nb) {return 0;}

// The config values are set by the user from the options, or can be changed
// by your AutoConfig function.
TVdjPluginTimecodeConfig *Config;
};

//////////////////////////////////////////////////////////////////////////
// VdjTimecodeEngine plugin class
// This class let you define your own timecode behavior

class IVdjPluginTimecodeEngine : public IVdjPlugin
{
public:
// called when timecode is activated on that deck
virtual HRESULT __stdcall Init() {return 0;}

// Implement your timecode behavior in this function.
// The function is called when a buffer of nb samples of timecode data have been processed.
// Return in speed the multiplier by which to accelerate/decelerate the output.
// In absolute mode, you might want to call SendCommand to jump to new positions.
// Also, you can change the Pitch value if you want the pitch to reflect in the skin.
virtual HRESULT __stdcall Process(int nb,float *speed)=0;

// These values are returned by the timecode signal module
int LastSyncCode; // value of the last timecode read-out (in 1/44100s)
int DeltaPosSinceSync; // movement registered on the disc since the last valid timecode
int UnsyncedLength; // time elapsed since the last valid timecode was found
int SilenceLength; // time elapsed since the last audible signal was picked
int Direction; // direction of the disc (-1 or +1)

// useful informations you can use
float Pitch; // Pitch multiplier (read/write variable)
int SongPosition; // actual position of the song
int SongLen; // length of the song in 1/44100s
int SongStatus; // -1=no song, 0=paused, 1=playing

// this function is called each time a new song is loaded
virtual HRESULT __stdcall OnNewSong() {return 0;}
// this function is called each time the user calls a cuepoint by software
virtual HRESULT __stdcall OnCue() {return 0;}
// this function is called in one-turntable mode when the user switch the desk
virtual HRESULT __stdcall SetChannel(int ch) {return 0;}
// this function is called when the timecode is activated/deactivated
virtual HRESULT __stdcall OnActivate(bool a) {return 0;}

TVdjPluginTimecodeConfig *Config;
};

//////////////////////////////////////////////////////////////////////////
// structs definitions

struct TVdjPluginTimecodeConfig
{
int Speed,Gain,RIAA,Invert,Silence,AntiSkip;
int Lead,RelMode,SmartCue,ClearSound,AutoBrowser;
int EndPos,AutoBrowserPos;
int ShiftRotation;
int RefOne,RefZero;
int PitchSensitivity;
};

//////////////////////////////////////////////////////////////////////////
// GUID definitions

#ifndef VDJTIMECODEGUID_DEFINED
#define VDJTIMECODEGUID_DEFINED
static const GUID IID_IVdjPluginTimecodeEngine = { 0xcfca612a, 0xb5be, 0x40b6, { 0xa2, 0x18, 0xad, 0x24, 0x07, 0x12, 0x04, 0x90 } };
static const GUID IID_IVdjPluginTimecodeSignal = { 0x6a208c33, 0x8415, 0x4afb, { 0xb9, 0x63, 0xdd, 0x76, 0xd6, 0x19, 0xbd, 0x1d } };
#else
extern static const GUID IID_IVdjPluginTimecodeEngine;
extern static const GUID IID_IVdjPluginTimecodeSignal;
#endif

//////////////////////////////////////////////////////////////////////////

#endif


Back to Developer page

Wiki HOME