//////////////////////////////////////////////////////////////////////////
//
// VirtualDJ / Cue
// Plugin SDK
// (c)Atomix Productions 2006
//
//////////////////////////////////////////////////////////////////////////
//
// 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 __stdcall OnStart(int pos,int deck) {return 0;}
	virtual HRESULT __stdcall 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 __stdcall OnProcessSamples(short *buffer,int nb,int pos)=0;
	// This function let you take specific action once a particular point has been reached
	virtual HRESULT __stdcall 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 (__stdcall *GetSongSamples)(int pos,int nb,short **buffer);
	// Call this function if you need to stop your plugin automatically
	HRESULT (__stdcall *Stop)();
	// Call this function if you want to change the current reading position displayed
	HRESULT (__stdcall *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, OnProcessSamples 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 desk output (useful for scratch plugins)
#define VDJPLUGINFLAG_PROCESSMASTER		0x10	// apply the plugin on the master output
#define VDJPLUGINFLAG_PROCESSMIC		0x20	// apply the plugin on the microhpone intput (DJConsole RMX)

//////////////////////////////////////////////////////////////////////////
// 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
